Changeset 2623

Show
Ignore:
Timestamp:
05/05/2008 10:32:08 AM (7 months ago)
Author:
Shadowhand
Message:

Changes to Kohana::

  • Updated key_string_sey to handle ArrayObjects?
  • Reversed the order of key_string() to match key_string_set()
  • Changed calls to key_string() to match the new param order

This WILL cause brokenness! Update your calls to Kohana::key_string!

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/system/core/Kohana.php

    r2621 r2623  
    820820 
    821821                // Get the line from the language 
    822                 $line = self::key_string($key, $language); 
     822                $line = self::key_string($language, $key); 
    823823 
    824824                // Return the key string as fallback 
     
    876876 
    877877                // Get the line from the language 
    878                 $line = self::key_string($key, $locale); 
     878                $line = self::key_string($locale, $key); 
    879879 
    880880                // Return the key string as fallback 
     
    896896         * @return  void    if the key is not found 
    897897         */ 
    898         public static function key_string($keys, $array) 
     898        public static function key_string($array, $keys) 
    899899        { 
    900900                // No array to search 
     
    954954        public static function key_string_set( & $array, $keys, $fill = NULL) 
    955955        { 
    956                 // This must always be an array 
    957                 $array = (array) $array; 
     956                if (is_object($array) AND ($array instanceof ArrayObject)) 
     957                { 
     958                        // Copy the array 
     959                        $array_copy = $array->getArrayCopy(); 
     960 
     961                        // Is an object 
     962                        $array_object = TRUE; 
     963                } 
     964                else 
     965                { 
     966                        if ( ! is_array($array)) 
     967                        { 
     968                                // Must always be an array 
     969                                $array = (array) $array; 
     970                        } 
     971 
     972                        // Copy is a reference to the array 
     973                        $array_copy =& $array; 
     974                } 
    958975 
    959976                if (empty($keys)) 
     
    964981 
    965982                // Create reference to the array 
    966                 $row =& $array; 
     983                $row =& $array_copy; 
    967984 
    968985                for ($i = 0, $end = count($keys) - 1; $i <= $end; $i++) 
     
    971988                        $key = $keys[$i]; 
    972989 
    973                         if ( ! isset($array[$key])) 
     990                        if ( ! isset($row[$key])) 
    974991                        { 
    975992                                if (isset($keys[$i + 1])) 
     
    9921009                        // Go down a level, creating a new row reference 
    9931010                        $row =& $row[$key]; 
     1011                } 
     1012 
     1013                if (isset($array_object)) 
     1014                { 
     1015                        // Swap the array back in 
     1016                        $array->exchangeArray($array_copy); 
    9941017                } 
    9951018        }