Changeset 2641
- Timestamp:
- 05/06/08 00:50:05 (4 months ago)
- Files:
-
- 1 modified
-
trunk/system/helpers/url.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/system/helpers/url.php
r2593 r2641 67 67 68 68 /** 69 * Fetches a site URL based on a URI segment.69 * Fetches an absolute site URL based on a URI segment. 70 70 * 71 71 * @param string site URI to convert … … 75 75 public static function site($uri = '', $protocol = FALSE) 76 76 { 77 $uri = trim($uri, '/'); 77 // uri/path 78 $path = trim(parse_url($uri, PHP_URL_PATH), '/'); 78 79 79 $qs = ''; // anchor?query=string80 $ id = ''; // anchor#id80 // ?query=string 81 $query = parse_url($uri, PHP_URL_QUERY); 81 82 82 if (strpos($uri, '?') !== FALSE) 83 { 84 list ($uri, $qs) = explode('?', $uri, 2); 85 $qs = '?'.$qs; 86 } 83 // #fragment 84 $fragment = parse_url($uri, PHP_URL_FRAGMENT); 87 85 88 if (strpos($uri, '#') !== FALSE) 89 { 90 list ($uri, $id) = explode('#', $uri, 2); 91 $id = '#'.$id; 92 } 86 // Set the URL suffix 87 $suffix = ($path !== '') ? Config::item('core.url_suffix') : ''; 93 88 94 $index_page = Config::item('core.index_page', TRUE); 95 $url_suffix = ($uri !== '') ? Config::item('core.url_suffix') : ''; 96 97 return url::base(FALSE, $protocol).$index_page.$uri.$url_suffix.$qs.$id; 89 // Concat the URL 90 return url::base(TRUE, $protocol).$path.$suffix.$query.$fragment; 98 91 } 99 92
