diff options
author | Ciro Mattia Gonano <ciromattia@gmail.com> | 2013-07-24 12:22:49 +0200 |
---|---|---|
committer | Ciro Mattia Gonano <ciromattia@gmail.com> | 2013-07-24 12:22:49 +0200 |
commit | 0f332e6564ed67ef7eb4d715ce3bcb5ff54c50cf (patch) | |
tree | 00cecb80224872c25e712a59b417c5f1dff240cb /framework/pradolite.php | |
parent | 3c208455c7775838e795909923536a7de13d9c5c (diff) |
Upgrade to newly released 3.2.23.2.2
Diffstat (limited to 'framework/pradolite.php')
-rw-r--r-- | framework/pradolite.php | 155 |
1 files changed, 118 insertions, 37 deletions
diff --git a/framework/pradolite.php b/framework/pradolite.php index ff7a89f7..6fb4c9d6 100644 --- a/framework/pradolite.php +++ b/framework/pradolite.php @@ -1,7 +1,7 @@ <?php /** * File Name: pradolite.php - * Last Update: 2013/04/24 09:57:50 + * Last Update: 2013/07/24 12:18:57 * Generated By: buildscripts/phpbuilder/build.php * * This file is used in lieu of prado.php to boost PRADO application performance. @@ -2225,13 +2225,13 @@ class TJavaScript ($g=Prado::getApplication()->getGlobalization(false))!==null && strtoupper($enc=$g->getCharset())!='UTF-8') $value=iconv($enc, 'UTF-8', $value); - $s = json_encode($value,$options); + $s = @json_encode($value,$options); self::checkJsonError(); return $s; } public static function jsonDecode($value, $assoc = false, $depth = 512) { - $s= json_decode($value, $assoc, $depth); + $s= @json_decode($value, $assoc, $depth); self::checkJsonError(); return $s; } @@ -2368,6 +2368,7 @@ class THttpRequest extends TApplicationComponent implements IteratorAggregate,Ar private $_requestResolved=false; private $_enableCookieValidation=false; private $_cgiFix=0; + private $_enableCache=false; private $_url=null; private $_id; private $_items=array(); @@ -2381,19 +2382,6 @@ class THttpRequest extends TApplicationComponent implements IteratorAggregate,Ar } public function init($config) { - if(empty($this->_urlManagerID)) - { - $this->_urlManager=new TUrlManager; - $this->_urlManager->init(null); - } - else - { - $this->_urlManager=$this->getApplication()->getModule($this->_urlManagerID); - if($this->_urlManager===null) - throw new TConfigurationException('httprequest_urlmanager_inexist',$this->_urlManagerID); - if(!($this->_urlManager instanceof TUrlManager)) - throw new TConfigurationException('httprequest_urlmanager_invalid',$this->_urlManagerID); - } if(php_sapi_name()==='cli') { $_SERVER['REMOTE_ADDR']='127.0.0.1'; @@ -2450,6 +2438,51 @@ class THttpRequest extends TApplicationComponent implements IteratorAggregate,Ar } return $this->_url; } + public function setEnableCache($value) + { + $this->_enableCache = TPropertyValue::ensureBoolean($value); + } + public function getEnableCache() + { + return $this->_enableCache; + } + protected function getCacheKey() + { + return $this->getID(); + } + protected function cacheUrlManager($manager) + { + if($this->getEnableCache()) + { + $cache = $this->getApplication()->getCache(); + if($cache !== null) + { + $dependencies = null; + if($this->getApplication()->getMode() !== TApplicationMode::Performance) + if ($manager instanceof TUrlMapping && $fn = $manager->getConfigFile()) + { + $fn = Prado::getPathOfNamespace($fn,$this->getApplication()->getConfigurationFileExt()); + $dependencies = new TFileCacheDependency($fn); + } + return $cache->set($this->getCacheKey(), $manager, 0, $dependencies); + } + } + return false; + } + protected function loadCachedUrlManager() + { + if($this->getEnableCache()) + { + $cache = $this->getApplication()->getCache(); + if($cache !== null) + { + $manager = $cache->get($this->getCacheKey()); + if($manager instanceof TUrlManager) + return $manager; + } + } + return null; + } public function getUrlManager() { return $this->_urlManagerID; @@ -2460,6 +2493,26 @@ class THttpRequest extends TApplicationComponent implements IteratorAggregate,Ar } public function getUrlManagerModule() { + if($this->_urlManager===null) + { + if(($this->_urlManager = $this->loadCachedUrlManager())===null) + { + if(empty($this->_urlManagerID)) + { + $this->_urlManager=new TUrlManager; + $this->_urlManager->init(null); + } + else + { + $this->_urlManager=$this->getApplication()->getModule($this->_urlManagerID); + if($this->_urlManager===null) + throw new TConfigurationException('httprequest_urlmanager_inexist',$this->_urlManagerID); + if(!($this->_urlManager instanceof TUrlManager)) + throw new TConfigurationException('httprequest_urlmanager_invalid',$this->_urlManagerID); + } + $this->cacheUrlManager($this->_urlManager); + } + } return $this->_urlManager; } public function getUrlFormat() @@ -2650,7 +2703,7 @@ class THttpRequest extends TApplicationComponent implements IteratorAggregate,Ar { if ($this->_cookieOnly===null) $this->_cookieOnly=(int)ini_get('session.use_cookies') && (int)ini_get('session.use_only_cookies'); - $url=$this->_urlManager->constructUrl($serviceID,$serviceParam,$getItems,$encodeAmpersand,$encodeGetItems); + $url=$this->getUrlManagerModule()->constructUrl($serviceID,$serviceParam,$getItems,$encodeAmpersand,$encodeGetItems); if(defined('SID') && SID != '' && !$this->_cookieOnly) return $url . (strpos($url,'?')===false? '?' : ($encodeAmpersand?'&':'&')) . SID; else @@ -2658,7 +2711,7 @@ class THttpRequest extends TApplicationComponent implements IteratorAggregate,Ar } protected function parseUrl() { - return $this->_urlManager->parseUrl(); + return $this->getUrlManagerModule()->parseUrl(); } public function resolveRequest($serviceIDs) { @@ -6383,7 +6436,14 @@ class TClientScriptManager extends TApplicationComponent } public function getStyleSheetUrls() { - $stylesheets = array_values(array_merge($this->_styleSheetFiles, $this->_styleSheets)); + $stylesheets = array_values( + array_merge( + array_map( + create_function('$e', 'return is_array($e) ? $e[0] : $e;'), + $this->_styleSheetFiles), + $this->_styleSheets + ) + ); foreach(Prado::getApplication()->getAssetManager()->getPublished() as $path=>$url) if (substr($url,strlen($url)-4)=='.css') $stylesheets[] = $url; @@ -6584,10 +6644,6 @@ class TClientScriptManager extends TApplicationComponent abstract class TClientSideOptions extends TComponent { private $_options; - public function __construct() - { - $this->_options = Prado::createComponent('System.Collections.TMap'); - } protected function setFunction($name, $code) { if(!TJavaScript::isJsLiteral($code)) @@ -6596,14 +6652,19 @@ abstract class TClientSideOptions extends TComponent } protected function getOption($name) { - return $this->_options->itemAt($name); + if ($this->_options) + return $this->_options->itemAt($name); + else + return null; } protected function setOption($name, $value) { - $this->_options->add($name, $value); + $this->getOptions()->add($name, $value); } public function getOptions() { + if (!$this->_options) + $this->_options = Prado::createComponent('System.Collections.TMap'); return $this->_options; } protected function ensureFunction($javascript) @@ -9467,6 +9528,7 @@ class TApplication extends TComponent private $_services; private $_service; private $_modules=array(); + private $_lazyModules=array(); private $_parameters; private $_configFile; private $_configFileExt; @@ -9699,7 +9761,7 @@ class TApplication extends TComponent { $this->_service=$value; } - public function setModule($id,IModule $module) + public function setModule($id,IModule $module=null) { if(isset($this->_modules[$id])) throw new TConfigurationException('application_moduleid_duplicated',$id); @@ -9708,7 +9770,14 @@ class TApplication extends TComponent } public function getModule($id) { - return isset($this->_modules[$id])?$this->_modules[$id]:null; + if(!array_key_exists($id, $this->_modules)) + return null; + if($this->_modules[$id]===null) + { + $module = $this->internalLoadModule($id, true); + $module[0]->init($module[1]); + } + return $this->_modules[$id]; } public function getModules() { @@ -9848,6 +9917,24 @@ class TApplication extends TComponent { return 'TApplicationConfiguration'; } + protected function internalLoadModule($id, $force=false) + { + list($moduleClass, $initProperties, $configElement)=$this->_lazyModules[$id]; + if(isset($initProperties['lazy']) && $initProperties['lazy'] && !$force) + { + $this->setModule($id, null); + return null; + } + $module=Prado::createComponent($moduleClass); + foreach($initProperties as $name=>$value) + { + if($name==='lazy') continue; + $module->setSubProperty($name,$value); + } + $this->setModule($id,$module); + unset($this->_lazyModules[$id]); + return array($module,$configElement); + } public function applyConfiguration($config,$withinService=false) { if($config->getIsEmpty()) @@ -9878,17 +9965,11 @@ class TApplication extends TComponent $modules=array(); foreach($config->getModules() as $id=>$moduleConfig) { - list($moduleClass, $initProperties, $configElement)=$moduleConfig; - $module=Prado::createComponent($moduleClass); if(!is_string($id)) - { - $id='_module'.count($this->_modules); - $initProperties['id']=$id; - } - $this->setModule($id,$module); - foreach($initProperties as $name=>$value) - $module->setSubProperty($name,$value); - $modules[]=array($module,$configElement); + $id='_module'.count($this->_lazyModules); + $this->_lazyModules[$id]=$moduleConfig; + if($module = $this->internalLoadModule($id)) + $modules[]=$module; } foreach($modules as $module) $module[0]->init($module[1]); |