diff options
author | xue <> | 2006-02-17 05:19:25 +0000 |
---|---|---|
committer | xue <> | 2006-02-17 05:19:25 +0000 |
commit | 7b38480de52c1d042ea542e2d06913a8c9b645fc (patch) | |
tree | 67ff025fb171a5325ac8fdc75a281ce8a19a2bd5 /framework/Web/UI | |
parent | ae1c1995b2fec431afe7cca23b2697e1bef17baf (diff) |
Add TApplicationComponent class and adjusted the relevant classes.
Diffstat (limited to 'framework/Web/UI')
-rw-r--r-- | framework/Web/UI/TClientScriptManager.php | 4 | ||||
-rw-r--r-- | framework/Web/UI/TControl.php | 85 | ||||
-rw-r--r-- | framework/Web/UI/TPageStatePersister.php | 13 | ||||
-rw-r--r-- | framework/Web/UI/TTemplateManager.php | 12 | ||||
-rw-r--r-- | framework/Web/UI/TThemeManager.php | 12 | ||||
-rw-r--r-- | framework/Web/UI/WebControls/TTextHighlighter.php | 2 |
6 files changed, 23 insertions, 105 deletions
diff --git a/framework/Web/UI/TClientScriptManager.php b/framework/Web/UI/TClientScriptManager.php index fd5a6eec..1ea4175d 100644 --- a/framework/Web/UI/TClientScriptManager.php +++ b/framework/Web/UI/TClientScriptManager.php @@ -140,7 +140,7 @@ class TClientScriptManager extends TComponent $base = Prado::getFrameworkPath(); $clientScripts = self::SCRIPT_DIR; $file = "{$base}/{$clientScripts}/{$lib}.js"; - Prado::getApplication()->getAssetManager()->publishFilePath($file); + $this->publishFilePath($file); $this->_publishedScriptFiles[$lib] = true; } } @@ -159,7 +159,7 @@ class TClientScriptManager extends TComponent $base = Prado::getFrameworkPath(); $clientScripts = self::SCRIPT_DIR; $file = "{$base}/{$clientScripts}/{$scriptFile}"; - $url= Prado::getApplication()->getAssetManager()->publishFilePath($file); + $url= $this->publishFilePath($file); $this->_publishedScriptFiles[$scriptFile] = $url; return $url; } diff --git a/framework/Web/UI/TControl.php b/framework/Web/UI/TControl.php index ded7049b..104200ed 100644 --- a/framework/Web/UI/TControl.php +++ b/framework/Web/UI/TControl.php @@ -68,7 +68,7 @@ Prado::using('System.Web.UI.TControlAdapter'); * @package System.Web.UI
* @since 3.0
*/
-class TControl extends TComponent
+class TControl extends TApplicationComponent
{
/**
* format of control ID
@@ -165,13 +165,6 @@ class TControl extends TComponent private $_rf=array();
/**
- * Constructor.
- */
- public function __construct()
- {
- }
-
- /**
* Returns a property value by name or a control by ID.
* This overrides the parent implementation by allowing accessing
* a control via its ID using the following syntax,
@@ -1556,80 +1549,6 @@ class TControl extends TComponent }
}
}
-
-
- /**
- * @return TApplication current application instance
- */
- public function getApplication()
- {
- return Prado::getApplication();
- }
-
- /**
- * @return IService the current service
- */
- public function getService()
- {
- return Prado::getApplication()->getService();
- }
-
- /**
- * @return THttpRequest the current user request
- */
- public function getRequest()
- {
- return Prado::getApplication()->getRequest();
- }
-
- /**
- * @return THttpResponse the response
- */
- public function getResponse()
- {
- return Prado::getApplication()->getResponse();
- }
-
- /**
- * @return THttpSession user session
- */
- public function getSession()
- {
- return Prado::getApplication()->getSession();
- }
-
- /**
- * @return IUser user
- */
- public function getUser()
- {
- return Prado::getApplication()->getUser();
- }
-
- /**
- * Publishes a private asset and gets its URL.
- * This method will publish a private asset (file or directory)
- * and gets the URL to the asset. Note, if the asset refers to
- * a directory, all contents under that directory will be published.
- * @param string path of the asset that is relative to the directory containing the control class file.
- * @return string URL to the asset path.
- */
- public function publishAsset($assetPath)
- {
- $class=new ReflectionClass(get_class($this));
- $fullPath=dirname($class->getFileName()).'/'.$assetPath;
- return $this->publishFilePath($fullPath);
- }
-
- /**
- * Publishes a file or directory and returns its URL.
- * @param string absolute path of the file or directory to be published
- * @return string URL to the published file or directory
- */
- public function publishFilePath($fullPath)
- {
- return $this->getApplication()->getAssetManager()->publishFilePath($fullPath);
- }
}
@@ -1658,6 +1577,7 @@ class TControlList extends TList */
public function __construct(TControl $owner)
{
+ parent::__construct();
$this->_o=$owner;
}
@@ -1741,6 +1661,7 @@ class TEmptyControlList extends TList */
public function __construct(TControl $owner)
{
+ parent::__construct();
$this->_o=$owner;
}
diff --git a/framework/Web/UI/TPageStatePersister.php b/framework/Web/UI/TPageStatePersister.php index 90af9665..49321ff5 100644 --- a/framework/Web/UI/TPageStatePersister.php +++ b/framework/Web/UI/TPageStatePersister.php @@ -55,13 +55,12 @@ class TPageStatePersister extends TComponent implements IPageStatePersister public function save($state)
{
Prado::trace("Saving state",'System.Web.UI.TPageStatePersister');
- $sm=Prado::getApplication()->getSecurityManager();
if($this->_page->getEnableStateValidation())
- $data=$sm->hashData(Prado::serialize($state));
+ $data=$this->getApplication()->getSecurityManager()->hashData(Prado::serialize($state));
else
$data=Prado::serialize($state);
if($this->_page->getEnableStateEncryption())
- $data=$sm->encrypt($data);
+ $data=$this->getApplication()->getSecurityManager()->encrypt($data);
if(extension_loaded('zlib'))
$data=gzcompress($data);
$this->_page->getClientScript()->registerHiddenField(TPage::FIELD_PAGESTATE,base64_encode($data));
@@ -75,9 +74,7 @@ class TPageStatePersister extends TComponent implements IPageStatePersister public function load()
{
Prado::trace("Loading state",'System.Web.UI.TPageStatePersister');
- $application=Prado::getApplication();
- $sm=$application->getSecurityManager();
- $str=base64_decode($application->getRequest()->itemAt(TPage::FIELD_PAGESTATE));
+ $str=base64_decode($this->getRequest()->itemAt(TPage::FIELD_PAGESTATE));
if($str==='')
return null;
if(extension_loaded('zlib'))
@@ -87,10 +84,10 @@ class TPageStatePersister extends TComponent implements IPageStatePersister if($data!==false)
{
if($this->_page->getEnableStateEncryption())
- $data=$sm->decrypt($data);
+ $data=$this->getApplication()->getSecurityManager()->decrypt($data);
if($this->_page->getEnableStateValidation())
{
- if(($data=$sm->validateData($data))!==false)
+ if(($data=$this->getApplication()->getSecurityManager()->validateData($data))!==false)
return Prado::unserialize($data);
}
else
diff --git a/framework/Web/UI/TTemplateManager.php b/framework/Web/UI/TTemplateManager.php index e87a23eb..67bda1b2 100644 --- a/framework/Web/UI/TTemplateManager.php +++ b/framework/Web/UI/TTemplateManager.php @@ -50,7 +50,7 @@ class TTemplateManager extends TModule */
public function init($config)
{
- $this->getApplication()->getPageService()->setTemplateManager($this);
+ $this->getService()->setTemplateManager($this);
}
/**
@@ -259,7 +259,7 @@ class TTemplate extends TComponent implements ITemplate public function instantiateIn($tplControl)
{
if(($page=$tplControl->getPage())===null)
- $page=Prado::getApplication()->getPageService()->getRequestedPage();
+ $page=$this->getService()->getRequestedPage();
$controls=array();
foreach($this->_tpl as $key=>$object)
{
@@ -371,11 +371,11 @@ class TTemplate extends TComponent implements ITemplate $component->$setter($value[1]);
break;
case self::CONFIG_ASSET: // asset URL
- $url=Prado::getApplication()->getAssetManager()->publishFilePath($this->_contextPath.'/'.$value[1]);
+ $url=$this->publishFilePath($this->_contextPath.'/'.$value[1]);
$component->$setter($url);
break;
case self::CONFIG_PARAMETER: // application parameter
- $component->$setter(Prado::getApplication()->getParameters()->itemAt($value[1]));
+ $component->$setter($this->getApplication()->getParameters()->itemAt($value[1]));
break;
case self::CONFIG_LOCALIZATION:
Prado::using('System.I18N.Translation');
@@ -411,11 +411,11 @@ class TTemplate extends TComponent implements ITemplate $component->setSubProperty($name,$value[1]);
break;
case self::CONFIG_ASSET: // asset URL
- $url=Prado::getApplication()->getAssetManager()->publishFilePath($this->_contextPath.'/'.$value[1]);
+ $url=$this->publishFilePath($this->_contextPath.'/'.$value[1]);
$component->setSubProperty($name,$url);
break;
case self::CONFIG_PARAMETER: // application parameter
- $component->setSubProperty($name,Prado::getApplication()->getParameters()->itemAt($value[1]));
+ $component->setSubProperty($name,$this->getApplication()->getParameters()->itemAt($value[1]));
break;
case self::CONFIG_LOCALIZATION:
$component->setSubProperty($name,localize($value[1]));
diff --git a/framework/Web/UI/TThemeManager.php b/framework/Web/UI/TThemeManager.php index 9110db7f..37e477d9 100644 --- a/framework/Web/UI/TThemeManager.php +++ b/framework/Web/UI/TThemeManager.php @@ -63,7 +63,7 @@ class TThemeManager extends TModule public function init($config)
{
$this->_initialized=true;
- $this->getApplication()->getPageService()->setThemeManager($this);
+ $this->getService()->setThemeManager($this);
}
/**
@@ -86,7 +86,7 @@ class TThemeManager extends TModule {
if($this->_basePath===null)
{
- $this->_basePath=dirname($this->getApplication()->getRequest()->getPhysicalApplicationPath()).'/'.self::DEFAULT_BASEPATH;
+ $this->_basePath=dirname($this->getRequest()->getPhysicalApplicationPath()).'/'.self::DEFAULT_BASEPATH;
if(($basePath=realpath($this->_basePath))===false || !is_dir($basePath))
throw new TConfigurationException('thememanager_basepath_invalid',$this->_basePath);
$this->_basePath=$basePath;
@@ -119,11 +119,11 @@ class TThemeManager extends TModule {
if($this->_baseUrl===null)
{
- $appPath=dirname($this->getApplication()->getRequest()->getPhysicalApplicationPath());
+ $appPath=dirname($this->getRequest()->getPhysicalApplicationPath());
$basePath=$this->getBasePath();
if(strpos($basePath,$appPath)===false)
throw new TConfigurationException('thememanager_baseurl_required');
- $appUrl=rtrim(dirname($this->getApplication()->getRequest()->getApplicationPath()),'/\\');
+ $appUrl=rtrim(dirname($this->getRequest()->getApplicationPath()),'/\\');
$this->_baseUrl=$appUrl.strtr(substr($basePath,strlen($appPath)),'\\','/');
}
return $this->_baseUrl;
@@ -209,14 +209,14 @@ class TTheme extends TComponent implements ITheme {
$this->_themeUrl=$themeUrl;
$this->_name=basename($themePath);
- if(($cache=Prado::getApplication()->getCache())!==null)
+ if(($cache=$this->getApplication()->getCache())!==null)
{
$array=$cache->get(self::THEME_CACHE_PREFIX.$themePath);
if(is_array($array))
{
list($skins,$cssFiles,$jsFiles,$timestamp)=$array;
$cacheValid=true;
- if(Prado::getApplication()->getMode()!==TApplication::STATE_PERFORMANCE)
+ if($this->getApplication()->getMode()!==TApplication::STATE_PERFORMANCE)
{
if(($dir=opendir($themePath))===false)
throw new TIOException('theme_path_inexistent',$themePath);
diff --git a/framework/Web/UI/WebControls/TTextHighlighter.php b/framework/Web/UI/WebControls/TTextHighlighter.php index 22717d05..281f131e 100644 --- a/framework/Web/UI/WebControls/TTextHighlighter.php +++ b/framework/Web/UI/WebControls/TTextHighlighter.php @@ -85,7 +85,7 @@ class TTextHighlighter extends TWebControl {
parent::onPreRender($writer);
$this->registerHighlightStyleSheet();
- //$this->getPage()->getClientScript()->registerClientScript('prado');
+ $this->getPage()->getClientScript()->registerClientScript('prado');
}
/**
|