Development

Changeset 6436

You must first sign up to be able to contribute.

Changeset 6436

Show
Ignore:
Timestamp:
12/11/07 01:47:43 (6 years ago)
Author:
Leon.van.der.Ree
Message:

Added function to handle array-values

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • plugins/sfExtjs2Plugin/trunk/lib/helper/sfExtjs2Helper.php

    r6151 r6436  
    119119      else 
    120120      { 
     121        // TODO: fix this $value = array, so encode it to { key, value} recursively! 
    121122        $attributes[$key] = $value; 
    122123      } 
     
    433434    foreach ($merged_attributes as $key => $value) 
    434435    { 
    435       $attributes .= sprintf('%s%s:%s', ($attributes === '' ? '' : ','), $key, $value); 
     436      $attributes .= sprintf('%s%s:%s', ($attributes === '' ? '' : ','), $key, sfExtjs2Plugin::_process_value($value)); 
    436437    } 
    437438 
    438439    return $attributes; 
     440  } 
     441   
     442  private static function _process_value($value = '') 
     443  { 
     444    if (is_array($value))  
     445    { 
     446      $array_value = $value; 
     447      $value = '{'; 
     448       
     449      foreach ($array_value as $key => $v) 
     450      { 
     451        if (!is_array($v) && ($v != 'true') && ($v != 'false')) 
     452        { 
     453          $value .= sprintf('%s%s:\'%s\'', ($value === '{' ? '' : ','), $key, sfExtjs2Plugin::_process_value($v)); 
     454        } 
     455        else 
     456        { 
     457          $value .= sprintf('%s%s:%s', ($value === '{' ? '' : ','), $key, sfExtjs2Plugin::_process_value($v)); 
     458        } 
     459      } 
     460        
     461      $value .= '}'; 
     462    } 
     463     
     464    return $value; 
    439465  } 
    440466