summaryrefslogtreecommitdiff
path: root/framework/Web/Javascripts
diff options
context:
space:
mode:
authorxue <>2007-12-24 16:06:39 +0000
committerxue <>2007-12-24 16:06:39 +0000
commita636ca22642c43b9df588714811da5679775fb38 (patch)
treea4d8038f15b7d6c30ba6dfda64e5a4dd7165d224 /framework/Web/Javascripts
parentd253ed938b33aa5bf45351a81e1a4d596e69b5f7 (diff)
TDataFieldAccessor now supports chained property access without getters.
TJavaScript::encode() will encode data as a list if integer indices are detected.
Diffstat (limited to 'framework/Web/Javascripts')
-rw-r--r--framework/Web/Javascripts/TJavaScript.php24
1 files changed, 15 insertions, 9 deletions
diff --git a/framework/Web/Javascripts/TJavaScript.php b/framework/Web/Javascripts/TJavaScript.php
index 228dc88f..4dce8e2e 100644
--- a/framework/Web/Javascripts/TJavaScript.php
+++ b/framework/Web/Javascripts/TJavaScript.php
@@ -153,20 +153,26 @@ class TJavaScript
return $value?'true':'false';
else if(is_array($value))
{
- $results=array();
- if($toMap)
+ $results='';
+ if(($n=count($value))>0 && array_keys($value)!==range(0,$n-1))
{
foreach($value as $k=>$v)
- if($v!=='')
- $results[]="'{$k}':".self::encode($v,$toMap);
- return '{'.implode(',',$results).'}';
+ {
+ if($results!=='')
+ $results.=',';
+ $results.="'$k':".self::encode($v,$toMap);
+ }
+ return '{'.$results.'}';
}
else
{
- foreach($value as $k=>$v)
- if($v!=='')
- $results[]=self::encode($v,$toMap);
- return '['.implode(',',$results).']';
+ foreach($value as $v)
+ {
+ if($results!=='')
+ $results.=',';
+ $results.=self::encode($v,$toMap);
+ }
+ return '['.$results.']';
}
}
else if(is_integer($value))