~tsep-dev/tsep/0.9-beta

« back to all changes in this revision

Viewing changes to branches/symfony/cake/libs/view/theme.php

  • Committer: geoffreyfishing
  • Date: 2011-01-11 23:46:12 UTC
  • Revision ID: svn-v4:ae0de26e-ed09-4cbe-9a20-e40b4c60ac6c::125
Created a symfony branch for future migration to symfony

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
<?php
 
2
/**
 
3
 * A custom view class that is used for themeing
 
4
 *
 
5
 * PHP versions 4 and 5
 
6
 *
 
7
 * CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
 
8
 * Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org)
 
9
 *
 
10
 * Licensed under The MIT License
 
11
 * Redistributions of files must retain the above copyright notice.
 
12
 *
 
13
 * @copyright     Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org)
 
14
 * @link          http://cakephp.org CakePHP(tm) Project
 
15
 * @package       cake
 
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)
 
19
 */
 
20
 
 
21
/**
 
22
 * Theme view class
 
23
 *
 
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.
 
28
 *
 
29
 * Example of theme path with `$this->theme = 'super_hot';` Would be `app/views/themed/super_hot/posts`
 
30
 *
 
31
 * @package       cake
 
32
 * @subpackage    cake.cake.libs.view
 
33
 */
 
34
class ThemeView extends View {
 
35
/**
 
36
 * Constructor for ThemeView sets $this->theme.
 
37
 *
 
38
 * @param Controller $controller Controller object to be rendered.
 
39
 * @param boolean $register Should the view be registered in the registry.
 
40
 */
 
41
        function __construct(&$controller, $register = true) {
 
42
                parent::__construct($controller, $register);
 
43
                $this->theme =& $controller->theme;
 
44
        }
 
45
 
 
46
/**
 
47
 * Return all possible paths to find view files in order
 
48
 *
 
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.
 
51
 * @return array paths
 
52
 * @access protected
 
53
 * @todo Make theme path building respect $cached parameter.
 
54
 */
 
55
        function _paths($plugin = null, $cached = true) {
 
56
                $paths = parent::_paths($plugin, $cached);
 
57
                $themePaths = array();
 
58
 
 
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) {
 
64
                                                if ($plugin) {
 
65
                                                        $themePaths[] = $paths[$i] . 'themed'. DS . $this->theme . DS . 'plugins' . DS . $plugin . DS;
 
66
                                                }
 
67
                                                $themePaths[] = $paths[$i] . 'themed'. DS . $this->theme . DS;
 
68
                                        }
 
69
                        }
 
70
                        $paths = array_merge($themePaths, $paths);
 
71
                }
 
72
                return $paths;
 
73
        }
 
74
}