Package | system.web |
---|---|
Inheritance | class CThemeManager » CApplicationComponent » CComponent |
Implements | IApplicationComponent |
Since | 1.0 |
Version | $Id$ |
Source Code | framework/web/CThemeManager.php |
Property | Type | Description | Defined By |
---|---|---|---|
basePath | string | the base path for all themes. | CThemeManager |
baseUrl | string | the base URL for all themes. | CThemeManager |
behaviors | array | the behaviors that should be attached to this component. | CApplicationComponent |
isInitialized | boolean | whether this application component has been initialized (i.e., init() is invoked. | CApplicationComponent |
themeClass | string | the name of the theme class for representing a theme. | CThemeManager |
themeNames | array | list of available theme names | CThemeManager |
Method | Description | Defined By |
---|---|---|
__call() | Calls the named method which is not a class method. | CComponent |
__get() | Returns a property value, an event handler list or a behavior based on its name. | CComponent |
__isset() | Checks if a property value is null. | CComponent |
__set() | Sets value of a component property. | CComponent |
__unset() | Sets a component property to be null. | CComponent |
asa() | Returns the named behavior object. | CComponent |
attachBehavior() | Attaches a behavior to this component. | CComponent |
attachBehaviors() | Attaches a list of behaviors to the component. | CComponent |
attachEventHandler() | Attaches an event handler to an event. | CComponent |
canGetProperty() | Determines whether a property can be read. | CComponent |
canSetProperty() | Determines whether a property can be set. | CComponent |
detachBehavior() | Detaches a behavior from the component. | CComponent |
detachBehaviors() | Detaches all behaviors from the component. | CComponent |
detachEventHandler() | Detaches an existing event handler. | CComponent |
disableBehavior() | Disables an attached behavior. | CComponent |
disableBehaviors() | Disables all behaviors attached to this component. | CComponent |
enableBehavior() | Enables an attached behavior. | CComponent |
enableBehaviors() | Enables all behaviors attached to this component. | CComponent |
getBasePath() | Returns the base path for all themes. Defaults to "WebRootPath/themes". | CThemeManager |
getBaseUrl() | Returns the base URL for all themes. Defaults to "/WebRoot/themes". | CThemeManager |
getEventHandlers() | Returns the list of attached event handlers for an event. | CComponent |
getIsInitialized() | Checks whether this application component has been initialized (i.e., init() is invoked.) | CApplicationComponent |
getTheme() | Returns the theme retrieved. Null if the theme does not exist. | CThemeManager |
getThemeNames() | Returns list of available theme names | CThemeManager |
hasEvent() | Determines whether an event is defined. | CComponent |
hasEventHandler() | Checks whether the named event has attached handlers. | CComponent |
hasProperty() | Determines whether a property is defined. | CComponent |
init() | Initializes the application component. | CApplicationComponent |
raiseEvent() | Raises an event. | CComponent |
setBasePath() | Sets the base path for all themes. | CThemeManager |
setBaseUrl() | Sets the base URL for all themes. | CThemeManager |
the base path for all themes. Defaults to "WebRootPath/themes".
the base URL for all themes. Defaults to "/WebRoot/themes".
the name of the theme class for representing a theme. Defaults to CTheme. This can also be a class name in dot syntax.
list of available theme names
public string getBasePath()
| ||
{return} | string | the base path for all themes. Defaults to "WebRootPath/themes". |
public function getBasePath()
{
if($this->_basePath===null)
$this->setBasePath(dirname(Yii::app()->getRequest()->getScriptFile()).DIRECTORY_SEPARATOR.self::DEFAULT_BASEPATH);
return $this->_basePath;
}
public string getBaseUrl()
| ||
{return} | string | the base URL for all themes. Defaults to "/WebRoot/themes". |
public function getBaseUrl()
{
if($this->_baseUrl===null)
$this->_baseUrl=Yii::app()->getBaseUrl().'/'.self::DEFAULT_BASEPATH;
return $this->_baseUrl;
}
public CTheme getTheme(string $name)
| ||
$name | string | name of the theme to be retrieved |
{return} | CTheme | the theme retrieved. Null if the theme does not exist. |
public function getTheme($name)
{
$themePath=$this->getBasePath().DIRECTORY_SEPARATOR.$name;
if(is_dir($themePath))
{
$class=Yii::import($this->themeClass);
return new $class($name,$themePath,$this->getBaseUrl().'/'.$name);
}
else
return null;
}
public array getThemeNames()
| ||
{return} | array | list of available theme names |
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;
}
public void setBasePath(string $value)
| ||
$value | string | the base path for all themes. |
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)));
}
public void setBaseUrl(string $value)
| ||
$value | string | the base URL for all themes. |
public function setBaseUrl($value)
{
$this->_baseUrl=rtrim($value,'/');
}
Signup or Login in order to comment.