theme.php

Go to the documentation of this file.
00001 <?php
00002 /* SVN FILE: $Id: theme_8php-source.html 580 2008-07-01 14:45:49Z gwoo $ */
00003 /**
00004  * A custom view class that is used for themeing
00005  *
00006  * PHP versions 4 and 5
00007  *
00008  * CakePHP(tm) :  Rapid Development Framework <http://www.cakephp.org/>
00009  * Copyright 2005-2008, Cake Software Foundation, Inc.
00010  *                              1785 E. Sahara Avenue, Suite 490-204
00011  *                              Las Vegas, Nevada 89104
00012  *
00013  * Licensed under The MIT License
00014  * Redistributions of files must retain the above copyright notice.
00015  *
00016  * @filesource
00017  * @copyright       Copyright 2005-2008, Cake Software Foundation, Inc.
00018  * @link                http://www.cakefoundation.org/projects/info/cakephp CakePHP(tm) Project
00019  * @package         cake
00020  * @subpackage      cake.cake.libs.view
00021  * @since           CakePHP(tm) v 0.10.0.1076
00022  * @version         $Revision: 580 $
00023  * @modifiedby      $LastChangedBy: gwoo $
00024  * @lastmodified    $Date: 2008-07-01 09:45:49 -0500 (Tue, 01 Jul 2008) $
00025  * @license         http://www.opensource.org/licenses/mit-license.php The MIT License
00026  */
00027 
00028 /**
00029  * Theme view class
00030  *
00031  * @package         cake
00032  * @subpackage      cake.cake.libs.view
00033  */
00034 class ThemeView extends View {
00035 /**
00036  * System path to themed element: themed . DS . theme . DS . elements . DS
00037  *
00038  * @var string
00039  */
00040     var $themeElement = null;
00041 /**
00042  * System path to themed layout: themed . DS . theme . DS . layouts . DS
00043  *
00044  * @var string
00045  */
00046     var $themeLayout = null;
00047 /**
00048  * System path to themed: themed . DS . theme . DS
00049  *
00050  * @var string
00051  */
00052     var $themePath = null;
00053 
00054 /**
00055  * Enter description here...
00056  *
00057  * @param unknown_type $controller
00058  */
00059     function __construct (&$controller) {
00060         parent::__construct($controller);
00061         $this->theme =& $controller->theme;
00062 
00063         if (!empty($this->theme)) {
00064             if (is_dir(WWW_ROOT . 'themed' . DS . $this->theme)) {
00065                 $this->themeWeb = 'themed/'. $this->theme .'/';
00066             }
00067             /* deprecated: as of 6128 the following properties are no longer needed */
00068             $this->themeElement = 'themed'. DS . $this->theme . DS .'elements'. DS;
00069             $this->themeLayout =  'themed'. DS . $this->theme . DS .'layouts'. DS;
00070             $this->themePath = 'themed'. DS . $this->theme . DS;
00071         }
00072     }
00073 
00074 /**
00075  * Return all possible paths to find view files in order
00076  *
00077  * @param string $plugin
00078  * @return array paths
00079  * @access private
00080  */
00081     function _paths($plugin = null, $cached = true) {
00082         $paths = parent::_paths($plugin, $cached);
00083 
00084         if (!empty($this->theme)) {
00085             $count = count($paths);
00086             for ($i = 0; $i < $count; $i++) {
00087                 $themePaths[] = $paths[$i] . 'themed'. DS . $this->theme . DS;
00088             }
00089             $paths = array_merge($themePaths, $paths);
00090         }
00091 
00092         if(empty($this->__paths)) {
00093             $this->__paths = $paths;
00094         }
00095 
00096         return $paths;
00097     }
00098 }
00099 ?>