~ubuntu-branches/ubuntu/saucy/libkohana3.2-php/saucy

« back to all changes in this revision

Viewing changes to system/classes/kohana/url.php

  • Committer: Package Import Robot
  • Author(s): Laszlo Boszormenyi (GCS)
  • Date: 2012-09-29 18:41:04 UTC
  • mfrom: (1.1.1)
  • Revision ID: package-import@ubuntu.com-20120929184104-dgwn32ao1ya3wjfi
Tags: 3.2.2-1
New upstream release.

Show diffs side-by-side

added added

removed removed

Lines of Context:
5
5
 * @package    Kohana
6
6
 * @category   Helpers
7
7
 * @author     Kohana Team
8
 
 * @copyright  (c) 2007-2011 Kohana Team
 
8
 * @copyright  (c) 2007-2012 Kohana Team
9
9
 * @license    http://kohanaframework.org/license
10
10
 */
11
11
class Kohana_URL {
44
44
 
45
45
                if ($protocol instanceof Request)
46
46
                {
47
 
                        // Use the current protocol
48
 
                        list($protocol) = explode('/', strtolower($protocol->protocol()));
 
47
                        if ( ! $protocol->secure())
 
48
                        {
 
49
                                // Use the current protocol
 
50
                                list($protocol) = explode('/', strtolower($protocol->protocol()));
 
51
                        }
 
52
                        else
 
53
                        {
 
54
                                $protocol = 'https';
 
55
                        }
49
56
                }
50
57
 
51
58
                if ( ! $protocol)
105
112
                if ( ! UTF8::is_ascii($path))
106
113
                {
107
114
                        // Encode all non-ASCII characters, as per RFC 1738
108
 
                        $path = preg_replace('~([^/]+)~e', 'rawurlencode("$1")', $path);
 
115
                        $path = preg_replace_callback('~([^/]+)~', 'URL::_rawurlencode_callback', $path);
109
116
                }
110
117
 
111
118
                // Concat the URL
113
120
        }
114
121
 
115
122
        /**
 
123
         * Callback used for encoding all non-ASCII characters, as per RFC 1738
 
124
         * Used by URL::site()
 
125
         * 
 
126
         * @param  array $matches  Array of matches from preg_replace_callback()
 
127
         * @return string          Encoded string
 
128
         */
 
129
        protected static function _rawurlencode_callback($matches)
 
130
        {
 
131
                return rawurlencode($matches[0]);
 
132
        }
 
133
 
 
134
        /**
116
135
         * Merges the current GET parameters with an array of new or overloaded
117
136
         * parameters and returns the resulting query string.
118
137
         *
140
159
                        else
141
160
                        {
142
161
                                // Merge the current and new parameters
143
 
                                $params = array_merge($_GET, $params);
 
162
                                $params = Arr::merge($_GET, $params);
144
163
                        }
145
164
                }
146
165
 
191
210
                return trim($title, $separator);
192
211
        }
193
212
 
194
 
} // End url
 
 
b'\\ No newline at end of file'
 
213
} // End url