mirror of
https://github.com/yiisoft/yii2.git
synced 2025-11-03 13:58:55 +08:00
working on caching.
This commit is contained in:
@ -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));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user