/**
  * Return all possible paths to find view files in order
  *
  * @param string $plugin Optional plugin name to scan for view files.
  * @param boolean $cached Set to true to force a refresh of view paths.
  * @return array paths
  */
 protected function _paths($plugin = null, $cached = true)
 {
     if ($plugin === null && $cached === true && !empty($this->_paths)) {
         return $this->_paths;
     }
     $paths = parent::_paths($plugin, $cached);
     $paths[] = App::pluginPath('Api') . 'View' . DS;
     return $this->_paths = $paths;
 }
 /**
  * Return all possible paths to find view files in order
  *
  * @param string $plugin
  * @return array paths
  * @access private
  */
 function _paths($plugin = null, $cached = true)
 {
     $paths = parent::_paths($plugin, $cached);
     if (!empty($this->theme)) {
         $count = count($paths);
         for ($i = 0; $i < $count; $i++) {
             $themePaths[] = $paths[$i] . 'themed' . DS . $this->theme . DS;
         }
         $paths = array_merge($themePaths, $paths);
     }
     if (empty($this->__paths)) {
         $this->__paths = $paths;
     }
     return $paths;
 }
 /**
  * Return all possible paths to find view files in order
  *
  * @param string $plugin The name of the plugin views are being found for.
  * @param boolean $cached Set to true to force dir scan.
  * @return array paths
  * @todo Make theme path building respect $cached parameter.
  */
 protected function _paths($plugin = null, $cached = true)
 {
     $paths = parent::_paths($plugin, $cached);
     $themePaths = array();
     if (!empty($this->theme)) {
         foreach ($paths as $path) {
             if (strpos($path, DS . 'Plugin' . DS) === false && strpos($path, DS . 'Cake' . DS . 'View') === false) {
                 if ($plugin) {
                     $themePaths[] = $path . 'Themed' . DS . $this->theme . DS . 'Plugin' . DS . $plugin . DS;
                 }
                 $themePaths[] = $path . 'Themed' . DS . $this->theme . DS;
             }
         }
         $paths = array_merge($themePaths, $paths);
     }
     return $paths;
 }
Example #4
0
 /**
  * Return all possible paths to find view files in order
  *
  * @param string $plugin The name of the plugin views are being found for.
  * @param boolean $cached Set to true to force dir scan.
  * @return array paths
  * @access protected
  * @todo Make theme path building respect $cached parameter.
  */
 function _paths($plugin = null, $cached = true)
 {
     $paths = parent::_paths($plugin, $cached);
     $themePaths = array();
     if (!empty($this->theme)) {
         $count = count($paths);
         for ($i = 0; $i < $count; $i++) {
             if (strpos($paths[$i], DS . 'plugins' . DS) === false && strpos($paths[$i], DS . 'libs' . DS . 'view') === false) {
                 if ($plugin) {
                     $themePaths[] = $paths[$i] . 'themed' . DS . $this->theme . DS . 'plugins' . DS . $plugin . DS;
                 }
                 $themePaths[] = $paths[$i] . 'themed' . DS . $this->theme . DS;
             }
         }
         $paths = array_merge($themePaths, $paths);
     }
     return $paths;
 }
Example #5
0
 /**
  * Return all possible paths to find view files in order.
  * We may have a 'themed' folder under /app/views for theme overrides
  *
  * @param string $plugin
  * @return array paths
  * 
  * @access protected
  */
 function _paths($plugin = null, $cached = true)
 {
     if ($cached === true && !empty($this->_cachedPaths[$plugin])) {
         return $this->_cachedPaths[$plugin];
     }
     $paths = parent::_paths($plugin, false);
     if ($this->theme) {
         // themed views (core app)
         $path = VIEWS . "themed/{$this->theme}/";
         array_unshift($paths, $path);
         // themed views (plugins)
         if ($plugin) {
             //                $path = App::pluginPath($plugin) . "views/themed/$this->theme/";
             //                array_unshift($paths, $path);
             $path = VIEWS . "themed/{$this->theme}/plugins/{$plugin}/";
             array_unshift($paths, $path);
         }
     }
     $this->_cachedPaths[$plugin] = $paths;
     return $paths;
 }
Example #6
0
 function _getViewFileName($name = null)
 {
     $this->subDir = null;
     $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 = View::_paths(Inflector::underscore($this->plugin));
     $exts = array($this->ext, '.ctp', '.thtml');
     foreach ($exts as $ext) {
         foreach ($paths as $path) {
             if (file_exists($path . $name . $ext)) {
                 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 false;
 }
Example #7
0
 /**
  * This method overwrites the View::_paths() method so it can include the dashboard plugin path as candidate
  * 
  * @access public
  * @return array Array of possible paths from View::_paths() merged with dashboard plugin path
  */
 function _paths($plugin = null, $cached = true)
 {
     $paths = parent::_paths($plugin, $cached);
     array_push($paths, App::pluginPath('backstage') . 'views' . DS);
     return $paths;
 }