mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-27 21:58:52 +00:00
Merge branch 'develop-ascraeus' into develop
* develop-ascraeus: [ticket/12852] Add unit tests [ticket/12852] Add space after if [ticket/12852] Remove whitespace [ticket/12852] Make get_url_parts handle get variable with no value
This commit is contained in:
commit
af10ca630d
2 changed files with 48 additions and 3 deletions
|
@ -316,16 +316,24 @@ class path_helper
|
|||
* Glue URL parameters together
|
||||
*
|
||||
* @param array $params URL parameters in the form of array(name => value)
|
||||
* @return string Returns the glued string, e.g. name1=value1&name2=value2
|
||||
* @return string Returns the glued string, e.g. name1=value1&name2&name3=value3
|
||||
*/
|
||||
public function glue_url_params($params)
|
||||
{
|
||||
$_params = array();
|
||||
|
||||
foreach ($params as $key => $value)
|
||||
{
|
||||
// some parameters do not have value
|
||||
if ($value !== null)
|
||||
{
|
||||
$_params[] = $key . '=' . $value;
|
||||
}
|
||||
else
|
||||
{
|
||||
$_params[] = $key;
|
||||
}
|
||||
}
|
||||
return implode('&', $_params);
|
||||
}
|
||||
|
||||
|
@ -353,7 +361,17 @@ class path_helper
|
|||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
// some parameters don't have value
|
||||
if (strpos($argument, '=') !== false)
|
||||
{
|
||||
list($key, $value) = explode('=', $argument, 2);
|
||||
}
|
||||
else
|
||||
{
|
||||
$key = $argument;
|
||||
$value = null;
|
||||
}
|
||||
|
||||
if ($key === '')
|
||||
{
|
||||
|
|
|
@ -205,6 +205,18 @@ class phpbb_path_helper_test extends phpbb_test_case
|
|||
array('test' => 'xyz', 'var' => 'value'),
|
||||
'test=xyz&var=value',
|
||||
),
|
||||
array(
|
||||
array('test' => null),
|
||||
'test',
|
||||
),
|
||||
array(
|
||||
array('test' => null, 'var' => null),
|
||||
'test&var',
|
||||
),
|
||||
array(
|
||||
array('test' => 'xyz', 'var' => null, 'bar' => 'value'),
|
||||
'test=xyz&var&bar=value',
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -254,6 +266,21 @@ class phpbb_path_helper_test extends phpbb_test_case
|
|||
true,
|
||||
array('base' => 'mcp.php', 'params' => array('f' => '3')),
|
||||
),
|
||||
array(
|
||||
'index.php?ready',
|
||||
false,
|
||||
array('base' => 'index.php', 'params' => array('ready' => null)),
|
||||
),
|
||||
array(
|
||||
'index.php?i=1&ready',
|
||||
true,
|
||||
array('base' => 'index.php', 'params' => array('i' => '1', 'ready' => null)),
|
||||
),
|
||||
array(
|
||||
'index.php?ready&i=1',
|
||||
false,
|
||||
array('base' => 'index.php', 'params' => array('ready' => null, 'i' => '1')),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue