Changeset 1539

Show
Ignore:
Timestamp:
12/14/2007 05:41:26 PM (10 months ago)
Author:
Shadowhand
Message:

Updates to Router/URI:

  • Remove Router::$query_string setup routine from URI::construct
  • Re-enabled the GET key optimization
Location:
trunk/system/libraries
Files:
2 modified

Legend:

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

    r1538 r1539  
    5050                { 
    5151                        // Set the query string to the current query string 
    52                         self::$query_string = $_SERVER['QUERY_STRING']; 
     52                        self::$query_string = trim($_SERVER['QUERY_STRING'], '&'); 
    5353                } 
    5454 
     
    202202                        } 
    203203                } 
    204                 elseif (isset($_SERVER['PATH_INFO']) AND $_SERVER['PATH_INFO']) 
    205                 { 
    206                         self::$current_uri = $_SERVER['PATH_INFO']; 
    207                 } 
    208                 elseif (isset($_SERVER['ORIG_PATH_INFO']) AND $_SERVER['ORIG_PATH_INFO']) 
    209                 { 
    210                         self::$current_uri = $_SERVER['ORIG_PATH_INFO']; 
    211                 } 
    212                 elseif (isset($_SERVER['PHP_SELF']) AND $_SERVER['PHP_SELF']) 
    213                 { 
    214                         self::$current_uri = $_SERVER['PHP_SELF']; 
    215                 } 
    216                 elseif (count($_GET) === 1 AND current($_GET) == '') 
    217                 { 
    218                         self::$current_uri = current(array_keys($_GET)); 
     204                elseif (count($_GET) === 1 AND current($_GET) == '' AND substr($_SERVER['QUERY_STRING'], -1) !== '=') 
     205                { 
     206                        // The URI is the array key, eg: ?this/is/the/uri 
     207                        self::$current_uri = key($_GET); 
    219208 
    220209                        // Fixes really strange handling of a suffix in a GET string 
     
    226215                        // Destroy GET 
    227216                        $_GET = array(); 
     217                        $_SERVER['QUERY_STRING'] = ''; 
     218                } 
     219                elseif (isset($_SERVER['PATH_INFO']) AND $_SERVER['PATH_INFO']) 
     220                { 
     221                        self::$current_uri = $_SERVER['PATH_INFO']; 
     222                } 
     223                elseif (isset($_SERVER['ORIG_PATH_INFO']) AND $_SERVER['ORIG_PATH_INFO']) 
     224                { 
     225                        self::$current_uri = $_SERVER['ORIG_PATH_INFO']; 
     226                } 
     227                elseif (isset($_SERVER['PHP_SELF']) AND $_SERVER['PHP_SELF']) 
     228                { 
     229                        self::$current_uri = $_SERVER['PHP_SELF']; 
    228230                } 
    229231 
  • trunk/system/libraries/URI.php

    r1522 r1539  
    1111 
    1212        /** 
    13          * Constructor: __construct 
    14          *  Detects current query string. 
     13         * Constructor. 
    1514         */ 
    1615        public function __construct() 
    1716        { 
    18                 if ( ! empty($_GET)) 
    19                 { 
    20                         self::$query_string = '?'; 
    21  
    22                         foreach($_GET as $key => $val) 
    23                         { 
    24                                 if (is_array($val)) 
    25                                 { 
    26                                         foreach($val as $sub_key => $sub_val) 
    27                                         { 
    28                                                 // Integer subkeys are numerically indexed arrays 
    29                                                 $sub_key = is_int($sub_key) ? '[]' : '['.$sub_key.']'; 
    30  
    31                                                 self::$query_string .= $key.rawurlencode($sub_key).'='.rawurlencode($sub_val).'&'; 
    32                                         } 
    33                                 } 
    34                                 else 
    35                                 { 
    36                                         self::$query_string .= $key.'='.rawurlencode($val).'&'; 
    37                                 } 
    38                         } 
    39  
    40                         // Remove the ending ampersand 
    41                         self::$query_string = rtrim(self::$query_string, '&'); 
    42                 } 
     17                Log::add('debug', 'URI library initialized.'); 
    4318        } 
    4419