Commit c2252422 by Qiang Xue

working on caching.

parent 0c85d56b
...@@ -34,7 +34,7 @@ class ErrorHandler extends ApplicationComponent ...@@ -34,7 +34,7 @@ class ErrorHandler extends ApplicationComponent
public $discardExistingOutput = true; public $discardExistingOutput = true;
/** /**
* @var string the route (eg 'site/error') to the controller action that will be used to display external errors. * @var string the route (eg 'site/error') to the controller action that will be used to display external errors.
* Inside the action, it can retrieve the error information by Yii::app()->errorHandler->error. * Inside the action, it can retrieve the error information by \Yii::$application->errorHandler->error.
* This property defaults to null, meaning ErrorHandler will handle the error display. * This property defaults to null, meaning ErrorHandler will handle the error display.
*/ */
public $errorAction; public $errorAction;
......
<?php
/**
* CInlineFilter class file.
*
* @author Qiang Xue <qiang.xue@gmail.com>
* @link http://www.yiiframework.com/
* @copyright Copyright &copy; 2008-2011 Yii Software LLC
* @license http://www.yiiframework.com/license/
*/
/**
* CInlineFilter represents a filter defined as a controller method.
*
* CInlineFilter executes the 'filterXYZ($action)' method defined
* in the controller, where the name 'XYZ' can be retrieved from the {@link name} property.
*
* @author Qiang Xue <qiang.xue@gmail.com>
* @version $Id$
* @package system.web.filters
* @since 1.0
*/
class CInlineFilter extends CFilter
{
/**
* @var string name of the filter. It stands for 'XYZ' in the filter method name 'filterXYZ'.
*/
public $name;
/**
* Creates an inline filter instance.
* The creation is based on a string describing the inline method name
* and action names that the filter shall or shall not apply to.
* @param CController $controller the controller who hosts the filter methods
* @param string $filterName the filter name
* @return CInlineFilter the created instance
* @throws CException if the filter method does not exist
*/
public static function create($controller,$filterName)
{
if(method_exists($controller,'filter'.$filterName))
{
$filter=new CInlineFilter;
$filter->name=$filterName;
return $filter;
}
else
throw new CException(Yii::t('yii','Filter "{filter}" is invalid. Controller "{class}" does not have the filter method "filter{filter}".',
array('{filter}'=>$filterName, '{class}'=>get_class($controller))));
}
/**
* Performs the filtering.
* This method calls the filter method defined in the controller class.
* @param CFilterChain $filterChain the filter chain that the filter is on.
*/
public function filter($filterChain)
{
$method='filter'.$this->name;
$filterChain->controller->$method($filterChain);
}
}
...@@ -99,13 +99,13 @@ class SecurityManager extends ApplicationComponent ...@@ -99,13 +99,13 @@ class SecurityManager extends ApplicationComponent
return $this->_validationKey; return $this->_validationKey;
} }
else { else {
if (($key = Yii::app()->getGlobalState(self::STATE_VALIDATION_KEY)) !== null) { if (($key = \Yii::$application->getGlobalState(self::STATE_VALIDATION_KEY)) !== null) {
$this->setValidationKey($key); $this->setValidationKey($key);
} }
else { else {
$key = $this->generateRandomKey(); $key = $this->generateRandomKey();
$this->setValidationKey($key); $this->setValidationKey($key);
Yii::app()->setGlobalState(self::STATE_VALIDATION_KEY, $key); \Yii::$application->setGlobalState(self::STATE_VALIDATION_KEY, $key);
} }
return $this->_validationKey; return $this->_validationKey;
} }
...@@ -135,13 +135,13 @@ class SecurityManager extends ApplicationComponent ...@@ -135,13 +135,13 @@ class SecurityManager extends ApplicationComponent
return $this->_encryptionKey; return $this->_encryptionKey;
} }
else { else {
if (($key = Yii::app()->getGlobalState(self::STATE_ENCRYPTION_KEY)) !== null) { if (($key = \Yii::$application->getGlobalState(self::STATE_ENCRYPTION_KEY)) !== null) {
$this->setEncryptionKey($key); $this->setEncryptionKey($key);
} }
else { else {
$key = $this->generateRandomKey(); $key = $this->generateRandomKey();
$this->setEncryptionKey($key); $this->setEncryptionKey($key);
Yii::app()->setGlobalState(self::STATE_ENCRYPTION_KEY, $key); \Yii::$application->setGlobalState(self::STATE_ENCRYPTION_KEY, $key);
} }
return $this->_encryptionKey; return $this->_encryptionKey;
} }
......
...@@ -2,12 +2,13 @@ ...@@ -2,12 +2,13 @@
/** /**
* CApcCache class file * CApcCache class file
* *
* @author Qiang Xue <qiang.xue@gmail.com>
* @link http://www.yiiframework.com/ * @link http://www.yiiframework.com/
* @copyright Copyright &copy; 2008-2011 Yii Software LLC * @copyright Copyright &copy; 2008-2012 Yii Software LLC
* @license http://www.yiiframework.com/license/ * @license http://www.yiiframework.com/license/
*/ */
namespace yii\caching;
/** /**
* CApcCache provides APC caching in terms of an application component. * CApcCache provides APC caching in terms of an application component.
* *
...@@ -17,9 +18,7 @@ ...@@ -17,9 +18,7 @@
* See {@link CCache} manual for common cache operations that are supported by CApcCache. * See {@link CCache} manual for common cache operations that are supported by CApcCache.
* *
* @author Qiang Xue <qiang.xue@gmail.com> * @author Qiang Xue <qiang.xue@gmail.com>
* @version $Id$ * @since 2.0
* @package system.caching
* @since 1.0
*/ */
class CApcCache extends CCache class CApcCache extends CCache
{ {
......
<?php
/**
* CacheDependency class file.
*
* @link http://www.yiiframework.com/
* @copyright Copyright &copy; 2008-2012 Yii Software LLC
* @license http://www.yiiframework.com/license/
*/
namespace yii\caching;
/**
* CacheDependency is the base class for cache dependency classes.
*
* CacheDependency implements the {@link ICacheDependency} interface.
* Child classes should override its {@link generateDependentData} for
* actual dependency checking.
*
* @property boolean $hasChanged Whether the dependency has changed.
* @property mixed $dependentData The data used to determine if dependency has been changed.
* This data is available after {@link evaluateDependency} is called.
*
* @author Qiang Xue <qiang.xue@gmail.com>
* @since 2.0
*/
class CacheDependency extends \yii\base\Object
{
/**
* @var boolean Whether this dependency is reusable or not.
* If set to true, dependent data for this cache dependency will only be generated once per request.
* You can then use the same cache dependency for multiple separate cache calls on the same page
* without the overhead of re-evaluating the dependency each time.
* Defaults to false;
* @since 1.1.11
*/
public $reuseDependentData = false;
/**
* @var array cached data for reusable dependencies.
* @since 1.1.11
*/
private static $_reusableData = array();
private $_hash;
private $_data;
/**
* Evaluates the dependency by generating and saving the data related with dependency.
* This method is invoked by cache before writing data into it.
*/
public function evaluateDependency()
{
if ($this->reuseDependentData) {
$hash = $this->getHash();
if (!isset(self::$_reusableData[$hash]['dependentData'])) {
self::$_reusableData[$hash]['dependentData'] = $this->generateDependentData();
}
$this->_data = self::$_reusableData[$hash]['dependentData'];
} else {
$this->_data = $this->generateDependentData();
}
}
/**
* @return boolean whether the dependency has changed.
*/
public function getHasChanged()
{
if ($this->reuseDependentData) {
$hash = $this->getHash();
if (!isset(self::$_reusableData[$hash]['hasChanged'])) {
if (!isset(self::$_reusableData[$hash]['dependentData'])) {
self::$_reusableData[$hash]['dependentData'] = $this->generateDependentData();
}
self::$_reusableData[$hash]['hasChanged'] = self::$_reusableData[$hash]['dependentData'] != $this->_data;
}
return self::$_reusableData[$hash]['hasChanged'];
} else {
return $this->generateDependentData() != $this->_data;
}
}
/**
* @return mixed the data used to determine if dependency has been changed.
* This data is available after {@link evaluateDependency} is called.
*/
public function getDependentData()
{
return $this->_data;
}
/**
* Generates the data needed to determine if dependency has been changed.
* Derived classes should override this method to generate actual dependent data.
* @return mixed the data needed to determine if dependency has been changed.
*/
protected function generateDependentData()
{
return null;
}
/**
* Generates a unique hash that identifies this cache dependency.
* @return string the hash for this cache dependency
*/
private function getHash()
{
if ($this->_hash === null) {
$this->_hash = sha1(serialize($this));
}
return $this->_hash;
}
}
\ No newline at end of file
...@@ -2,12 +2,13 @@ ...@@ -2,12 +2,13 @@
/** /**
* CChainedCacheDependency class file. * CChainedCacheDependency class file.
* *
* @author Qiang Xue <qiang.xue@gmail.com>
* @link http://www.yiiframework.com/ * @link http://www.yiiframework.com/
* @copyright Copyright &copy; 2008-2011 Yii Software LLC * @copyright Copyright &copy; 2008-2012 Yii Software LLC
* @license http://www.yiiframework.com/license/ * @license http://www.yiiframework.com/license/
*/ */
namespace yii\caching;
/** /**
* CChainedCacheDependency represents a list of cache dependencies. * CChainedCacheDependency represents a list of cache dependencies.
* *
...@@ -22,9 +23,7 @@ ...@@ -22,9 +23,7 @@
* @property boolean $hasChanged Whether the dependency is changed or not. * @property boolean $hasChanged Whether the dependency is changed or not.
* *
* @author Qiang Xue <qiang.xue@gmail.com> * @author Qiang Xue <qiang.xue@gmail.com>
* @version $Id$ * @since 2.0
* @package system.caching.dependencies
* @since 1.0
*/ */
class CChainedCacheDependency extends CComponent implements ICacheDependency class CChainedCacheDependency extends CComponent implements ICacheDependency
{ {
......
...@@ -2,12 +2,14 @@ ...@@ -2,12 +2,14 @@
/** /**
* CDbCache class file * CDbCache class file
* *
* @author Qiang Xue <qiang.xue@gmail.com>
* @link http://www.yiiframework.com/ * @link http://www.yiiframework.com/
* @copyright Copyright &copy; 2008-2011 Yii Software LLC * @copyright Copyright &copy; 2008-2012 Yii Software LLC
* @license http://www.yiiframework.com/license/ * @license http://www.yiiframework.com/license/
*/ */
namespace yii\caching;
/** /**
* CDbCache implements a cache application component by storing cached data in a database. * CDbCache implements a cache application component by storing cached data in a database.
* *
...@@ -27,9 +29,7 @@ ...@@ -27,9 +29,7 @@
* @property CDbConnection $dbConnection The DB connection instance. * @property CDbConnection $dbConnection The DB connection instance.
* *
* @author Qiang Xue <qiang.xue@gmail.com> * @author Qiang Xue <qiang.xue@gmail.com>
* @version $Id$ * @since 2.0
* @package system.caching
* @since 1.0
*/ */
class CDbCache extends CCache class CDbCache extends CCache
{ {
...@@ -150,7 +150,7 @@ EOD; ...@@ -150,7 +150,7 @@ EOD;
return $this->_db; return $this->_db;
else if(($id=$this->connectionID)!==null) else if(($id=$this->connectionID)!==null)
{ {
if(($this->_db=Yii::app()->getComponent($id)) instanceof CDbConnection) if(($this->_db=\Yii::$application->getComponent($id)) instanceof CDbConnection)
return $this->_db; return $this->_db;
else else
throw new CException(Yii::t('yii','CDbCache.connectionID "{id}" is invalid. Please make sure it refers to the ID of a CDbConnection application component.', throw new CException(Yii::t('yii','CDbCache.connectionID "{id}" is invalid. Please make sure it refers to the ID of a CDbConnection application component.',
...@@ -158,7 +158,7 @@ EOD; ...@@ -158,7 +158,7 @@ EOD;
} }
else else
{ {
$dbFile=Yii::app()->getRuntimePath().DIRECTORY_SEPARATOR.'cache-'.Yii::getVersion().'.db'; $dbFile=\Yii::$application->getRuntimePath().DIRECTORY_SEPARATOR.'cache-'.Yii::getVersion().'.db';
return $this->_db=new CDbConnection('sqlite:'.$dbFile); return $this->_db=new CDbConnection('sqlite:'.$dbFile);
} }
} }
......
...@@ -2,12 +2,14 @@ ...@@ -2,12 +2,14 @@
/** /**
* CDbCacheDependency class file. * CDbCacheDependency class file.
* *
* @author Qiang Xue <qiang.xue@gmail.com>
* @link http://www.yiiframework.com/ * @link http://www.yiiframework.com/
* @copyright Copyright &copy; 2008-2011 Yii Software LLC * @copyright Copyright &copy; 2008-2012 Yii Software LLC
* @license http://www.yiiframework.com/license/ * @license http://www.yiiframework.com/license/
*/ */
namespace yii\caching;
/** /**
* CDbCacheDependency represents a dependency based on the query result of a SQL statement. * CDbCacheDependency represents a dependency based on the query result of a SQL statement.
* *
...@@ -17,9 +19,7 @@ ...@@ -17,9 +19,7 @@
* component. It is this DB connection that is used to perform the query. * component. It is this DB connection that is used to perform the query.
* *
* @author Qiang Xue <qiang.xue@gmail.com> * @author Qiang Xue <qiang.xue@gmail.com>
* @version $Id$ * @since 2.0
* @package system.caching.dependencies
* @since 1.0
*/ */
class CDbCacheDependency extends CCacheDependency class CDbCacheDependency extends CCacheDependency
{ {
...@@ -102,7 +102,7 @@ class CDbCacheDependency extends CCacheDependency ...@@ -102,7 +102,7 @@ class CDbCacheDependency extends CCacheDependency
return $this->_db; return $this->_db;
else else
{ {
if(($this->_db=Yii::app()->getComponent($this->connectionID)) instanceof CDbConnection) if(($this->_db=\Yii::$application->getComponent($this->connectionID)) instanceof CDbConnection)
return $this->_db; return $this->_db;
else else
throw new CException(Yii::t('yii','CDbCacheDependency.connectionID "{id}" is invalid. Please make sure it refers to the ID of a CDbConnection application component.', throw new CException(Yii::t('yii','CDbCacheDependency.connectionID "{id}" is invalid. Please make sure it refers to the ID of a CDbConnection application component.',
......
...@@ -2,12 +2,13 @@ ...@@ -2,12 +2,13 @@
/** /**
* CCacheDependency class file. * CCacheDependency class file.
* *
* @author Qiang Xue <qiang.xue@gmail.com>
* @link http://www.yiiframework.com/ * @link http://www.yiiframework.com/
* @copyright Copyright &copy; 2008-2011 Yii Software LLC * @copyright Copyright &copy; 2008-2012 Yii Software LLC
* @license http://www.yiiframework.com/license/ * @license http://www.yiiframework.com/license/
*/ */
namespace yii\caching;
/** /**
* CCacheDependency is the base class for cache dependency classes. * CCacheDependency is the base class for cache dependency classes.
* *
...@@ -20,9 +21,7 @@ ...@@ -20,9 +21,7 @@
* This data is available after {@link evaluateDependency} is called. * This data is available after {@link evaluateDependency} is called.
* *
* @author Qiang Xue <qiang.xue@gmail.com> * @author Qiang Xue <qiang.xue@gmail.com>
* @version $Id$ * @since 2.0
* @package system.caching.dependencies
* @since 1.0
*/ */
class CCacheDependency extends CComponent implements ICacheDependency class CCacheDependency extends CComponent implements ICacheDependency
{ {
......
...@@ -2,12 +2,14 @@ ...@@ -2,12 +2,14 @@
/** /**
* CDirectoryCacheDependency class file. * CDirectoryCacheDependency class file.
* *
* @author Qiang Xue <qiang.xue@gmail.com>
* @link http://www.yiiframework.com/ * @link http://www.yiiframework.com/
* @copyright Copyright &copy; 2008-2011 Yii Software LLC * @copyright Copyright &copy; 2008-2012 Yii Software LLC
* @license http://www.yiiframework.com/license/ * @license http://www.yiiframework.com/license/
*/ */
namespace yii\caching;
/** /**
* CDirectoryCacheDependency represents a dependency based on change of a directory. * CDirectoryCacheDependency represents a dependency based on change of a directory.
* *
...@@ -25,9 +27,7 @@ ...@@ -25,9 +27,7 @@
* accessing modification time of multiple files under the directory. * accessing modification time of multiple files under the directory.
* *
* @author Qiang Xue <qiang.xue@gmail.com> * @author Qiang Xue <qiang.xue@gmail.com>
* @version $Id$ * @since 2.0
* @package system.caching.dependencies
* @since 1.0
*/ */
class CDirectoryCacheDependency extends CCacheDependency class CDirectoryCacheDependency extends CCacheDependency
{ {
......
...@@ -2,24 +2,23 @@ ...@@ -2,24 +2,23 @@
/** /**
* CDummyCache class file. * CDummyCache class file.
* *
* @author Qiang Xue <qiang.xue@gmail.com>
* @link http://www.yiiframework.com/ * @link http://www.yiiframework.com/
* @copyright Copyright &copy; 2008-2011 Yii Software LLC * @copyright Copyright &copy; 2008-2012 Yii Software LLC
* @license http://www.yiiframework.com/license/ * @license http://www.yiiframework.com/license/
*/ */
namespace yii\caching;
/** /**
* CDummyCache is a placeholder cache component. * CDummyCache is a placeholder cache component.
* *
* CDummyCache does not cache anything. It is provided so that one can always configure * CDummyCache does not cache anything. It is provided so that one can always configure
* a 'cache' application component and he does not need to check if Yii::app()->cache is null or not. * a 'cache' application component and he does not need to check if \Yii::$application->cache is null or not.
* By replacing CDummyCache with some other cache component, one can quickly switch from * By replacing CDummyCache with some other cache component, one can quickly switch from
* non-caching mode to caching mode. * non-caching mode to caching mode.
* *
* @author Qiang Xue <qiang.xue@gmail.com> * @author Qiang Xue <qiang.xue@gmail.com>
* @version $Id$ * @since 2.0
* @package system.caching
* @since 1.0
*/ */
class CDummyCache extends CApplicationComponent implements ICache, ArrayAccess class CDummyCache extends CApplicationComponent implements ICache, ArrayAccess
{ {
...@@ -36,7 +35,7 @@ class CDummyCache extends CApplicationComponent implements ICache, ArrayAccess ...@@ -36,7 +35,7 @@ class CDummyCache extends CApplicationComponent implements ICache, ArrayAccess
{ {
parent::init(); parent::init();
if($this->keyPrefix===null) if($this->keyPrefix===null)
$this->keyPrefix=Yii::app()->getId(); $this->keyPrefix=\Yii::$application->getId();
} }
/** /**
......
...@@ -2,12 +2,14 @@ ...@@ -2,12 +2,14 @@
/** /**
* CEAcceleratorCache class file * CEAcceleratorCache class file
* *
* @author Steffen Dietz <steffo.dietz[at]googlemail[dot]com>
* @link http://www.yiiframework.com/ * @link http://www.yiiframework.com/
* @copyright Copyright &copy; 2008-2011 Yii Software LLC * @copyright Copyright &copy; 2008-2012 Yii Software LLC
* @license http://www.yiiframework.com/license/ * @license http://www.yiiframework.com/license/
*/ */
namespace yii\caching;
/** /**
* CEAcceleratorCache implements a cache application module based on {@link http://eaccelerator.net/ eaccelerator}. * CEAcceleratorCache implements a cache application module based on {@link http://eaccelerator.net/ eaccelerator}.
* *
...@@ -18,9 +20,8 @@ ...@@ -18,9 +20,8 @@
* Please note that as of v0.9.6, eAccelerator no longer supports data caching. * Please note that as of v0.9.6, eAccelerator no longer supports data caching.
* This means if you still want to use this component, your eAccelerator should be of 0.9.5.x or lower version. * This means if you still want to use this component, your eAccelerator should be of 0.9.5.x or lower version.
* *
* @author Steffen Dietz <steffo.dietz[at]googlemail[dot]com> * @author Qiang Xue <qiang.xue@gmail.com>
* @version $Id$ * @since 2.0
* @package system.caching
*/ */
class CEAcceleratorCache extends CCache class CEAcceleratorCache extends CCache
{ {
......
...@@ -2,12 +2,13 @@ ...@@ -2,12 +2,13 @@
/** /**
* CExpressionDependency class file. * CExpressionDependency class file.
* *
* @author Qiang Xue <qiang.xue@gmail.com>
* @link http://www.yiiframework.com/ * @link http://www.yiiframework.com/
* @copyright Copyright &copy; 2008-2011 Yii Software LLC * @copyright Copyright &copy; 2008-2012 Yii Software LLC
* @license http://www.yiiframework.com/license/ * @license http://www.yiiframework.com/license/
*/ */
namespace yii\caching;
/** /**
* CExpressionDependency represents a dependency based on the result of a PHP expression. * CExpressionDependency represents a dependency based on the result of a PHP expression.
* *
...@@ -17,9 +18,7 @@ ...@@ -17,9 +18,7 @@
* the same as the one evaluated when storing the data to cache. * the same as the one evaluated when storing the data to cache.
* *
* @author Qiang Xue <qiang.xue@gmail.com> * @author Qiang Xue <qiang.xue@gmail.com>
* @version $Id$ * @since 2.0
* @package system.caching.dependencies
* @since 1.0
*/ */
class CExpressionDependency extends CCacheDependency class CExpressionDependency extends CCacheDependency
{ {
......
...@@ -2,12 +2,13 @@ ...@@ -2,12 +2,13 @@
/** /**
* CFileCache class file * CFileCache class file
* *
* @author Qiang Xue <qiang.xue@gmail.com>
* @link http://www.yiiframework.com/ * @link http://www.yiiframework.com/
* @copyright Copyright &copy; 2008-2011 Yii Software LLC * @copyright Copyright &copy; 2008-2012 Yii Software LLC
* @license http://www.yiiframework.com/license/ * @license http://www.yiiframework.com/license/
*/ */
namespace yii\caching;
/** /**
* CFileCache provides a file-based caching mechanism. * CFileCache provides a file-based caching mechanism.
* *
...@@ -21,8 +22,7 @@ ...@@ -21,8 +22,7 @@
* when storing a piece of data in the cache. Defaults to 100, meaning 0.01% chance. * when storing a piece of data in the cache. Defaults to 100, meaning 0.01% chance.
* *
* @author Qiang Xue <qiang.xue@gmail.com> * @author Qiang Xue <qiang.xue@gmail.com>
* @version $Id$ * @since 2.0
* @package system.caching
*/ */
class CFileCache extends CCache class CFileCache extends CCache
{ {
...@@ -56,7 +56,7 @@ class CFileCache extends CCache ...@@ -56,7 +56,7 @@ class CFileCache extends CCache
{ {
parent::init(); parent::init();
if($this->cachePath===null) if($this->cachePath===null)
$this->cachePath=Yii::app()->getRuntimePath().DIRECTORY_SEPARATOR.'cache'; $this->cachePath=\Yii::$application->getRuntimePath().DIRECTORY_SEPARATOR.'cache';
if(!is_dir($this->cachePath)) if(!is_dir($this->cachePath))
mkdir($this->cachePath,0777,true); mkdir($this->cachePath,0777,true);
} }
......
...@@ -2,12 +2,14 @@ ...@@ -2,12 +2,14 @@
/** /**
* CFileCacheDependency class file. * CFileCacheDependency class file.
* *
* @author Qiang Xue <qiang.xue@gmail.com>
* @link http://www.yiiframework.com/ * @link http://www.yiiframework.com/
* @copyright Copyright &copy; 2008-2011 Yii Software LLC * @copyright Copyright &copy; 2008-2012 Yii Software LLC
* @license http://www.yiiframework.com/license/ * @license http://www.yiiframework.com/license/
*/ */
namespace yii\caching;
/** /**
* CFileCacheDependency represents a dependency based on a file's last modification time. * CFileCacheDependency represents a dependency based on a file's last modification time.
* *
...@@ -17,9 +19,7 @@ ...@@ -17,9 +19,7 @@
* last modification time remains unchanged. * last modification time remains unchanged.
* *
* @author Qiang Xue <qiang.xue@gmail.com> * @author Qiang Xue <qiang.xue@gmail.com>
* @version $Id$ * @since 2.0
* @package system.caching.dependencies
* @since 1.0
*/ */
class CFileCacheDependency extends CCacheDependency class CFileCacheDependency extends CCacheDependency
{ {
......
...@@ -2,12 +2,13 @@ ...@@ -2,12 +2,13 @@
/** /**
* CMemCache class file * CMemCache class file
* *
* @author Qiang Xue <qiang.xue@gmail.com>
* @link http://www.yiiframework.com/ * @link http://www.yiiframework.com/
* @copyright Copyright &copy; 2008-2011 Yii Software LLC * @copyright Copyright &copy; 2008-2012 Yii Software LLC
* @license http://www.yiiframework.com/license/ * @license http://www.yiiframework.com/license/
*/ */
namespace yii\caching;
/** /**
* CMemCache implements a cache application component based on {@link http://memcached.org/ memcached}. * CMemCache implements a cache application component based on {@link http://memcached.org/ memcached}.
* *
...@@ -55,9 +56,7 @@ ...@@ -55,9 +56,7 @@
* @property array $servers List of memcache server configurations. Each element is a {@link CMemCacheServerConfiguration}. * @property array $servers List of memcache server configurations. Each element is a {@link CMemCacheServerConfiguration}.
* *
* @author Qiang Xue <qiang.xue@gmail.com> * @author Qiang Xue <qiang.xue@gmail.com>
* @version $Id$ * @since 2.0
* @package system.caching
* @since 1.0
*/ */
class CMemCache extends CCache class CMemCache extends CCache
{ {
......
...@@ -2,12 +2,13 @@ ...@@ -2,12 +2,13 @@
/** /**
* CWinCache class file * CWinCache class file
* *
* @author Alexander Makarov <sam@rmcreative.ru>
* @link http://www.yiiframework.com/ * @link http://www.yiiframework.com/
* @copyright Copyright &copy; 2008-2011 Yii Software LLC * @copyright Copyright &copy; 2008-2012 Yii Software LLC
* @license http://www.yiiframework.com/license/ * @license http://www.yiiframework.com/license/
*/ */
namespace yii\caching;
/** /**
* CWinCache implements a cache application component based on {@link http://www.iis.net/expand/wincacheforphp WinCache}. * CWinCache implements a cache application component based on {@link http://www.iis.net/expand/wincacheforphp WinCache}.
* *
...@@ -15,10 +16,8 @@ ...@@ -15,10 +16,8 @@
* *
* See {@link CCache} manual for common cache operations that are supported by CWinCache. * See {@link CCache} manual for common cache operations that are supported by CWinCache.
* *
* @author Alexander Makarov <sam@rmcreative.ru> * @author Qiang Xue <qiang.xue@gmail.com>
* @version $Id$ * @since 2.0
* @package system.caching
* @since 1.1.2
*/ */
class CWinCache extends CCache { class CWinCache extends CCache {
/** /**
......
...@@ -2,12 +2,13 @@ ...@@ -2,12 +2,13 @@
/** /**
* CXCache class file * CXCache class file
* *
* @author Wei Zhuo <weizhuo[at]gmail[dot]com>
* @link http://www.yiiframework.com/ * @link http://www.yiiframework.com/
* @copyright Copyright &copy; 2008-2011 Yii Software LLC * @copyright Copyright &copy; 2008-2012 Yii Software LLC
* @license http://www.yiiframework.com/license/ * @license http://www.yiiframework.com/license/
*/ */
namespace yii\caching;
/** /**
* CXCache implements a cache application module based on {@link http://xcache.lighttpd.net/ xcache}. * CXCache implements a cache application module based on {@link http://xcache.lighttpd.net/ xcache}.
* *
...@@ -16,9 +17,8 @@ ...@@ -16,9 +17,8 @@
* *
* See {@link CCache} manual for common cache operations that are supported by CXCache. * See {@link CCache} manual for common cache operations that are supported by CXCache.
* *
* @author Wei Zhuo <weizhuo[at]gmail[dot]com> * @author Qiang Xue <qiang.xue@gmail.com>
* @version $Id$ * @since 2.0
* @package system.caching
*/ */
class CXCache extends CCache class CXCache extends CCache
{ {
......
...@@ -2,12 +2,13 @@ ...@@ -2,12 +2,13 @@
/** /**
* CZendDataCache class file * CZendDataCache class file
* *
* @author Steffen Dietz <steffo.dietz[at]googlemail[dot]com>
* @link http://www.yiiframework.com/ * @link http://www.yiiframework.com/
* @copyright Copyright &copy; 2008-2011 Yii Software LLC * @copyright Copyright &copy; 2008-2012 Yii Software LLC
* @license http://www.yiiframework.com/license/ * @license http://www.yiiframework.com/license/
*/ */
namespace yii\caching;
/** /**
* CZendDataCache implements a cache application module based on the Zend Data Cache * CZendDataCache implements a cache application module based on the Zend Data Cache
* delivered with {@link http://www.zend.com/en/products/server/ ZendServer}. * delivered with {@link http://www.zend.com/en/products/server/ ZendServer}.
...@@ -16,9 +17,8 @@ ...@@ -16,9 +17,8 @@
* *
* See {@link CCache} manual for common cache operations that are supported by CZendDataCache. * See {@link CCache} manual for common cache operations that are supported by CZendDataCache.
* *
* @author Steffen Dietz <steffo.dietz[at]googlemail[dot]com> * @author Qiang Xue <qiang.xue@gmail.com>
* @version $Id$ * @since 2.0
* @package system.caching
*/ */
class CZendDataCache extends CCache class CZendDataCache extends CCache
{ {
......
...@@ -416,7 +416,7 @@ class MigrateCommand extends CConsoleCommand ...@@ -416,7 +416,7 @@ class MigrateCommand extends CConsoleCommand
{ {
if($this->_db!==null) if($this->_db!==null)
return $this->_db; return $this->_db;
else if(($this->_db=Yii::app()->getComponent($this->connectionID)) instanceof CDbConnection) else if(($this->_db=\Yii::$application->getComponent($this->connectionID)) instanceof CDbConnection)
return $this->_db; return $this->_db;
else else
die("Error: CMigrationCommand.connectionID '{$this->connectionID}' is invalid. Please make sure it refers to the ID of a CDbConnection application component.\n"); die("Error: CMigrationCommand.connectionID '{$this->connectionID}' is invalid. Please make sure it refers to the ID of a CDbConnection application component.\n");
......
...@@ -112,7 +112,7 @@ EOD; ...@@ -112,7 +112,7 @@ EOD;
if(($_path_=@getenv('YIIC_SHELL_COMMAND_PATH'))!==false) if(($_path_=@getenv('YIIC_SHELL_COMMAND_PATH'))!==false)
$_runner_->addCommands($_path_); $_runner_->addCommands($_path_);
$_commands_=$_runner_->commands; $_commands_=$_runner_->commands;
$log=Yii::app()->log; $log=\Yii::$application->log;
while(($_line_=$this->prompt("\n>>"))!==false) while(($_line_=$this->prompt("\n>>"))!==false)
{ {
......
...@@ -97,7 +97,7 @@ class CAssetManager extends CApplicationComponent ...@@ -97,7 +97,7 @@ class CAssetManager extends CApplicationComponent
{ {
if($this->_basePath===null) if($this->_basePath===null)
{ {
$request=Yii::app()->getRequest(); $request=\Yii::$application->getRequest();
$this->setBasePath(dirname($request->getScriptFile()).DIRECTORY_SEPARATOR.self::DEFAULT_BASEPATH); $this->setBasePath(dirname($request->getScriptFile()).DIRECTORY_SEPARATOR.self::DEFAULT_BASEPATH);
} }
return $this->_basePath; return $this->_basePath;
...@@ -125,7 +125,7 @@ class CAssetManager extends CApplicationComponent ...@@ -125,7 +125,7 @@ class CAssetManager extends CApplicationComponent
{ {
if($this->_baseUrl===null) if($this->_baseUrl===null)
{ {
$request=Yii::app()->getRequest(); $request=\Yii::$application->getRequest();
$this->setBaseUrl($request->getBaseUrl().'/'.self::DEFAULT_BASEPATH); $this->setBaseUrl($request->getBaseUrl().'/'.self::DEFAULT_BASEPATH);
} }
return $this->_baseUrl; return $this->_baseUrl;
......
...@@ -130,7 +130,7 @@ class CHttpRequest extends CApplicationComponent ...@@ -130,7 +130,7 @@ class CHttpRequest extends CApplicationComponent
} }
if($this->enableCsrfValidation) if($this->enableCsrfValidation)
Yii::app()->attachEventHandler('onBeginRequest',array($this,'validateCsrfToken')); \Yii::$application->attachEventHandler('onBeginRequest',array($this,'validateCsrfToken'));
} }
...@@ -762,7 +762,7 @@ class CHttpRequest extends CApplicationComponent ...@@ -762,7 +762,7 @@ class CHttpRequest extends CApplicationComponent
$url=$this->getHostInfo().$url; $url=$this->getHostInfo().$url;
header('Location: '.$url, true, $statusCode); header('Location: '.$url, true, $statusCode);
if($terminate) if($terminate)
Yii::app()->end(); \Yii::$application->end();
} }
/** /**
...@@ -816,7 +816,7 @@ class CHttpRequest extends CApplicationComponent ...@@ -816,7 +816,7 @@ class CHttpRequest extends CApplicationComponent
{ {
// clean up the application first because the file downloading could take long time // clean up the application first because the file downloading could take long time
// which may cause timeout of some resources (such as DB connection) // which may cause timeout of some resources (such as DB connection)
Yii::app()->end(0,false); \Yii::$application->end(0,false);
echo $content; echo $content;
exit(0); exit(0);
} }
...@@ -858,7 +858,7 @@ class CHttpRequest extends CApplicationComponent ...@@ -858,7 +858,7 @@ class CHttpRequest extends CApplicationComponent
* <b>Example</b>: * <b>Example</b>:
* <pre> * <pre>
* <?php * <?php
* Yii::app()->request->xSendFile('/home/user/Pictures/picture1.jpg',array( * \Yii::$application->request->xSendFile('/home/user/Pictures/picture1.jpg',array(
* 'saveName'=>'image1.jpg', * 'saveName'=>'image1.jpg',
* 'mimeType'=>'image/jpeg', * 'mimeType'=>'image/jpeg',
* 'terminate'=>false, * 'terminate'=>false,
...@@ -906,7 +906,7 @@ class CHttpRequest extends CApplicationComponent ...@@ -906,7 +906,7 @@ class CHttpRequest extends CApplicationComponent
header(trim($options['xHeader']).': '.$filePath); header(trim($options['xHeader']).': '.$filePath);
if(!isset($options['terminate']) || $options['terminate']) if(!isset($options['terminate']) || $options['terminate'])
Yii::app()->end(); \Yii::$application->end();
} }
/** /**
...@@ -1029,7 +1029,7 @@ class CCookieCollection extends CMap ...@@ -1029,7 +1029,7 @@ class CCookieCollection extends CMap
$cookies=array(); $cookies=array();
if($this->_request->enableCookieValidation) if($this->_request->enableCookieValidation)
{ {
$sm=Yii::app()->getSecurityManager(); $sm=\Yii::$application->getSecurityManager();
foreach($_COOKIE as $name=>$value) foreach($_COOKIE as $name=>$value)
{ {
if(is_string($value) && ($value=$sm->validateData($value))!==false) if(is_string($value) && ($value=$sm->validateData($value))!==false)
...@@ -1090,7 +1090,7 @@ class CCookieCollection extends CMap ...@@ -1090,7 +1090,7 @@ class CCookieCollection extends CMap
{ {
$value=$cookie->value; $value=$cookie->value;
if($this->_request->enableCookieValidation) if($this->_request->enableCookieValidation)
$value=Yii::app()->getSecurityManager()->hashData(serialize($value)); $value=\Yii::$application->getSecurityManager()->hashData(serialize($value));
if(version_compare(PHP_VERSION,'5.2.0','>=')) if(version_compare(PHP_VERSION,'5.2.0','>='))
setcookie($cookie->name,$value,$cookie->expire,$cookie->path,$cookie->domain,$cookie->secure,$cookie->httpOnly); setcookie($cookie->name,$value,$cookie->expire,$cookie->path,$cookie->domain,$cookie->secure,$cookie->httpOnly);
else else
......
...@@ -303,7 +303,7 @@ class CSort extends CComponent ...@@ -303,7 +303,7 @@ class CSort extends CComponent
else else
$directions=array($attribute=>$descending); $directions=array($attribute=>$descending);
$url=$this->createUrl(Yii::app()->getController(),$directions); $url=$this->createUrl(\Yii::$application->getController(),$directions);
return $this->createLink($attribute,$label,$url,$htmlOptions); return $this->createLink($attribute,$label,$url,$htmlOptions);
} }
......
...@@ -126,7 +126,7 @@ class CTheme extends CComponent ...@@ -126,7 +126,7 @@ class CTheme extends CComponent
$module=$module->getParentModule(); $module=$module->getParentModule();
} }
if($module===null) if($module===null)
$layoutName=Yii::app()->layout; $layoutName=\Yii::$application->layout;
else else
{ {
$layoutName=$module->layout; $layoutName=$module->layout;
......
...@@ -96,7 +96,7 @@ class CThemeManager extends CApplicationComponent ...@@ -96,7 +96,7 @@ class CThemeManager extends CApplicationComponent
public function getBasePath() public function getBasePath()
{ {
if($this->_basePath===null) if($this->_basePath===null)
$this->setBasePath(dirname(Yii::app()->getRequest()->getScriptFile()).DIRECTORY_SEPARATOR.self::DEFAULT_BASEPATH); $this->setBasePath(dirname(\Yii::$application->getRequest()->getScriptFile()).DIRECTORY_SEPARATOR.self::DEFAULT_BASEPATH);
return $this->_basePath; return $this->_basePath;
} }
...@@ -117,7 +117,7 @@ class CThemeManager extends CApplicationComponent ...@@ -117,7 +117,7 @@ class CThemeManager extends CApplicationComponent
public function getBaseUrl() public function getBaseUrl()
{ {
if($this->_baseUrl===null) if($this->_baseUrl===null)
$this->_baseUrl=Yii::app()->getBaseUrl().'/'.self::DEFAULT_BASEPATH; $this->_baseUrl=\Yii::$application->getBaseUrl().'/'.self::DEFAULT_BASEPATH;
return $this->_baseUrl; return $this->_baseUrl;
} }
......
...@@ -214,7 +214,7 @@ class CUrlManager extends CApplicationComponent ...@@ -214,7 +214,7 @@ class CUrlManager extends CApplicationComponent
{ {
if(empty($this->rules) || $this->getUrlFormat()===self::GET_FORMAT) if(empty($this->rules) || $this->getUrlFormat()===self::GET_FORMAT)
return; return;
if($this->cacheID!==false && ($cache=Yii::app()->getComponent($this->cacheID))!==null) if($this->cacheID!==false && ($cache=\Yii::$application->getComponent($this->cacheID))!==null)
{ {
$hash=md5(serialize($this->rules)); $hash=md5(serialize($this->rules));
if(($data=$cache->get(self::CACHE_KEY))!==false && isset($data[1]) && $data[1]===$hash) if(($data=$cache->get(self::CACHE_KEY))!==false && isset($data[1]) && $data[1]===$hash)
...@@ -466,9 +466,9 @@ class CUrlManager extends CApplicationComponent ...@@ -466,9 +466,9 @@ class CUrlManager extends CApplicationComponent
else else
{ {
if($this->showScriptName) if($this->showScriptName)
$this->_baseUrl=Yii::app()->getRequest()->getScriptUrl(); $this->_baseUrl=\Yii::$application->getRequest()->getScriptUrl();
else else
$this->_baseUrl=Yii::app()->getRequest()->getBaseUrl(); $this->_baseUrl=\Yii::$application->getRequest()->getBaseUrl();
return $this->_baseUrl; return $this->_baseUrl;
} }
} }
...@@ -767,7 +767,7 @@ class CUrlRule extends CBaseUrlRule ...@@ -767,7 +767,7 @@ class CUrlRule extends CBaseUrlRule
if($this->hasHostInfo) if($this->hasHostInfo)
{ {
$hostInfo=Yii::app()->getRequest()->getHostInfo(); $hostInfo=\Yii::$application->getRequest()->getHostInfo();
if(stripos($url,$hostInfo)===0) if(stripos($url,$hostInfo)===0)
$url=substr($url,strlen($hostInfo)); $url=substr($url,strlen($hostInfo));
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment