From 76fa2962008b8c16c2d36289f04e176892b502a0 Mon Sep 17 00:00:00 2001 From: "Christophe.Boulain" <> Date: Mon, 23 Feb 2009 11:59:37 +0000 Subject: Fixed Issue#87 --- framework/Web/Javascripts/TJavaScript.php | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'framework/Web/Javascripts/TJavaScript.php') 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 * @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.']'; -- cgit v1.2.3