Author: Jeremy Bush (jeremy.bush@kohanaframework.org)
Inheritance: extends Kohana_Kostache
Ejemplo n.º 1
0
 public function __construct($template = NULL, array $partials = NULL)
 {
     if (Request::current() !== null) {
         // URL страницы
         $this->page = Request::current()->param('page');
     }
     // Register infoblocks
     $this->header_phone_block = Sprig::factory('infoblock', array('id' => 1))->load()->content;
     $this->footer_copyright_block = Sprig::factory('infoblock', array('id' => 2))->load()->content;
     $this->footer_address_block = Sprig::factory('infoblock', array('id' => 3))->load()->content;
     $this->footer_phone_block = Sprig::factory('infoblock', array('id' => 4))->load()->content;
     $this->footer_counters_block = Sprig::factory('infoblock', array('id' => 5))->load()->content;
     // Current year
     $this->year = date('Y');
     // Split phone number for two parts - code and phone
     if (preg_match('!^\\(([^)]+)\\)(.*)$!', $this->header_phone_block, $header_phone_parts)) {
         $header_phone_block_tmp = array();
         $header_phone_block_tmp['code'] = $header_phone_parts[1];
         $header_phone_block_tmp['phone'] = $header_phone_parts[2];
         $this->header_phone_block = $header_phone_block_tmp;
     } else {
         $header_phone_block_tmp = array();
         $header_phone_block_tmp['code'] = $this->header_phone_block;
         $this->header_phone_block = $header_phone_block_tmp;
     }
     // Выбираем случайно одно преимущество
     $benefitO = Sprig::factory('benefits')->load(DB::select('*')->where('status', '=', '1')->order_by(NULL, 'RAND()'), 1);
     $this->benefit = $benefitO->as_array();
     parent::__construct($template, $partials);
 }
Ejemplo n.º 2
0
 public function __construct($template = NULL, array $partials = NULL, $alien_call = false)
 {
     // Если объект создается сторонним приложением для использования
     // определенных функция - конструктор надо освободить от выполнения
     // лишних операций
     if (!empty($alien_call)) {
         return;
     }
     // Получаем нужные настройки админ.части
     $this->site_name = $this->get_variable('site_name');
     $this->js_path = $this->get_variable('js_path');
     $this->css_path = $this->get_variable('css_path');
     $this->image_path = $this->get_variable('image_path');
     $this->packages_path = $this->get_variable('packages_path');
     // Фомируем текущую дату для использования в шаблоне
     $this->datetime = date('H:i d/m/y');
     // Получаем ID из запроса
     $this->request = new Request(Request::detect_uri());
     $this->id = $this->request->param('id');
     // Формируем пользователя
     if (empty($this->auth)) {
         $this->auth = Auth::instance();
         $this->user = $this->auth->get_user();
         if (!empty($this->user)) {
             // Узнаем роль пользователя (помимо роли Login)
             $roleuser = Sprig::factory('roleuser')->load(DB::select('*')->where('user_id', '=', $this->user->id)->and_where('role_id', '!=', '1'), NULL);
             // Вытаскиваем роль
             if (!empty($roleuser[0]->role_id)) {
                 $this->role = Sprig::factory('role', array('id' => $roleuser[0]->role_id))->load();
             }
         }
     }
     parent::__construct($template, $partials);
 }
Ejemplo n.º 3
0
 public function render($class, $template = NULL)
 {
     if (!empty($class->_partials)) {
         $partials = array();
         foreach ($class->_partials as $key => $value) {
             $partials[$key] = file_get_contents(Kohana::find_file('templates', $value, 'mustache'));
         }
         $this->_engine->setPartials($partials);
     }
     return parent::render($class, $template);
 }
Ejemplo n.º 4
0
 public function __construct($template = NULL, array $partials = NULL)
 {
     parent::__construct($template, $partials);
 }
Ejemplo n.º 5
0
	/**
	 * Renders the template using the current view.
	 *
	 * @return	string
	 */
	public function render()
	{
		$this->charset = Kohana::$charset;
		$this->lang = I18n::$lang;
		$this->production = Kohana::$environment === Kohana::PRODUCTION;

		if (Kohana::$profiling === true)
		{
			// Start a new benchmark
			$benchmark = Profiler::start('Layout', __FUNCTION__);
		}

		$rendered = parent::render();

		if (isset($benchmark))
		{
			// Stop the benchmark
			Profiler::stop($benchmark);
		}

		return $rendered;
	}