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鐢ㄦ埛璁块棶銆
涓涓富棰樻槸涓涓獀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
灞炴
鎵鏈変富棰樼殑鍩烘湰璺緞銆傞粯璁ゆ槸鈥淲ebRootPath/themes鈥濄
baseUrl
灞炴
鎵鏈変富棰樼殑鍩烘湰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->themeClass, true);
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,'/');
}