function _render($___viewFn, $___dataForView, $loadHelpers = true, $cached = false) { if (isset($___dataForView['title_for_layout'])) { $this->pageTitle = $___dataForView['title_for_layout']; } return parent::_render($___viewFn, $___dataForView, $loadHelpers, $cached); }
/** * テンプレートのファイル名を取得する * プレフィックスが設定されている場合は、プレフィックスを除外する * @param string $name * @return string $fileName * @access protected */ function _getViewFileName($name = null) { if (!$name && isset($this->params['prefix'])) { $prefix = $this->params['prefix']; if (preg_match('/^' . $prefix . '_/', $this->action)) { $name = str_replace($prefix . '_', '', $this->action); } elseif (preg_match('/^admin_/', $this->action)) { // プレフィックスをadminとしてすり替え $name = str_replace('admin_', '', $this->action); } } if ($this->name == 'CakeError' && $this->viewPath == 'errors') { // CakeErrorの場合はサブフォルダを除外 $subDir = $this->subDir; $this->subDir = ''; $fileName = parent::_getViewFileName($name); $this->subDir = $subDir; return $fileName; } else { return parent::_getViewFileName($name); } }
/** * test memory leaks that existed in _paths at one point. * * @return void */ public function testMemoryLeakInPaths() { $this->Controller->plugin = null; $this->Controller->name = 'Posts'; $this->Controller->viewPath = 'posts'; $this->Controller->layout = 'whatever'; $this->Controller->theme = 'TestTheme'; $View = new ThemeView($this->Controller); $View->element('test_element'); $start = memory_get_usage(); for ($i = 0; $i < 10; $i++) { $View->element('test_element'); } $end = memory_get_usage(); $this->assertLessThanOrEqual($start + 5000, $end); }
/** * Outputs cached dispatch view cache * * @param string $path Requested URL path * @return string|boolean False if is not cached or output */ public function cached($path) { if (Configure::read('Cache.check') === true) { if ($path == '/') { $path = 'home'; } $path = strtolower(Inflector::slug($path)); $filename = CACHE . 'views' . DS . $path . '.php'; if (!file_exists($filename)) { $filename = CACHE . 'views' . DS . $path . '_index.php'; } if (file_exists($filename)) { App::uses('ThemeView', 'View'); $controller = null; $view = new ThemeView($controller); return $view->renderCache($filename, microtime(true)); } } return false; }
/** * */ public function __construct(&$controller) { parent::__construct($controller); $this->schema = $this->params['controller'] . '-' . $this->params['action']; $this->themePath = WWW_ROOT . '/themed/'; }
/** * Returns filename of given action's template file (.ctp) as a string. * CamelCased action names will be under_scored! This means that you can have * LongActionNames that refer to long_action_names.ctp views. * * @param string $action Controller action to find template filename for * @return string Template filename * @access protected */ function _getViewFileName($name = null) { // CUSTOMIZE ADD 2012/04/11 ryuring // プレフィックスが設定されている場合は、プレフィックスを除外する // >>> if (!$name && isset($this->params['prefix'])) { $prefix = $this->params['prefix']; if (preg_match('/^' . $prefix . '_/', $this->action)) { $name = str_replace($prefix . '_', '', $this->action); } elseif (preg_match('/^admin_/', $this->action)) { // プレフィックスをadminとしてすり替え $name = str_replace('admin_', '', $this->action); } } if ($this->name == 'CakeError' && $this->viewPath == 'errors') { // CakeErrorの場合はサブフォルダを除外 $subDir = $this->subDir; $this->subDir = ''; $fileName = parent::_getViewFileName($name); $this->subDir = $subDir; return $fileName; } // <<< $subDir = null; if (!is_null($this->subDir)) { $subDir = $this->subDir . DS; } if ($name === null) { $name = $this->action; } $name = str_replace('/', DS, $name); if (strpos($name, DS) === false && $name[0] !== '.') { $name = $this->viewPath . DS . $subDir . Inflector::underscore($name); } elseif (strpos($name, DS) !== false) { if ($name[0] === DS || $name[1] === ':') { if (is_file($name)) { return $name; } $name = trim($name, DS); } else { if ($name[0] === '.') { $name = substr($name, 3); } else { $name = $this->viewPath . DS . $subDir . $name; } } } $paths = $this->_paths(Inflector::underscore($this->plugin)); $exts = array($this->ext, '.ctp', '.thtml'); // CUSTOMIZE MODIFY 2012/04/11 ryuring // 拡張子優先順位よりもパスの優先順位を優先する仕様に変更 // @deprecated .php への移行を推奨 // >>> /*foreach ($exts as $ext) { foreach ($paths as $path) { if (file_exists($path . $name . $ext)) { return $path . $name . $ext; } } }*/ // --- foreach ($paths as $path) { foreach ($exts as $ext) { if (file_exists($path . $name . $ext)) { if ($ext == '.ctp') { trigger_error('ビューテンプレートの拡張子 .ctp は非推奨です。.php を利用してください。<br />' . $path . $name . $ext, E_USER_WARNING); } return $path . $name . $ext; } } } // <<< $defaultPath = $paths[0]; if ($this->plugin) { $pluginPaths = Configure::read('pluginPaths'); foreach ($paths as $path) { if (strpos($path, $pluginPaths[0]) === 0) { $defaultPath = $path; break; } } } return $this->_missingView($defaultPath . $name . $this->ext, 'missingView'); }