summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorxue <>2006-02-17 05:19:25 +0000
committerxue <>2006-02-17 05:19:25 +0000
commit7b38480de52c1d042ea542e2d06913a8c9b645fc (patch)
tree67ff025fb171a5325ac8fdc75a281ce8a19a2bd5
parentae1c1995b2fec431afe7cca23b2697e1bef17baf (diff)
Add TApplicationComponent class and adjusted the relevant classes.
-rw-r--r--.gitattributes1
-rw-r--r--framework/Collections/TList.php1
-rw-r--r--framework/Collections/TMap.php1
-rw-r--r--framework/Data/TXmlDocument.php2
-rw-r--r--framework/Exceptions/TErrorHandler.php2
-rw-r--r--framework/Security/TAuthManager.php8
-rw-r--r--framework/Security/TAuthorizationRule.php1
-rw-r--r--framework/Security/TUserManager.php1
-rw-r--r--framework/TApplication.php2
-rw-r--r--framework/TApplicationComponent.php111
-rw-r--r--framework/TComponent.php87
-rw-r--r--framework/Web/Services/TPageService.php6
-rw-r--r--framework/Web/THttpRequest.php147
-rw-r--r--framework/Web/THttpResponse.php9
-rw-r--r--framework/Web/THttpSession.php10
-rw-r--r--framework/Web/UI/TClientScriptManager.php4
-rw-r--r--framework/Web/UI/TControl.php85
-rw-r--r--framework/Web/UI/TPageStatePersister.php13
-rw-r--r--framework/Web/UI/TTemplateManager.php12
-rw-r--r--framework/Web/UI/TThemeManager.php12
-rw-r--r--framework/Web/UI/WebControls/TTextHighlighter.php2
-rw-r--r--framework/core.php24
22 files changed, 384 insertions, 157 deletions
diff --git a/.gitattributes b/.gitattributes
index ba033331..a1bddbb4 100644
--- a/.gitattributes
+++ b/.gitattributes
@@ -585,6 +585,7 @@ framework/Security/TMembershipManager.php -text
framework/Security/TSecurityManager.php -text
framework/Security/TUserManager.php -text
framework/TApplication.php -text
+framework/TApplicationComponent.php -text
framework/TComponent.php -text
framework/Web/Javascripts/TClientScript.php -text
framework/Web/Javascripts/TJSON.php -text
diff --git a/framework/Collections/TList.php b/framework/Collections/TList.php
index 7383b684..1090ce77 100644
--- a/framework/Collections/TList.php
+++ b/framework/Collections/TList.php
@@ -58,6 +58,7 @@ class TList extends TComponent implements IteratorAggregate,ArrayAccess
*/
public function __construct($data=null)
{
+ parent::__construct();
if($data!==null)
$this->copyFrom($data);
}
diff --git a/framework/Collections/TMap.php b/framework/Collections/TMap.php
index 7c46ae70..4d810503 100644
--- a/framework/Collections/TMap.php
+++ b/framework/Collections/TMap.php
@@ -53,6 +53,7 @@ class TMap extends TComponent implements IteratorAggregate,ArrayAccess
*/
public function __construct($data=null)
{
+ parent::__construct();
if($data!==null)
$this->copyFrom($data);
}
diff --git a/framework/Data/TXmlDocument.php b/framework/Data/TXmlDocument.php
index dfd65ebe..bb22b254 100644
--- a/framework/Data/TXmlDocument.php
+++ b/framework/Data/TXmlDocument.php
@@ -55,6 +55,7 @@ class TXmlElement extends TComponent
*/
public function __construct($tagName)
{
+ parent::__construct();
$this->setTagName($tagName);
}
@@ -403,6 +404,7 @@ class TXmlElementList extends TList
*/
public function __construct(TXmlElement $owner)
{
+ parent::__construct();
$this->_o=$owner;
}
diff --git a/framework/Exceptions/TErrorHandler.php b/framework/Exceptions/TErrorHandler.php
index 2bbc3c7b..87f6b1c2 100644
--- a/framework/Exceptions/TErrorHandler.php
+++ b/framework/Exceptions/TErrorHandler.php
@@ -124,7 +124,7 @@ class TErrorHandler extends TModule
else
{
$handling=true;
- if(($response=$this->getApplication()->getResponse())!==null)
+ if(($response=$this->getResponse())!==null)
$response->clear();
if(!headers_sent())
header('Content-Type: text/html; charset=UTF-8');
diff --git a/framework/Security/TAuthManager.php b/framework/Security/TAuthManager.php
index a41da914..819b7b36 100644
--- a/framework/Security/TAuthManager.php
+++ b/framework/Security/TAuthManager.php
@@ -133,7 +133,7 @@ class TAuthManager extends TModule
{
$this->onAuthenticate($param);
- $service=$this->getApplication()->getService();
+ $service=$this->getService();
if(($service instanceof TPageService) && $service->getRequestedPagePath()===$this->getLoginPage())
$this->_skipAuthorization=true;
}
@@ -181,7 +181,7 @@ class TAuthManager extends TModule
*/
public function getReturnUrl()
{
- return $this->getApplication()->getSession()->itemAt(self::RETURN_URL_VAR);
+ return $this->getSession()->itemAt(self::RETURN_URL_VAR);
}
/**
@@ -244,7 +244,7 @@ class TAuthManager extends TModule
{
if(!$user->getIsGuest())
{
- if(($session=$this->getApplication()->getSession())===null)
+ if(($session=$this->getSession())===null)
throw new TConfigurationException('authmanager_session_required');
else
$session->add($this->generateUserSessionKey(),$user->saveToString());
@@ -279,7 +279,7 @@ class TAuthManager extends TModule
*/
public function logout()
{
- if(($session=$this->getApplication()->getSession())===null)
+ if(($session=$this->getSession())===null)
throw new TConfigurationException('authmanager_session_required');
else
{
diff --git a/framework/Security/TAuthorizationRule.php b/framework/Security/TAuthorizationRule.php
index 8248a45a..81955a44 100644
--- a/framework/Security/TAuthorizationRule.php
+++ b/framework/Security/TAuthorizationRule.php
@@ -63,6 +63,7 @@ class TAuthorizationRule extends TComponent
*/
public function __construct($action,$users,$roles,$verb='')
{
+ parent::__construct();
$action=strtolower(trim($action));
if($action==='allow' || $action==='deny')
$this->_action=$action;
diff --git a/framework/Security/TUserManager.php b/framework/Security/TUserManager.php
index c799c446..06b5d321 100644
--- a/framework/Security/TUserManager.php
+++ b/framework/Security/TUserManager.php
@@ -52,6 +52,7 @@ class TUser extends TComponent implements IUser
*/
public function __construct($manager=null)
{
+ parent::__construct();
$this->_manager=$manager;
}
diff --git a/framework/TApplication.php b/framework/TApplication.php
index 8cc1e9f9..b61fa30d 100644
--- a/framework/TApplication.php
+++ b/framework/TApplication.php
@@ -289,6 +289,8 @@ class TApplication extends TComponent
*/
public function __construct($basePath='protected',$cacheConfig=true)
{
+ parent::__construct();
+
// register application as a singleton
Prado::setApplication($this);
diff --git a/framework/TApplicationComponent.php b/framework/TApplicationComponent.php
new file mode 100644
index 00000000..580f1d33
--- /dev/null
+++ b/framework/TApplicationComponent.php
@@ -0,0 +1,111 @@
+<?php
+/**
+ * TApplicationComponent class
+ *
+ * @author Qiang Xue <qiang.xue@gmail.com>
+ * @link http://www.pradosoft.com/
+ * @copyright Copyright &copy; 2005 PradoSoft
+ * @license http://www.pradosoft.com/license/
+ * @version $Revision: $ $Date: $
+ * @package System
+ */
+
+/**
+ * TApplicationComponent class
+ *
+ * TApplicationComponent is the base class for all components that are
+ * application-related, such as controls, modules, services, etc.
+ *
+ * TApplicationComponent mainly defines a few properties that are shortcuts
+ * to some commonly used methods. The {@link getApplication Application}
+ * property gives the application instance that this component belongs to;
+ * {@link getService Service} gives the current running service;
+ * {@link getRequest Request}, {@link getResponse Response} and {@link getSession Session}
+ * return the request and response modules, respectively;
+ * And {@link getUser User} gives the current user instance.
+ *
+ * Besides, TApplicationComponent defines two shortcut methods for
+ * publishing private files: {@link publishAsset} and {@link publishFilePath}.
+ *
+ * @author Qiang Xue <qiang.xue@gmail.com>
+ * @version $Revision: $ $Date: $
+ * @package System
+ * @since 3.0
+ */
+class TApplicationComponent 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 Prado::getApplication()->getAssetManager()->publishFilePath($fullPath);
+ }
+}
+
+?> \ No newline at end of file
diff --git a/framework/TComponent.php b/framework/TComponent.php
index 7443168d..8d6be46e 100644
--- a/framework/TComponent.php
+++ b/framework/TComponent.php
@@ -79,6 +79,20 @@ class TComponent
private $_e=array();
/**
+ * Constructor.
+ */
+ public function __construct()
+ {
+ }
+
+ /**
+ * Destructor.
+ */
+ public function __destruct()
+ {
+ }
+
+ /**
* Returns a property value or an event handler list by property or event name.
* Do not call this method. This is a PHP magic method that we override
* to allow using the following syntax to read a property:
@@ -412,6 +426,79 @@ class TComponent
throw new TInvalidOperationException('component_statements_invalid',get_class($this),$statements,$e->getMessage());
}
}
+
+ /**
+ * @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);
+ }
}
/**
diff --git a/framework/Web/Services/TPageService.php b/framework/Web/Services/TPageService.php
index 013bb35f..bb80b902 100644
--- a/framework/Web/Services/TPageService.php
+++ b/framework/Web/Services/TPageService.php
@@ -202,7 +202,7 @@ class TPageService extends TService
*/
protected function determineRequestedPagePath()
{
- $pagePath=$this->getApplication()->getRequest()->getServiceParameter();
+ $pagePath=$this->getRequest()->getServiceParameter();
if(empty($pagePath))
$pagePath=$this->getDefaultPage();
return $pagePath;
@@ -441,7 +441,7 @@ class TPageService extends TService
else
throw new THttpException(404,'pageservice_page_unknown',$this->getRequestedPagePath());
- $this->_page->run($this->getApplication()->getResponse()->createHtmlWriter());
+ $this->_page->run($this->getResponse()->createHtmlWriter());
}
/**
@@ -453,7 +453,7 @@ class TPageService extends TService
*/
public function constructUrl($pagePath,$getParams=null,$encodeAmpersand=false)
{
- return $this->getApplication()->getRequest()->constructUrl($this->_id,$pagePath,$getParams,$encodeAmpersand);
+ return $this->getRequest()->constructUrl($this->_id,$pagePath,$getParams,$encodeAmpersand);
}
}
diff --git a/framework/Web/THttpRequest.php b/framework/Web/THttpRequest.php
index 201addd1..7ebd9151 100644
--- a/framework/Web/THttpRequest.php
+++ b/framework/Web/THttpRequest.php
@@ -49,7 +49,7 @@
* @package System.Web
* @since 3.0
*/
-class THttpRequest extends TMap implements IModule
+class THttpRequest extends TApplicationComponent implements IteratorAggregate,ArrayAccess,IModule
{
/**
* GET variable name to store service information
@@ -95,6 +95,11 @@ class THttpRequest extends TMap implements IModule
private $_id;
/**
+ * @var array contains all request variables
+ */
+ private $_items=array();
+
+ /**
* @return string id of this module
*/
public function getID()
@@ -157,10 +162,10 @@ class THttpRequest extends TMap implements IModule
if($i+1<$n)
$getVariables[$paths[$i]]=$paths[++$i];
}
- $this->copyFrom(array_merge($getVariables,array_merge($_GET,$_POST)));
+ $this->_items=array_merge($getVariables,array_merge($_GET,$_POST));
}
else
- $this->copyFrom(array_merge($_GET,$_POST));
+ $this->_items=array_merge($_GET,$_POST);
$this->_initialized=true;
$this->getApplication()->setRequest($this);
@@ -534,20 +539,141 @@ class THttpRequest extends TMap implements IModule
$this->_serviceParam=$value;
}
+ //------ The following methods enable THttpRequest to be TMap-like -----
+
+ /**
+ * Returns an iterator for traversing the items in the list.
+ * This method is required by the interface IteratorAggregate.
+ * @return Iterator an iterator for traversing the items in the list.
+ */
+ public function getIterator()
+ {
+ return new TMapIterator($this->_items);
+ }
+
+ /**
+ * @return integer the number of items in the request
+ */
+ public function getCount()
+ {
+ return count($this->_items);
+ }
+
+ /**
+ * @return array the key list
+ */
+ public function getKeys()
+ {
+ return array_keys($this->_items);
+ }
+
+ /**
+ * Returns the item with the specified key.
+ * This method is exactly the same as {@link offsetGet}.
+ * @param mixed the key
+ * @return mixed the element at the offset, null if no element is found at the offset
+ */
+ public function itemAt($key)
+ {
+ return isset($this->_items[$key]) ? $this->_items[$key] : null;
+ }
+
+ /**
+ * Adds an item into the request.
+ * Note, if the specified key already exists, the old value will be overwritten.
+ * @param mixed key
+ * @param mixed value
+ */
+ public function add($key,$value)
+ {
+ $this->_items[$key]=$value;
+ }
+
+ /**
+ * Removes an item from the request by its key.
+ * @param mixed the key of the item to be removed
+ * @return mixed the removed value, null if no such key exists.
+ * @throws TInvalidOperationException if the item cannot be removed
+ */
+ public function remove($key)
+ {
+ if(isset($this->_items[$key]) || array_key_exists($key,$this->_items))
+ {
+ $value=$this->_items[$key];
+ unset($this->_items[$key]);
+ return $value;
+ }
+ else
+ return null;
+ }
+
+ /**
+ * Removes all items in the request.
+ */
+ public function clear()
+ {
+ foreach(array_keys($this->_items) as $key)
+ $this->remove($key);
+ }
+
+ /**
+ * @param mixed the key
+ * @return boolean whether the request contains an item with the specified key
+ */
+ public function contains($key)
+ {
+ return isset($this->_items[$key]) || array_key_exists($key,$this->_items);
+ }
+
+ /**
+ * @return array the list of items in array
+ */
+ public function toArray()
+ {
+ return $this->_items;
+ }
+
+ /**
+ * Returns whether there is an element at the specified offset.
+ * This method is required by the interface ArrayAccess.
+ * @param mixed the offset to check on
+ * @return boolean
+ */
+ public function offsetExists($offset)
+ {
+ return $this->contains($offset);
+ }
+
+ /**
+ * Returns the element at the specified offset.
+ * This method is required by the interface ArrayAccess.
+ * @param integer the offset to retrieve element.
+ * @return mixed the element at the offset, null if no element is found at the offset
+ */
+ public function offsetGet($offset)
+ {
+ return $this->itemAt($offset);
+ }
+
/**
- * @return THttpResponse response module
+ * Sets the element at the specified offset.
+ * This method is required by the interface ArrayAccess.
+ * @param integer the offset to set element
+ * @param mixed the element value
*/
- public function getResponse()
+ public function offsetSet($offset,$item)
{
- return Prado::getApplication()->getResponse();
+ $this->add($offset,$item);
}
/**
- * @return TApplication application instance
+ * Unsets the element at the specified offset.
+ * This method is required by the interface ArrayAccess.
+ * @param mixed the offset to unset element
*/
- public function getApplication()
+ public function offsetUnset($offset)
{
- return Prado::getApplication();
+ $this->remove($offset);
}
}
@@ -574,6 +700,7 @@ class THttpCookieCollection extends TList
*/
public function __construct($owner=null)
{
+ parent::__construct();
$this->_o=$owner;
}
@@ -658,6 +785,7 @@ class THttpCookie extends TComponent
*/
public function __construct($name,$value)
{
+ parent::__construct();
$this->_name=$name;
$this->_value=$value;
}
@@ -839,6 +967,7 @@ class TUri extends TComponent
*/
public function __construct($uri)
{
+ parent::__construct();
if(($ret=@parse_url($uri))!==false)
{
// decoding???
diff --git a/framework/Web/THttpResponse.php b/framework/Web/THttpResponse.php
index 3da9a5d5..1607b9d5 100644
--- a/framework/Web/THttpResponse.php
+++ b/framework/Web/THttpResponse.php
@@ -79,6 +79,7 @@ class THttpResponse extends TModule implements ITextWriter
{
if($this->_bufferOutput)
@ob_end_flush();
+ parent::__destruct();
}
/**
@@ -395,14 +396,6 @@ class THttpResponse extends TModule implements ITextWriter
$type=$this->_htmlWriterType;
return Prado::createComponent($type,$this);
}
-
- /**
- * @return THttpRequest request module
- */
- public function getRequest()
- {
- return $this->getApplication()->getRequest();
- }
}
?> \ No newline at end of file
diff --git a/framework/Web/THttpSession.php b/framework/Web/THttpSession.php
index 605b858a..1292b548 100644
--- a/framework/Web/THttpSession.php
+++ b/framework/Web/THttpSession.php
@@ -55,7 +55,7 @@
* @package System.Web
* @since 3.0
*/
-class THttpSession extends TComponent implements IteratorAggregate,ArrayAccess,IModule
+class THttpSession extends TApplicationComponent implements IteratorAggregate,ArrayAccess,IModule
{
/**
* @var boolean whether this module has been initialized
@@ -606,14 +606,6 @@ class THttpSession extends TComponent implements IteratorAggregate,ArrayAccess,I
{
unset($_SESSION[$offset]);
}
-
- /**
- * @return TApplication application instance
- */
- public function getApplication()
- {
- return Prado::getApplication();
- }
}
/**
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');
}
/**
diff --git a/framework/core.php b/framework/core.php
index 93d19002..c3a14c5d 100644
--- a/framework/core.php
+++ b/framework/core.php
@@ -22,6 +22,10 @@ define('PRADO_DIR',dirname(__FILE__));
*/
require_once(PRADO_DIR.'/TComponent.php');
/**
+ * Includes TApplicationComponent definition
+ */
+require_once(PRADO_DIR.'/TApplicationComponent.php');
+/**
* Includes exception definitions
*/
require_once(PRADO_DIR.'/Exceptions/TException.php');
@@ -264,7 +268,7 @@ interface IStatePersister
* @package System
* @since 3.0
*/
-abstract class TModule extends TComponent implements IModule
+abstract class TModule extends TApplicationComponent implements IModule
{
/**
* @var string module id
@@ -295,14 +299,6 @@ abstract class TModule extends TComponent implements IModule
{
$this->_id=$value;
}
-
- /**
- * @return TApplication current application instance
- */
- public function getApplication()
- {
- return Prado::getApplication();
- }
}
/**
@@ -316,7 +312,7 @@ abstract class TModule extends TComponent implements IModule
* @package System
* @since 3.0
*/
-abstract class TService extends TComponent implements IService
+abstract class TService extends TApplicationComponent implements IService
{
/**
* @var string service id
@@ -354,14 +350,6 @@ abstract class TService extends TComponent implements IService
public function run()
{
}
-
- /**
- * @return TApplication current application instance
- */
- public function getApplication()
- {
- return Prado::getApplication();
- }
}
/**