3 * A custom view class that is used for themeing
7 * CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
8 * Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org)
10 * Licensed under The MIT License
11 * Redistributions of files must retain the above copyright notice.
13 * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org)
14 * @link http://cakephp.org CakePHP(tm) Project
16 * @subpackage cake.cake.libs.view
17 * @since CakePHP(tm) v 0.10.0.1076
18 * @license MIT License (http://www.opensource.org/licenses/mit-license.php)
24 * Allows the creation of multiple themes to be used in an app. Theme views are regular view files
25 * that can provide unique HTML and static assets. If theme views are not found for the current view
26 * the default app view files will be used. You can set `$this->theme` and `$this->view = 'Theme'`
27 * in your Controller to use the ThemeView.
29 * Example of theme path with `$this->theme = 'super_hot';` Would be `app/views/themed/super_hot/posts`
32 * @subpackage cake.cake.libs.view
34 class ThemeView
extends View
{
36 * Constructor for ThemeView sets $this->theme.
38 * @param Controller $controller Controller object to be rendered.
39 * @param boolean $register Should the view be registered in the registry.
41 function __construct(&$controller, $register = true) {
42 parent
::__construct($controller, $register);
43 $this->theme
=& $controller->theme
;
47 * Return all possible paths to find view files in order
49 * @param string $plugin The name of the plugin views are being found for.
50 * @param boolean $cached Set to true to force dir scan.
53 * @todo Make theme path building respect $cached parameter.
55 function _paths($plugin = null, $cached = true) {
56 $paths = parent
::_paths($plugin, $cached);
57 $themePaths = array();
59 if (!empty($this->theme
)) {
60 $count = count($paths);
61 for ($i = 0; $i < $count; $i++
) {
62 if (strpos($paths[$i], DS
. 'plugins' . DS
) === false
63 && strpos($paths[$i], DS
. 'libs' . DS
. 'view') === false) {
65 $themePaths[] = $paths[$i] . 'themed'. DS
. $this->theme
. DS
. 'plugins' . DS
. $plugin . DS
;
67 $themePaths[] = $paths[$i] . 'themed'. DS
. $this->theme
. DS
;
70 $paths = array_merge($themePaths, $paths);