summaryrefslogtreecommitdiff
path: root/framework
diff options
context:
space:
mode:
authorCiro Mattia Gonano <ciromattia@gmail.com>2013-07-24 12:22:49 +0200
committerCiro Mattia Gonano <ciromattia@gmail.com>2013-07-24 12:22:49 +0200
commit0f332e6564ed67ef7eb4d715ce3bcb5ff54c50cf (patch)
tree00cecb80224872c25e712a59b417c5f1dff240cb /framework
parent3c208455c7775838e795909923536a7de13d9c5c (diff)
Upgrade to newly released 3.2.23.2.2
Diffstat (limited to 'framework')
-rw-r--r--framework/Data/Common/TDbMetaData.php5
-rw-r--r--framework/Data/SqlMap/Statements/TPreparedCommand.php9
-rw-r--r--framework/Data/SqlMap/Statements/TPreparedStatement.php37
-rw-r--r--framework/Exceptions/messages/messages.txt4
-rw-r--r--framework/I18N/core/data/fr_CA.dat2
-rw-r--r--framework/TApplication.php73
-rw-r--r--framework/Web/Javascripts/TJavaScript.php8
-rw-r--r--framework/Web/Javascripts/source/prado/prado.js2
-rw-r--r--framework/Web/Javascripts/source/prado/scriptaculous-adapter.js5
-rw-r--r--framework/Web/THttpRequest.php120
-rw-r--r--framework/Web/TUrlMapping.php111
-rw-r--r--framework/Web/UI/ActiveControls/TActiveLinkButton.php37
-rwxr-xr-xframework/Web/UI/ActiveControls/TDraggable.php40
-rwxr-xr-xframework/Web/UI/ActiveControls/TDropContainer.php37
-rw-r--r--framework/Web/UI/TClientScriptManager.php33
-rw-r--r--framework/Web/UI/WebControls/TButtonColumn.php7
-rw-r--r--framework/Web/UI/WebControls/TEmailAddressValidator.php17
-rw-r--r--framework/Web/UI/WebControls/THyperLink.php31
-rw-r--r--framework/Web/UI/WebControls/TListControl.php7
-rw-r--r--framework/Web/UI/WebControls/TRequiredFieldValidator.php24
-rw-r--r--framework/Web/UI/WebControls/TWizard.php34
-rw-r--r--framework/pradolite.php155
22 files changed, 605 insertions, 193 deletions
diff --git a/framework/Data/Common/TDbMetaData.php b/framework/Data/Common/TDbMetaData.php
index 91cf9616..2ad5c592 100644
--- a/framework/Data/Common/TDbMetaData.php
+++ b/framework/Data/Common/TDbMetaData.php
@@ -6,7 +6,7 @@
* @link http://www.pradosoft.com/
* @copyright Copyright &copy; 2005-2013 PradoSoft
* @license http://www.pradosoft.com/license/
- * @version $Id: TDbMetaData.php 3245 2013-01-07 20:23:32Z ctrlaltca $
+ * @version $Id: TDbMetaData.php 3284 2013-04-11 07:14:59Z ctrlaltca $
* @package System.Data.Common
*/
@@ -17,7 +17,7 @@
* Use the {@link getTableInfo} method to retrieve a table information.
*
* @author Wei Zhuo <weizho[at]gmail[dot]com>
- * @version $Id: TDbMetaData.php 3245 2013-01-07 20:23:32Z ctrlaltca $
+ * @version $Id: TDbMetaData.php 3284 2013-04-11 07:14:59Z ctrlaltca $
* @package System.Data.Common
* @since 3.1
*/
@@ -70,6 +70,7 @@ abstract class TDbMetaData extends TComponent
Prado::using('System.Data.Common.Sqlite.TSqliteMetaData');
return new TSqliteMetaData($conn);
case 'mssql': // Mssql driver on windows hosts
+ case 'sqlsrv': // sqlsrv driver on windows hosts
case 'dblib': // dblib drivers on linux (and maybe others os) hosts
Prado::using('System.Data.Common.Mssql.TMssqlMetaData');
return new TMssqlMetaData($conn);
diff --git a/framework/Data/SqlMap/Statements/TPreparedCommand.php b/framework/Data/SqlMap/Statements/TPreparedCommand.php
index 59a58b5d..1e6906a1 100644
--- a/framework/Data/SqlMap/Statements/TPreparedCommand.php
+++ b/framework/Data/SqlMap/Statements/TPreparedCommand.php
@@ -6,7 +6,7 @@
* @link http://www.pradosoft.com/
* @copyright Copyright &copy; 2005-2013 PradoSoft
* @license http://www.pradosoft.com/license/
- * @version $Id: TPreparedCommand.php 3245 2013-01-07 20:23:32Z ctrlaltca $
+ * @version $Id: TPreparedCommand.php 3261 2013-01-22 22:36:51Z ctrlaltca $
* @package System.Data.SqlMap.Statements
*/
@@ -17,7 +17,7 @@ Prado::using('System.Data.Common.TDbCommandBuilder');
* TPreparedCommand class.
*
* @author Wei Zhuo <weizho[at]gmail[dot]com>
- * @version $Id: TPreparedCommand.php 3245 2013-01-07 20:23:32Z ctrlaltca $
+ * @version $Id: TPreparedCommand.php 3261 2013-01-22 22:36:51Z ctrlaltca $
* @package System.Data.SqlMap.Statements
* @since 3.1
*/
@@ -47,9 +47,10 @@ class TPreparedCommand
protected function applyParameterMap($manager,$command,$prepared, $statement, $parameterObject)
{
- $properties = $prepared->getParameterNames();
- $parameters = $prepared->getParameterValues();
+ $properties = $prepared->getParameterNames(false);
+ //$parameters = $prepared->getParameterValues();
$registry=$manager->getTypeHandlers();
+ if ($properties)
for($i = 0, $k=$properties->getCount(); $i<$k; $i++)
{
$property = $statement->parameterMap()->getProperty($i);
diff --git a/framework/Data/SqlMap/Statements/TPreparedStatement.php b/framework/Data/SqlMap/Statements/TPreparedStatement.php
index f46994ab..4127eae0 100644
--- a/framework/Data/SqlMap/Statements/TPreparedStatement.php
+++ b/framework/Data/SqlMap/Statements/TPreparedStatement.php
@@ -6,7 +6,7 @@
* @link http://www.pradosoft.com/
* @copyright Copyright &copy; 2005-2013 PradoSoft
* @license http://www.pradosoft.com/license/
- * @version $Id: TPreparedStatement.php 3245 2013-01-07 20:23:32Z ctrlaltca $
+ * @version $Id: TPreparedStatement.php 3261 2013-01-22 22:36:51Z ctrlaltca $
* @package System.Data.SqlMap.Statements
*/
@@ -14,7 +14,7 @@
* TpreparedStatement class.
*
* @author Wei Zhuo <weizho[at]gmail[dot]com>
- * @version $Id: TPreparedStatement.php 3245 2013-01-07 20:23:32Z ctrlaltca $
+ * @version $Id: TPreparedStatement.php 3261 2013-01-22 22:36:51Z ctrlaltca $
* @package System.Data.SqlMap.Statements
* @since 3.1
*/
@@ -24,33 +24,32 @@ class TPreparedStatement extends TComponent
private $_parameterNames;
private $_parameterValues;
- public function __construct()
- {
- $this->_parameterNames=new TList;
- $this->_parameterValues=new TMap;
- }
-
public function getPreparedSql(){ return $this->_sqlString; }
public function setPreparedSql($value){ $this->_sqlString = $value; }
- public function getParameterNames(){ return $this->_parameterNames; }
- public function setParameterNames($value){ $this->_parameterNames = $value; }
+ public function getParameterNames($needed = true)
+ {
+ if (!$this->_parameterNames and $needed)
+ $this->_parameterNames = new TList;
+ return $this->_parameterNames;
+ }
- public function getParameterValues(){ return $this->_parameterValues; }
- public function setParameterValues($value){ $this->_parameterValues = $value; }
+ public function setParameterNames($value){ $this->_parameterNames = $value; }
- public function __wakeup()
- {
- parent::__wakeup();
- if (!$this->_parameterNames) $this->_parameterNames = new TList;
- if (!$this->_parameterValues) $this->_parameterValues = new TMap;
+ public function getParameterValues($needed = true)
+ {
+ if (!$this->_parameterValues and $needed)
+ $this->_parameterValues=new TMap;
+ return $this->_parameterValues;
}
+
+ public function setParameterValues($value){ $this->_parameterValues = $value; }
public function __sleep()
{
$exprops = array(); $cn = __CLASS__;
- if (!$this->_parameterNames->getCount()) $exprops[] = "\0$cn\0_parameterNames";
- if (!$this->_parameterValues->getCount()) $exprops[] = "\0$cn\0_parameterValues";
+ if (!$this->_parameterNames or !$this->_parameterNames->getCount()) $exprops[] = "\0$cn\0_parameterNames";
+ if (!$this->_parameterValues or !$this->_parameterValues->getCount()) $exprops[] = "\0$cn\0_parameterValues";
return array_diff(parent::__sleep(),$exprops);
}
}
diff --git a/framework/Exceptions/messages/messages.txt b/framework/Exceptions/messages/messages.txt
index 69fd89fc..c9e7f9c5 100644
--- a/framework/Exceptions/messages/messages.txt
+++ b/framework/Exceptions/messages/messages.txt
@@ -102,11 +102,11 @@ memcache_host_unchangeable = TMemCache.Host cannot be modified after the modu
memcache_port_unchangeable = TMemCache.Port cannot be modified after the module is initialized.
apccache_extension_required = TAPCCache requires APC PHP extension.
-apccache_add_unsupported = TAPCCache.add() is not supported.
-apccache_replace_unsupported = TAPCCache.replace() is not supported.
apccache_extension_not_enabled = TAPCCache need apc.enabled = 1 in php.ini in order to work.
apccache_extension_not_enabled_cli = TAPCCache need apc.enable_cli = 1 in php.ini in order to work with PHP from the command line.
+eacceleratorcache_extension_required = TEACache requires eAccellerator PHP extension.
+
errorhandler_errortemplatepath_invalid = TErrorHandler.ErrorTemplatePath '{0}' is invalid. Make sure it is in namespace form and points to a valid directory containing error template files.
pageservice_page_unknown = Page '{0}' Not Found
diff --git a/framework/I18N/core/data/fr_CA.dat b/framework/I18N/core/data/fr_CA.dat
index fb152bf0..855fe7a6 100644
--- a/framework/I18N/core/data/fr_CA.dat
+++ b/framework/I18N/core/data/fr_CA.dat
@@ -1 +1 @@
-a:4:{s:10:"Currencies";a:2:{s:3:"CAD";a:2:{i:0;s:1:"$";i:1;s:15:"dollar canadien";}s:3:"USD";a:2:{i:0;s:4:"$ US";i:1;s:22:"dollar des États-Unis";}}s:14:"NumberPatterns";a:4:{i:0;s:20:"#,##0.###;-#,##0.###";i:1;s:24:"#,##0.00 ¤;(#,##0.00¤)";i:2;s:6:"#,##0%";i:3;s:3:"#E0";}s:7:"Version";a:1:{i:0;s:3:"1.2";}s:8:"calendar";a:1:{s:9:"gregorian";a:3:{s:26:"DateTimeElements:intvector";a:2:{i:0;i:1;i:1;i:4;}s:16:"DateTimePatterns";a:9:{i:0;s:24:"HH' h 'mm' min 'ss' s 'z";i:1;s:10:"HH:mm:ss z";i:2;s:8:"HH:mm:ss";i:3;s:5:"HH:mm";i:4;s:16:"EEEE d MMMM yyyy";i:5;s:11:"d MMMM yyyy";i:6;s:8:"yy-MM-dd";i:7;s:8:"yy-MM-dd";i:8;s:7:"{1} {0}";}s:17:"weekend:intvector";a:4:{i:0;i:7;i:1;i:0;i:2;i:1;i:3;i:86400000;}}}} \ No newline at end of file
+a:4:{s:10:"Currencies";a:2:{s:3:"CAD";a:2:{i:0;s:1:"$";i:1;s:15:"dollar canadien";}s:3:"USD";a:2:{i:0;s:4:"$ US";i:1;s:22:"dollar des États-Unis";}}s:14:"NumberPatterns";a:4:{i:0;s:20:"#,##0.###;-#,##0.###";i:1;s:24:"#,##0.00 ¤;(#,##0.00¤)";i:2;s:6:"#,##0%";i:3;s:3:"#E0";}s:7:"Version";a:1:{i:0;s:3:"1.2";}s:8:"calendar";a:1:{s:9:"gregorian";a:3:{s:26:"DateTimeElements:intvector";a:2:{i:0;i:1;i:1;i:4;}s:16:"DateTimePatterns";a:9:{i:0;s:24:"HH' h 'mm' min 'ss' s 'z";i:1;s:10:"HH:mm:ss z";i:2;s:8:"HH:mm:ss";i:3;s:5:"HH:mm";i:4;s:16:"EEEE d MMMM yyyy";i:5;s:11:"d MMMM yyyy";i:6;s:10:"yyyy-MM-dd";i:7;s:8:"yy-MM-dd";i:8;s:7:"{1} {0}";}s:17:"weekend:intvector";a:4:{i:0;i:7;i:1;i:0;i:2;i:1;i:3;i:86400000;}}}} \ No newline at end of file
diff --git a/framework/TApplication.php b/framework/TApplication.php
index 6a404bcc..a4a4b423 100644
--- a/framework/TApplication.php
+++ b/framework/TApplication.php
@@ -6,7 +6,7 @@
* @link http://www.pradosoft.com/
* @copyright Copyright &copy; 2005-2013 PradoSoft
* @license http://www.pradosoft.com/license/
- * @version $Id: TApplication.php 3245 2013-01-07 20:23:32Z ctrlaltca $
+ * @version $Id: TApplication.php 3272 2013-02-13 21:43:28Z ctrlaltca $
* @package System
*/
@@ -105,7 +105,7 @@ Prado::using('System.I18N.TGlobalization');
* </code>
*
* @author Qiang Xue <qiang.xue@gmail.com>
- * @version $Id: TApplication.php 3245 2013-01-07 20:23:32Z ctrlaltca $
+ * @version $Id: TApplication.php 3272 2013-02-13 21:43:28Z ctrlaltca $
* @package System
* @since 3.0
*/
@@ -205,10 +205,14 @@ class TApplication extends TComponent
*/
private $_service;
/**
- * @var array list of application modules
+ * @var array list of loaded application modules
*/
private $_modules=array();
/**
+ * @var array list of application modules yet to be loaded
+ */
+ private $_lazyModules=array();
+ /**
* @var TMap list of application parameters
*/
private $_parameters;
@@ -607,7 +611,7 @@ class TApplication extends TComponent
}
/**
- * @return string the applictaion configuration type. default is 'xml'
+ * @return string the application configuration type. default is 'xml'
*/
public function getConfigurationFileExt()
{
@@ -685,9 +689,9 @@ class TApplication extends TComponent
* Adds a module to application.
* Note, this method does not do module initialization.
* @param string ID of the module
- * @param IModule module object
+ * @param IModule module object or null if the module has not been loaded yet
*/
- 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);
@@ -700,10 +704,22 @@ 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;
+
+ // force loading of a lazy module
+ if($this->_modules[$id]===null)
+ {
+ $module = $this->internalLoadModule($id, true);
+ $module[0]->init($module[1]);
+ }
+
+ return $this->_modules[$id];
}
/**
+ * Returns a list of application modules indexed by module IDs.
+ * Modules that have not been loaded yet are returned as null objects.
* @return array list of loaded application modules, indexed by module IDs
*/
public function getModules()
@@ -938,6 +954,28 @@ 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)
+ {
+ Prado::trace("Postponed loading of lazy module $id ({$moduleClass})",'System.TApplication');
+ $this->setModule($id, null);
+ return null;
+ }
+
+ Prado::trace("Loading module $id ({$moduleClass})",'System.TApplication');
+ $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);
+ }
/**
* Applies an application configuration.
* @param TApplicationConfiguration the configuration
@@ -982,18 +1020,11 @@ class TApplication extends TComponent
$modules=array();
foreach($config->getModules() as $id=>$moduleConfig)
{
- Prado::trace("Loading module $id ({$moduleConfig[0]})",'System.TApplication');
- 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]);
@@ -1248,7 +1279,7 @@ class TApplication extends TComponent
* - Normal: the application is running in normal production mode.
* - Performance: the application is running in performance mode.
* @author Qiang Xue <qiang.xue@gmail.com>
- * @version $Id: TApplication.php 3245 2013-01-07 20:23:32Z ctrlaltca $
+ * @version $Id: TApplication.php 3272 2013-02-13 21:43:28Z ctrlaltca $
* @package System
* @since 3.0.4
*/
@@ -1268,7 +1299,7 @@ class TApplicationMode extends TEnumerable
*
* @author Qiang Xue <qiang.xue@gmail.com>
* @author Carl G. Mathisen <carlgmathisen@gmail.com>
- * @version $Id: TApplication.php 3245 2013-01-07 20:23:32Z ctrlaltca $
+ * @version $Id: TApplication.php 3272 2013-02-13 21:43:28Z ctrlaltca $
* @package System
* @since 3.0
*/
@@ -1777,7 +1808,7 @@ class TApplicationConfiguration extends TComponent
* Cache will be exploited if it is enabled.
*
* @author Qiang Xue <qiang.xue@gmail.com>
- * @version $Id: TApplication.php 3245 2013-01-07 20:23:32Z ctrlaltca $
+ * @version $Id: TApplication.php 3272 2013-02-13 21:43:28Z ctrlaltca $
* @package System
* @since 3.0
*/
diff --git a/framework/Web/Javascripts/TJavaScript.php b/framework/Web/Javascripts/TJavaScript.php
index 7f4733a2..0f6fef1c 100644
--- a/framework/Web/Javascripts/TJavaScript.php
+++ b/framework/Web/Javascripts/TJavaScript.php
@@ -6,7 +6,7 @@
* @link http://www.pradosoft.com/
* @copyright Copyright &copy; 2005-2013 PradoSoft
* @license http://www.pradosoft.com/license/
- * @version $Id: TJavaScript.php 3245 2013-01-07 20:23:32Z ctrlaltca $
+ * @version $Id: TJavaScript.php 3291 2013-05-09 17:44:58Z ctrlaltca $
* @package System.Web.Javascripts
*/
@@ -17,7 +17,7 @@
* functions.
*
* @author Wei Zhuo<weizhuo[at]gmail[dot]com>
- * @version $Id: TJavaScript.php 3245 2013-01-07 20:23:32Z ctrlaltca $
+ * @version $Id: TJavaScript.php 3291 2013-05-09 17:44:58Z ctrlaltca $
* @package System.Web.Javascripts
* @since 3.0
*/
@@ -219,7 +219,7 @@ 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;
}
@@ -234,7 +234,7 @@ class TJavaScript
*/
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;
}
diff --git a/framework/Web/Javascripts/source/prado/prado.js b/framework/Web/Javascripts/source/prado/prado.js
index 36a08426..b827b125 100644
--- a/framework/Web/Javascripts/source/prado/prado.js
+++ b/framework/Web/Javascripts/source/prado/prado.js
@@ -8,7 +8,7 @@ var Prado =
* Version of Prado clientscripts
* @var Version
*/
- Version: '3.2.1',
+ Version: '3.2.2',
/**
* Registry for Prado components
diff --git a/framework/Web/Javascripts/source/prado/scriptaculous-adapter.js b/framework/Web/Javascripts/source/prado/scriptaculous-adapter.js
index 3c186d3e..febe6ad9 100644
--- a/framework/Web/Javascripts/source/prado/scriptaculous-adapter.js
+++ b/framework/Web/Javascripts/source/prado/scriptaculous-adapter.js
@@ -202,6 +202,9 @@ Prado.PostBack = function(event,options)
/*if(options['StopEvent']) */
Event.stop(event);
Event.fireEvent(form,"submit");
+
+ $('PRADO_POSTBACK_TARGET').value = '';
+ $('PRADO_POSTBACK_PARAMETER').value = '';
};
/**
@@ -283,7 +286,7 @@ Prado.Element =
{
var el = $(element);
if(!el) return;
- if((attribute == "disabled" || attribute == "multiple" || attribute == "readonly") && value==false)
+ if((attribute == "disabled" || attribute == "multiple" || attribute == "readonly" || attribute == "href") && value==false)
el.removeAttribute(attribute);
else if(attribute.match(/^on/i)) //event methods
{
diff --git a/framework/Web/THttpRequest.php b/framework/Web/THttpRequest.php
index 7752d54d..f621d1eb 100644
--- a/framework/Web/THttpRequest.php
+++ b/framework/Web/THttpRequest.php
@@ -6,7 +6,7 @@
* @link http://www.pradosoft.com/
* @copyright Copyright &copy; 2005-2013 PradoSoft
* @license http://www.pradosoft.com/license/
- * @version $Id: THttpRequest.php 3253 2013-01-16 08:57:12Z ctrlaltca $
+ * @version $Id: THttpRequest.php 3273 2013-02-13 21:51:21Z ctrlaltca $
* @package System.Web
*/
@@ -64,7 +64,7 @@ Prado::using('System.Web.TUrlManager');
* request module. It can be accessed via {@link TApplication::getRequest()}.
*
* @author Qiang Xue <qiang.xue@gmail.com>
- * @version $Id: THttpRequest.php 3253 2013-01-16 08:57:12Z ctrlaltca $
+ * @version $Id: THttpRequest.php 3273 2013-02-13 21:51:21Z ctrlaltca $
* @package System.Web
* @since 3.0
*/
@@ -114,6 +114,10 @@ class THttpRequest extends TApplicationComponent implements IteratorAggregate,Ar
private $_enableCookieValidation=false;
private $_cgiFix=0;
/**
+ * @var boolean whether to cache the TUrlManager class (useful with a lot of TUrlMappings)
+ */
+ private $_enableCache=false;
+ /**
* @var string request URL
*/
private $_url=null;
@@ -151,20 +155,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);
- }
-
// Fill in default request info when the script is run in command line
if(php_sapi_name()==='cli')
{
@@ -246,6 +236,72 @@ class THttpRequest extends TApplicationComponent implements IteratorAggregate,Ar
}
/**
+ * Set true to cache the UrlManager instance. Consider to enable this cache
+ * when the application defines a lot of TUrlMappingPatterns
+ * @param boolean true to cache urlmanager instance.
+ */
+ public function setEnableCache($value)
+ {
+ $this->_enableCache = TPropertyValue::ensureBoolean($value);
+ }
+
+ /**
+ * @return boolean true if urlmanager instance should be cached, false otherwise.
+ */
+ public function getEnableCache()
+ {
+ return $this->_enableCache;
+ }
+
+ protected function getCacheKey()
+ {
+ return $this->getID();
+ }
+
+ /**
+ * Saves the current UrlManager instance to cache.
+ * @return boolean true if UrlManager instance was cached, false otherwise.
+ */
+ 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;
+ }
+
+ /**
+ * Loads UrlManager instance from cache.
+ * @return TUrlManager intance if load was successful, null otherwise.
+ */
+ 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;
+ }
+
+ /**
* @return string the ID of the URL manager module
*/
public function getUrlManager()
@@ -271,6 +327,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;
}
@@ -643,7 +719,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?'&amp;':'&')) . SID;
else
@@ -658,7 +734,7 @@ class THttpRequest extends TApplicationComponent implements IteratorAggregate,Ar
*/
protected function parseUrl()
{
- return $this->_urlManager->parseUrl();
+ return $this->getUrlManagerModule()->parseUrl();
}
/**
@@ -893,7 +969,7 @@ class THttpRequest extends TApplicationComponent implements IteratorAggregate,Ar
* </code>
*
* @author Qiang Xue <qiang.xue@gmail.com>
- * @version $Id: THttpRequest.php 3253 2013-01-16 08:57:12Z ctrlaltca $
+ * @version $Id: THttpRequest.php 3273 2013-02-13 21:51:21Z ctrlaltca $
* @package System.Web
* @since 3.0
*/
@@ -981,7 +1057,7 @@ class THttpCookieCollection extends TList
* domain, path, expire, and secure.
*
* @author Qiang Xue <qiang.xue@gmail.com>
- * @version $Id: THttpRequest.php 3253 2013-01-16 08:57:12Z ctrlaltca $
+ * @version $Id: THttpRequest.php 3273 2013-02-13 21:51:21Z ctrlaltca $
* @package System.Web
* @since 3.0
*/
@@ -1156,7 +1232,7 @@ class THttpCookie extends TComponent
* - fragment: anchor
*
* @author Qiang Xue <qiang.xue@gmail.com>
- * @version $Id: THttpRequest.php 3253 2013-01-16 08:57:12Z ctrlaltca $
+ * @version $Id: THttpRequest.php 3273 2013-02-13 21:51:21Z ctrlaltca $
* @package System.Web
* @since 3.0
*/
@@ -1323,7 +1399,7 @@ class TUri extends TComponent
* - HiddenPath: the URL format is like /path/to/name1,value1/name2,value2...
*
* @author Qiang Xue <qiang.xue@gmail.com>
- * @version $Id: THttpRequest.php 3253 2013-01-16 08:57:12Z ctrlaltca $
+ * @version $Id: THttpRequest.php 3273 2013-02-13 21:51:21Z ctrlaltca $
* @package System.Web
* @since 3.0.4
*/
diff --git a/framework/Web/TUrlMapping.php b/framework/Web/TUrlMapping.php
index ecbe5935..abfa02fd 100644
--- a/framework/Web/TUrlMapping.php
+++ b/framework/Web/TUrlMapping.php
@@ -6,7 +6,7 @@
* @link http://www.pradosoft.com/
* @copyright Copyright &copy; 2005-2013 PradoSoft
* @license http://www.pradosoft.com/license/
- * @version $Id: TUrlMapping.php 3245 2013-01-07 20:23:32Z ctrlaltca $
+ * @version $Id: TUrlMapping.php 3290 2013-05-06 08:32:15Z ctrlaltca $
* @package System.Web
*/
@@ -63,7 +63,7 @@ Prado::using('System.Collections.TAttributeCollection');
* in the GET variables.
*
* @author Wei Zhuo <weizhuo[at]gmail[dot]com>
- * @version $Id: TUrlMapping.php 3245 2013-01-07 20:23:32Z ctrlaltca $
+ * @version $Id: TUrlMapping.php 3290 2013-05-06 08:32:15Z ctrlaltca $
* @package System.Web
* @since 3.0.5
*/
@@ -109,7 +109,15 @@ class TUrlMapping extends TUrlManager
$this->loadConfigFile();
$this->loadUrlMappings($config);
if($this->_urlPrefix==='')
- $this->_urlPrefix=$this->getRequest()->getApplicationUrl();
+ {
+ $request=$this->getRequest();
+ if($request->getUrlFormat()===THttpRequestUrlFormat::HiddenPath)
+ {
+ $this->_urlPrefix=dirname($request->getApplicationUrl());
+ } else {
+ $this->_urlPrefix=$request->getApplicationUrl();
+ }
+ }
$this->_urlPrefix=rtrim($this->_urlPrefix,'/');
}
@@ -331,6 +339,9 @@ class TUrlMapping extends TUrlManager
* If {@link THttpRequest::setUrlFormat THttpRequest.UrlFormat} is 'Path',
* the following format is used instead:
* /entryscript.php/serviceID/serviceParameter/get1,value1/get2,value2...
+ * If {@link THttpRequest::setUrlFormat THttpRequest.UrlFormat} is 'HiddenPath',
+ * the following format is used instead:
+ * /serviceID/serviceParameter/get1,value1/get2,value2...
* @param string service ID
* @param string service parameter
* @param array GET parameters, null if not provided
@@ -450,7 +461,7 @@ class TUrlMapping extends TUrlManager
*
* <url ServiceParameter="adminpages.*" pattern="admin/{*}/{id}" parameters.id="\d+" />
*
- * To enable automatic parameter encoding in a path format fro wildcard patterns you can set
+ * To enable automatic parameter encoding in a path format from wildcard patterns you can set
* {@setUrlFormat UrlFormat} to 'Path':
*
* <url ServiceParameter="adminpages.*" pattern="admin/{*}" UrlFormat="Path" />
@@ -465,8 +476,19 @@ class TUrlMapping extends TUrlManager
*
* <tt>.../index.php/admin/listuser/param1-value1/param2-value2</tt>.
*
+ * Since 3.2.2 you can also add a list of "constants" parameters that can be used just
+ * like the original "parameters" parameters, except that the supplied value will be treated
+ * as a simple string constant instead of a regular expression. For example
+ *
+ * <url ServiceParameter="MyPage" pattern="/mypage/mypath/list/detail/{pageidx}" parameters.pageidx="\d+" constants.listtype="detailed"/>
+ * <url ServiceParameter="MyPage" pattern="/mypage/mypath/list/summary/{pageidx}" parameters.pageidx="\d+" constants.listtype="summarized"/>
+ *
+ * These rules, when matched by the actual request, will make the application see a "lisstype" parameter present
+ * (even through not supplied in the request) and equal to "detailed" or "summarized", depending on the friendly url matched.
+ * The constants is practically a table-based validation and translation of specified, fixed-set parameter values.
+ *
* @author Wei Zhuo <weizhuo[at]gmail[dot]com>
- * @version $Id: TUrlMapping.php 3245 2013-01-07 20:23:32Z ctrlaltca $
+ * @version $Id: TUrlMapping.php 3290 2013-05-06 08:32:15Z ctrlaltca $
* @package System.Web
* @since 3.0.5
*/
@@ -485,10 +507,14 @@ class TUrlMappingPattern extends TComponent
*/
private $_pattern;
/**
- * @var TMap parameter regular expressions.
+ * @var TAttributeCollection parameter regular expressions.
*/
private $_parameters;
/**
+ * @var TAttributeCollection of constant parameters.
+ */
+ protected $_constants;
+ /**
* @var string regular expression pattern.
*/
private $_regexp='';
@@ -518,8 +544,6 @@ class TUrlMappingPattern extends TComponent
public function __construct(TUrlManager $manager)
{
$this->_manager=$manager;
- $this->_parameters=new TAttributeCollection;
- $this->_parameters->setCaseSensitive(true);
}
/**
@@ -552,12 +576,16 @@ class TUrlMappingPattern extends TComponent
{
$params=array();
$values=array();
- foreach($this->_parameters as $key=>$value)
+ if ($this->_parameters)
{
- $params[]='{'.$key.'}';
- $values[]='(?P<'.$key.'>'.$value.')';
+ foreach($this->_parameters as $key=>$value)
+ {
+ $params[]='{'.$key.'}';
+ $values[]='(?P<'.$key.'>'.$value.')';
+ }
}
- if ($this->getIsWildCardPattern()) {
+ if ($this->getIsWildCardPattern())
+ {
$params[]='{*}';
// service parameter must not contain '=' and '/'
$values[]='(?P<'.$this->getServiceID().'>[^=/]+)';
@@ -660,6 +688,11 @@ class TUrlMappingPattern extends TComponent
*/
public function getParameters()
{
+ if (!$this->_parameters)
+ {
+ $this->_parameters=new TAttributeCollection;
+ $this->_parameters->setCaseSensitive(true);
+ }
return $this->_parameters;
}
@@ -672,6 +705,20 @@ class TUrlMappingPattern extends TComponent
}
/**
+ * @return TAttributeCollection constanst parameter key value pairs.
+ * @since 3.2.2
+ */
+ public function getConstants()
+ {
+ if (!$this->_constants)
+ {
+ $this->_constants = new TAttributeCollection;
+ $this->_constants->setCaseSensitive(true);
+ }
+ return $this->_constants;
+ }
+
+ /**
* Uses URL pattern (or full regular expression if available) to
* match the given url path.
* @param THttpRequest the request module
@@ -708,6 +755,12 @@ class TUrlMappingPattern extends TComponent
unset($matches['urlparams']);
}
+ if(count($matches) > 0 && $this->_constants)
+ {
+ foreach($this->_constants->toArray() as $key=>$value)
+ $matches[$key] = $value;
+ }
+
return $matches;
}
@@ -755,7 +808,7 @@ class TUrlMappingPattern extends TComponent
* Changing the UrlFormat will affect {@link constructUrl} and how GET variables
* are parsed.
* @param THttpRequestUrlFormat the format of URLs.
- * @param since 3.1.4
+ * @since 3.1.4
*/
public function setUrlFormat($value)
{
@@ -809,10 +862,24 @@ class TUrlMappingPattern extends TComponent
{
if(!$this->_customUrl || $this->getPattern()===null)
return false;
- foreach($this->_parameters as $key=>$value)
+ if ($this->_parameters)
+ {
+ foreach($this->_parameters as $key=>$value)
+ {
+ if(!isset($getItems[$key]))
+ return false;
+ }
+ }
+
+ if ($this->_constants)
{
- if(!isset($getItems[$key]))
- return false;
+ foreach($this->_constants->toArray() as $key=>$value)
+ {
+ if (!isset($getItems[$key]))
+ return false;
+ if ($getItems[$key]!=$value)
+ return false;
+ }
}
return true;
}
@@ -827,12 +894,20 @@ class TUrlMappingPattern extends TComponent
*/
public function constructUrl($getItems,$encodeAmpersand,$encodeGetItems)
{
+ if ($this->_constants)
+ {
+ foreach($this->_constants->toArray() as $key=>$value)
+ {
+ unset($getItems[$key]);
+ }
+ }
+
$extra=array();
$replace=array();
// for the GET variables matching the pattern, put them in the URL path
foreach($getItems as $key=>$value)
{
- if($this->_parameters->contains($key) || $key==='*' && $this->getIsWildCardPattern())
+ if(($this->_parameters && $this->_parameters->contains($key)) || ($key==='*' && $this->getIsWildCardPattern()))
$replace['{'.$key.'}']=$encodeGetItems ? rawurlencode($value) : $value;
else
$extra[$key]=$value;
@@ -930,7 +1005,7 @@ class TUrlMappingPattern extends TComponent
* URL prefix behavior that can be used by {@link TUrlMappingPattern::constructUrl()}.
*
* @author Yves Berkholz <godzilla80[at]gmx[dot]net>
- * @version $Id: TUrlMapping.php 3245 2013-01-07 20:23:32Z ctrlaltca $
+ * @version $Id: TUrlMapping.php 3290 2013-05-06 08:32:15Z ctrlaltca $
* @package System.Web
* @since 3.2
*/
diff --git a/framework/Web/UI/ActiveControls/TActiveLinkButton.php b/framework/Web/UI/ActiveControls/TActiveLinkButton.php
index b95dad88..d8a8ffcb 100644
--- a/framework/Web/UI/ActiveControls/TActiveLinkButton.php
+++ b/framework/Web/UI/ActiveControls/TActiveLinkButton.php
@@ -6,7 +6,7 @@
* @link http://www.pradosoft.com/
* @copyright Copyright &copy; 2005-2013 PradoSoft
* @license http://www.pradosoft.com/license/
- * @version $Id: TActiveLinkButton.php 3245 2013-01-07 20:23:32Z ctrlaltca $
+ * @version $Id: TActiveLinkButton.php 3292 2013-05-31 08:51:42Z ctrlaltca $
* @package System.Web.UI.ActiveControls
*/
@@ -29,7 +29,7 @@ Prado::using('System.Web.UI.ActiveControls.TActiveControlAdapter');
* will update the link text upon callback response completion.
*
* @author Wei Zhuo <weizhuo[at]gmail[dot]com>
- * @version $Id: TActiveLinkButton.php 3245 2013-01-07 20:23:32Z ctrlaltca $
+ * @version $Id: TActiveLinkButton.php 3292 2013-05-31 08:51:42Z ctrlaltca $
* @package System.Web.UI.ActiveControls
* @since 3.1
*/
@@ -118,9 +118,36 @@ class TActiveLinkButton extends TLinkButton implements IActiveControl, ICallback
{
parent::addAttributesToRender($writer);
$writer->addAttribute('id',$this->getClientID());
- $this->renderLinkButtonHref($writer);
- $this->getActiveControl()->registerCallbackClientScript(
- $this->getClientClassName(), $this->getPostBackOptions());
+
+ if($this->getEnabled(true))
+ {
+ $this->getActiveControl()->registerCallbackClientScript(
+ $this->getClientClassName(), $this->getPostBackOptions());
+ }
+ }
+
+ /**
+ * Ensures that the anchor is rendered correctly when its Enabled property
+ * changes in a callback
+ * @param bool enabled
+ */
+ public function setEnabled($value)
+ {
+ parent::setEnabled($value);
+ if($this->getActiveControl()->canUpdateClientSide())
+ {
+ if($this->getEnabled(true))
+ {
+ $nop = "javascript:;//".$this->getClientID();
+ $this->getPage()->getCallbackClient()->setAttribute($this, 'href', $nop);
+
+ $this->getActiveControl()->registerCallbackClientScript(
+ $this->getClientClassName(), $this->getPostBackOptions());
+
+ } else {
+ $this->getPage()->getCallbackClient()->setAttribute($this, 'href', false);
+ }
+ }
}
/**
diff --git a/framework/Web/UI/ActiveControls/TDraggable.php b/framework/Web/UI/ActiveControls/TDraggable.php
index 23687207..df92bec5 100755
--- a/framework/Web/UI/ActiveControls/TDraggable.php
+++ b/framework/Web/UI/ActiveControls/TDraggable.php
@@ -6,7 +6,27 @@
* @copyright Copyright &copy; 2008, PradoSoft
* @license http://www.pradosoft.com/license
* @package System.Web.UI.ActiveControls
- * @version $Id: TDraggable.php 3247 2013-01-07 21:38:18Z ctrlaltca $
+ * @version $Id: TDraggable.php 3285 2013-04-11 07:28:07Z ctrlaltca $
+ */
+
+/**
+ * TDraggable is a control which can be dragged
+ *
+ * This control will make "draggable" control.
+ * Properties :
+ *
+ * <b>{@link setGhosting Ghosting}</b> : If set to "Ghosting" or "True", the dragged element will be cloned, and the clone will be dragged.
+ * If set to "SuperGhosting", the element will be cloned, and attached to body, so it can be dragged outside of its parent.
+ * If set to "None" of "False" (default), the element itself is dragged
+ * <b>{@link setRevert Revert}</b>: Set to True if you want your dragged element to revert to its initial position if not dropped on a valid area.
+ * <b>{@link setConstraint Constraint}</b>: Set this to Horizontal or Vertical if you want to constraint your move in one direction.
+ * <b>{@link setHandle Handle}</b>:
+ *
+ * @author Christophe BOULAIN (Christophe.Boulain@gmail.com)
+ * @copyright Copyright &copy; 2008, PradoSoft
+ * @license http://www.pradosoft.com/license
+ * @package System.Web.UI.ActiveControls
+ * @version $Id: TDraggable.php 3285 2013-04-11 07:28:07Z ctrlaltca $
*/
class TDraggable extends TPanel
{
@@ -193,7 +213,21 @@ class TDraggable extends TPanel
* @copyright Copyright &copy; 2008, PradoSoft
* @license http://www.pradosoft.com/license
* @package System.Web.UI.ActiveControls
- * @version $Id: TDraggable.php 3247 2013-01-07 21:38:18Z ctrlaltca $
+ * @version $Id: TDraggable.php 3285 2013-04-11 07:28:07Z ctrlaltca $
+ */
+class TDraggableConstraint extends TEnumerable
+{
+ const None='None';
+ const Horizontal='Horizontal';
+ const Vertical='Vertical';
+}
+
+/**
+ * @author Christophe BOULAIN (Christophe.Boulain@gmail.com)
+ * @copyright Copyright &copy; 2008, PradoSoft
+ * @license http://www.pradosoft.com/license
+ * @package System.Web.UI.ActiveControls
+ * @version $Id: TDraggable.php 3285 2013-04-11 07:28:07Z ctrlaltca $
*/
class TDraggableGhostingOptions extends TEnumerable
{
@@ -207,7 +241,7 @@ class TDraggableGhostingOptions extends TEnumerable
* @copyright Copyright &copy; 2008, PradoSoft
* @license http://www.pradosoft.com/license
* @package System.Web.UI.ActiveControls
- * @version $Id: TDraggable.php 3247 2013-01-07 21:38:18Z ctrlaltca $
+ * @version $Id: TDraggable.php 3285 2013-04-11 07:28:07Z ctrlaltca $
*/
class TDraggableRevertOptions extends TEnumerable
{
diff --git a/framework/Web/UI/ActiveControls/TDropContainer.php b/framework/Web/UI/ActiveControls/TDropContainer.php
index e603adf9..43e8017c 100755
--- a/framework/Web/UI/ActiveControls/TDropContainer.php
+++ b/framework/Web/UI/ActiveControls/TDropContainer.php
@@ -7,7 +7,40 @@
* @license http://www.pradosoft.com/license
* @version $Id: TDropContainer.php 3159 2012-2013 PradoSoft
* @license http://www.pradosoft.com/license
- * @version $Id: TDropContainer.php 3245 2013-01-07 20:23:32Z ctrlaltca $
+ * @version $Id: TDropContainer.php 3285 2013-04-11 07:28:07Z ctrlaltca $
+ * @package System.Web.UI.ActiveControls
+ */
+
+/**
+ * Load active control adapter.
+ */
+Prado::using('System.Web.UI.ActiveControls.TActiveControlAdapter');
+/**
+ * Load active panel.
+ */
+Prado::using('System.Web.UI.ActiveControls.TActivePanel');
+
+
+/**
+ * TDropContainer is a panel where TDraggable controls can be dropped.
+ * When a TDraggable component is dropped into a TDropContainer, the {@link OnDrop OnDrop} event is raised.
+ * The {@link TDropContainerEventParameter} param will contain the dropped control.
+ *
+ * Properties :
+ *
+ * <b>{@link setAcceptCssClass AcceptCssClass}</b> : a coma delimited classname of elements that the drop container can accept.
+ * <b>{@link setHoverCssClass HoverCssClass}</b>: CSS classname of the container when a draggable element hovers over the container.
+ *
+ * Events:
+ *
+ * <b>{@link OnDrop OnDrop}</b> : raised when a TDraggable control is dropped. The dropped control id is encapsulated in the event parameter,
+ * as well as mouse coordinates and key modifiers status
+ *
+ *
+ * @author Christophe BOULAIN (Christophe.Boulain@gmail.com)
+ * @copyright Copyright &copy; 2008, PradoSoft
+ * @license http://www.pradosoft.com/license
+ * @version $Id: TDropContainer.php 3285 2013-04-11 07:28:07Z ctrlaltca $
* @package System.Web.UI.ActiveControls
*/
class TDropContainer extends TPanel implements IActiveControl, ICallbackEventHandler
@@ -225,7 +258,7 @@ class TDropContainer extends TPanel implements IActiveControl, ICallbackEventHan
* @author Christophe BOULAIN (Christophe.Boulain@ceram.fr)
* @copyright Copyright &copy; 2008, PradoSoft
* @license http://www.pradosoft.com/license
- * @version $Id: TDropContainer.php 3245 2013-01-07 20:23:32Z ctrlaltca $
+ * @version $Id: TDropContainer.php 3285 2013-04-11 07:28:07Z ctrlaltca $
* @package System.Web.UI.ActiveControls
*/
class TDropContainerEventParameter extends TEventParameter
diff --git a/framework/Web/UI/TClientScriptManager.php b/framework/Web/UI/TClientScriptManager.php
index 8a7afdad..0cdf3e32 100644
--- a/framework/Web/UI/TClientScriptManager.php
+++ b/framework/Web/UI/TClientScriptManager.php
@@ -7,7 +7,7 @@
* @link http://www.pradosoft.com/
* @copyright Copyright &copy; 2005-2013 PradoSoft
* @license http://www.pradosoft.com/license/
- * @version $Id: TClientScriptManager.php 3245 2013-01-07 20:23:32Z ctrlaltca $
+ * @version $Id: TClientScriptManager.php 3280 2013-03-13 20:19:30Z ctrlaltca $
* @package System.Web.UI
*/
@@ -18,7 +18,7 @@
*
* @author Qiang Xue <qiang.xue@gmail.com>
* @author Gabor Berczi <gabor.berczi@devworx.hu> (lazyload additions & progressive rendering)
- * @version $Id: TClientScriptManager.php 3245 2013-01-07 20:23:32Z ctrlaltca $
+ * @version $Id: TClientScriptManager.php 3280 2013-03-13 20:19:30Z ctrlaltca $
* @package System.Web.UI
* @since 3.0
*/
@@ -406,8 +406,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')
@@ -758,7 +764,7 @@ class TClientScriptManager extends TApplicationComponent
* between ActiveControls and validators.
*
* @author <weizhuo[at]gmail[dot]com>
- * @version $Id: TClientScriptManager.php 3245 2013-01-07 20:23:32Z ctrlaltca $
+ * @version $Id: TClientScriptManager.php 3280 2013-03-13 20:19:30Z ctrlaltca $
* @package System.Web.UI
* @since 3.0
*/
@@ -770,14 +776,6 @@ abstract class TClientSideOptions extends TComponent
private $_options;
/**
- * Constructor, initialize the options list.
- */
- public function __construct()
- {
- $this->_options = Prado::createComponent('System.Collections.TMap');
- }
-
- /**
* Adds on client-side event handler by wrapping the code within a
* javascript function block. If the code begins with "javascript:", the
* code is assumed to be a javascript function block rather than arbiturary
@@ -797,7 +795,10 @@ 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;
}
/**
@@ -806,7 +807,7 @@ abstract class TClientSideOptions extends TComponent
*/
protected function setOption($name, $value)
{
- $this->_options->add($name, $value);
+ $this->getOptions()->add($name, $value);
}
/**
@@ -814,6 +815,8 @@ abstract class TClientSideOptions extends TComponent
*/
public function getOptions()
{
+ if (!$this->_options)
+ $this->_options = Prado::createComponent('System.Collections.TMap');
return $this->_options;
}
diff --git a/framework/Web/UI/WebControls/TButtonColumn.php b/framework/Web/UI/WebControls/TButtonColumn.php
index 7a0484c3..258fecf2 100644
--- a/framework/Web/UI/WebControls/TButtonColumn.php
+++ b/framework/Web/UI/WebControls/TButtonColumn.php
@@ -6,7 +6,7 @@
* @link http://www.pradosoft.com/
* @copyright Copyright &copy; 2005-2013 PradoSoft
* @license http://www.pradosoft.com/license/
- * @version $Id: TButtonColumn.php 3245 2013-01-07 20:23:32Z ctrlaltca $
+ * @version $Id: TButtonColumn.php 3287 2013-04-30 10:10:16Z ctrlaltca $
* @package System.Web.UI.WebControls
*/
@@ -31,7 +31,7 @@ Prado::using('System.Web.UI.WebControls.TImageButton');
* If {@link setDataTextFormatString DataTextFormatString} is not empty,
* the value will be formatted before rendering.
*
- * The buttons in the column can be set to display as hyperlinks or push buttons
+ * The buttons in the column can be set to display as hyperlinks, push buttons or images
* by setting the {@link setButtonType ButtonType} property.
* The {@link setCommandName CommandName} will assign its value to
* all button's <b>CommandName</b> property. The datagrid will capture
@@ -48,7 +48,7 @@ Prado::using('System.Web.UI.WebControls.TImageButton');
* datagrid cell is the first child.
*
* @author Qiang Xue <qiang.xue@gmail.com>
- * @version $Id: TButtonColumn.php 3245 2013-01-07 20:23:32Z ctrlaltca $
+ * @version $Id: TButtonColumn.php 3287 2013-04-30 10:10:16Z ctrlaltca $
* @package System.Web.UI.WebControls
* @since 3.0
*/
@@ -237,6 +237,7 @@ class TButtonColumn extends TDataGridColumn
{
$button=new TImageButton;
$button->setImageUrl($this->getImageUrl());
+ $button->setToolTip($this->getText());
}
$button->setText($this->getText());
$button->setCommandName($this->getCommandName());
diff --git a/framework/Web/UI/WebControls/TEmailAddressValidator.php b/framework/Web/UI/WebControls/TEmailAddressValidator.php
index 3bfd3e7b..dffe912e 100644
--- a/framework/Web/UI/WebControls/TEmailAddressValidator.php
+++ b/framework/Web/UI/WebControls/TEmailAddressValidator.php
@@ -6,7 +6,7 @@
* @link http://www.pradosoft.com/
* @copyright Copyright &copy; 2005-2013 PradoSoft
* @license http://www.pradosoft.com/license/
- * @version $Id: TEmailAddressValidator.php 3245 2013-01-07 20:23:32Z ctrlaltca $
+ * @version $Id: TEmailAddressValidator.php 3283 2013-03-24 10:19:08Z ctrlaltca $
* @package System.Web.UI.WebControls
*/
@@ -24,7 +24,7 @@ Prado::using('System.Web.UI.WebControls.TRegularExpressionValidator');
* checkdnsrr() is available in the installed PHP.
*
* @author Qiang Xue <qiang.xue@gmail.com>
- * @version $Id: TEmailAddressValidator.php 3245 2013-01-07 20:23:32Z ctrlaltca $
+ * @version $Id: TEmailAddressValidator.php 3283 2013-03-24 10:19:08Z ctrlaltca $
* @package System.Web.UI.WebControls
* @since 3.0
*/
@@ -32,8 +32,9 @@ class TEmailAddressValidator extends TRegularExpressionValidator
{
/**
* Regular expression used to validate the email address
+ * @see http://www.regular-expressions.info/email.html
*/
- const EMAIL_REGEXP="\\w+([-+.]\\w+)*@\\w+([-.]\\w+)*\\.\\w+([-.]\\w+)*";
+ const EMAIL_REGEXP='[a-zA-Z0-9!#$%&\'*+/=?^_`{|}~-]+(?:\.[a-zA-Z0-9!#$%&\'*+/=?^_`{|}~-]+)*@(?:[a-zA-Z0-9](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?\.)+[a-zA-Z0-9](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?';
/**
* Gets the name of the javascript class responsible for performing validation for this control.
@@ -60,10 +61,12 @@ class TEmailAddressValidator extends TRegularExpressionValidator
*/
public function evaluateIsValid()
{
- $valid=parent::evaluateIsValid();
+ $value=$this->getValidationValue($this->getValidationTarget());
+ $valid=$valid=is_string($value) && strlen($value)<=254 && parent::evaluateIsValid();
+
if($valid && $this->getCheckMXRecord() && function_exists('checkdnsrr'))
{
- if(($value=$this->getValidationValue($this->getValidationTarget()))!=='')
+ if($value!=='')
{
if(($pos=strpos($value,'@'))!==false)
{
@@ -82,7 +85,7 @@ class TEmailAddressValidator extends TRegularExpressionValidator
*/
public function getCheckMXRecord()
{
- return $this->getViewState('CheckMXRecord',true);
+ return $this->getViewState('CheckMXRecord',false);
}
/**
@@ -91,7 +94,7 @@ class TEmailAddressValidator extends TRegularExpressionValidator
*/
public function setCheckMXRecord($value)
{
- $this->setViewState('CheckMXRecord',TPropertyValue::ensureBoolean($value),true);
+ $this->setViewState('CheckMXRecord',TPropertyValue::ensureBoolean($value),false);
}
}
diff --git a/framework/Web/UI/WebControls/THyperLink.php b/framework/Web/UI/WebControls/THyperLink.php
index bc6c3642..56aa5391 100644
--- a/framework/Web/UI/WebControls/THyperLink.php
+++ b/framework/Web/UI/WebControls/THyperLink.php
@@ -6,7 +6,7 @@
* @link http://www.xisc.com/
* @copyright Copyright &copy; 2005-2013 PradoSoft
* @license http://www.opensource.org/licenses/bsd-license.php BSD License
- * @version $Id: THyperLink.php 3245 2013-01-07 20:23:32Z ctrlaltca $
+ * @version $Id: THyperLink.php 3286 2013-04-18 06:09:19Z ctrlaltca $
* @package System.Web.UI.WebControls
*/
@@ -17,13 +17,16 @@
* via the {@link setNavigateUrl NavigateUrl} property, and link text is via
* the {@link setText Text} property. It is also possible to display an image
* by setting the {@link setImageUrl ImageUrl} property. In this case,
- * {@link getText Text} is displayed as the alternate text of the image.
+ * the alignment of the image displayed is set by the
+ * {@link setImageAlign ImageAlign} property and {@link getText Text} is
+ * displayed as the alternate text of the image.
+ *
* The link target is specified via the {@link setTarget Target} property.
* If both {@link getImageUrl ImageUrl} and {@link getText Text} are empty,
* the content enclosed within the control tag will be rendered.
*
* @author Qiang Xue <qiang.xue@gmail.com>
- * @version $Id: THyperLink.php 3245 2013-01-07 20:23:32Z ctrlaltca $
+ * @version $Id: THyperLink.php 3286 2013-04-18 06:09:19Z ctrlaltca $
* @package System.Web.UI.WebControls
* @since 3.0
*/
@@ -92,6 +95,8 @@ class THyperLink extends TWebControl implements IDataRenderer
$image->setToolTip($toolTip);
if(($text=$this->getText())!=='')
$image->setAlternateText($text);
+ if(($align=$this->getImageAlign())!=='')
+ $image->setImageAlign($align);
$image->setBorderWidth('0');
return $image;
}
@@ -114,6 +119,26 @@ class THyperLink extends TWebControl implements IDataRenderer
}
/**
+ * @return string the alignment of the image with respective to other elements on the page, defaults to empty.
+ */
+ public function getImageAlign()
+ {
+ return $this->getViewState('ImageAlign','');
+ }
+
+ /**
+ * Sets the alignment of the image with respective to other elements on the page.
+ * Possible values include: absbottom, absmiddle, baseline, bottom, left,
+ * middle, right, texttop, and top. If an empty string is passed in,
+ * imagealign attribute will not be rendered.
+ * @param string the alignment of the image
+ */
+ public function setImageAlign($value)
+ {
+ $this->setViewState('ImageAlign',$value,'');
+ }
+
+ /**
* @return string height of the image in the THyperLink
*/
public function getImageHeight()
diff --git a/framework/Web/UI/WebControls/TListControl.php b/framework/Web/UI/WebControls/TListControl.php
index 2cd430d6..f9fdd77f 100644
--- a/framework/Web/UI/WebControls/TListControl.php
+++ b/framework/Web/UI/WebControls/TListControl.php
@@ -8,7 +8,7 @@
* @link http://www.pradosoft.com/
* @copyright Copyright &copy; 2005-2013 PradoSoft
* @license http://www.pradosoft.com/license/
- * @version $Id: TListControl.php 3245 2013-01-07 20:23:32Z ctrlaltca $
+ * @version $Id: TListControl.php 3288 2013-04-30 10:36:50Z ctrlaltca $
* @package System.Web.UI.WebControls
*/
@@ -75,8 +75,11 @@ Prado::using('System.Util.TDataFieldAccessor');
* used to format how the item should be displayed. See {@link formatDataValue()}
* for an explanation of the format string.
*
+ * The {@link setPromptText PromptText} and {@link setPromptValue PromptValue} properties can
+ * be used to add a dummy list item that will be rendered first.
+ *
* @author Qiang Xue <qiang.xue@gmail.com>
- * @version $Id: TListControl.php 3245 2013-01-07 20:23:32Z ctrlaltca $
+ * @version $Id: TListControl.php 3288 2013-04-30 10:36:50Z ctrlaltca $
* @package System.Web.UI.WebControls
* @since 3.0
*/
diff --git a/framework/Web/UI/WebControls/TRequiredFieldValidator.php b/framework/Web/UI/WebControls/TRequiredFieldValidator.php
index 8d370502..7a0bad8c 100644
--- a/framework/Web/UI/WebControls/TRequiredFieldValidator.php
+++ b/framework/Web/UI/WebControls/TRequiredFieldValidator.php
@@ -6,7 +6,7 @@
* @link http://www.pradosoft.com/
* @copyright Copyright &copy; 2005-2013 PradoSoft
* @license http://www.pradosoft.com/license/
- * @version $Id: TRequiredFieldValidator.php 3245 2013-01-07 20:23:32Z ctrlaltca $
+ * @version $Id: TRequiredFieldValidator.php 3288 2013-04-30 10:36:50Z ctrlaltca $
* @package System.Web.UI.WebControls
*/
@@ -25,8 +25,11 @@ Prado::using('System.Web.UI.WebControls.TBaseValidator');
* Validation will also succeed if input is of TListControl type and the number
* of selected values different from the initial value is greater than zero.
*
+ * If the input is of TListControl type and has a {@link TListControl::setPromptValue PromptValue}
+ * set, it will be automatically considered as the validator's {@link setInitialValue InitialValue}.
+ *
* @author Qiang Xue <qiang.xue@gmail.com>
- * @version $Id: TRequiredFieldValidator.php 3245 2013-01-07 20:23:32Z ctrlaltca $
+ * @version $Id: TRequiredFieldValidator.php 3288 2013-04-30 10:36:50Z ctrlaltca $
* @package System.Web.UI.WebControls
* @since 3.0
*/
@@ -43,16 +46,29 @@ class TRequiredFieldValidator extends TBaseValidator
}
/**
- * @return string the initial value of the associated input control. Defaults to empty string.
+ * @return string the initial value of the associated input control. Defaults to empty string
+ * unless the control has a prompt value set.
* If the associated input control does not change from this initial value
* upon postback, the validation fails.
*/
public function getInitialValue()
{
- return $this->getViewState('InitialValue','');
+ return $this->getViewState('InitialValue',$this->getControlPromptValue());
}
/**
+ * @return string the initial value of the associated input control. Defaults to empty string.
+ * If the associated input control does not change from this initial value
+ * upon postback, the validation fails.
+ */
+ protected function getControlPromptValue()
+ {
+ $control = $this->getValidationTarget();
+ if($control instanceof TListControl)
+ return $control->getPromptValue();
+ return '';
+ }
+ /**
* @param string the initial value of the associated input control.
* If the associated input control does not change from this initial value
* upon postback, the validation fails.
diff --git a/framework/Web/UI/WebControls/TWizard.php b/framework/Web/UI/WebControls/TWizard.php
index c29cb90c..67cbc4e4 100644
--- a/framework/Web/UI/WebControls/TWizard.php
+++ b/framework/Web/UI/WebControls/TWizard.php
@@ -6,7 +6,7 @@
* @link http://www.pradosoft.com/
* @copyright Copyright &copy; 2005-2013 PradoSoft
* @license http://www.pradosoft.com/license/
- * @version $Id: TWizard.php 3245 2013-01-07 20:23:32Z ctrlaltca $
+ * @version $Id: TWizard.php 3274 2013-02-15 08:32:25Z ctrlaltca $
* @package System.Web.UI.WebControls
*/
@@ -77,7 +77,7 @@ Prado::using('System.Web.UI.WebControls.TWizardNavigationButtonStyle');
* - side bar: {@link getSideBarStyle SideBarStyle} and {@link getSideBarButtonStyle SideBarButtonStyle}.
*
* @author Qiang Xue <qiang.xue@gmail.com>
- * @version $Id: TWizard.php 3245 2013-01-07 20:23:32Z ctrlaltca $
+ * @version $Id: TWizard.php 3274 2013-02-15 08:32:25Z ctrlaltca $
* @package System.Web.UI.WebControls
* @since 3.0
*/
@@ -284,7 +284,6 @@ class TWizard extends TWebControl implements INamingContainer
public function setShowSideBar($value)
{
$this->setViewState('ShowSideBar',TPropertyValue::ensureBoolean($value),true);
- $this->requiresControlsRecreation();
}
/**
@@ -772,6 +771,7 @@ class TWizard extends TWebControl implements INamingContainer
{
parent::onInit($param);
$this->ensureChildControls();
+ $this->setEnsureId(true);
if($this->getActiveStepIndex()<0 && $this->getWizardSteps()->getCount()>0)
$this->setActiveStepIndex(0);
}
@@ -1449,7 +1449,7 @@ class TWizard extends TWebControl implements INamingContainer
* set {@link setAllowReturn AllowReturn} to true.
*
* @author Qiang Xue <qiang.xue@gmail.com>
- * @version $Id: TWizard.php 3245 2013-01-07 20:23:32Z ctrlaltca $
+ * @version $Id: TWizard.php 3274 2013-02-15 08:32:25Z ctrlaltca $
* @package System.Web.UI.WebControls
* @since 3.0
*/
@@ -1539,7 +1539,7 @@ class TWizardStep extends TView
* TCompleteWizardStep represents a wizard step of type TWizardStepType::Complete.
*
* @author Qiang Xue <qiang.xue@gmail.com>
- * @version $Id: TWizard.php 3245 2013-01-07 20:23:32Z ctrlaltca $
+ * @version $Id: TWizard.php 3274 2013-02-15 08:32:25Z ctrlaltca $
* @package System.Web.UI.WebControls
* @since 3.0
*/
@@ -1574,7 +1574,7 @@ class TCompleteWizardStep extends TWizardStep
* if the navigation template is not specified, default navigation will be used.
*
* @author Qiang Xue <qiang.xue@gmail.com>
- * @version $Id: TWizard.php 3245 2013-01-07 20:23:32Z ctrlaltca $
+ * @version $Id: TWizard.php 3274 2013-02-15 08:32:25Z ctrlaltca $
* @package System.Web.UI.WebControls
* @since 3.0
*/
@@ -1676,7 +1676,7 @@ class TTemplatedWizardStep extends TWizardStep implements INamingContainer
* by a {@link TWizard}.
*
* @author Qiang Xue <qiang.xue@gmail.com>
- * @version $Id: TWizard.php 3245 2013-01-07 20:23:32Z ctrlaltca $
+ * @version $Id: TWizard.php 3274 2013-02-15 08:32:25Z ctrlaltca $
* @package System.Web.UI.WebControls
* @since 3.0
*/
@@ -1740,7 +1740,7 @@ class TWizardStepCollection extends TList
* {@link getCancelButton CancelButton}, {@link getCompleteButton CompleteButton}.
*
* @author Qiang Xue <qiang.xue@gmail.com>
- * @version $Id: TWizard.php 3245 2013-01-07 20:23:32Z ctrlaltca $
+ * @version $Id: TWizard.php 3274 2013-02-15 08:32:25Z ctrlaltca $
* @package System.Web.UI.WebControls
* @since 3.0
*/
@@ -1832,7 +1832,7 @@ class TWizardNavigationContainer extends TControl implements INamingContainer
* to true.
*
* @author Qiang Xue <qiang.xue@gmail.com>
- * @version $Id: TWizard.php 3245 2013-01-07 20:23:32Z ctrlaltca $
+ * @version $Id: TWizard.php 3274 2013-02-15 08:32:25Z ctrlaltca $
* @package System.Web.UI.WebControls
* @since 3.0
*/
@@ -1897,7 +1897,7 @@ class TWizardNavigationEventParameter extends TEventParameter
* TWizardSideBarTemplate class.
* TWizardSideBarTemplate is the default template for wizard sidebar.
* @author Qiang Xue <qiang.xue@gmail.com>
- * @version $Id: TWizard.php 3245 2013-01-07 20:23:32Z ctrlaltca $
+ * @version $Id: TWizard.php 3274 2013-02-15 08:32:25Z ctrlaltca $
* @package System.Web.UI.WebControls
* @since 3.0
*/
@@ -1922,7 +1922,7 @@ class TWizardSideBarTemplate extends TComponent implements ITemplate
* TWizardSideBarListItemTemplate class.
* TWizardSideBarListItemTemplate is the default template for each item in the sidebar datalist.
* @author Qiang Xue <qiang.xue@gmail.com>
- * @version $Id: TWizard.php 3245 2013-01-07 20:23:32Z ctrlaltca $
+ * @version $Id: TWizard.php 3274 2013-02-15 08:32:25Z ctrlaltca $
* @package System.Web.UI.WebControls
* @since 3.0
*/
@@ -1945,7 +1945,7 @@ class TWizardSideBarListItemTemplate extends TComponent implements ITemplate
* TWizardNavigationTemplate class.
* TWizardNavigationTemplate is the base class for various navigation templates.
* @author Qiang Xue <qiang.xue@gmail.com>
- * @version $Id: TWizard.php 3245 2013-01-07 20:23:32Z ctrlaltca $
+ * @version $Id: TWizard.php 3274 2013-02-15 08:32:25Z ctrlaltca $
* @package System.Web.UI.WebControls
* @since 3.0
*/
@@ -2017,7 +2017,7 @@ class TWizardNavigationTemplate extends TComponent implements ITemplate
* TWizardStartNavigationTemplate is the template used as default wizard start navigation panel.
* It consists of two buttons, Next and Cancel.
* @author Qiang Xue <qiang.xue@gmail.com>
- * @version $Id: TWizard.php 3245 2013-01-07 20:23:32Z ctrlaltca $
+ * @version $Id: TWizard.php 3274 2013-02-15 08:32:25Z ctrlaltca $
* @package System.Web.UI.WebControls
* @since 3.0
*/
@@ -2047,7 +2047,7 @@ class TWizardStartNavigationTemplate extends TWizardNavigationTemplate
* TWizardFinishNavigationTemplate is the template used as default wizard finish navigation panel.
* It consists of three buttons, Previous, Complete and Cancel.
* @author Qiang Xue <qiang.xue@gmail.com>
- * @version $Id: TWizard.php 3245 2013-01-07 20:23:32Z ctrlaltca $
+ * @version $Id: TWizard.php 3274 2013-02-15 08:32:25Z ctrlaltca $
* @package System.Web.UI.WebControls
* @since 3.0
*/
@@ -2081,7 +2081,7 @@ class TWizardFinishNavigationTemplate extends TWizardNavigationTemplate
* TWizardStepNavigationTemplate is the template used as default wizard step navigation panel.
* It consists of three buttons, Previous, Next and Cancel.
* @author Qiang Xue <qiang.xue@gmail.com>
- * @version $Id: TWizard.php 3245 2013-01-07 20:23:32Z ctrlaltca $
+ * @version $Id: TWizard.php 3274 2013-02-15 08:32:25Z ctrlaltca $
* @package System.Web.UI.WebControls
* @since 3.0
*/
@@ -2122,7 +2122,7 @@ class TWizardStepNavigationTemplate extends TWizardNavigationTemplate
* - Link: a hyperlink button
*
* @author Qiang Xue <qiang.xue@gmail.com>
- * @version $Id: TWizard.php 3245 2013-01-07 20:23:32Z ctrlaltca $
+ * @version $Id: TWizard.php 3274 2013-02-15 08:32:25Z ctrlaltca $
* @package System.Web.UI.WebControls
* @since 3.0.4
*/
@@ -2146,7 +2146,7 @@ class TWizardNavigationButtonType extends TEnumerable
* - Finish: the last step before the Complete step.
*
* @author Qiang Xue <qiang.xue@gmail.com>
- * @version $Id: TWizard.php 3245 2013-01-07 20:23:32Z ctrlaltca $
+ * @version $Id: TWizard.php 3274 2013-02-15 08:32:25Z ctrlaltca $
* @package System.Web.UI.WebControls
* @since 3.0.4
*/
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?'&amp;':'&')) . 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]);