Yii Framework v1.1.10 绫诲弬鑰

CThemeManager

system.web
缁ф壙 class CThemeManager » CApplicationComponent » CComponent
瀹炵幇 IApplicationComponent
婧愯嚜 1.0
鐗堟湰 $Id: CThemeManager.php 3426 2011-10-25 00:01:09Z alexander.makarow $
婧愮爜 framework/web/CThemeManager.php
CThemeManager绠$悊web搴旂敤绋嬪簭鐨勪富棰樸

涓涓富棰樻槸涓涓獀iew/layout鏂囦欢鍜岃祫婧愭枃浠 锛堜緥濡俢ss锛宨mage锛宩s鏂囦欢锛夌殑闆嗗悎銆傚綋涓涓富棰樻槸婵娲荤殑鏃讹紝CController 灏嗛鍏堝湪涓婚鏂囦欢澶逛笅鏌ユ壘鎸囧畾鐨剉iew/layout銆 濡傛灉姝や富棰樻彁渚涗簡瀹冧滑锛岀浉搴旂殑view/layout鏂囦欢灏嗚浣跨敤銆 鍚﹀垯锛岄粯璁ょ殑view/layout鏂囦欢灏嗚浣跨敤銆

榛樿鎯呭喌涓嬶紝姣忎竴涓富棰樿缁勭粐涓轰竴涓洰褰曪紝鐩綍鍚嶅氨鏄富棰樺悕銆 鎵鏈夌殑涓婚瀛樻斁鍦ㄢ淲ebRootPath/themes鈥濈洰褰曚笅銆

瑕佹縺娲讳竴涓富棰橈紝璁剧疆theme灞炴 涓轰富棰樼殑鍚嶅瓧銆

涓涓嫭绔嬬殑涓婚缁忓父鍖呭惈鍙粡web璁块棶鐨勮祫婧愭枃浠讹紝 璇风‘淇漹iew/layout鏂囦欢琚繚鎶や笉琚玾eb鐢ㄦ埛璁块棶銆

鍏叡灞炴

闅愯棌缁ф壙灞炴

灞炴绫诲瀷鎻忚堪瀹氫箟鍦
basePath string 鎵鏈変富棰樼殑鍩烘湰璺緞銆傞粯璁ゆ槸鈥淲ebRootPath/themes鈥濄 CThemeManager
baseUrl string 鎵鏈変富棰樼殑鍩烘湰URL銆傞粯璁ゆ槸鈥/WebRoot/themes鈥濄 CThemeManager
behaviors array 杩欎釜搴旂敤缁勪欢闄勫姞鐨勮涓恒 杩欐琛屼负灏嗗湪搴旂敤缁勪欢璋冪敤init鏃堕檮鍔犲湪搴旂敤缁勪欢涓娿 璇峰弬鐓CModel::behaviors濡備綍鎸囧畾姝ゅ睘鎬у笺 CApplicationComponent
isInitialized boolean 妫鏌ュ簲鐢ㄧ粍浠舵槸鍚﹀凡缁忓垵濮嬪寲銆 CApplicationComponent
themeClass string 琛ㄧず涓涓富棰樼殑涓婚绫诲悕绉般 榛樿鏄CTheme銆傝繖涔熷彲浠ユ槸涓涓甫鐐硅娉曠殑绫诲悕銆 CThemeManager
themeNames array 鍙敤涓婚鍚嶅垪琛 CThemeManager

鍏叡鏂规硶

闅愯棌缁ф壙鏂规硶

鏂规硶鎻忚堪瀹氫箟鍦
__call() 濡傛灉绫讳腑娌℃湁璋冪殑鏂规硶鍚嶏紝鍒欒皟鐢ㄨ繖涓柟娉曘 CComponent
__get() 杩斿洖涓涓睘鎬у笺佷竴涓簨浠跺鐞嗙▼搴忓垪琛ㄦ垨涓涓涓哄悕绉般 CComponent
__isset() 妫鏌ヤ竴涓睘鎬ф槸鍚︿负null銆 CComponent
__set() 璁剧疆涓涓粍浠剁殑灞炴у笺 CComponent
__unset() 璁剧疆涓涓粍浠剁殑灞炴т负null銆 CComponent
asa() 杩斿洖杩欎釜鍚嶅瓧鐨勮涓哄璞° CComponent
attachBehavior() 闄勫姞涓涓涓哄埌缁勪欢銆 CComponent
attachBehaviors() 闄勫姞涓涓涓哄垪琛ㄥ埌缁勪欢銆 CComponent
attachEventHandler() 涓轰簨浠堕檮鍔犱竴涓簨浠跺鐞嗙▼搴忋 CComponent
canGetProperty() 纭畾灞炴ф槸鍚﹀彲璇汇 CComponent
canSetProperty() 纭畾灞炴ф槸鍚﹀彲鍐欍 CComponent
detachBehavior() 浠庣粍浠朵腑鍒嗙涓涓涓恒 CComponent
detachBehaviors() 浠庣粍浠朵腑鍒嗙鎵鏈夎涓恒 CComponent
detachEventHandler() 鍒嗙涓涓瓨鍦ㄧ殑浜嬩欢澶勭悊绋嬪簭銆 CComponent
disableBehavior() 绂佺敤涓涓檮鍔犺涓恒 CComponent
disableBehaviors() 绂佺敤缁勪欢闄勫姞鐨勬墍鏈夎涓恒 CComponent
enableBehavior() 鍚敤涓涓檮鍔犺涓恒 CComponent
enableBehaviors() 鍚敤缁勪欢闄勫姞鐨勬墍鏈夎涓恒 CComponent
evaluateExpression() 璁$畻涓涓狿HP琛ㄨ揪寮忥紝鎴栨牴鎹粍浠朵笂涓嬫枃鎵ц鍥炶皟銆 CComponent
getBasePath() 杩斿洖鎵鏈変富棰樼殑鍩烘湰璺緞銆傞粯璁ゆ槸鈥淲ebRootPath/themes鈥濄 CThemeManager
getBaseUrl() 杩斿洖鎵鏈変富棰樼殑鍩烘湰URL銆傞粯璁ゆ槸鈥/WebRoot/themes鈥濄 CThemeManager
getEventHandlers() 杩斿洖涓涓簨浠剁殑闄勫姞澶勭悊绋嬪簭鍒楄〃銆 CComponent
getIsInitialized() 妫鏌ュ簲鐢ㄧ粍浠舵槸鍚﹀凡缁忓垵濮嬪寲銆 CApplicationComponent
getTheme() 杩斿洖宸插彇鍥炵殑涓婚銆傚鏋滀富棰樹笉瀛樺湪涓篘ull銆 CThemeManager
getThemeNames() 杩斿洖鍙敤涓婚鍚嶅垪琛 CThemeManager
hasEvent() 纭畾涓涓簨浠舵槸鍚﹀畾涔夈 CComponent
hasEventHandler() 妫鏌ヤ簨浠舵槸鍚︽湁闄勫姞鐨勫鐞嗙▼搴忋 CComponent
hasProperty() 纭畾灞炴ф槸鍚﹁瀹氫箟銆 CComponent
init() 鍒濆鍖栧簲鐢ㄧ粍浠躲 CApplicationComponent
raiseEvent() 鍙戣捣涓涓簨浠躲 CComponent
setBasePath() 璁剧疆鎵鏈変富棰樺熀鏈矾寰勩 CThemeManager
setBaseUrl() 璁剧疆鎵鏈変富棰樼殑鍩烘湰URL銆 CThemeManager

灞炴ц缁

basePath 灞炴
public string getBasePath()
public void setBasePath(string $value)

鎵鏈変富棰樼殑鍩烘湰璺緞銆傞粯璁ゆ槸鈥淲ebRootPath/themes鈥濄

baseUrl 灞炴
public string getBaseUrl()
public void setBaseUrl(string $value)

鎵鏈変富棰樼殑鍩烘湰URL銆傞粯璁ゆ槸鈥/WebRoot/themes鈥濄

themeClass 灞炴
public string $themeClass;

琛ㄧず涓涓富棰樼殑涓婚绫诲悕绉般 榛樿鏄CTheme銆傝繖涔熷彲浠ユ槸涓涓甫鐐硅娉曠殑绫诲悕銆

themeNames 灞炴 鍙
public array getThemeNames()

鍙敤涓婚鍚嶅垪琛

鏂规硶璇︾粏

getBasePath() 鏂规硶
public string getBasePath()
{return} string 鎵鏈変富棰樼殑鍩烘湰璺緞銆傞粯璁ゆ槸鈥淲ebRootPath/themes鈥濄
婧愮爜锛 framework/web/CThemeManager.php#96 (鏄剧ず)
public function getBasePath()
{
    if(
$this->_basePath===null)
        
$this->setBasePath(dirname(Yii::app()->getRequest()->getScriptFile()).DIRECTORY_SEPARATOR.self::DEFAULT_BASEPATH);
    return 
$this->_basePath;
}

getBaseUrl() 鏂规硶
public string getBaseUrl()
{return} string 鎵鏈変富棰樼殑鍩烘湰URL銆傞粯璁ゆ槸鈥/WebRoot/themes鈥濄
婧愮爜锛 framework/web/CThemeManager.php#117 (鏄剧ず)
public function getBaseUrl()
{
    if(
$this->_baseUrl===null)
        
$this->_baseUrl=Yii::app()->getBaseUrl().'/'.self::DEFAULT_BASEPATH;
    return 
$this->_baseUrl;
}

getTheme() 鏂规硶
public CTheme getTheme(string $name)
$name string 瑕佸彇鍥炵殑涓婚鐨勫悕绉
{return} CTheme 宸插彇鍥炵殑涓婚銆傚鏋滀富棰樹笉瀛樺湪涓篘ull銆
婧愮爜锛 framework/web/CThemeManager.php#59 (鏄剧ず)
public function getTheme($name)
{
    
$themePath=$this->getBasePath().DIRECTORY_SEPARATOR.$name;
    if(
is_dir($themePath))
    {
        
$class=Yii::import($this->themeClasstrue);
        return new 
$class($name,$themePath,$this->getBaseUrl().'/'.$name);
    }
    else
        return 
null;
}

getThemeNames() 鏂规硶
public array getThemeNames()
{return} array 鍙敤涓婚鍚嶅垪琛
婧愮爜锛 framework/web/CThemeManager.php#74 (鏄剧ず)
public function getThemeNames()
{
    static 
$themes;
    if(
$themes===null)
    {
        
$themes=array();
        
$basePath=$this->getBasePath();
        
$folder=@opendir($basePath);
        while((
$file=@readdir($folder))!==false)
        {
            if(
$file!=='.' && $file!=='..' && $file!=='.svn' && is_dir($basePath.DIRECTORY_SEPARATOR.$file))
                
$themes[]=$file;
        }
        
closedir($folder);
        
sort($themes);
    }
    return 
$themes;
}

setBasePath() 鏂规硶
public void setBasePath(string $value)
$value string 鎵鏈変富棰樺熀鏈矾寰勩
婧愮爜锛 framework/web/CThemeManager.php#107 (鏄剧ず)
public function setBasePath($value)
{
    
$this->_basePath=realpath($value);
    if(
$this->_basePath===false || !is_dir($this->_basePath))
        throw new 
CException(Yii::t('yii','Theme directory "{directory}" does not exist.',array('{directory}'=>$value)));
}

setBaseUrl() 鏂规硶
public void setBaseUrl(string $value)
$value string 鎵鏈変富棰樼殑鍩烘湰URL銆
婧愮爜锛 framework/web/CThemeManager.php#127 (鏄剧ず)
public function setBaseUrl($value)
{
    
$this->_baseUrl=rtrim($value,'/');
}

Copyright © 2008-2011 by Yii Software LLC
All Rights Reserved.