diff options
author | xue <> | 2005-12-07 00:32:29 +0000 |
---|---|---|
committer | xue <> | 2005-12-07 00:32:29 +0000 |
commit | b4e9f6795206fab6b952f814ccf812677a34c635 (patch) | |
tree | e3be7c6031cd947f233d9e6cbcdec813e391f5ef | |
parent | ec46fdc945f591e910051aca0457097825afd34c (diff) |
-rw-r--r-- | framework/Data/TMemCache.php | 24 | ||||
-rw-r--r-- | framework/Data/TSqliteCache.php | 24 | ||||
-rw-r--r-- | framework/Exceptions/TErrorHandler.php | 24 | ||||
-rw-r--r-- | framework/Security/TAuthManager.php | 24 | ||||
-rw-r--r-- | framework/Security/TUserManager.php | 24 | ||||
-rw-r--r-- | framework/Web/THttpRequest.php | 23 | ||||
-rw-r--r-- | framework/Web/THttpResponse.php | 25 | ||||
-rw-r--r-- | framework/Web/THttpSession.php | 24 | ||||
-rw-r--r-- | framework/Web/UI/TAssetManager.php | 24 | ||||
-rw-r--r-- | framework/Web/UI/TTemplateManager.php | 24 | ||||
-rw-r--r-- | framework/Web/UI/TThemeManager.php | 23 | ||||
-rw-r--r-- | framework/core.php | 45 |
12 files changed, 76 insertions, 232 deletions
diff --git a/framework/Data/TMemCache.php b/framework/Data/TMemCache.php index b78014fb..d50c5b9d 100644 --- a/framework/Data/TMemCache.php +++ b/framework/Data/TMemCache.php @@ -62,7 +62,7 @@ * @package System.Data
* @since 3.0
*/
-class TMemCache extends TComponent implements IModule, ICache
+class TMemCache extends TModule implements ICache
{
/**
* @var boolean if the module is initialized
@@ -84,10 +84,6 @@ class TMemCache extends TComponent implements IModule, ICache * @var integer the port number of the memcache server
*/
private $_port=11211;
- /**
- * @var string ID of this module
- */
- private $_id='';
/**
* Destructor.
@@ -111,6 +107,8 @@ class TMemCache extends TComponent implements IModule, ICache */
public function init($application,$config)
{
+ parent::init($application,$config);
+
if(!extension_loaded('memcache'))
throw new TConfigurationException('memcache_extension_required');
$this->_cache=new Memcache;
@@ -123,22 +121,6 @@ class TMemCache extends TComponent implements IModule, ICache }
/**
- * @return string id of this module
- */
- public function getID()
- {
- return $this->_id;
- }
-
- /**
- * @param string id of this module
- */
- public function setID($value)
- {
- $this->_id=$value;
- }
-
- /**
* @return string host name of the memcache server
*/
public function getHost()
diff --git a/framework/Data/TSqliteCache.php b/framework/Data/TSqliteCache.php index 5eb692d4..13455849 100644 --- a/framework/Data/TSqliteCache.php +++ b/framework/Data/TSqliteCache.php @@ -64,7 +64,7 @@ * @package System.Data
* @since 3.0
*/
-class TSqliteCache extends TComponent implements IModule, ICache
+class TSqliteCache extends TModule implements ICache
{
/**
* name of the table storing cache data
@@ -91,10 +91,6 @@ class TSqliteCache extends TComponent implements IModule, ICache * @var string the database file name
*/
private $_file=null;
- /**
- * @var string id of this module
- */
- private $_id='';
/**
* Destructor.
@@ -119,6 +115,8 @@ class TSqliteCache extends TComponent implements IModule, ICache */
public function init($application,$config)
{
+ parent::init($application,$config);
+
if(!function_exists('sqlite_open'))
throw new TConfigurationException('sqlitecache_extension_required');
if($this->_file===null)
@@ -142,22 +140,6 @@ class TSqliteCache extends TComponent implements IModule, ICache }
/**
- * @return string id of this module
- */
- public function getID()
- {
- return $this->_id;
- }
-
- /**
- * @param string id of this module
- */
- public function setID($value)
- {
- $this->_id=$value;
- }
-
- /**
* @return string database file path (in namespace form)
*/
public function getDbFile()
diff --git a/framework/Exceptions/TErrorHandler.php b/framework/Exceptions/TErrorHandler.php index 913b3ac3..ebdaf41c 100644 --- a/framework/Exceptions/TErrorHandler.php +++ b/framework/Exceptions/TErrorHandler.php @@ -49,7 +49,7 @@ * @package System.Exceptions
* @since 3.0
*/
-class TErrorHandler extends TComponent implements IModule
+class TErrorHandler extends TModule
{
/**
* error template file basename
@@ -65,10 +65,6 @@ class TErrorHandler extends TComponent implements IModule const SOURCE_LINES=12;
/**
- * @var string module ID
- */
- private $_id='error';
- /**
* @var TApplication application instance
*/
private $_application;
@@ -85,27 +81,13 @@ class TErrorHandler extends TComponent implements IModule */
public function init($application,$config)
{
+ parent::init($application,$config);
+
$this->_application=$application;
$application->setErrorHandler($this);
}
/**
- * @return string id of this module
- */
- public function getID()
- {
- return $this->_id;
- }
-
- /**
- * @param string id of this module
- */
- public function setID($value)
- {
- $this->_id=$value;
- }
-
- /**
* @return string the directory containing error template files.
*/
public function getErrorTemplatePath()
diff --git a/framework/Security/TAuthManager.php b/framework/Security/TAuthManager.php index ae3f713f..3bf6964e 100644 --- a/framework/Security/TAuthManager.php +++ b/framework/Security/TAuthManager.php @@ -34,17 +34,13 @@ Prado::using('System.Security.TUserManager'); * @package System.Security
* @since 3.0
*/
-class TAuthManager extends TComponent implements IModule
+class TAuthManager extends TModule
{
/**
* GET variable name for return url
*/
const RETURN_URL_VAR='ReturnUrl';
/**
- * @var string module ID
- */
- private $_id;
- /**
* @var boolean if the module has been initialized
*/
private $_initialized=false;
@@ -66,22 +62,6 @@ class TAuthManager extends TComponent implements IModule private $_skipAuthorization=false;
/**
- * @return string id of this module
- */
- public function getID()
- {
- return $this->_id;
- }
-
- /**
- * @param string id of this module
- */
- public function setID($value)
- {
- $this->_id=$value;
- }
-
- /**
* Initializes this module.
* This method is required by the IModule interface.
* @param TApplication Prado application, can be null
@@ -90,6 +70,8 @@ class TAuthManager extends TComponent implements IModule */
public function init($application,$config)
{
+ parent::init($application,$config);
+
if($this->_userManager===null)
throw new TConfigurationException('authmanager_usermanager_required');
if(is_string($this->_userManager))
diff --git a/framework/Security/TUserManager.php b/framework/Security/TUserManager.php index 9da386f0..d9210661 100644 --- a/framework/Security/TUserManager.php +++ b/framework/Security/TUserManager.php @@ -189,13 +189,9 @@ class TUser extends TComponent implements IUser * @package System.Security
* @since 3.0
*/
-class TUserManager extends TComponent implements IModule
+class TUserManager extends TModule
{
/**
- * @var string id of this module
- */
- private $_id;
- /**
* @var array list of users managed by this module
*/
private $_users=array();
@@ -221,6 +217,8 @@ class TUserManager extends TComponent implements IModule */
public function init($application,$config)
{
+ parent::init($application,$config);
+
foreach($config->getElementsByTagName('user') as $node)
$this->_users[strtolower($node->getAttribute('name'))]=$node->getAttribute('password');
foreach($config->getElementsByTagName('role') as $node)
@@ -234,22 +232,6 @@ class TUserManager extends TComponent implements IModule }
/**
- * @return string id of this module
- */
- public function getID()
- {
- return $this->_id;
- }
-
- /**
- * @param string id of this module
- */
- public function setID($value)
- {
- $this->_id=$value;
- }
-
- /**
* @return string guest name, defaults to 'Guest'
*/
public function getGuestName()
diff --git a/framework/Web/THttpRequest.php b/framework/Web/THttpRequest.php index 80e87d15..0c21a020 100644 --- a/framework/Web/THttpRequest.php +++ b/framework/Web/THttpRequest.php @@ -29,7 +29,7 @@ * @package System.Web
* @since 3.0
*/
-class THttpRequest extends TComponent implements IModule
+class THttpRequest extends TModule
{
/**
* GET variable name to store service information
@@ -40,10 +40,6 @@ class THttpRequest extends TComponent implements IModule */
private $_initialized=false;
/**
- * @var string module ID
- */
- private $_id;
- /**
* @var string requested service ID
*/
private $_serviceID=null;
@@ -76,6 +72,7 @@ class THttpRequest extends TComponent implements IModule */
public function init($application,$config)
{
+ parent::init($application,$config);
// Info about server variables:
// PHP_SELF contains real URI (w/ path info, w/o query string)
// SCRIPT_NAME is the real URI for the requested script (w/o path info and query string)
@@ -125,22 +122,6 @@ class THttpRequest extends TComponent implements IModule }
/**
- * @return string id of this module
- */
- public function getID()
- {
- return $this->_id;
- }
-
- /**
- * @param string id of this module
- */
- public function setID($value)
- {
- $this->_id=$value;
- }
-
- /**
* @return TUri the request URL
*/
public function getUrl()
diff --git a/framework/Web/THttpResponse.php b/framework/Web/THttpResponse.php index dfa2d023..ad290fb0 100644 --- a/framework/Web/THttpResponse.php +++ b/framework/Web/THttpResponse.php @@ -37,13 +37,9 @@ * @package System.Web
* @since 3.0
*/
-class THttpResponse extends TComponent implements IModule, ITextWriter
+class THttpResponse extends TModule implements ITextWriter
{
/**
- * @var string id of this module (response)
- */
- private $_id;
- /**
* @var boolean whether to buffer output
*/
private $_bufferOutput=true;
@@ -84,6 +80,8 @@ class THttpResponse extends TComponent implements IModule, ITextWriter */
public function init($application,$config)
{
+ parent::init($application,$config);
+
if($this->_bufferOutput)
ob_start();
$this->_initialized=true;
@@ -91,23 +89,6 @@ class THttpResponse extends TComponent implements IModule, ITextWriter }
/**
- * @return string id of this module
- */
- public function getID()
- {
- return $this->_id;
- }
-
- /**
- * @param string id of this module
- */
- public function setID($value)
- {
- $this->_id=$value;
- }
-
-
- /**
* @return integer time-to-live for cached session pages in minutes, this has no effect for nocache limiter. Defaults to 180.
*/
public function getCacheExpire()
diff --git a/framework/Web/THttpSession.php b/framework/Web/THttpSession.php index 5afcfb7a..0698d4d8 100644 --- a/framework/Web/THttpSession.php +++ b/framework/Web/THttpSession.php @@ -54,13 +54,9 @@ * @package System.Web
* @since 3.0
*/
-class THttpSession extends TComponent implements IModule
+class THttpSession extends TModule
{
/**
- * @var string ID of this module
- */
- private $_id;
- /**
* @var THttpSessionCollection list of session variables
*/
private $_items;
@@ -89,6 +85,8 @@ class THttpSession extends TComponent implements IModule */
public function init($application,$config)
{
+ parent::init($application,$config);
+
if($this->_autoStart)
session_start();
$this->_initialized=true;
@@ -134,22 +132,6 @@ class THttpSession extends TComponent implements IModule }
/**
- * @return string the ID of this session module (not session ID)
- */
- public function getID()
- {
- return $this->_id;
- }
-
- /**
- * @param string the ID of this session module (not session ID)
- */
- public function setID($value)
- {
- $this->_id=$value;
- }
-
- /**
* @return THttpSessionCollection list of session variables
*/
public function getItems()
diff --git a/framework/Web/UI/TAssetManager.php b/framework/Web/UI/TAssetManager.php index 0f96ae90..df189b58 100644 --- a/framework/Web/UI/TAssetManager.php +++ b/framework/Web/UI/TAssetManager.php @@ -41,7 +41,7 @@ * @package System.Web.UI
* @since 3.0
*/
-class TAssetManager extends TComponent implements IModule
+class TAssetManager extends TModule
{
/**
* Default web accessible base path for storing private files
@@ -56,10 +56,6 @@ class TAssetManager extends TComponent implements IModule */
private $_baseUrl=null;
/**
- * @var string module ID
- */
- private $_id='asset';
- /**
* @var boolean whether to use timestamp checking to ensure files are published with up-to-date versions.
*/
private $_checkTimestamp=false;
@@ -80,6 +76,8 @@ class TAssetManager extends TComponent implements IModule */
public function init($application,$config)
{
+ parent::init($application,$config);
+
$this->_application=$application;
if($this->_basePath===null)
$this->_basePath=dirname($application->getRequest()->getPhysicalApplicationPath()).'/'.self::DEFAULT_BASEPATH;
@@ -91,22 +89,6 @@ class TAssetManager extends TComponent implements IModule }
/**
- * @return string id of this module
- */
- public function getID()
- {
- return $this->_id;
- }
-
- /**
- * @param string id of this module
- */
- public function setID($value)
- {
- $this->_id=$value;
- }
-
- /**
* @return string the root directory storing published asset files
*/
public function getBasePath()
diff --git a/framework/Web/UI/TTemplateManager.php b/framework/Web/UI/TTemplateManager.php index 1f3044a2..6864e038 100644 --- a/framework/Web/UI/TTemplateManager.php +++ b/framework/Web/UI/TTemplateManager.php @@ -27,7 +27,7 @@ * @package System.Web.UI
* @since 3.0
*/
-class TTemplateManager extends TComponent implements IModule
+class TTemplateManager extends TModule
{
/**
* Template file extension
@@ -41,10 +41,6 @@ class TTemplateManager extends TComponent implements IModule * @var TApplication application instance
*/
private $_application;
- /**
- * @var string module ID
- */
- private $_id;
/**
* Initializes the module.
@@ -55,27 +51,13 @@ class TTemplateManager extends TComponent implements IModule */
public function init($application,$config)
{
+ parent::init($application,$config);
+
$this->_application=$application;
$application->getService()->setTemplateManager($this);
}
/**
- * @return string id of this module
- */
- public function getID()
- {
- return $this->_id;
- }
-
- /**
- * @param string id of this module
- */
- public function setID($value)
- {
- $this->_id=$value;
- }
-
- /**
* Loads the template corresponding to the specified class name.
* @return ITemplate template for the class name, null if template doesn't exist.
*/
diff --git a/framework/Web/UI/TThemeManager.php b/framework/Web/UI/TThemeManager.php index 504e8ecb..746e36cb 100644 --- a/framework/Web/UI/TThemeManager.php +++ b/framework/Web/UI/TThemeManager.php @@ -36,17 +36,13 @@ * @package System.Web.UI
* @since 3.0
*/
-class TThemeManager extends TComponent implements IModule
+class TThemeManager extends TModule
{
/**
* default themes base path
*/
const DEFAULT_BASEPATH='themes';
/**
- * @var string module ID
- */
- private $_id='theme';
- /**
* @var boolean whether this module has been initialized
*/
private $_initialized=false;
@@ -71,28 +67,13 @@ class TThemeManager extends TComponent implements IModule */
public function init($application,$config)
{
+ parent::init($application,$config);
$this->_application=$application;
$this->_initialized=true;
$application->getService()->setThemeManager($this);
}
/**
- * @return string id of this module
- */
- public function getID()
- {
- return $this->_id;
- }
-
- /**
- * @param string id of this module
- */
- public function setID($value)
- {
- $this->_id=$value;
- }
-
- /**
* @param string name of the theme to be retrieved
* @return TTheme the theme retrieved
*/
diff --git a/framework/core.php b/framework/core.php index 794384b4..efd091ad 100644 --- a/framework/core.php +++ b/framework/core.php @@ -311,6 +311,51 @@ interface IPageStatePersister }
/**
+ * TModule class.
+ *
+ * TModule implements the basic methods required by IModule and may be
+ * used as the basic class for application modules.
+ *
+ * @author Qiang Xue <qiang.xue@gmail.com>
+ * @version $Revision: $ $Date: $
+ * @package System
+ * @since 3.0
+ */
+class TModule extends TComponent implements IModule
+{
+ /**
+ * @var string module id
+ */
+ private $_id;
+
+ /**
+ * Initializes the module.
+ * This method is required by IModule and is invoked by application.
+ * @param TApplication application
+ * @param TXmlElement module configuration
+ */
+ public function init($application,$config)
+ {
+ }
+
+ /**
+ * @return string id of this module
+ */
+ public function getID()
+ {
+ return $this->_id;
+ }
+
+ /**
+ * @param string id of this module
+ */
+ public function setID($value)
+ {
+ $this->_id=$value;
+ }
+}
+
+/**
* PradoBase class.
*
* PradoBase implements a few fundamental static methods.
|