Changeset 844

Show
Ignore:
Timestamp:
10/18/2007 01:31:17 PM (12 months ago)
Author:
Geert
Message:
  • Added URI->toString
  • Added URI->label() which returns the value of the segment that is preceded by another segment aka 'label'
    • Example: if your URI looks like site.com/cat/general/page/8/order/desc, URI->label('order') will return 'desc', URI->label('cat') will return 'general'. You get the idea.
    • You can set a default return value in the second parameter.
Files:
1 modified

Legend:

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

    r825 r844  
    104104                return self::$current_uri; 
    105105        } 
     106         
     107        public function __toString() 
     108        { 
     109                return $this->string(); 
     110        } 
     111 
     112        /** 
     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        } 
    106127 
    107128        /**