public function set_filename($file) { // Get path for possible translations if (strrpos($file, "/") !== FALSE) { $split = strrpos($file, "/"); $firstpart = substr($file, 0, $split + 1); // The +1 to catch the / $lastpart = substr($file, $split + 1); } else { $firstpart = ""; $lastpart = $file; } // Try to get translated view, with complete area suffix (e.g. en-us) try { parent::set_filename($firstpart . "i18n/" . i18n::lang() . "/" . $lastpart); // Will try to load file, and fail if file cannot be found } catch (Exception $e) { // Try to get translated view for the overall language, without area suffix (e.g. 'en' from 'en-us') try { parent::set_filename($firstpart . "i18n/" . substr(i18n::lang(), 0, 2) . "/" . $lastpart); } catch (Exception $e) { parent::set_filename($file); } } return $this; }
public function set_filename($file) { $mustacheFile = Kohana::find_file('views', $file, 'mustache'); if ($mustacheFile === false) { return parent::set_filename($file); } $this->_file = $mustacheFile; $this->_tmpl = $file; return $this; }
public function set_filename($file) { try { parent::set_filename($file); } catch (Kohana_View_Exception $e) { if (($path = Kohana::find_file('views', $file, 'md')) === FALSE) { throw $e; // re-throw } $this->_markdown = TRUE; $this->_file = $path; } return $this; }
public function set_filename($file) { if (isset(self::$_files[$file])) { return parent::set_filename(self::$_files[$file]); } // На основе данных из Request попробуем сообразить, где искать нужный скрипт вида $request = Request::current(); if ($request) { // Ищем файл либо в <directory>/<controller> и <directory>, либо в <controller> // в зависимости от того, указана ли <directory> $directory = mb_strtolower($request->directory()); $controller = mb_strtolower($request->controller()); if ($directory) { // <directory>/<controller> $new_file = $directory . '/' . $controller . '/' . $file; if (($path = Kohana::find_file('views', $new_file)) !== FALSE) { self::$_files[$file] = $new_file; return parent::set_filename($new_file); } // <directory> $new_file = $directory . '/' . $file; if (($path = Kohana::find_file('views', $new_file)) !== FALSE) { self::$_files[$file] = $new_file; return parent::set_filename($new_file); } } else { // <controller> $new_file = $controller . '/' . $file; if (($path = Kohana::find_file('views', $new_file)) !== FALSE) { self::$_files[$file] = $new_file; return parent::set_filename($new_file); } } // Если не нашли в подходящих директориях - пытаемся поискать в обычном месте if (($path = Kohana::find_file('views', $file)) !== FALSE) { self::$_files[$file] = $file; return parent::set_filename($file); } // Последний оплот - ядро экстази $new_file = 'extasy/' . $file; if (($path = Kohana::find_file('views', $new_file)) !== FALSE) { self::$_files[$file] = $new_file; return parent::set_filename($new_file); } } // Нигде не нашли - ну и пусть Kohana сама разбирается с этой ситуацией self::$_files[$file] = $file; return parent::set_filename($file); }
/** * Parse a template name and set the renderer and filename. * * @throws View_Exception (parent) * @param string filename * @return View */ public function set_filename($file) { // first extract the renderer, if any $pos = strpos($file, ':'); if ($pos === false) { $this->_renderer = $this->_default_renderer; } elseif ($pos == 0) { $this->_renderer = 'parent'; $file = substr($file, 1); } else { $this->_renderer = substr($file, 0, $pos); $file = substr($file, $pos + 1); } // allow the parent method to do it its own way if ($this->_renderer == 'parent') { return parent::set_filename($file); } // REVISIT we should implement this in the renderer $this->_set_filename($file); }
/** * Sets the view filename. * * $view->set_filename($file); * * @param string view filename * @return View * @throws Kohana_View_Exception */ public function set_filename($file) { if (self::is_smarty_template($file)) { throw new Kohana_Exception('Cannot use set_filename to initialise Smarty template :tpl; use View::factory instead', array(':tpl' => $file)); } return parent::set_filename($file); }
public function set_filename($file) { parent::set_filename($file); $this->_file = $file; return $this; }