diff options
author | xue <> | 2005-11-19 04:35:07 +0000 |
---|---|---|
committer | xue <> | 2005-11-19 04:35:07 +0000 |
commit | 8fd040ef49321fce9d3d0b9c44937984a2112b52 (patch) | |
tree | 573dcfe6a3ec6d5a3b7fde9298dcc1b4f45116b1 | |
parent | bc1a7e1e3a67537189d30013ea6d5fa4bf98e8e4 (diff) |
-rw-r--r-- | framework/Data/TMemCache.php | 10 | ||||
-rw-r--r-- | framework/Data/TSqliteCache.php | 21 | ||||
-rw-r--r-- | framework/Exceptions/messages.txt | 12 | ||||
-rw-r--r-- | framework/Web/UI/TThemeManager.php | 2 |
4 files changed, 36 insertions, 9 deletions
diff --git a/framework/Data/TMemCache.php b/framework/Data/TMemCache.php index 9786b467..b78014fb 100644 --- a/framework/Data/TMemCache.php +++ b/framework/Data/TMemCache.php @@ -49,6 +49,14 @@ * $object2=$cache->get('object');
* </code>
*
+ * If loaded, TMemCache will register itself with {@link TApplication} as the
+ * cache module. It can be accessed via {@link TApplication::getCache()}.
+ *
+ * TMemCache may be configured in application configuration file as follows
+ * <module id="cache" type="System.Data.TMemCache" Host="localhost" Port=11211 />
+ * where {@link getHost Host} and {@link getPort Port} are configurable properties
+ * of TMemCache.
+ *
* @author Qiang Xue <qiang.xue@gmail.com>
* @version $Revision: $ $Date: $
* @package System.Data
@@ -107,7 +115,7 @@ class TMemCache extends TComponent implements IModule, ICache throw new TConfigurationException('memcache_extension_required');
$this->_cache=new Memcache;
if($this->_cache->connect($this->_host,$this->_port)===false)
- throw new TInvalidConfigurationException('memcache_connection_failed');
+ throw new TInvalidConfigurationException('memcache_connection_failed',$this->_host,$this->_port);
if($application instanceof TApplication)
$this->_prefix=$application->getUniqueID();
$this->_initialized=true;
diff --git a/framework/Data/TSqliteCache.php b/framework/Data/TSqliteCache.php index eac22dd2..5eb692d4 100644 --- a/framework/Data/TSqliteCache.php +++ b/framework/Data/TSqliteCache.php @@ -17,7 +17,8 @@ *
* The database file is specified by the DbFile property. This property must
* be set before {@link init} is invoked. If the specified database file does not
- * exist, it will be created automatically. Make sure the database file is writable.
+ * exist, it will be created automatically. Make sure the directory containing
+ * the specified DB file and the file itself must be writable by the Web server process.
*
* The following basic cache operations are implemented:
* - {@link get} : retrieve the value with a key (if any) from cache
@@ -50,6 +51,14 @@ * $object2=$cache->get('object');
* </code>
*
+ * If loaded, TSqliteCache will register itself with {@link TApplication} as the
+ * cache module. It can be accessed via {@link TApplication::getCache()}.
+ *
+ * TMemCache may be configured in application configuration file as follows
+ * <module id="cache" type="System.Data.TSqliteCache" DbFile="Application.Data.site" />
+ * where {@link getDbFile DbFile} is a property specifying the location of the
+ * SQLite DB file (in the namespace format).
+ *
* @author Qiang Xue <qiang.xue@gmail.com>
* @version $Revision: $ $Date: $
* @package System.Data
@@ -113,11 +122,9 @@ class TSqliteCache extends TComponent implements IModule, ICache if(!function_exists('sqlite_open'))
throw new TConfigurationException('sqlitecache_extension_required');
if($this->_file===null)
- throw new TConfigurationException('sqlitecache_filename_required');
+ throw new TConfigurationException('sqlitecache_dbfile_required');
$error='';
- if(($fname=Prado::getPathOfNamespace($this->_file,self::DB_FILE_EXT))===null)
- throw new TConfigurationException('sqlitecache_dbfile_invalid',$this->_file);
- if(($this->_db=new SQLiteDatabase($fname,0666,$error))===false)
+ if(($this->_db=new SQLiteDatabase($this->_file,0666,$error))===false)
throw new TConfigurationException('sqlitecache_connection_failed',$error);
if(($res=$this->_db->query('SELECT * FROM sqlite_master WHERE tbl_name=\''.self::CACHE_TABLE.'\' AND type=\'table\''))!=false)
{
@@ -166,8 +173,8 @@ class TSqliteCache extends TComponent implements IModule, ICache {
if($this->_initialized)
throw new TInvalidOperationException('sqlitecache_dbfile_unchangeable');
- else
- $this->_file=$value;
+ else if(($this->_file=Prado::getPathOfNamespace($value,self::DB_FILE_EXT))===null)
+ throw new TConfigurationException('sqlitecache_dbfile_invalid',$value);
}
/**
diff --git a/framework/Exceptions/messages.txt b/framework/Exceptions/messages.txt index e808938c..9ed1160b 100644 --- a/framework/Exceptions/messages.txt +++ b/framework/Exceptions/messages.txt @@ -43,6 +43,18 @@ assetmanager_basepath_invalid = TAssetManager.BasePath '%s' is invalid. Make s assetmanager_basepath_unchangeable = TAssetManager.BasePath cannot be modified after the module is initialized.
assetmanager_baseurl_unchangeable = TAssetManager.BaseUrl cannot be modified after the module is initialized.
+sqlitecache_extension_required = TSqliteCache requires SQLite PHP extension.
+sqlitecache_dbfile_required = TSqliteCache.DbFile is required.
+sqlitecache_connection_failed = TSqliteCache database connection failed. %s.
+sqlitecache_table_creation_failed = TSqliteCache failed to create cache database. %s.
+sqlitecache_dbfile_unchangeable = TSqliteCache.DbFile cannot be modified after the module is initialized.
+sqlitecache_dbfile_invalid = TSqliteCache.DbFile is invalid. Make sure it is in a proper namespace format.
+
+memcache_extension_required = TMemCache requires memcache PHP extension.
+memcache_connection_failed = TMemCache failed to connect to memcache server %s:%d.
+memcache_host_unchangeable = TMemCache.Host cannot be modified after the module is initialized.
+memcache_port_unchangeable = TMemCache.Port cannot be modified after the module is initialized.
+
pageservice_page_unknown = Page '%s' Not Found
diff --git a/framework/Web/UI/TThemeManager.php b/framework/Web/UI/TThemeManager.php index b51aecac..5dcc640e 100644 --- a/framework/Web/UI/TThemeManager.php +++ b/framework/Web/UI/TThemeManager.php @@ -150,7 +150,7 @@ class TTheme extends TTemplate if(strpos($themePath,$appPath)===false)
throw new TConfigurationException('theme_baseurl_required');
$appUrl=dirname(Prado::getApplication()->getRequest()->getApplicationPath());
- $this->_themeUrl=$appUrl.'/'.strtr(substr($theme,strlen($basePath)),'\\','/');
+ $this->_themeUrl=$appUrl.'/'.strtr(substr($themePath,strlen($appPath)),'\\','/');
}
else
$this->_themeUrl=$baseUrl.'/'.basename($themePath);
|