2008-05-30 11:40:08 +00:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* A custom view class that is used for themeing
|
|
|
|
*
|
|
|
|
* PHP versions 4 and 5
|
|
|
|
*
|
2009-11-06 17:46:59 +11:00
|
|
|
* CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
|
2010-01-26 14:18:20 -05:00
|
|
|
* Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org)
|
2008-05-30 11:40:08 +00:00
|
|
|
*
|
|
|
|
* Licensed under The MIT License
|
|
|
|
* Redistributions of files must retain the above copyright notice.
|
|
|
|
*
|
2010-01-26 14:18:20 -05:00
|
|
|
* @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org)
|
2009-11-06 17:00:11 +11:00
|
|
|
* @link http://cakephp.org CakePHP(tm) Project
|
2008-10-30 17:30:26 +00:00
|
|
|
* @package cake
|
|
|
|
* @subpackage cake.cake.libs.view
|
|
|
|
* @since CakePHP(tm) v 0.10.0.1076
|
2009-11-06 17:51:51 +11:00
|
|
|
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
|
2008-05-30 11:40:08 +00:00
|
|
|
*/
|
2009-07-24 21:18:37 +02:00
|
|
|
|
2008-05-30 11:40:08 +00:00
|
|
|
/**
|
|
|
|
* Theme view class
|
|
|
|
*
|
2009-08-24 22:57:01 -04:00
|
|
|
* Allows the creation of multiple themes to be used in an app. Theme views are regular view files
|
|
|
|
* that can provide unique HTML and static assets. If theme views are not found for the current view
|
|
|
|
* the default app view files will be used. You can set `$this->theme` and `$this->view = 'Theme'`
|
|
|
|
* in your Controller to use the ThemeView.
|
|
|
|
*
|
|
|
|
* Example of theme path with `$this->theme = 'super_hot';` Would be `app/views/themed/super_hot/posts`
|
|
|
|
*
|
2008-10-30 17:30:26 +00:00
|
|
|
* @package cake
|
|
|
|
* @subpackage cake.cake.libs.view
|
2008-05-30 11:40:08 +00:00
|
|
|
*/
|
|
|
|
class ThemeView extends View {
|
|
|
|
/**
|
2009-08-24 22:53:09 -04:00
|
|
|
* Constructor for ThemeView sets $this->theme.
|
2008-05-30 11:40:08 +00:00
|
|
|
*
|
2009-08-24 22:53:09 -04:00
|
|
|
* @param Controller $controller
|
2008-05-30 11:40:08 +00:00
|
|
|
*/
|
2009-12-08 23:07:43 -05:00
|
|
|
function __construct(&$controller, $register = true) {
|
|
|
|
parent::__construct($controller, $register);
|
2008-06-20 11:57:56 +00:00
|
|
|
$this->theme =& $controller->theme;
|
2008-05-30 11:40:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Return all possible paths to find view files in order
|
|
|
|
*
|
|
|
|
* @param string $plugin
|
2010-01-25 18:14:16 -05:00
|
|
|
* @param boolean $cached Set to true to force dir scan.
|
2008-05-30 11:40:08 +00:00
|
|
|
* @return array paths
|
2010-01-25 18:14:16 -05:00
|
|
|
* @access protected
|
|
|
|
* @todo Make theme path building respect $cached parameter.
|
2008-05-30 11:40:08 +00:00
|
|
|
*/
|
|
|
|
function _paths($plugin = null, $cached = true) {
|
|
|
|
$paths = parent::_paths($plugin, $cached);
|
2009-11-26 17:50:33 -05:00
|
|
|
$themePaths = array();
|
2008-05-30 11:40:08 +00:00
|
|
|
|
|
|
|
if (!empty($this->theme)) {
|
|
|
|
$count = count($paths);
|
|
|
|
for ($i = 0; $i < $count; $i++) {
|
2009-11-25 22:29:54 -06:00
|
|
|
if (strpos($paths[$i], DS . 'plugins' . DS) === false
|
2009-11-27 00:49:20 -06:00
|
|
|
&& strpos($paths[$i], DS . 'libs' . DS . 'view') === false) {
|
2009-11-25 22:29:54 -06:00
|
|
|
if ($plugin) {
|
2009-11-25 22:58:02 -06:00
|
|
|
$themePaths[] = $paths[$i] . 'themed'. DS . $this->theme . DS . 'plugins' . DS . $plugin . DS;
|
2009-11-25 22:29:54 -06:00
|
|
|
}
|
2009-11-26 14:52:38 -06:00
|
|
|
$themePaths[] = $paths[$i] . 'themed'. DS . $this->theme . DS;
|
2009-11-25 22:29:54 -06:00
|
|
|
}
|
2008-05-30 11:40:08 +00:00
|
|
|
}
|
|
|
|
$paths = array_merge($themePaths, $paths);
|
|
|
|
}
|
2010-02-11 22:57:24 -05:00
|
|
|
return $paths;
|
2008-05-30 11:40:08 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
?>
|