2008-05-30 11:40:08 +00:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* A custom view class that is used for themeing
|
|
|
|
*
|
2010-10-03 16:38:58 +00:00
|
|
|
* PHP 5
|
2008-05-30 11:40:08 +00:00
|
|
|
*
|
2009-11-06 06:46:59 +00:00
|
|
|
* CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
|
2011-05-29 21:31:39 +00:00
|
|
|
* Copyright 2005-2011, 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.
|
|
|
|
*
|
2011-05-29 21:31:39 +00:00
|
|
|
* @copyright Copyright 2005-2011, Cake Software Foundation, Inc. (http://cakefoundation.org)
|
2009-11-06 06:00:11 +00:00
|
|
|
* @link http://cakephp.org CakePHP(tm) Project
|
2011-07-26 06:16:14 +00:00
|
|
|
* @package Cake.View
|
2008-10-30 17:30:26 +00:00
|
|
|
* @since CakePHP(tm) v 0.10.0.1076
|
2009-11-06 06:51:51 +00:00
|
|
|
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
|
2008-05-30 11:40:08 +00:00
|
|
|
*/
|
2010-12-03 23:07:21 +00:00
|
|
|
App::uses('View', 'View');
|
2009-07-24 19:18:37 +00:00
|
|
|
|
2008-05-30 11:40:08 +00:00
|
|
|
/**
|
|
|
|
* Theme view class
|
|
|
|
*
|
2009-08-25 02:57:01 +00: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
|
2011-03-09 22:24:20 +00:00
|
|
|
* the default app view files will be used. You can set `$this->theme` and `$this->viewClass = 'Theme'`
|
2009-08-25 02:57:01 +00:00
|
|
|
* in your Controller to use the ThemeView.
|
|
|
|
*
|
2011-06-20 00:28:40 +00:00
|
|
|
* Example of theme path with `$this->theme = 'super_hot';` Would be `app/View/Themed/SuperHot/Posts`
|
2009-08-25 02:57:01 +00:00
|
|
|
*
|
2011-07-26 06:16:14 +00:00
|
|
|
* @package Cake.View
|
2008-05-30 11:40:08 +00:00
|
|
|
*/
|
|
|
|
class ThemeView extends View {
|
|
|
|
/**
|
2009-08-25 02:53:09 +00:00
|
|
|
* Constructor for ThemeView sets $this->theme.
|
2008-05-30 11:40:08 +00:00
|
|
|
*
|
2010-06-10 18:23:49 +00:00
|
|
|
* @param Controller $controller Controller object to be rendered.
|
2008-05-30 11:40:08 +00:00
|
|
|
*/
|
2011-05-28 20:38:46 +00:00
|
|
|
public function __construct($controller) {
|
2010-07-15 03:14:39 +00:00
|
|
|
parent::__construct($controller);
|
2010-09-15 03:13:00 +00:00
|
|
|
$this->theme = $controller->theme;
|
2008-05-30 11:40:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Return all possible paths to find view files in order
|
|
|
|
*
|
2010-06-10 18:23:49 +00:00
|
|
|
* @param string $plugin The name of the plugin views are being found for.
|
2010-01-25 23:14:16 +00: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 23:14:16 +00:00
|
|
|
* @todo Make theme path building respect $cached parameter.
|
2008-05-30 11:40:08 +00:00
|
|
|
*/
|
2011-05-28 20:38:46 +00:00
|
|
|
protected function _paths($plugin = null, $cached = true) {
|
2008-05-30 11:40:08 +00:00
|
|
|
$paths = parent::_paths($plugin, $cached);
|
2009-11-26 22:50:33 +00:00
|
|
|
$themePaths = array();
|
2008-05-30 11:40:08 +00:00
|
|
|
|
|
|
|
if (!empty($this->theme)) {
|
|
|
|
$count = count($paths);
|
|
|
|
for ($i = 0; $i < $count; $i++) {
|
2011-05-13 07:49:00 +00:00
|
|
|
if (strpos($paths[$i], DS . 'Plugins' . DS) === false
|
2010-12-20 04:19:20 +00:00
|
|
|
&& strpos($paths[$i], DS . 'Cake' . DS . 'View') === false) {
|
2009-11-26 04:29:54 +00:00
|
|
|
if ($plugin) {
|
2011-05-13 07:49:00 +00:00
|
|
|
$themePaths[] = $paths[$i] . 'Themed'. DS . $this->theme . DS . 'Plugins' . DS . $plugin . DS;
|
2009-11-26 04:29:54 +00:00
|
|
|
}
|
2011-05-13 07:49:00 +00:00
|
|
|
$themePaths[] = $paths[$i] . 'Themed'. DS . $this->theme . DS;
|
2009-11-26 04:29:54 +00:00
|
|
|
}
|
2008-05-30 11:40:08 +00:00
|
|
|
}
|
|
|
|
$paths = array_merge($themePaths, $paths);
|
|
|
|
}
|
2010-02-12 03:57:24 +00:00
|
|
|
return $paths;
|
2008-05-30 11:40:08 +00:00
|
|
|
}
|
|
|
|
}
|