From 8a4e5a9b04c479fa027acfba52f4d68cf3bd6679 Mon Sep 17 00:00:00 2001 From: xue <> Date: Sat, 12 Nov 2005 18:17:58 +0000 Subject: Added asset manager. --- framework/Web/Services/TPageService.php | 80 +++++++-------------------------- 1 file changed, 16 insertions(+), 64 deletions(-) (limited to 'framework/Web/Services/TPageService.php') diff --git a/framework/Web/Services/TPageService.php b/framework/Web/Services/TPageService.php index e4791543..f6609725 100644 --- a/framework/Web/Services/TPageService.php +++ b/framework/Web/Services/TPageService.php @@ -38,7 +38,7 @@ class TPageService extends TComponent implements IService /** * @var string root path of pages */ - private $_pageRootPath; + private $_pageBasePath; /** * @var string default page */ @@ -51,14 +51,6 @@ class TPageService extends TComponent implements IService * @var string requested page type */ private $_pageType; - /** - * @var string the base URL for accessing published assets - */ - private $_assetBaseUrl; - /** - * @var string the root path for storing published asset files - */ - private $_assetRootPath; /** * @var array list of initial page property values */ @@ -86,8 +78,8 @@ class TPageService extends TComponent implements IService { $this->_application=$application; - if(($pageRootPath=Prado::getPathOfNamespace($this->_pageRootPath))===null || !is_dir($pageRootPath)) - throw new TConfigurationException('pageservice_pagerootpath_invalid',$this->_pageRootPath); + if(($pageBasePath=Prado::getPathOfNamespace($this->_pageBasePath))===null || !is_dir($pageBasePath)) + throw new TConfigurationException('pageservice_pagebasepath_invalid',$this->_pageBasePath); $this->_pagePath=$application->getRequest()->getServiceParameter(); if(empty($this->_pagePath)) @@ -99,7 +91,7 @@ class TPageService extends TComponent implements IService { $pageConfig=new TPageConfiguration; $pageConfig->loadXmlElement($config,dirname($application->getConfigurationFile()),null); - $pageConfig->loadConfigurationFiles($this->_pagePath,$pageRootPath); + $pageConfig->loadConfigurationFiles($this->_pagePath,$pageBasePath); } else { @@ -113,7 +105,7 @@ class TPageService extends TComponent implements IService // check to see if cache is the latest $paths=explode('.',$this->_pagePath); array_pop($paths); - $configPath=$pageRootPath; + $configPath=$pageBasePath; foreach($paths as $path) { if(@filemtime($configPath.'/'.self::CONFIG_FILE)>$timestamp) @@ -133,7 +125,7 @@ class TPageService extends TComponent implements IService { $pageConfig=new TPageConfiguration; $pageConfig->loadXmlElement($config,dirname($application->getConfigurationFile()),null); - $pageConfig->loadConfigurationFiles($this->_pagePath,$pageRootPath); + $pageConfig->loadConfigurationFiles($this->_pagePath,$pageBasePath); $cache->set(self::CONFIG_CACHE_PREFIX.$this->_pagePath,array($pageConfig,time()),$this->_cacheExpire<0?0:$this->_cacheExpire); } } @@ -163,7 +155,7 @@ class TPageService extends TComponent implements IService } } - // load modules specified in app config + // load modules specified in page directory config foreach($pageConfig->getModules() as $id=>$moduleConfig) { $module=Prado::createComponent($moduleConfig[0]); @@ -274,61 +266,21 @@ class TPageService extends TComponent implements IService /** * @return string root directory (in namespace form) storing pages */ - public function getPageRootPath() + public function getPageBasePath() { - return $this->_pageRootPath; + return $this->_pageBasePath; } /** * @param string root directory (in namespace form) storing pages * @throws TInvalidOperationException if the service is initialized already */ - public function setPageRootPath($value) - { - if($this->_initialized) - throw new TInvalidOperationException('pageservice_pagerootpath_unchangeable'); - else - $this->_pageRootPath=$value; - } - - /** - * @return string the root directory storing published asset files - */ - public function getAssetRootPath() - { - return $this->_assetRootPath; - } - - /** - * @param string the root directory storing published asset files - * @throws TInvalidOperationException if the service is initialized already - */ - public function setAssetRootPath($value) - { - if($this->_initialized) - throw new TInvalidOperationException('pageservice_assetrootpath_unchangeable'); - else - $this->_assetRootPath=$value; - } - - /** - * @return string the base url that the published asset files can be accessed - */ - public function getAssetBaseUrl() - { - return $this->_assetBaseUrl; - } - - /** - * @param string the base url that the published asset files can be accessed - * @throws TInvalidOperationException if the service is initialized already - */ - public function setAssetBaseUrl($value) + public function setPageBasePath($value) { if($this->_initialized) - throw new TInvalidOperationException('pageservice_assetbaseurl_unchangeable'); + throw new TInvalidOperationException('pageservice_pagebasepath_unchangeable'); else - $this->_assetBaseUrl=$value; + $this->_pageBasePath=$value; } /** @@ -347,7 +299,7 @@ class TPageService extends TComponent implements IService $p=explode('.',$this->_pagePath); array_pop($p); array_push($p,$className); - $path=Prado::getPathOfNamespace($this->_pageRootPath).'/'.implode('/',$p).Prado::CLASS_FILE_EXT; + $path=Prado::getPathOfNamespace($this->_pageBasePath).'/'.implode('/',$p).Prado::CLASS_FILE_EXT; require_once($path); } } @@ -419,7 +371,7 @@ class TPageConfiguration extends TComponent */ private $_modules=array( 'template'=>array('System.Web.UI.TTemplateManager',array(),null), - //'asset'=>array('System.Web.TAssetManager',array(),null) + 'asset'=>array('System.Web.TAssetManager',array(),null) ); /** * @var array list of parameters @@ -525,11 +477,11 @@ class TPageConfiguration extends TComponent * @param string path to the page (dot-connected format) * @param string root path for pages */ - public function loadConfigurationFiles($pagePath,$pageRootPath) + public function loadConfigurationFiles($pagePath,$pageBasePath) { $paths=explode('.',$pagePath); $page=array_pop($paths); - $path=$pageRootPath; + $path=$pageBasePath; foreach($paths as $p) { $this->loadFromFile($path.'/'.TPageService::CONFIG_FILE,null); -- cgit v1.2.3