Commit c2252422 by Qiang Xue

working on caching.

parent 0c85d56b
......@@ -34,7 +34,7 @@ class ErrorHandler extends ApplicationComponent
public $discardExistingOutput = true;
/**
* @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.
*/
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
return $this->_validationKey;
}
else {
if (($key = Yii::app()->getGlobalState(self::STATE_VALIDATION_KEY)) !== null) {
if (($key = \Yii::$application->getGlobalState(self::STATE_VALIDATION_KEY)) !== null) {
$this->setValidationKey($key);
}
else {
$key = $this->generateRandomKey();
$this->setValidationKey($key);
Yii::app()->setGlobalState(self::STATE_VALIDATION_KEY, $key);
\Yii::$application->setGlobalState(self::STATE_VALIDATION_KEY, $key);
}
return $this->_validationKey;
}
......@@ -135,13 +135,13 @@ class SecurityManager extends ApplicationComponent
return $this->_encryptionKey;
}
else {
if (($key = Yii::app()->getGlobalState(self::STATE_ENCRYPTION_KEY)) !== null) {
if (($key = \Yii::$application->getGlobalState(self::STATE_ENCRYPTION_KEY)) !== null) {
$this->setEncryptionKey($key);
}
else {
$key = $this->generateRandomKey();
$this->setEncryptionKey($key);
Yii::app()->setGlobalState(self::STATE_ENCRYPTION_KEY, $key);
\Yii::$application->setGlobalState(self::STATE_ENCRYPTION_KEY, $key);
}
return $this->_encryptionKey;
}
......
......@@ -2,12 +2,13 @@
/**
* CApcCache class file
*
* @author Qiang Xue <qiang.xue@gmail.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/
*/
namespace yii\caching;
/**
* CApcCache provides APC caching in terms of an application component.
*
......@@ -17,9 +18,7 @@
* See {@link CCache} manual for common cache operations that are supported by CApcCache.
*
* @author Qiang Xue <qiang.xue@gmail.com>
* @version $Id$
* @package system.caching
* @since 1.0
* @since 2.0
*/
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 @@
/**
* CChainedCacheDependency class file.
*
* @author Qiang Xue <qiang.xue@gmail.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/
*/
namespace yii\caching;
/**
* CChainedCacheDependency represents a list of cache dependencies.
*
......@@ -22,9 +23,7 @@
* @property boolean $hasChanged Whether the dependency is changed or not.
*
* @author Qiang Xue <qiang.xue@gmail.com>
* @version $Id$
* @package system.caching.dependencies
* @since 1.0
* @since 2.0
*/
class CChainedCacheDependency extends CComponent implements ICacheDependency
{
......
......@@ -2,12 +2,14 @@
/**
* CDbCache class file
*
* @author Qiang Xue <qiang.xue@gmail.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/
*/
namespace yii\caching;
/**
* CDbCache implements a cache application component by storing cached data in a database.
*
......@@ -27,9 +29,7 @@
* @property CDbConnection $dbConnection The DB connection instance.
*
* @author Qiang Xue <qiang.xue@gmail.com>
* @version $Id$
* @package system.caching
* @since 1.0
* @since 2.0
*/
class CDbCache extends CCache
{
......@@ -150,7 +150,7 @@ EOD;
return $this->_db;
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;
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.',
......@@ -158,7 +158,7 @@ EOD;
}
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);
}
}
......
......@@ -2,12 +2,14 @@
/**
* CDbCacheDependency class file.
*
* @author Qiang Xue <qiang.xue@gmail.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/
*/
namespace yii\caching;
/**
* CDbCacheDependency represents a dependency based on the query result of a SQL statement.
*
......@@ -17,9 +19,7 @@
* component. It is this DB connection that is used to perform the query.
*
* @author Qiang Xue <qiang.xue@gmail.com>
* @version $Id$
* @package system.caching.dependencies
* @since 1.0
* @since 2.0
*/
class CDbCacheDependency extends CCacheDependency
{
......@@ -102,7 +102,7 @@ class CDbCacheDependency extends CCacheDependency
return $this->_db;
else
{
if(($this->_db=Yii::app()->getComponent($this->connectionID)) instanceof CDbConnection)
if(($this->_db=\Yii::$application->getComponent($this->connectionID)) instanceof CDbConnection)
return $this->_db;
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.',
......
......@@ -2,12 +2,13 @@
/**
* CCacheDependency class file.
*
* @author Qiang Xue <qiang.xue@gmail.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/
*/
namespace yii\caching;
/**
* CCacheDependency is the base class for cache dependency classes.
*
......@@ -20,9 +21,7 @@
* This data is available after {@link evaluateDependency} is called.
*
* @author Qiang Xue <qiang.xue@gmail.com>
* @version $Id$
* @package system.caching.dependencies
* @since 1.0
* @since 2.0
*/
class CCacheDependency extends CComponent implements ICacheDependency
{
......
......@@ -2,12 +2,14 @@
/**
* CDirectoryCacheDependency class file.
*
* @author Qiang Xue <qiang.xue@gmail.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/
*/
namespace yii\caching;
/**
* CDirectoryCacheDependency represents a dependency based on change of a directory.
*
......@@ -25,9 +27,7 @@
* accessing modification time of multiple files under the directory.
*
* @author Qiang Xue <qiang.xue@gmail.com>
* @version $Id$
* @package system.caching.dependencies
* @since 1.0
* @since 2.0
*/
class CDirectoryCacheDependency extends CCacheDependency
{
......
......@@ -2,24 +2,23 @@
/**
* CDummyCache class file.
*
* @author Qiang Xue <qiang.xue@gmail.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/
*/
namespace yii\caching;
/**
* CDummyCache is a placeholder cache component.
*
* 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
* non-caching mode to caching mode.
*
* @author Qiang Xue <qiang.xue@gmail.com>
* @version $Id$
* @package system.caching
* @since 1.0
* @since 2.0
*/
class CDummyCache extends CApplicationComponent implements ICache, ArrayAccess
{
......@@ -36,7 +35,7 @@ class CDummyCache extends CApplicationComponent implements ICache, ArrayAccess
{
parent::init();
if($this->keyPrefix===null)
$this->keyPrefix=Yii::app()->getId();
$this->keyPrefix=\Yii::$application->getId();
}
/**
......
......@@ -2,12 +2,14 @@
/**
* CEAcceleratorCache class file
*
* @author Steffen Dietz <steffo.dietz[at]googlemail[dot]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/
*/
namespace yii\caching;
/**
* CEAcceleratorCache implements a cache application module based on {@link http://eaccelerator.net/ eaccelerator}.
*
......@@ -18,9 +20,8 @@
* 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.
*
* @author Steffen Dietz <steffo.dietz[at]googlemail[dot]com>
* @version $Id$
* @package system.caching
* @author Qiang Xue <qiang.xue@gmail.com>
* @since 2.0
*/
class CEAcceleratorCache extends CCache
{
......
......@@ -2,12 +2,13 @@
/**
* CExpressionDependency class file.
*
* @author Qiang Xue <qiang.xue@gmail.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/
*/
namespace yii\caching;
/**
* CExpressionDependency represents a dependency based on the result of a PHP expression.
*
......@@ -17,9 +18,7 @@
* the same as the one evaluated when storing the data to cache.
*
* @author Qiang Xue <qiang.xue@gmail.com>
* @version $Id$
* @package system.caching.dependencies
* @since 1.0
* @since 2.0
*/
class CExpressionDependency extends CCacheDependency
{
......
......@@ -2,12 +2,13 @@
/**
* CFileCache class file
*
* @author Qiang Xue <qiang.xue@gmail.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/
*/
namespace yii\caching;
/**
* CFileCache provides a file-based caching mechanism.
*
......@@ -21,8 +22,7 @@
* when storing a piece of data in the cache. Defaults to 100, meaning 0.01% chance.
*
* @author Qiang Xue <qiang.xue@gmail.com>
* @version $Id$
* @package system.caching
* @since 2.0
*/
class CFileCache extends CCache
{
......@@ -56,7 +56,7 @@ class CFileCache extends CCache
{
parent::init();
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))
mkdir($this->cachePath,0777,true);
}
......
......@@ -2,12 +2,14 @@
/**
* CFileCacheDependency class file.
*
* @author Qiang Xue <qiang.xue@gmail.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/
*/
namespace yii\caching;
/**
* CFileCacheDependency represents a dependency based on a file's last modification time.
*
......@@ -17,9 +19,7 @@
* last modification time remains unchanged.
*
* @author Qiang Xue <qiang.xue@gmail.com>
* @version $Id$
* @package system.caching.dependencies
* @since 1.0
* @since 2.0
*/
class CFileCacheDependency extends CCacheDependency
{
......
......@@ -2,12 +2,13 @@
/**
* CMemCache class file
*
* @author Qiang Xue <qiang.xue@gmail.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/
*/
namespace yii\caching;
/**
* CMemCache implements a cache application component based on {@link http://memcached.org/ memcached}.
*
......@@ -55,9 +56,7 @@
* @property array $servers List of memcache server configurations. Each element is a {@link CMemCacheServerConfiguration}.
*
* @author Qiang Xue <qiang.xue@gmail.com>
* @version $Id$
* @package system.caching
* @since 1.0
* @since 2.0
*/
class CMemCache extends CCache
{
......
......@@ -2,12 +2,13 @@
/**
* CWinCache class file
*
* @author Alexander Makarov <sam@rmcreative.ru>
* @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/
*/
namespace yii\caching;
/**
* CWinCache implements a cache application component based on {@link http://www.iis.net/expand/wincacheforphp WinCache}.
*
......@@ -15,10 +16,8 @@
*
* See {@link CCache} manual for common cache operations that are supported by CWinCache.
*
* @author Alexander Makarov <sam@rmcreative.ru>
* @version $Id$
* @package system.caching
* @since 1.1.2
* @author Qiang Xue <qiang.xue@gmail.com>
* @since 2.0
*/
class CWinCache extends CCache {
/**
......
......@@ -2,12 +2,13 @@
/**
* CXCache class file
*
* @author Wei Zhuo <weizhuo[at]gmail[dot]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/
*/
namespace yii\caching;
/**
* CXCache implements a cache application module based on {@link http://xcache.lighttpd.net/ xcache}.
*
......@@ -16,9 +17,8 @@
*
* See {@link CCache} manual for common cache operations that are supported by CXCache.
*
* @author Wei Zhuo <weizhuo[at]gmail[dot]com>
* @version $Id$
* @package system.caching
* @author Qiang Xue <qiang.xue@gmail.com>
* @since 2.0
*/
class CXCache extends CCache
{
......
......@@ -2,12 +2,13 @@
/**
* CZendDataCache class file
*
* @author Steffen Dietz <steffo.dietz[at]googlemail[dot]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/
*/
namespace yii\caching;
/**
* CZendDataCache implements a cache application module based on the Zend Data Cache
* delivered with {@link http://www.zend.com/en/products/server/ ZendServer}.
......@@ -16,9 +17,8 @@
*
* See {@link CCache} manual for common cache operations that are supported by CZendDataCache.
*
* @author Steffen Dietz <steffo.dietz[at]googlemail[dot]com>
* @version $Id$
* @package system.caching
* @author Qiang Xue <qiang.xue@gmail.com>
* @since 2.0
*/
class CZendDataCache extends CCache
{
......
......@@ -416,7 +416,7 @@ class MigrateCommand extends CConsoleCommand
{
if($this->_db!==null)
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;
else
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;
if(($_path_=@getenv('YIIC_SHELL_COMMAND_PATH'))!==false)
$_runner_->addCommands($_path_);
$_commands_=$_runner_->commands;
$log=Yii::app()->log;
$log=\Yii::$application->log;
while(($_line_=$this->prompt("\n>>"))!==false)
{
......
......@@ -97,7 +97,7 @@ class CAssetManager extends CApplicationComponent
{
if($this->_basePath===null)
{
$request=Yii::app()->getRequest();
$request=\Yii::$application->getRequest();
$this->setBasePath(dirname($request->getScriptFile()).DIRECTORY_SEPARATOR.self::DEFAULT_BASEPATH);
}
return $this->_basePath;
......@@ -125,7 +125,7 @@ class CAssetManager extends CApplicationComponent
{
if($this->_baseUrl===null)
{
$request=Yii::app()->getRequest();
$request=\Yii::$application->getRequest();
$this->setBaseUrl($request->getBaseUrl().'/'.self::DEFAULT_BASEPATH);
}
return $this->_baseUrl;
......
......@@ -130,7 +130,7 @@ class CHttpRequest extends CApplicationComponent
}
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
$url=$this->getHostInfo().$url;
header('Location: '.$url, true, $statusCode);
if($terminate)
Yii::app()->end();
\Yii::$application->end();
}
/**
......@@ -816,7 +816,7 @@ class CHttpRequest extends CApplicationComponent
{
// clean up the application first because the file downloading could take long time
// which may cause timeout of some resources (such as DB connection)
Yii::app()->end(0,false);
\Yii::$application->end(0,false);
echo $content;
exit(0);
}
......@@ -858,7 +858,7 @@ class CHttpRequest extends CApplicationComponent
* <b>Example</b>:
* <pre>
* <?php
* Yii::app()->request->xSendFile('/home/user/Pictures/picture1.jpg',array(
* \Yii::$application->request->xSendFile('/home/user/Pictures/picture1.jpg',array(
* 'saveName'=>'image1.jpg',
* 'mimeType'=>'image/jpeg',
* 'terminate'=>false,
......@@ -906,7 +906,7 @@ class CHttpRequest extends CApplicationComponent
header(trim($options['xHeader']).': '.$filePath);
if(!isset($options['terminate']) || $options['terminate'])
Yii::app()->end();
\Yii::$application->end();
}
/**
......@@ -1029,7 +1029,7 @@ class CCookieCollection extends CMap
$cookies=array();
if($this->_request->enableCookieValidation)
{
$sm=Yii::app()->getSecurityManager();
$sm=\Yii::$application->getSecurityManager();
foreach($_COOKIE as $name=>$value)
{
if(is_string($value) && ($value=$sm->validateData($value))!==false)
......@@ -1090,7 +1090,7 @@ class CCookieCollection extends CMap
{
$value=$cookie->value;
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','>='))
setcookie($cookie->name,$value,$cookie->expire,$cookie->path,$cookie->domain,$cookie->secure,$cookie->httpOnly);
else
......
......@@ -303,7 +303,7 @@ class CSort extends CComponent
else
$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);
}
......
......@@ -126,7 +126,7 @@ class CTheme extends CComponent
$module=$module->getParentModule();
}
if($module===null)
$layoutName=Yii::app()->layout;
$layoutName=\Yii::$application->layout;
else
{
$layoutName=$module->layout;
......
......@@ -96,7 +96,7 @@ class CThemeManager extends CApplicationComponent
public function getBasePath()
{
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;
}
......@@ -117,7 +117,7 @@ class CThemeManager extends CApplicationComponent
public function getBaseUrl()
{
if($this->_baseUrl===null)
$this->_baseUrl=Yii::app()->getBaseUrl().'/'.self::DEFAULT_BASEPATH;
$this->_baseUrl=\Yii::$application->getBaseUrl().'/'.self::DEFAULT_BASEPATH;
return $this->_baseUrl;
}
......
......@@ -214,7 +214,7 @@ class CUrlManager extends CApplicationComponent
{
if(empty($this->rules) || $this->getUrlFormat()===self::GET_FORMAT)
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));
if(($data=$cache->get(self::CACHE_KEY))!==false && isset($data[1]) && $data[1]===$hash)
......@@ -466,9 +466,9 @@ class CUrlManager extends CApplicationComponent
else
{
if($this->showScriptName)
$this->_baseUrl=Yii::app()->getRequest()->getScriptUrl();
$this->_baseUrl=\Yii::$application->getRequest()->getScriptUrl();
else
$this->_baseUrl=Yii::app()->getRequest()->getBaseUrl();
$this->_baseUrl=\Yii::$application->getRequest()->getBaseUrl();
return $this->_baseUrl;
}
}
......@@ -767,7 +767,7 @@ class CUrlRule extends CBaseUrlRule
if($this->hasHostInfo)
{
$hostInfo=Yii::app()->getRequest()->getHostInfo();
$hostInfo=\Yii::$application->getRequest()->getHostInfo();
if(stripos($url,$hostInfo)===0)
$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