Changeset 845

Show
Ignore:
Timestamp:
10/18/2007 01:47:55 PM (14 months ago)
Author:
Geert
Message:

Integrated URI->label() into URI->segment()

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/system/libraries/URI.php

    r844 r845  
    4141         * 
    4242         * @access      public 
    43          * @param       integer 
     43         * @param       mixed 
    4444         * @param       mixed 
    4545         * @return      mixed 
     
    4747        public function segment($index = 1, $default = FALSE) 
    4848        { 
     49                if (is_string($index)) 
     50                { 
     51                        if (($key = array_search($index, self::$segments)) === FALSE) 
     52                                return $default; 
     53 
     54                        $index = $key + 2; 
     55                } 
     56 
    4957                $index = (int) $index - 1; 
    5058 
     
    111119 
    112120        /** 
    113          * Returns the URI segment that is preceded by a certain other segment (label) 
    114          * 
    115          * @access      public 
    116          * @param       string 
    117          * @param       mixed 
    118          * @return      mixed 
    119          */ 
    120         public function label($label, $default = FALSE) 
    121         { 
    122                 if (($key = array_search($label, self::$segments)) === FALSE) 
    123                         return $default; 
    124  
    125                 return $this->segment($key + 2, $default); 
    126         } 
    127  
    128         /** 
    129121         * Returns the total number of URI segments 
    130122         *