diff options
-rw-r--r-- | demos/controls/protected/application.xml | 4 | ||||
-rw-r--r-- | demos/controls/protected/pages/HomePage.php | 4 | ||||
-rw-r--r-- | framework/Exceptions/TErrorHandler.php | 24 | ||||
-rw-r--r-- | framework/Exceptions/error.en | 9 | ||||
-rw-r--r-- | framework/TApplication.php | 20 | ||||
-rw-r--r-- | framework/Web/Services/TPageService.php | 40 | ||||
-rw-r--r-- | framework/Web/UI/TThemeManager.php | 17 |
7 files changed, 60 insertions, 58 deletions
diff --git a/demos/controls/protected/application.xml b/demos/controls/protected/application.xml index 2cfc14d9..856ae087 100644 --- a/demos/controls/protected/application.xml +++ b/demos/controls/protected/application.xml @@ -1,15 +1,13 @@ <?xml version="1.0" encoding="utf-8"?>
-<configuration id="controls">
+<configuration id="controls" mode="Debug">
<paths>
<alias id="Demo" path="." />
<alias id="Pages" path="pages" />
</paths>
<!-- modules configured and loaded for all services -->
<modules>
- <!-- make sure the path "protected" is writable by web server process if you enable this cache
<module id="cache" type="System.Data.TSqliteCache" DbFile="Demo.cache"/>
- -->
<module id="session" type="THttpSession" />
</modules>
<services>
diff --git a/demos/controls/protected/pages/HomePage.php b/demos/controls/protected/pages/HomePage.php index 6c69e44b..7339f364 100644 --- a/demos/controls/protected/pages/HomePage.php +++ b/demos/controls/protected/pages/HomePage.php @@ -5,8 +5,8 @@ class HomePage extends TPage public function onPreInit($param)
{
parent::onPreInit($param);
- if(!$this->getUser()->getIsGuest())
- $this->setTheme('');
+ if(!$this->User->IsGuest)
+ $this->Theme='';
}
public function testClick($sender,$param)
diff --git a/framework/Exceptions/TErrorHandler.php b/framework/Exceptions/TErrorHandler.php index 47feb54c..af41e056 100644 --- a/framework/Exceptions/TErrorHandler.php +++ b/framework/Exceptions/TErrorHandler.php @@ -39,11 +39,23 @@ class TErrorHandler extends TComponent implements IModule public function handleError($sender,$param)
{
- $type='Unhandled Exception';
- $this->displayException($param,$type);
+ if(($response=Prado::getApplication()->getResponse())!==null)
+ $response->clear();
+ switch(Prado::getApplication()->getMode())
+ {
+ case 'Off':
+ case 'Debug':
+ $this->displayException($param);
+ exit(1);
+ case 'Normal':
+ case 'Performance':
+ error_log($param->__toString());
+ header("HTTP/1.0 500 Internal Error");
+ exit(1);
+ }
}
- protected function displayException($exception,$type)
+ protected function displayException($exception)
{
$lines=file($exception->getFile());
$errorLine=$exception->getLine();
@@ -66,7 +78,8 @@ class TErrorHandler extends TComponent implements IModule '%%SourceFile%%',
'%%SourceCode%%',
'%%StackTrace%%',
- '%%Version%%'
+ '%%Version%%',
+ '%%Time%%'
);
$values=array(
get_class($exception),
@@ -74,7 +87,8 @@ class TErrorHandler extends TComponent implements IModule htmlspecialchars($exception->getFile()).' ('.$exception->getLine().')',
$source,
htmlspecialchars($exception->getTraceAsString()),
- $_SERVER['SERVER_SOFTWARE'].' <a href="http://www.pradosoft.com/">PRADO</a>/'.Prado::getVersion()
+ $_SERVER['SERVER_SOFTWARE'].' <a href="http://www.pradosoft.com/">PRADO</a>/'.Prado::getVersion(),
+ strftime('%Y-%m-%d %H:%m',time())
);
$languages=Prado::getUserLanguages();
$errorFile=dirname(__FILE__).'/error.'.$languages[0];
diff --git a/framework/Exceptions/error.en b/framework/Exceptions/error.en index 146ed2e8..1d76c7f2 100644 --- a/framework/Exceptions/error.en +++ b/framework/Exceptions/error.en @@ -8,7 +8,7 @@ h2 { font-family:"Verdana";font-weight:normal;font-size:14pt;color:maroon } h3 {font-family:"Verdana";font-weight:bold;font-size:11pt}
p {font-family:"Verdana";font-weight:normal;color:black;font-size:9pt;margin-top: -5px}
code,pre {font-family:"Lucida Console";}
-.version {color: gray;font-size:8pt;border-top:1px solid #aaaaaa;}
+td,.version {color: gray;font-size:8pt;border-top:1px solid #aaaaaa;}
.source {font-family:"Lucida Console";font-weight:normal;background-color:#ffffee;}
</style>
</head>
@@ -16,7 +16,7 @@ code,pre {font-family:"Lucida Console";} <body bgcolor="white">
<h1>%%ErrorType%%</h1>
<h3>Description</h3>
-<p>%%ErrorMessage%%</p>
+<p style="color:maroon">%%ErrorMessage%%</p>
<p>
<h3>Source File</h3>
<p>%%SourceFile%%</p>
@@ -29,6 +29,9 @@ code,pre {font-family:"Lucida Console";} %%StackTrace%%
</pre></code>
</div>
-<div class="version">%%Version%%</div>
+<div class="version">
+%%Version%%<br/>
+%%Time%%
+</div>
</body>
</html>
\ No newline at end of file diff --git a/framework/TApplication.php b/framework/TApplication.php index 5b52fd22..9ac9a8a0 100644 --- a/framework/TApplication.php +++ b/framework/TApplication.php @@ -157,6 +157,10 @@ class TApplication extends TComponent * @var TAuthorizationRuleCollection collection of authorization rules
*/
private $_authRules=null;
+ /**
+ * @var string application mode
+ */
+ private $_mode='Debug';
/**
* Constructor.
@@ -242,6 +246,22 @@ class TApplication extends TComponent }
/**
+ * @return string application mode (Off|Debug|Normal|Peformance), defaults to Debug.
+ */
+ public function getMode()
+ {
+ return $this->_mode;
+ }
+
+ /**
+ * @param string application mode. Valid values include Off, Debug, Normal, or Peformance
+ */
+ public function setMode($value)
+ {
+ $this->_mode=TPropertyValue::ensureEnum($value,array('Off','Debug','Normal','Performance'));
+ }
+
+ /**
* @return string configuration file path
*/
public function getConfigurationFile()
diff --git a/framework/Web/Services/TPageService.php b/framework/Web/Services/TPageService.php index 6c690046..bc921c0e 100644 --- a/framework/Web/Services/TPageService.php +++ b/framework/Web/Services/TPageService.php @@ -56,10 +56,6 @@ class TPageService extends TComponent implements IService */
private $_properties;
/**
- * @var integer cache expiration
- */
- private $_cacheExpire=-1;
- /**
* @var boolean whether service is initialized
*/
private $_initialized=false;
@@ -100,7 +96,7 @@ class TPageService extends TComponent implements IService if(is_array($arr))
{
list($pageConfig,$timestamp)=$arr;
- if($this->_cacheExpire<0)
+ if($application->getMode()!=='Performance')
{
// check to see if cache is the latest
$paths=explode('.',$this->_pagePath);
@@ -126,7 +122,7 @@ class TPageService extends TComponent implements IService $pageConfig=new TPageConfiguration;
$pageConfig->loadXmlElement($config,dirname($application->getConfigurationFile()),null);
$pageConfig->loadConfigurationFiles($this->_pagePath,$basePath);
- $cache->set(self::CONFIG_CACHE_PREFIX.$this->_pagePath,array($pageConfig,time()),$this->_cacheExpire<0?0:$this->_cacheExpire);
+ $cache->set(self::CONFIG_CACHE_PREFIX.$this->_pagePath,array($pageConfig,time()));
}
}
@@ -219,38 +215,6 @@ class TPageService extends TComponent implements IService }
/**
- * @return integer the expiration time of the configuration saved in cache,
- * -1 (default) ensures the cached configuration always catches up the latest configuration files,
- * 0 means never expire,
- * a number less or equal than 60*60*24*30 means the number of seconds that the value will remain valid.
- * a number greater than 60 means a UNIX timestamp after which the value will expire.
- */
- public function getCacheExpire()
- {
- return $this->_cacheExpire;
- }
-
- /**
- * Sets the expiration time of the configuration saved in cache.
- * TPageService will try to use cache to save parsed configuration files.
- * CacheExpire is used to control the caching policy.
- * If you have changed this property, make sure to clean up cache first.
- * @param integer the expiration time of the configuration saved in cache,
- * -1 (default) ensures the cached configuration always catches up the latest configuration files,
- * 0 means never expire,
- * a number less or equal than 60*60*24*30 means the number of seconds that the value will remain valid.
- * a number greater than 60 means a UNIX timestamp after which the value will expire.
- * @throws TInvalidOperationException if the service is already initialized
- */
- public function setCacheExpire($value)
- {
- if($this->_initialized)
- throw new TInvalidOperationException('pageservice_cacheexpire_unchangeable');
- else
- $this->_cacheExpire=TPropertyValue::ensureInteger($value);
- }
-
- /**
* @return string default page path to be served if no explicit page is request
*/
public function getDefaultPage()
diff --git a/framework/Web/UI/TThemeManager.php b/framework/Web/UI/TThemeManager.php index 5f347e8f..9b407b90 100644 --- a/framework/Web/UI/TThemeManager.php +++ b/framework/Web/UI/TThemeManager.php @@ -64,17 +64,20 @@ class TThemeManager extends TComponent implements IModule {
list($theme,$timestamp)=$array;
$cacheValid=true;
- if(($dir=opendir($themePath))===false)
- throw new TIOException('thememanager_themepath_invalid',$themePath);
- while(($file=readdir($dir))!==false)
+ if($this->_application->getMode()!=='Performance')
{
- if(basename($file,'.skin')!==$file && filemtime($themePath.'/'.$file)>$timestamp)
+ if(($dir=opendir($themePath))===false)
+ throw new TIOException('thememanager_themepath_invalid',$themePath);
+ while(($file=readdir($dir))!==false)
{
- $cacheValid=false;
- break;
+ if(basename($file,'.skin')!==$file && filemtime($themePath.'/'.$file)>$timestamp)
+ {
+ $cacheValid=false;
+ break;
+ }
}
+ closedir($dir);
}
- closedir($dir);
if($cacheValid)
return $theme;
}
|