summaryrefslogtreecommitdiff
path: root/framework
diff options
context:
space:
mode:
authorxue <>2005-12-08 19:20:59 +0000
committerxue <>2005-12-08 19:20:59 +0000
commit84f52b18da70cb1fa2648f4d82ee45c6415c64ed (patch)
treee1ecd3a785bd87dda33d7338bf6a78c274ba7f75 /framework
parentaf2d46c638c91ade1b627e957241ddaf98f5ed5f (diff)
Diffstat (limited to 'framework')
-rw-r--r--framework/Web/UI/TPage.php4
-rw-r--r--framework/Web/UI/TThemeManager.php52
2 files changed, 39 insertions, 17 deletions
diff --git a/framework/Web/UI/TPage.php b/framework/Web/UI/TPage.php
index f9d8f879..0bcba739 100644
--- a/framework/Web/UI/TPage.php
+++ b/framework/Web/UI/TPage.php
@@ -451,11 +451,15 @@ class TPage extends TTemplateControl
{
foreach($this->_theme->getStyleSheetFiles() as $url)
$cs->registerStyleSheetFile($url,$url);
+ foreach($this->_theme->getJavaScriptFiles() as $url)
+ $cs->registerHeadScriptFile($url,$url);
}
if($this->_styleSheet)
{
foreach($this->_styleSheet->getStyleSheetFiles() as $url)
$cs->registerStyleSheetFile($url,$url);
+ foreach($this->_styleSheet->getJavaScriptFiles() as $url)
+ $cs->registerHeadScriptFile($url,$url);
}
}
diff --git a/framework/Web/UI/TThemeManager.php b/framework/Web/UI/TThemeManager.php
index cc406305..bc1edd25 100644
--- a/framework/Web/UI/TThemeManager.php
+++ b/framework/Web/UI/TThemeManager.php
@@ -201,6 +201,10 @@ class TTheme extends TComponent
* @var array list of css files
*/
private $_cssFiles=array();
+ /**
+ * @var array list of js files
+ */
+ private $_jsFiles=array();
/**
* Constructor.
@@ -218,31 +222,35 @@ class TTheme extends TComponent
$array=$cache->get(self::THEME_CACHE_PREFIX.$themePath);
if(is_array($array))
{
- list($skins,$cssFiles,$timestamp)=$array;
+ list($skins,$cssFiles,$jsFiles,$timestamp)=$array;
$cacheValid=true;
if($application->getMode()!=='Performance')
{
- if(filemtime($themePath)>$timestamp)
- $cacheValid=false;
- else
+ if(($dir=opendir($themePath))===false)
+ throw new TIOException('theme_path_inexistent',$themePath);
+ while(($file=readdir($dir))!==false)
{
- if(($dir=opendir($themePath))===false)
- throw new TIOException('theme_path_inexistent',$themePath);
- while(($file=readdir($dir))!==false)
+ if($file==='.' || $file==='..')
+ continue;
+ else if(basename($file,'.css')!==$file)
+ $this->_cssFiles[]=$themeUrl.'/'.$file;
+ else if(basename($file,'.js')!==$file)
+ $this->_jsFiles[]=$themeUrl.'/'.$file;
+ else if(basename($file,self::SKIN_FILE_EXT)!==$file && filemtime($themePath.'/'.$file)>$timestamp)
{
- if(basename($file,self::SKIN_FILE_EXT)!==$file && filemtime($themePath.'/'.$file)>$timestamp)
- {
- $cacheValid=false;
- break;
- }
+ $cacheValid=false;
+ break;
}
- closedir($dir);
}
+ closedir($dir);
+ if($cacheValid)
+ $this->_skins=$skins;
}
- if($cacheValid)
+ else
{
- $this->_skins=$skins;
$this->_cssFiles=$cssFiles;
+ $this->_jsFiles=$jsFiles;
+ $this->_skins=$skins;
}
}
}
@@ -254,8 +262,10 @@ class TTheme extends TComponent
{
if($file==='.' || $file==='..')
continue;
- else if(basename($file,'.css')!==$file) // is a css file
+ else if(basename($file,'.css')!==$file)
$this->_cssFiles[]=$themeUrl.'/'.$file;
+ else if(basename($file,'.js')!==$file)
+ $this->_jsFiles[]=$themeUrl.'/'.$file;
else if(basename($file,self::SKIN_FILE_EXT)!==$file)
{
$template=new TTemplate(file_get_contents($themePath.'/'.$file),$themePath,$themePath.'/'.$file);
@@ -281,7 +291,7 @@ class TTheme extends TComponent
}
closedir($dir);
if($cache!==null)
- $cache->set(self::THEME_CACHE_PREFIX.$themePath,array($this->_skins,$this->_cssFiles,time()));
+ $cache->set(self::THEME_CACHE_PREFIX.$themePath,array($this->_skins,$this->_cssFiles,$this->_jsFiles,time()));
}
}
@@ -351,6 +361,14 @@ class TTheme extends TComponent
{
return $this->_cssFiles;
}
+
+ /**
+ * @return array list of Javascript files (URL) in the theme
+ */
+ public function getJavaScriptFiles()
+ {
+ return $this->_jsFiles;
+ }
}
?> \ No newline at end of file