Код: Выделить всё
#
#----[ OPEN ]----
#
viewforum.php
#
#----[ FIND ]----
#
make_jumpbox('viewforum.'.$phpEx);
#
#----[ REPLACE WITH ]----
#
// +Smart Jump Box
make_jumpbox('viewforum.'.$phpEx, $forum_id);
// -Smart Jump Box
#
#----[ OPEN ]----
#
includes/functions.php
#
#----[ FIND ]----
#
function make_jumpbox($action, $match_forum_id = 0)
{
global $template, $userdata, $lang, $db, $nav_links, $phpEx, $SID;
// $is_auth = auth(AUTH_VIEW, AUTH_LIST_ALL, $userdata);
$sql = "SELECT c.cat_id, c.cat_title, c.cat_order
FROM " . CATEGORIES_TABLE . " c, " . FORUMS_TABLE . " f
WHERE f.cat_id = c.cat_id
GROUP BY c.cat_id, c.cat_title, c.cat_order
ORDER BY c.cat_order";
if ( !($result = $db->sql_query($sql)) )
{
message_die(GENERAL_ERROR, "Couldn't obtain category list.", "", __LINE__, __FILE__, $sql);
}
$category_rows = array();
while ( $row = $db->sql_fetchrow($result) )
{
$category_rows[] = $row;
}
if ( $total_categories = count($category_rows) )
{
$sql = "SELECT *
FROM " . FORUMS_TABLE . "
ORDER BY cat_id, forum_order";
if ( !($result = $db->sql_query($sql)) )
{
message_die(GENERAL_ERROR, 'Could not obtain forums information', '', __LINE__, __FILE__, $sql);
}
$boxstring = '<select name="' . POST_FORUM_URL . '" onchange="if(this.options[this.selectedIndex].value != -1){ forms[\'jumpbox\'].submit() }"
$forum_rows = array();
while ( $row = $db->sql_fetchrow($result) )
{
$forum_rows[] = $row;
}
if ( $total_forums = count($forum_rows) )
{
for($i = 0; $i < $total_categories; $i++)
{
$boxstring_forums = '';
for($j = 0; $j < $total_forums; $j++)
{
if ( $forum_rows[$j]['cat_id'] == $category_rows[$i]['cat_id'] && $forum_rows[$j]['auth_view'] <= AUTH_REG )
{
// if ( $forum_rows[$j]['cat_id'] == $category_rows[$i]['cat_id'] && $is_auth[$forum_rows[$j]['forum_id']]['auth_view'] )
// {
$selected = ( $forum_rows[$j]['forum_id'] == $match_forum_id ) ? 'selected="selected"' : '';
$boxstring_forums .= '<option value="' . $forum_rows[$j]['forum_id'] . '"' . $selected . '>' . $forum_rows[$j
//
// Add an array to $nav_links for the Mozilla navigation bar.
// 'chapter' and 'forum' can create multiple items, therefore we are using a nested array.
//
$nav_links['chapter forum'][$forum_rows[$j]['forum_id']] = array (
'url' => append_sid("viewforum.$phpEx?" . POST_FORUM_URL . "=" . $forum_rows[$j]['forum_id']),
'title' => $forum_rows[$j]['forum_name']
);
}
}
if ( $boxstring_forums != '' )
{
$boxstring .= '<option value="-1"> </option>';
$boxstring .= '<option value="-1">' . $category_rows[$i]['cat_title'] . '</option>';
$boxstring .= '<option value="-1">----------------</option>';
$boxstring .= $boxstring_forums;
}
}
}
$boxstring .= '</select>';
}
else
{
$boxstring .= '<select name="' . POST_FORUM_URL . '" onchange="if(this.options[this.selectedIndex].value != -1){ forms[\'jumpbox\'].submit() }
}
// Let the jumpbox work again in sites having additional session id checks.
// if ( !empty($SID) )
// {
$boxstring .= '<input type="hidden" name="sid" value="' . $userdata['session_id'] . '" />';
// }
$template->set_filenames(array(
'jumpbox' => 'jumpbox.tpl')
);
$template->assign_vars(array(
'L_GO' => $lang['Go'],
'L_JUMP_TO' => $lang['Jump_to'],
'L_SELECT_FORUM' => $lang['Select_forum'],
'S_JUMPBOX_SELECT' => $boxstring,
'S_JUMPBOX_ACTION' => append_sid($action))
);
$template->assign_var_from_handle('JUMPBOX', 'jumpbox');
return;
}
#
#----[ REPLACE WITH ]----
#
// +Smart Jump Box
function make_jumpbox($action, $match_forum_id = 0)
{
global $db, $userdata, $template, $nav_links, $phpEx, $lang;
$sql = "SELECT c.cat_title, f.*
FROM " . FORUMS_TABLE . " f, " . CATEGORIES_TABLE . " c
WHERE c.cat_id = f.cat_id
AND f.auth_view <= " . AUTH_REG . "
ORDER BY c.cat_order, f.forum_order";
if ( !($result = $db->sql_query($sql)) )
{
message_die(GENERAL_ERROR, "Couldn't obtain categories/forums information.", "", __LINE__, __FILE__, $sql);
}
$jb_rows = array();
$last_cat_id = false;
while ( $row = $db->sql_fetchrow($result) )
{
if ( $last_cat_id !== $row['cat_id'] )
{
$last_cat_id = $row['cat_id'];
$jb_rows[] = array();
}
$jb_rows[count($jb_rows) - 1][] = $row;
}
if ( empty($jb_rows) )
{
return;
}
$template->set_filenames(array(
'jumpbox' => 'jumpbox.tpl')
);
$template->assign_vars(array(
'L_GO' => $lang['Go'],
'L_JUMP_TO' => $lang['Jump_to'],
'L_SELECT_FORUM' => $lang['Select_forum'],
'S_SELECT_FORUM' => POST_FORUM_URL,
'S_JUMPBOX_ACTION' => append_sid($action),
));
$last_cat_id = false;
foreach ($jb_rows as $k => $cat)
{
if ( empty($cat) )
{
continue;
}
$template->assign_block_vars('jb_cat', array(
'CAT_TITLE' => $cat[0]['cat_title'],
));
foreach ($cat as $l => $forum)
{
$template->assign_block_vars('jb_cat.jb_forum', array(
'FORUM_ID' => $forum['forum_id'],
'FORUM_SEL' => $match_forum_id && $match_forum_id == $forum['forum_id'] ? ' selected="selected" ' : '',
//'FORUM_SEL' => isset($_GET[POST_FORUM_URL]) && $_GET[POST_FORUM_URL] == $forum['forum_id'] ? ' selected="selected" ' : '',
'FORUM_TITLE' => $forum['forum_name'],
));
//
// Add an array to $nav_links for the Mozilla navigation bar.
// 'chapter' and 'forum' can create multiple items, therefore we are using a nested array.
//
$nav_links['chapter forum'][$forum['forum_id']] = array (
'url' => append_sid("viewforum.$phpEx?" . POST_FORUM_URL . "=" . $forum['forum_id']),
'title' => $forum['forum_name'],
);
}
}
$template->assign_var_from_handle('JUMPBOX', 'jumpbox');
return;
}
// -Smart Jump Box
#
#----[ OPEN ]----
#
templates/subSilver/jumpbox.tpl
#
#----[ FIND ]----
#
{S_JUMPBOX_SELECT}
#
#----[ REPLACE WITH ]----
#
<select name="{S_SELECT_FORUM}" onchange="if(this.options[this.selectedIndex].value != -1){ forms['jumpbox'].submit() }">
<option value="-1">{L_SELECT_FORUM}</option>
<!-- BEGIN jb_cat -->
<optgroup label="{jb_cat.CAT_TITLE}">
<!-- BEGIN jb_forum -->
<option value="{jb_cat.jb_forum.FORUM_ID}" {jb_cat.jb_forum.FORUM_SEL} >{jb_cat.jb_forum.FORUM_TITLE}</option>
<!-- END jb_forum -->
</optgroup>
<!-- END jb_cat -->
</select>
#
#----[ SAVE/CLOSE ALL FILES ]----
#
#
# EoM
#