aboutsummaryrefslogtreecommitdiffstats
path: root/phpBB
diff options
context:
space:
mode:
authorMeik Sievertsen <acydburn@phpbb.com>2008-10-06 05:44:32 +0000
committerMeik Sievertsen <acydburn@phpbb.com>2008-10-06 05:44:32 +0000
commit9f0b6766f9040d420cd9795520ed8b446612d987 (patch)
tree174961abdcd273fac530a742b6ef61264536878e /phpBB
parent059acbcd1dc501129a2817cfc5cf78c196f170fc (diff)
downloadforums-9f0b6766f9040d420cd9795520ed8b446612d987.tar
forums-9f0b6766f9040d420cd9795520ed8b446612d987.tar.gz
forums-9f0b6766f9040d420cd9795520ed8b446612d987.tar.bz2
forums-9f0b6766f9040d420cd9795520ed8b446612d987.tar.xz
forums-9f0b6766f9040d420cd9795520ed8b446612d987.zip
Fix for r8752
(the code removed actually was quite important - this checkin merges this with the new code) git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@8970 89ea8834-ac86-4346-8a33-228a782c2dd0
Diffstat (limited to 'phpBB')
-rw-r--r--phpBB/includes/functions_content.php38
1 files changed, 24 insertions, 14 deletions
diff --git a/phpBB/includes/functions_content.php b/phpBB/includes/functions_content.php
index a15efbcebb..627e6a71cd 100644
--- a/phpBB/includes/functions_content.php
+++ b/phpBB/includes/functions_content.php
@@ -49,47 +49,57 @@ function gen_sort_selects(&$limit_days, &$sort_by_text, &$sort_days, &$sort_key,
$sorts = array(
'st' => array(
- 'selected' => $sort_days,
+ 'key' => 'sort_days',
'default' => $def_st,
'options' => $limit_days,
- 'output' => &$s_limit_days,),
+ 'output' => &$s_limit_days,
+ ),
+
'sk' => array(
- 'selected' => $sort_key,
+ 'key' => 'sort_key',
'default' => $def_sk,
'options' => $sort_by_text,
- 'output' => &$s_sort_key,),
+ 'output' => &$s_sort_key,
+ ),
+
'sd' => array(
- 'selected' => $sort_dir,
+ 'key' => 'sort_dir',
'default' => $def_sd,
'options' => $sort_dir_text,
- 'output' => &$s_sort_dir,),
+ 'output' => &$s_sort_dir,
+ ),
);
$u_sort_param = '';
+
foreach ($sorts as $name => $sort_ary)
{
+ $key = $sort_ary['key'];
+ $selected = $$sort_ary['key'];
+
// Check if the key is selectable. If not, we reset to the default or first key found.
- // This ensures the values are always valid.
- if (!isset($sort_ary['options'][$sort_ary['selected']]))
+ // This ensures the values are always valid. We also set $sort_dir/sort_key/etc. to the
+ // correct value, else the protection is void. ;)
+ if (!isset($sort_ary['options'][$selected]))
{
if ($sort_ary['default'] !== false)
{
- $sort_ary['selected'] = $sort_ary['default'];
+ $selected = $$key = $sort_ary['default'];
}
else
{
@reset($sort_ary['options']);
- $sort_ary['selected'] = key($sort_ary['options']);
+ $selected = $$key = key($sort_ary['options']);
}
}
-
+
$sort_ary['output'] = '<select name="' . $name . '" id="' . $name . '">';
foreach ($sort_ary['options'] as $option => $text)
{
- $selected = ($sort_ary['selected']== $option) ? ' selected="selected"' : '';
- $sort_ary['output'] .= '<option value="' . $option . '"' . $selected . '>' . $text . '</option>';
+ $sort_ary['output'] .= '<option value="' . $option . '"' . (($selected == $option) ? ' selected="selected"' : '') . '>' . $text . '</option>';
}
$sort_ary['output'] .= '</select>';
- $u_sort_param .= ($sort_ary['selected'] !== $sort_ary['default']) ? ((strlen($u_sort_param)) ? '&amp;' : '') . "{$name}={$sort_ary['selected']}" : '';
+
+ $u_sort_param .= ($selected !== $sort_ary['default']) ? ((strlen($u_sort_param)) ? '&amp;' : '') . "{$name}={$selected}" : '';
}
return;