He firespade,

I actually came up with another method that is more efficient, as it
does not require a loop to check for numeric keys.  You can see the
change here, as well as the test case that proves it:
https://trac.cakephp.org/changeset/4838

Also, in the future, if you'd like to submit patches (or bug reports
[Josh ;-)]), please read
https://trac.cakephp.org/wiki/bugreport
and this:
https://trac.cakephp.org/wiki/Developement/CodingStandards

Generally speaking, we don't respond to patches or bug reports on the
mailing list, as this isn't the place for it.  Thanks guys.

On Apr 11, 1:05 pm, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote:
> Place this over the original Object method in the javascript.php
> located in "\cake\libs\view\helpers\".
> Enjoy.
>
> function object($data, $block = false, $prefix = '', $postfix = '',
> $stringKeys = array(), $quoteKeys = true, $q = "\"")
>         {
>             $parts = array();
>             $is_list = false;
>
>             $keys = array_keys($data);
>             $max_length = count($data)-1;
>
>             if(($keys[0] == 0) and ($keys[$max_length] == $max_length)) {
>                 $is_list = true;
>
>                 for($i=0; $i<count($keys); $i++) {
>                     if($i != $keys[$i]) {
>                         $is_list = false;
>                         break;
>                     }
>                 }
>
>             }
>
>             foreach($data as $key=>$value) {
>                 if(is_array($value)) {
>                     if($is_list) $parts[] = $this->object($value, false, '',
> '', $stringKeys, $quoteKeys, $q);
>                     else $parts[] = $q . $this->escapeString($key) . $q .
> ':' . $this->object($value, false, '', '', $stringKeys, $quoteKeys,
> $q);
>                 } else {
>                     $str = '';
>                     if(!$is_list) $str = $q . $this->escapeString($key) .
> $q .':';
>
>                     if(is_numeric($value)) $str .= $value;
>                     elseif($value === false) $str .= 'false';
>                     elseif($value === true) $str .= 'true';
>                     else $str .= $q . $this->escapeString($value) . $q;
>
>                     $parts[] = $str;
>                 }
>             }
>             $json = implode(',',$parts);
>
>             if($is_list) return '[' . $json . ']';
>             else $rt = '{' . $json . '}';
>
>             $rt = $prefix . $rt . $postfix;
>
>             if($block)
>             {
>                 $rt = $this->codeBlock($rt);
>             }
>
>             return $rt;
>         }


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Cake 
PHP" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to