Exemplo n.º 1
0
 /**
  * テンプレートのファイル名を取得する
  * プレフィックスが設定されている場合は、プレフィックスを除外する
  * @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);
     }
 }
Exemplo n.º 2
0
 /**
  * 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');
 }