summaryrefslogtreecommitdiff
path: root/framework/Web/UI/TThemeManager.php
diff options
context:
space:
mode:
authorxue <>2005-11-15 15:34:38 +0000
committerxue <>2005-11-15 15:34:38 +0000
commit4c9067bf7ae89b446bb0e236ab20c5b4fa3ee3e3 (patch)
treebe5b2366fdedd2d2789955deb18ef7e072ca4e6e /framework/Web/UI/TThemeManager.php
parentfdce469afc80e6cf922c07500f9b7bfd5b302c35 (diff)
Added a new template/theme syntax for URL support.
Diffstat (limited to 'framework/Web/UI/TThemeManager.php')
-rw-r--r--framework/Web/UI/TThemeManager.php44
1 files changed, 17 insertions, 27 deletions
diff --git a/framework/Web/UI/TThemeManager.php b/framework/Web/UI/TThemeManager.php
index 019ccc85..7b370746 100644
--- a/framework/Web/UI/TThemeManager.php
+++ b/framework/Web/UI/TThemeManager.php
@@ -31,7 +31,7 @@ class TThemeManager extends TComponent implements IModule
{
$this->_application=$application;
if($this->_themePath===null)
- $this->_themePath=dirname($application->getConfigurationFile()).'/'.self::DEFAULT_THEME_PATH;
+ $this->_themePath=dirname($application->getRequest()->getPhysicalApplicationPath()).'/'.self::DEFAULT_THEME_PATH;
$this->_initialized=true;
}
@@ -111,14 +111,21 @@ class TThemeManager extends TComponent implements IModule
class TTheme extends TTemplate
{
- const ASSET_PATH='assets';
private $_themePath;
- private $_themeFile;
+ private $_themeUrl;
private $_skins=array();
public function __construct($content,$themePath)
{
- $this->_themePath=$themePath;
+ $this->_themePath=strtr($themePath,'\\','/');
+ $basePath=dirname(Prado::getApplication()->getRequest()->getPhysicalApplicationPath());
+ if(($pos=strpos($this->_themePath,$basePath))===false)
+ throw new TConfigurationException('theme_themepath_invalid',$themePath);
+ else
+ {
+ $baseUrl=dirname(Prado::getApplication()->getRequest()->getApplicationPath());
+ $this->_themeUrl=$baseUrl.'/'.strtr(substr($this->_themePath,strlen($basePath)),'\\','/');
+ }
$theme=&$this->parse($content);
foreach($theme as $skin)
{
@@ -150,7 +157,12 @@ class TTheme extends TTemplate
foreach($this->_skins[$type][$id] as $name=>$value)
{
if(is_array($value))
- $value=$this->evaluateExpression($value[1]);
+ {
+ if($value[0]===1)
+ $value=$this->evaluateExpression($value[1]);
+ else if($value[0]===2)
+ $value=$this->_themeUrl.'/'.$value[1];
+ }
if(strpos($name,'.')===false) // is simple property or custom attribute
{
if($control->hasProperty($name))
@@ -176,28 +188,6 @@ class TTheme extends TTemplate
else
return false;
}
-
- public function publishFile($file)
- {
- return Prado::getApplication()->getService()->getAssetManager()->publishFile($file);
- }
-
- public function publishDirectory($directory)
- {
- return Prado::getApplication()->getService()->getAssetManager()->publishDirectory($directory);
- }
-
- public function getAsset($assetName)
- {
- $assetFile=$this->_themePath.'/'.self::ASSET_PATH.'/'.$assetName;
- if(is_file($assetFile))
- return $this->publishFile($assetFile);
- else if(is_dir($assetFile))
- return $this->publishDirectory($assetFile);
- else
- return '';
- }
-
}