diff options
author | Christophe.Boulain <> | 2009-02-23 11:59:37 +0000 |
---|---|---|
committer | Christophe.Boulain <> | 2009-02-23 11:59:37 +0000 |
commit | 76fa2962008b8c16c2d36289f04e176892b502a0 (patch) | |
tree | a07d9f6d109dae1a06b0d90b521ad12ae2cf5445 /framework/Web/Javascripts | |
parent | 8df351ed171f896b5780e3e9b3b4afa891fd18a4 (diff) |
Fixed Issue#87
Diffstat (limited to 'framework/Web/Javascripts')
-rw-r--r-- | framework/Web/Javascripts/TJavaScript.php | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/framework/Web/Javascripts/TJavaScript.php b/framework/Web/Javascripts/TJavaScript.php index 9c4741a4..2134c2d1 100644 --- a/framework/Web/Javascripts/TJavaScript.php +++ b/framework/Web/Javascripts/TJavaScript.php @@ -4,7 +4,7 @@ *
* @author Wei Zhuo<weizhuo[at]gmail[dot]com>
* @link http://www.pradosoft.com/
- * @copyright Copyright © 2005-2008 PradoSoft + * @copyright Copyright © 2005-2008 PradoSoft
* @license http://www.pradosoft.com/license/
* @version $Id$
* @package System.Web.Javascripts
@@ -130,9 +130,11 @@ class TJavaScript *
* @param mixed PHP variable to be encoded
* @param boolean whether the output is a map or a list.
+ * @since 3.1.5
+ * @param boolean wether to encode empty strings too. Default to false for BC.
* @return string the encoded string
*/
- public static function encode($value,$toMap=true)
+ public static function encode($value,$toMap=true,$encodeEmptyStrings=false)
{
if(is_string($value))
{
@@ -158,11 +160,11 @@ class TJavaScript {
foreach($value as $k=>$v)
{
- if($v!=='')
+ if($v!=='' || $encodeEmptyStrings)
{
if($results!=='')
$results.=',';
- $results.="'$k':".self::encode($v,$toMap);
+ $results.="'$k':".self::encode($v,$toMap,$encodeEmptyStrings);
}
}
return '{'.$results.'}';
@@ -171,11 +173,11 @@ class TJavaScript {
foreach($value as $v)
{
- if($v!=='')
+ if($v!=='' || $encodeEmptyStrings)
{
if($results!=='')
$results.=',';
- $results.=self::encode($v,$toMap);
+ $results.=self::encode($v,$toMap, $encodeEmptyStrings);
}
}
return '['.$results.']';
|