13 * to license@zend.com so we can send you a copy immediately. |
13 * to license@zend.com so we can send you a copy immediately. |
14 * |
14 * |
15 * @category Zend |
15 * @category Zend |
16 * @package Zend_Controller |
16 * @package Zend_Controller |
17 * @subpackage Router |
17 * @subpackage Router |
18 * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) |
18 * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) |
19 * @version $Id: Module.php 20096 2010-01-06 02:05:09Z bkarwin $ |
19 * @version $Id: Module.php 24593 2012-01-05 20:35:02Z matthew $ |
20 * @license http://framework.zend.com/license/new-bsd New BSD License |
20 * @license http://framework.zend.com/license/new-bsd New BSD License |
21 */ |
21 */ |
22 |
22 |
23 /** Zend_Controller_Router_Route_Abstract */ |
23 /** Zend_Controller_Router_Route_Abstract */ |
24 require_once 'Zend/Controller/Router/Route/Abstract.php'; |
24 require_once 'Zend/Controller/Router/Route/Abstract.php'; |
28 * |
28 * |
29 * Default route for module functionality |
29 * Default route for module functionality |
30 * |
30 * |
31 * @package Zend_Controller |
31 * @package Zend_Controller |
32 * @subpackage Router |
32 * @subpackage Router |
33 * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) |
33 * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) |
34 * @license http://framework.zend.com/license/new-bsd New BSD License |
34 * @license http://framework.zend.com/license/new-bsd New BSD License |
35 * @see http://manuals.rubyonrails.com/read/chapter/65 |
35 * @see http://manuals.rubyonrails.com/read/chapter/65 |
36 */ |
36 */ |
37 class Zend_Controller_Router_Route_Module extends Zend_Controller_Router_Route_Abstract |
37 class Zend_Controller_Router_Route_Module extends Zend_Controller_Router_Route_Abstract |
38 { |
38 { |
39 /** |
|
40 * URI delimiter |
|
41 */ |
|
42 const URI_DELIMITER = '/'; |
|
43 |
|
44 /** |
39 /** |
45 * Default values for the route (ie. module, controller, action, params) |
40 * Default values for the route (ie. module, controller, action, params) |
46 * @var array |
41 * @var array |
47 */ |
42 */ |
48 protected $_defaults; |
43 protected $_defaults; |
235 foreach ($params as $key => $value) { |
230 foreach ($params as $key => $value) { |
236 $key = ($encode) ? urlencode($key) : $key; |
231 $key = ($encode) ? urlencode($key) : $key; |
237 if (is_array($value)) { |
232 if (is_array($value)) { |
238 foreach ($value as $arrayValue) { |
233 foreach ($value as $arrayValue) { |
239 $arrayValue = ($encode) ? urlencode($arrayValue) : $arrayValue; |
234 $arrayValue = ($encode) ? urlencode($arrayValue) : $arrayValue; |
240 $url .= '/' . $key; |
235 $url .= self::URI_DELIMITER . $key; |
241 $url .= '/' . $arrayValue; |
236 $url .= self::URI_DELIMITER . $arrayValue; |
242 } |
237 } |
243 } else { |
238 } else { |
244 if ($encode) $value = urlencode($value); |
239 if ($encode) $value = urlencode($value); |
245 $url .= '/' . $key; |
240 $url .= self::URI_DELIMITER . $key; |
246 $url .= '/' . $value; |
241 $url .= self::URI_DELIMITER . $value; |
247 } |
242 } |
248 } |
243 } |
249 |
244 |
250 if (!empty($url) || $action !== $this->_defaults[$this->_actionKey]) { |
245 if (!empty($url) || $action !== $this->_defaults[$this->_actionKey]) { |
251 if ($encode) $action = urlencode($action); |
246 if ($encode) $action = urlencode($action); |
252 $url = '/' . $action . $url; |
247 $url = self::URI_DELIMITER . $action . $url; |
253 } |
248 } |
254 |
249 |
255 if (!empty($url) || $controller !== $this->_defaults[$this->_controllerKey]) { |
250 if (!empty($url) || $controller !== $this->_defaults[$this->_controllerKey]) { |
256 if ($encode) $controller = urlencode($controller); |
251 if ($encode) $controller = urlencode($controller); |
257 $url = '/' . $controller . $url; |
252 $url = self::URI_DELIMITER . $controller . $url; |
258 } |
253 } |
259 |
254 |
260 if (isset($module)) { |
255 if (isset($module)) { |
261 if ($encode) $module = urlencode($module); |
256 if ($encode) $module = urlencode($module); |
262 $url = '/' . $module . $url; |
257 $url = self::URI_DELIMITER . $module . $url; |
263 } |
258 } |
264 |
259 |
265 return ltrim($url, self::URI_DELIMITER); |
260 return ltrim($url, self::URI_DELIMITER); |
266 } |
261 } |
267 |
262 |