mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-19 17:58:51 +00:00
Merge pull request #7 from nickvergessen/ticket/imkingdavid/11334-2
[ticket/11334] Allow parameters to be specified in the route
This commit is contained in:
commit
aaee4c69d9
2 changed files with 11 additions and 4 deletions
|
@ -95,6 +95,13 @@ class phpbb_controller_helper
|
|||
*/
|
||||
public function url($route, $params = false, $is_amp = true, $session_id = false)
|
||||
{
|
||||
$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(
|
||||
|
@ -110,7 +117,7 @@ class phpbb_controller_helper
|
|||
$params = array('controller' => $route);
|
||||
}
|
||||
|
||||
return append_sid($this->phpbb_root_path . 'app' . $this->php_ext, $params, $is_amp, $session_id);
|
||||
return append_sid($this->phpbb_root_path . 'app' . $this->php_ext . $route_params, $params, $is_amp, $session_id);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -15,7 +15,7 @@ class phpbb_controller_helper_url_test extends phpbb_test_case
|
|||
public function helper_url_data()
|
||||
{
|
||||
return array(
|
||||
// Unsupported: array('foo/bar?t=1&f=2', false, true, false, 'app.php?controller=foo/bar&t=1&f=2', 'parameters in url-argument'),
|
||||
array('foo/bar?t=1&f=2', false, true, false, 'app.php?t=1&f=2&controller=foo/bar', 'parameters in url-argument'),
|
||||
array('foo/bar', 't=1&f=2', true, false, 'app.php?controller=foo/bar&t=1&f=2', 'parameters in params-argument using amp'),
|
||||
array('foo/bar', 't=1&f=2', false, false, 'app.php?controller=foo/bar&t=1&f=2', 'parameters in params-argument using &'),
|
||||
array('foo/bar', array('t' => 1, 'f' => 2), true, false, 'app.php?controller=foo/bar&t=1&f=2', 'parameters in params-argument as array'),
|
||||
|
@ -24,12 +24,12 @@ class phpbb_controller_helper_url_test extends phpbb_test_case
|
|||
array('foo/bar', 't=1&f=2', true, 'custom-sid', 'app.php?controller=foo/bar&t=1&f=2&sid=custom-sid', 'using session_id'),
|
||||
|
||||
// Testing anchors
|
||||
// Unsupported: array('foo/bar?t=1&f=2#anchor', false, true, false, 'app.php?controller=foo/bar&t=1&f=2#anchor', 'anchor in url-argument'),
|
||||
array('foo/bar?t=1&f=2#anchor', false, true, false, 'app.php?t=1&f=2&controller=foo/bar#anchor', 'anchor in url-argument'),
|
||||
array('foo/bar', 't=1&f=2#anchor', true, false, 'app.php?controller=foo/bar&t=1&f=2#anchor', 'anchor in params-argument'),
|
||||
array('foo/bar', array('t' => 1, 'f' => 2, '#' => 'anchor'), true, false, 'app.php?controller=foo/bar&t=1&f=2#anchor', 'anchor in params-argument (array)'),
|
||||
|
||||
// Anchors and custom sid
|
||||
// Unsupported: array('foo/bar?t=1&f=2#anchor', false, true, 'custom-sid', 'app.php?controller=foo/bar&t=1&f=2&sid=custom-sid#anchor', 'anchor in url-argument using session_id'),
|
||||
array('foo/bar?t=1&f=2#anchor', false, true, 'custom-sid', 'app.php?t=1&f=2&controller=foo/bar&sid=custom-sid#anchor', 'anchor in url-argument using session_id'),
|
||||
array('foo/bar', 't=1&f=2#anchor', true, 'custom-sid', 'app.php?controller=foo/bar&t=1&f=2&sid=custom-sid#anchor', 'anchor in params-argument using session_id'),
|
||||
array('foo/bar', array('t' => 1, 'f' => 2, '#' => 'anchor'), true, 'custom-sid', 'app.php?controller=foo/bar&t=1&f=2&sid=custom-sid#anchor', 'anchor in params-argument (array) using session_id'),
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue