diff options
author | Nils Adermann <naderman@naderman.de> | 2013-04-03 06:44:15 -0700 |
---|---|---|
committer | Nils Adermann <naderman@naderman.de> | 2013-04-03 06:44:15 -0700 |
commit | 3985bdbc1b66be93ffef373ac1625d4daaf2221b (patch) | |
tree | 1570945fdb5d899b06e99526e135731f8425eeb4 /phpBB/includes | |
parent | a7cf2bdace6dbe97e807e55a063ef6fb8ed20921 (diff) | |
parent | aaee4c69d977fe6ebd62f2710c9c0ab90f1af98f (diff) | |
download | forums-3985bdbc1b66be93ffef373ac1625d4daaf2221b.tar forums-3985bdbc1b66be93ffef373ac1625d4daaf2221b.tar.gz forums-3985bdbc1b66be93ffef373ac1625d4daaf2221b.tar.bz2 forums-3985bdbc1b66be93ffef373ac1625d4daaf2221b.tar.xz forums-3985bdbc1b66be93ffef373ac1625d4daaf2221b.zip |
Merge pull request #1199 from imkingdavid/ticket/11334
[ticket/11334] Properly generate controller URL with helper url() method
Diffstat (limited to 'phpBB/includes')
-rw-r--r-- | phpBB/includes/controller/helper.php | 38 |
1 files changed, 30 insertions, 8 deletions
diff --git a/phpBB/includes/controller/helper.php b/phpBB/includes/controller/helper.php index 6cacc8fefa..46c6307cb4 100644 --- a/phpBB/includes/controller/helper.php +++ b/phpBB/includes/controller/helper.php @@ -85,17 +85,39 @@ class phpbb_controller_helper } /** - * Easily generate a URL + * Generate a URL * - * @param array $url_parts Each array element is a 'folder' - * i.e. array('my', 'ext') maps to ./app.php/my/ext - * @param mixed $query The Query string, passed directly into the second - * argument of append_sid() - * @return string A URL that has already been run through append_sid() + * @param string $route The route to travel + * @param mixed $params String or array of additional url parameters + * @param bool $is_amp Is url using & (true) or & (false) + * @param string $session_id Possibility to use a custom session id instead of the global one + * @return string The URL already passed through append_sid() */ - public function url(array $url_parts, $query = '') + public function url($route, $params = false, $is_amp = true, $session_id = false) { - return append_sid($this->phpbb_root_path . implode('/', $url_parts), $query); + $route_params = ''; + if (($route_delim = strpos($route, '?')) !== false) + { + $route_params = substr($route, $route_delim); + $route = substr($route, 0, $route_delim); + } + + if (is_array($params) && !empty($params)) + { + $params = array_merge(array( + 'controller' => $route, + ), $params); + } + else if (is_string($params) && $params) + { + $params = 'controller=' . $route . (($is_amp) ? '&' : '&') . $params; + } + else + { + $params = array('controller' => $route); + } + + return append_sid($this->phpbb_root_path . 'app' . $this->php_ext . $route_params, $params, $is_amp, $session_id); } /** |