1
0
Fork 0
mirror of https://github.com/Oreolek/kangana.git synced 2024-07-07 17:14:24 +03:00
kangana/application/classes/View/Layout.php

113 lines
2.4 KiB
PHP
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?php defined('SYSPATH') or die('No direct script access.');
/**
* Layout view controller
**/
class View_Layout {
public $_view = NULL;
public $title = '';
public $scripts = array();
public $base_scripts = array(
);
public $errors;
/**
* Inherited paging function
**/
public function get_paging() {}
public function has_errors()
{
return !empty($this->errors);
}
public function site_title()
{
if (Auth::instance()->logged_in())
{
return 'Добро пожаловать, '.Auth::instance()->get_user()->username;
}
else
{
return Kohana::$config->load('common.title');
}
}
public function stylesheet()
{
return Less::compile(APPPATH.'assets/stylesheets/main');
}
public function get_content()
{
return Kostache::factory()->render($this->content);
}
public function scripts()
{
$scripts = array_merge ($this->base_scripts, $this->scripts);
$temp = "";
foreach($scripts as $script):
if (strstr($script, '://') === FALSE) //no protocol given, script is local
{
if ($script === 'jquery') // CDN shortcut
{
$temp .= HTML::script('https://yandex.st/jquery/2.0.3/jquery.min.js')."\n";
}
else
{
$temp .= HTML::script('application/assets/javascript/'.$script)."\n";
}
}
else
{
$temp .= HTML::script($script)."\n";
}
endforeach;
return $temp;
}
public function favicon()
{
return URL::site('favicon.ico');
}
public function navigation()
{
$result = array();
$navigation = array(
// 'Список страниц' => 'page/index',
// 'О сайте' => 'page/view/1',
);
if (!Auth::instance()->logged_in())
{
$navigation = array_merge($navigation, array('Вход' => 'user/signin'));
}
else
{
$navigation = array_merge($navigation, array(
'Клиенты' => 'clients/index',
'Поиск клиентов' => 'clients/search',
));
}
foreach ($navigation as $key => $value)
{
array_push($result, array(
'url' => URL::site('/'.$value),
'title' => $key
));
}
return $result;
}
public function get_errors()
{
$result = array();
foreach ($this->errors as $key => $string)
{
array_push($result, $string);
}
return $result;
}
}