1
0
mirror of https://github.com/e107inc/e107.git synced 2025-08-04 05:37:32 +02:00

Working on breadcrumb, almost there

This commit is contained in:
mcfly
2008-12-14 03:18:45 +00:00
parent 2c158e6050
commit 97ab0f6a93
5 changed files with 124 additions and 110 deletions

View File

@@ -1,31 +1,29 @@
global $pref; global $pref;
$e107 = e107::getInstance();
@include_once(e_LANGUAGEDIR.e_LANGUAGE."/lan_np.php"); include_lan(e_LANGUAGEDIR.'English/lan_np.php');
@include_once(e_LANGUAGEDIR."English/lan_np.php"); $parm_count = substr_count($parm, ',');
$parm_count = substr_count($parm, ",");
while($parm_count < 5) while($parm_count < 5)
{ {
$parm .= ","; $parm .= ',';
$parm_count++; $parm_count++;
} }
$p = explode(",", $parm, 6); $p = explode(',', $parm, 6);
$total_items = intval($p[0]); $total_items = intval($p[0]);
$perpage = intval($p[1]); $perpage = intval($p[1]);
$current_start = intval($p[2]); $current_start = intval($p[2]);
$url = trim($p[3]); $url = trim($p[3]);
$caption = trim($p[4]); $caption = trim($p[4]);
$pagetitle = explode("|",trim($p[5])); $pagetitle = explode('|',trim($p[5]));
if($total_items < $perpage) { return ""; } if($total_items < $perpage) { return ''; }
$caption = (!$caption || $caption == "off") ? NP_3."&nbsp;" : $caption; $caption = (!$caption || $caption == 'off') ? NP_3.'&nbsp;' : $caption;
while(substr($url, -1) == ".") while(substr($url, -1) == '.')
{ {
$url=substr($url, 0, -1); $url=substr($url, 0, -1);
} }
@@ -35,16 +33,16 @@ $total_pages = ceil($total_items/$perpage);
if($total_pages > 1) if($total_pages > 1)
{ {
if(isset($pref['old_np']) && $pref['old_np']) if(varsettrue($pref['old_np']))
{ {
$NP_PRE_ACTIVE = ""; $NP_PRE_ACTIVE = '';
$NP_POST_ACTIVE = ""; $NP_POST_ACTIVE = '';
$NP_STYLE = ""; $NP_STYLE = '';
if(!defined("NEXTPREV_NOSTYLE") || NEXTPREV_NOSTYLE==FALSE){ if(!defined('NEXTPREV_NOSTYLE') || NEXTPREV_NOSTYLE==FALSE){
$NP_PRE_ACTIVE = "["; $NP_PRE_ACTIVE = '[';
$NP_POST_ACTIVE = "] "; $NP_POST_ACTIVE = '] ';
$NP_STYLE = "style='text-decoration:underline'"; $NP_STYLE = "style='text-decoration:underline'";
} }
@@ -147,8 +145,8 @@ if($total_pages > 1)
// Use NEW nextprev method // Use NEW nextprev method
$np_parm['template'] = "[PREV]&nbsp;&nbsp;[DROPDOWN]&nbsp;&nbsp;[NEXT]"; $np_parm['template'] = "[PREV]&nbsp;&nbsp;[DROPDOWN]&nbsp;&nbsp;[NEXT]";
$np_parms['prev'] = "&nbsp;&nbsp;&lt;&lt;&nbsp;&nbsp;"; $np_parms['prev'] = '&nbsp;&nbsp;&lt;&lt;&nbsp;&nbsp;';
$np_parms['next'] = "&nbsp;&nbsp;&gt;&gt;&nbsp;&nbsp;"; $np_parms['next'] = '&nbsp;&nbsp;&gt;&gt;&nbsp;&nbsp;';
$np_parms['np_class'] = 'tbox npbutton'; $np_parms['np_class'] = 'tbox npbutton';
$np_parms['dropdown_class'] = 'tbox npdropdown'; $np_parms['dropdown_class'] = 'tbox npdropdown';
@@ -161,39 +159,67 @@ if($total_pages > 1)
} }
} }
$prev=""; $prev='';
$next=""; $next='';
if($current_page > 1) if($current_page > 1)
{ {
$prevstart = ($current_start - $perpage); $prevstart = ($current_start - $perpage);
$link = str_replace("[FROM]", $prevstart, $url);
if(substr($url, 0, 5) == 'url::')
{
$urlParms = explode('::', $url);
$urlParms[3] = str_replace('[FROM]', $prevstart, $urlParms[3]);
$link = $e107->url->getUrl($urlParms[1], $urlParms[2], $urlParms[3]);
}
else
{
$link = str_replace('[FROM]', $prevstart, $url);
}
$prev = "<a class='{$np_parms['np_class']}' style='text-decoration:none' href='{$link}'>{$np_parms['prev']}</a>"; $prev = "<a class='{$np_parms['np_class']}' style='text-decoration:none' href='{$link}'>{$np_parms['prev']}</a>";
} }
if($current_page < $total_pages) if($current_page < $total_pages)
{ {
$nextstart = ($current_start + $perpage); $nextstart = ($current_start + $perpage);
$link = str_replace("[FROM]", $nextstart, $url); if(substr($url, 0, 5) == 'url::')
{
$urlParms = explode('::', $url);
$urlParms[3] = str_replace('[FROM]', $nextstart, $urlParms[3]);
$link = $e107->url->getUrl($urlParms[1], $urlParms[2], $urlParms[3]);
}
else
{
$link = str_replace('[FROM]', $nextstart, $url);
}
$next = "<a class='{$np_parms['np_class']}' style='text-decoration:none' href='{$link}'>{$np_parms['next']}</a>"; $next = "<a class='{$np_parms['np_class']}' style='text-decoration:none' href='{$link}'>{$np_parms['next']}</a>";
} }
$dropdown = "<select class='{$np_parms['dropdown_class']}' name='pageSelect' onchange='location.href=this.options[selectedIndex].value'>"; $dropdown = "<select class='{$np_parms['dropdown_class']}' name='pageSelect' onchange='location.href=this.options[selectedIndex].value'>";
for($i = 1; $i <= $total_pages; $i++) for($i = 1; $i <= $total_pages; $i++)
{ {
$sel = ""; $sel = '';
if($current_page == $i) if($current_page == $i)
{ {
$sel = " selected='selected' "; $sel = " selected='selected' ";
} }
$newstart = ($i-1)*$perpage; $newstart = ($i-1)*$perpage;
$link = str_replace("[FROM]", $newstart, $url); if(substr($url, 0, 5) == 'url::')
{
$urlParms = explode('::', $url);
$urlParms[3] = str_replace('[FROM]', $newstart, $urlParms[3]);
$link = $e107->url->getUrl($urlParms[1], $urlParms[2], $urlParms[3]);
}
else
{
$link = str_replace('[FROM]', $newstart, $url);
}
$c = $i-1; $c = $i-1;
$title = ($pagetitle[$c]) ? $pagetitle[$c] : $i; $title = ($pagetitle[$c]) ? $pagetitle[$c] : $i;
$dropdown .= "<option value='{$link}' {$sel}>{$title}</option>\n"; $dropdown .= "<option value='{$link}' {$sel}>{$title}</option>\n";
} }
$dropdown .= "</select>"; $dropdown .= '</select>';
$ret = $np_parm['template']; $ret = $np_parm['template'];
$ret = str_replace('[DROPDOWN]', $dropdown, $ret); $ret = str_replace('[DROPDOWN]', $dropdown, $ret);
$ret = str_replace('[PREV]', $prev, $ret); $ret = str_replace('[PREV]', $prev, $ret);
$ret = str_replace('[NEXT]', $next, $ret); $ret = str_replace('[NEXT]', $next, $ret);
return $caption.$ret; return $caption.$ret;
} }
return ""; return '';

View File

@@ -1,5 +1,5 @@
<?php <?php
// $Id: thread.php,v 1.6 2008-12-13 21:52:19 mcfly_e107 Exp $ // $Id: thread.php,v 1.7 2008-12-14 03:18:45 mcfly_e107 Exp $
function url_forum_thread($parms) function url_forum_thread($parms)
{ {
switch($parms['func']) switch($parms['func'])
@@ -28,7 +28,7 @@ function url_forum_thread($parms)
case 'report': case 'report':
$page = (isset($parms['page']) ? (int)$parms['page'] : 0 ); $page = (isset($parms['page']) ? (int)$parms['page'] : 0 );
return e_PLUGIN_ABS."forum/forum_viewtopic.php?f=report&id={$parms['report']}&page={$page}"; return e_PLUGIN_ABS."forum/forum_viewtopic.php?f=report&id={$parms['report']}&p={$page}";
break; break;
case 'edit': case 'edit':

View File

@@ -11,8 +11,8 @@
| GNU General Public License (http://gnu.org). | GNU General Public License (http://gnu.org).
| |
| $Source: /cvs_backup/e107_0.8/e107_plugins/forum/forum_class.php,v $ | $Source: /cvs_backup/e107_0.8/e107_plugins/forum/forum_class.php,v $
| $Revision: 1.25 $ | $Revision: 1.26 $
| $Date: 2008-12-13 21:52:18 $ | $Date: 2008-12-14 03:18:45 $
| $Author: mcfly_e107 $ | $Author: mcfly_e107 $
+----------------------------------------------------------------------------+ +----------------------------------------------------------------------------+
*/ */
@@ -282,9 +282,14 @@ class e107forum
{ {
//TODO: Fix query to get only forum and parent info needed, with correct naming //TODO: Fix query to get only forum and parent info needed, with correct naming
$qry = ' $qry = '
SELECT t.*, f.*, tr.track_userid SELECT t.*, f.*,
fp.forum_id as parent_id, fp.forum_name as parent_name,
sp.forum_id as forum_sub, sp.forum_name as sub_parent,
tr.track_userid
FROM `#forum_thread` AS t FROM `#forum_thread` AS t
LEFT JOIN `#forum` AS f ON t.thread_forum_id = f.forum_id LEFT JOIN `#forum` AS f ON t.thread_forum_id = f.forum_id
LEFT JOIN `#forum` AS fp ON fp.forum_id = f.forum_parent
LEFT JOIN `#forum` AS sp ON sp.forum_id = f.forum_sub
LEFT JOIN `#forum_track` AS tr ON tr.track_thread = t.thread_id AND tr.track_userid = '.$uid.' LEFT JOIN `#forum_track` AS tr ON tr.track_thread = t.thread_id AND tr.track_userid = '.$uid.'
WHERE thread_id = '.$id; WHERE thread_id = '.$id;
} }
@@ -1347,63 +1352,57 @@ class e107forum
*/ */
function set_crumb($forum_href=false, $thread_title='') function set_crumb($forum_href=false, $thread_title='')
{ {
global $FORUM_CRUMB, $forum_info, $threadInfo, $tp; $e107 = e107::getInstance();
global $FORUM_CRUMB, $forumInfo, $thread;
global $BREADCRUMB,$BACKLINK; // Eventually we should deprecate BACKLINK global $BREADCRUMB,$BACKLINK; // Eventually we should deprecate BACKLINK
if(!$forumInfo) { $forumInfo = $thread->threadInfo; }
// var_dump($forumInfo);
// var_dump($thread);
if(is_array($FORUM_CRUMB)) if(is_array($FORUM_CRUMB))
{ {
$search = array("{SITENAME}", "{SITENAME_HREF}"); $search = array('{SITENAME}', '{SITENAME_HREF}');
$replace = array(SITENAME, "href='".e_BASE."index.php'"); $replace = array(SITENAME, "href='".$e107->url->getUrl('core:core', 'main', 'action=index')."'");
$FORUM_CRUMB['sitename']['value'] = str_replace($search, $replace, $FORUM_CRUMB['sitename']['value']); $FORUM_CRUMB['sitename']['value'] = str_replace($search, $replace, $FORUM_CRUMB['sitename']['value']);
$search = array("{FORUMS_TITLE}", "{FORUMS_HREF}"); $search = array('{FORUMS_TITLE}', '{FORUMS_HREF}');
$replace = array(LAN_01, "href='".e_PLUGIN."forum/forum.php'"); $replace = array(LAN_01, "href='".$e107->url->getUrl('forum', 'forum', 'func=main')."'");
$FORUM_CRUMB['forums']['value'] = str_replace($search, $replace, $FORUM_CRUMB['forums']['value']); $FORUM_CRUMB['forums']['value'] = str_replace($search, $replace, $FORUM_CRUMB['forums']['value']);
$search = "{PARENT_TITLE}"; $search = '{PARENT_TITLE}';
$replace = $tp->toHTML($forum_info['parent_name']); $replace = $e107->tp->toHTML($forumInfo['parent_name']);
$FORUM_CRUMB['parent']['value'] = str_replace($search, $replace, $FORUM_CRUMB['parent']['value']); $FORUM_CRUMB['parent']['value'] = str_replace($search, $replace, $FORUM_CRUMB['parent']['value']);
if($forum_info['sub_parent']) if($forum_info['forum_sub'])
{ {
$search = array("{SUBPARENT_TITLE}", "{SUBPARENT_HREF}"); $search = array('{SUBPARENT_TITLE}', '{SUBPARENT_HREF}');
$forum_sub_parent = (substr($forum_info['sub_parent'], 0, 1) == "*" ? substr($forum_info['sub_parent'], 1) : $forum_info['sub_parent']); $replace = array(ltrim($forumInfo['sub_parent'], '*'), "href='".$e107->url->getUrl('forum', 'forum', "func=view&id={$forumInfo['forum_sub']}")."'");
$replace = array($forum_sub_parent, "href='".e_PLUGIN."forum/forum_viewforum.php?{$forum_info['forum_sub']}'");
$FORUM_CRUMB['subparent']['value'] = str_replace($search, $replace, $FORUM_CRUMB['subparent']['value']); $FORUM_CRUMB['subparent']['value'] = str_replace($search, $replace, $FORUM_CRUMB['subparent']['value']);
} }
else else
{ {
$FORUM_CRUMB['subparent']['value'] = ""; $FORUM_CRUMB['subparent']['value'] = '';
} }
$search = array("{FORUM_TITLE}", "{FORUM_HREF}"); $search = array('{FORUM_TITLE}', '{FORUM_HREF}');
$tmpFname = $forum_info['forum_name']; $replace = array(ltrim($forumInfo['forum_name'], '*'),"href='".$e107->url->getUrl('forum', 'forum', "func=view&id={$forumInfo['forum_id']}")."'");
if(substr($tmpFname, 0, 1) == "*") { $tmpFname = substr($tmpFname, 1); }
$replace = array($tmpFname,"href='".e_PLUGIN."forum/forum_viewforum.php?{$forum_info['forum_id']}'");
$FORUM_CRUMB['forum']['value'] = str_replace($search, $replace, $FORUM_CRUMB['forum']['value']); $FORUM_CRUMB['forum']['value'] = str_replace($search, $replace, $FORUM_CRUMB['forum']['value']);
if(strlen($thread_title)) $search = array('{THREAD_TITLE}');
{ $replace = array($thread->threadInfo['thread_name']);
$search = array("{THREAD_TITLE}");
$replace = array($thread_title);
$FORUM_CRUMB['thread']['value'] = str_replace($search, $replace, $FORUM_CRUMB['thread']['value']); $FORUM_CRUMB['thread']['value'] = str_replace($search, $replace, $FORUM_CRUMB['thread']['value']);
$FORUM_CRUMB['fieldlist'] = 'sitename,forums,parent,subparent,forum,thread';
$BREADCRUMB = $e107->tp->parseTemplate('{BREADCRUMB=FORUM_CRUMB}', true);
} }
else else
{ {
$FORUM_CRUMB['thread']['value'] = ""; $dfltsep = ' :: ';
}
$FORUM_CRUMB['fieldlist'] = "sitename,forums,parent,subparent,forum,thread";
$BREADCRUMB = $tp->parseTemplate("{BREADCRUMB=FORUM_CRUMB}", true);
}
else
{
$dfltsep = " :: ";
$BREADCRUMB = "<a class='forumlink' href='".e_BASE."index.php'>".SITENAME."</a>".$dfltsep."<a class='forumlink' href='".e_PLUGIN."forum/forum.php'>".LAN_01."</a>".$dfltsep; $BREADCRUMB = "<a class='forumlink' href='".e_BASE."index.php'>".SITENAME."</a>".$dfltsep."<a class='forumlink' href='".e_PLUGIN."forum/forum.php'>".LAN_01."</a>".$dfltsep;
if($forum_info['sub_parent']) if($forum_info['sub_parent'])
{ {
$forum_sub_parent = (substr($forum_info['sub_parent'], 0, 1) == "*" ? substr($forum_info['sub_parent'], 1) : $forum_info['sub_parent']); $forum_sub_parent = (substr($forum_info['sub_parent'], 0, 1) == '*' ? substr($forum_info['sub_parent'], 1) : $forum_info['sub_parent']);
$BREADCRUMB .= "<a class='forumlink' href='".e_PLUGIN."forum/forum_viewforum.php?{$forum_info['forum_sub']}'>{$forum_sub_parent}</a>".$dfltsep; $BREADCRUMB .= "<a class='forumlink' href='".e_PLUGIN."forum/forum_viewforum.php?{$forum_info['forum_sub']}'>{$forum_sub_parent}</a>".$dfltsep;
} }
@@ -1448,35 +1447,35 @@ function img_path($filename)
{ {
global $pref; global $pref;
$multilang = array("reply.png","newthread.png","moderator.png","main_admin.png","admin.png"); $multilang = array('reply.png','newthread.png','moderator.png','main_admin.png','admin.png');
$ML = (in_array($filename,$multilang)) ? TRUE : FALSE; $ML = (in_array($filename,$multilang)) ? TRUE : FALSE;
if(file_exists(THEME.'forum/'.$filename) || is_readable(THEME.'forum/'.e_LANGUAGE."_".$filename)) if(file_exists(THEME.'forum/'.$filename) || is_readable(THEME.'forum/'.e_LANGUAGE.'_'.$filename))
{ {
$image = ($ML && is_readable(THEME.'forum/'.e_LANGUAGE."_".$filename)) ? THEME.'forum/'.e_LANGUAGE."_".$filename : THEME.'forum/'.$filename; $image = ($ML && is_readable(THEME.'forum/'.e_LANGUAGE.'_'.$filename)) ? THEME.'forum/'.e_LANGUAGE."_".$filename : THEME.'forum/'.$filename;
} }
else else
{ {
if(defined("IMODE")) if(defined('IMODE'))
{ {
if($ML) if($ML)
{ {
$image = (is_readable(e_PLUGIN."forum/images/".IMODE."/".e_LANGUAGE."_".$filename)) ? e_PLUGIN."forum/images/".IMODE."/".e_LANGUAGE."_".$filename : e_PLUGIN."forum/images/".IMODE."/English_".$filename; $image = (is_readable(e_PLUGIN.'forum/images/'.IMODE.'/'.e_LANGUAGE.'_'.$filename)) ? e_PLUGIN.'forum/images/'.IMODE.'/'.e_LANGUAGE.'_'.$filename : e_PLUGIN.'forum/images/'.IMODE.'/English_'.$filename;
} }
else else
{ {
$image = e_PLUGIN."forum/images/".IMODE."/".$filename; $image = e_PLUGIN.'forum/images/'.IMODE.'/'.$filename;
} }
} }
else else
{ {
if($ML) if($ML)
{ {
$image = (is_readable(e_PLUGIN."forum/images/lite/".e_LANGUAGE."_".$filename)) ? e_PLUGIN."forum/images/lite/".e_LANGUAGE."_".$filename : e_PLUGIN."forum/images/lite/English_".$filename; $image = (is_readable(e_PLUGIN."forum/images/lite/".e_LANGUAGE.'_'.$filename)) ? e_PLUGIN.'forum/images/lite/'.e_LANGUAGE.'_'.$filename : e_PLUGIN.'forum/images/lite/English_'.$filename;
} }
else else
{ {
$image = e_PLUGIN."forum/images/lite/".$filename; $image = e_PLUGIN.'forum/images/lite/'.$filename;
} }
} }

View File

@@ -9,8 +9,8 @@
* View specific forums * View specific forums
* *
* $Source: /cvs_backup/e107_0.8/e107_plugins/forum/forum_viewforum.php,v $ * $Source: /cvs_backup/e107_0.8/e107_plugins/forum/forum_viewforum.php,v $
* $Revision: 1.8 $ * $Revision: 1.9 $
* $Date: 2008-12-12 03:36:39 $ * $Date: 2008-12-14 03:18:45 $
* $Author: mcfly_e107 $ * $Author: mcfly_e107 $
* *
*/ */
@@ -33,20 +33,6 @@ if (!e_QUERY)
$view = 25; $view = 25;
$threadFrom = (isset($_REQUEST['p']) ? $_REQUEST['p'] * $view : 0); $threadFrom = (isset($_REQUEST['p']) ? $_REQUEST['p'] * $view : 0);
/*
else
{
$tmp = explode('.', e_QUERY);
$forum_id = (int)$tmp[0];
$thread_from = (isset($tmp[1]) ? (int)$tmp[1] : 0);
}
if(is_numeric(e_MENU))
{
$thread_from = (intval(e_MENU)-1)*$view;
}
*/
require_once(e_PLUGIN.'forum/forum_class.php'); require_once(e_PLUGIN.'forum/forum_class.php');
$forum = new e107forum; $forum = new e107forum;
@@ -68,6 +54,8 @@ if (!$forum->checkPerm($forumId, 'view'))
$forumInfo = $forum->forum_get($forumId); $forumInfo = $forum->forum_get($forumId);
//var_dump($forumInfo);
if (!$FORUM_VIEW_START) if (!$FORUM_VIEW_START)
{ {
if (file_exists(THEME.'forum_viewforum_template.php')) if (file_exists(THEME.'forum_viewforum_template.php'))
@@ -239,11 +227,6 @@ if(is_array($sub_list))
if (count($threadList) ) if (count($threadList) )
{ {
// foreach($threadList as $thread_info)
// {
// $idArray[] = $thread_info['thread_id'];
// }
// $inList = '('.implode(',', $idArray).')';
foreach($threadList as $thread_info) foreach($threadList as $thread_info)
{ {
if($thread_info['thread_options']) if($thread_info['thread_options'])
@@ -294,7 +277,6 @@ else
$forum_view_forum .= "<tr><td class='forumheader' colspan='6'>".LAN_58."</td></tr>"; $forum_view_forum .= "<tr><td class='forumheader' colspan='6'>".LAN_58."</td></tr>";
} }
//$sql->db_Select('forum', '*', "forum_parent !=0 AND forum_class != '255' ");
$FORUMJUMP = forumjump(); $FORUMJUMP = forumjump();
$TOPLINK = "<a href='".e_SELF.'?'.e_QUERY."#top' onclick=\"window.scrollTo(0,0);\">".LAN_02.'</a>'; $TOPLINK = "<a href='".e_SELF.'?'.e_QUERY."#top' onclick=\"window.scrollTo(0,0);\">".LAN_02.'</a>';
@@ -428,13 +410,15 @@ function parse_thread($thread_info)
for($a = 0; $a <= 2; $a++) for($a = 0; $a <= 2; $a++)
{ {
$PAGES .= $PAGES ? ' ' : ''; $PAGES .= $PAGES ? ' ' : '';
$PAGES .= "<a href='".e_PLUGIN."forum/forum_viewtopic.php?".$thread_info['thread_id'].".".($a * $pref['forum_postspage'])."'>".($a+1)."</a>"; $url = $e107->url->getUrl('forum', 'thread', "func=view&id={$thread_info['thread_id']}&page={$a}");
$PAGES .= "<a href='{$url}'>".($a+1).'</a>';
} }
$PAGES .= ' ... '; $PAGES .= ' ... ';
for($a = $pages-3; $a <= $pages-1; $a++) for($a = $pages-3; $a <= $pages-1; $a++)
{ {
$PAGES .= $PAGES ? " " : ""; $PAGES .= $PAGES ? ' ' : '';
$PAGES .= "<a href='".e_PLUGIN."forum/forum_viewtopic.php?".$thread_info['thread_id'].".".($a * $pref['forum_postspage'])."'>".($a+1)."</a>"; $url = $e107->url->getUrl('forum', 'thread', "func=view&id={$thread_info['thread_id']}&page={$a}");
$PAGES .= "<a href='{$url}'>".($a+1).'</a>';
} }
} }
else else
@@ -442,7 +426,8 @@ function parse_thread($thread_info)
for($a = 0; $a <= ($pages-1); $a++) for($a = 0; $a <= ($pages-1); $a++)
{ {
$PAGES .= $PAGES ? ' ' : ''; $PAGES .= $PAGES ? ' ' : '';
$PAGES .= "<a href='".e_PLUGIN."forum/forum_viewtopic.php?".$thread_info['thread_id'].".".($a * $pref['forum_postspage'])."'>".($a+1)."</a>"; $url = $e107->url->getUrl('forum', 'thread', "func=view&id={$thread_info['thread_id']}&page={$a}");
$PAGES .= "<a href='{$url}'>".($a+1).'</a>';
} }
} }
$PAGES = LAN_316.' [&nbsp;'.$PAGES.'&nbsp;]'; $PAGES = LAN_316.' [&nbsp;'.$PAGES.'&nbsp;]';

View File

@@ -12,8 +12,8 @@
| GNU General Public License (http://gnu.org). | GNU General Public License (http://gnu.org).
| |
| $Source: /cvs_backup/e107_0.8/e107_plugins/forum/forum_viewtopic.php,v $ | $Source: /cvs_backup/e107_0.8/e107_plugins/forum/forum_viewtopic.php,v $
| $Revision: 1.14 $ | $Revision: 1.15 $
| $Date: 2008-12-13 21:52:18 $ | $Date: 2008-12-14 03:18:45 $
| $Author: mcfly_e107 $ | $Author: mcfly_e107 $
+----------------------------------------------------------------------------+ +----------------------------------------------------------------------------+
*/ */
@@ -59,7 +59,7 @@ if(isset($_POST['track_toggle']))
if(isset($_GET['f'])) if(isset($_GET['f']))
{ {
$thread->processFunction(); $thread->processFunction();
$thread->init(); if($_GET['f'] != 'last') { $thread->init(); }
} }
require_once (e_PLUGIN . 'forum/forum_shortcodes.php'); require_once (e_PLUGIN . 'forum/forum_shortcodes.php');
@@ -84,7 +84,7 @@ if (MODERATOR && isset($_POST['mod']))
$thread->threadInfo = $forum->threadGet($thread->threadId); $thread->threadInfo = $forum->threadGet($thread->threadId);
} }
$postList = $forum->PostGet($thread->threadId, ($thread->page-1) * $thread->perPage, $thread->perPage); $postList = $forum->PostGet($thread->threadId, $thread->page * $thread->perPage, $thread->perPage);
//var_dump($thread->threadInfo); //var_dump($thread->threadInfo);
require_once (e_HANDLER . 'level_handler.php'); require_once (e_HANDLER . 'level_handler.php');
@@ -166,9 +166,11 @@ $THREADSTATUS = (!$thread->threadInfo['thread_active'] ? LAN_66 : '');
//$pages = ceil(($threadInfo['thread_total_replies'] + 1) / $perPage); //$pages = ceil(($threadInfo['thread_total_replies'] + 1) / $perPage);
//echo "pages = {$thread->pages}<br />";
//var_dump($thread);
if ($thread->pages > 1) if ($thread->pages > 1)
{ {
$parms = ($thread->threadInfo['thread_total_replies'] + 1) . ",{$perPage},{$topic_from}," . e_SELF . '?' . $this->threadId . '.[FROM],off'; $parms = ($thread->pages).",1,{$thread->page},url::forum::thread::func=view&id={$thread->threadId}&page=[FROM],off";
$GOTOPAGES = $tp->parseTemplate("{NEXTPREV={$parms}}"); $GOTOPAGES = $tp->parseTemplate("{NEXTPREV={$parms}}");
} }
@@ -445,7 +447,7 @@ function rpg($user_join, $user_forums)
class e107ForumThread class e107ForumThread
{ {
var $message, $threadId, $threadInfo, $forumId, $perPage, $noInc; var $message, $threadId, $threadInfo, $forumId, $perPage, $noInc, $pages;
function init() function init()
{ {
@@ -453,7 +455,7 @@ class e107ForumThread
$e107 = e107::getInstance(); $e107 = e107::getInstance();
$this->threadId = (int)varset($_GET['id']); $this->threadId = (int)varset($_GET['id']);
$this->perPage = (varset($_GET['perpage']) ? (int)$_GET['perpage'] : $pref['forum_postspage']); $this->perPage = (varset($_GET['perpage']) ? (int)$_GET['perpage'] : $pref['forum_postspage']);
$this->page = (varset($_GET['p']) ? (int)$_GET['p'] : 1); $this->page = (varset($_GET['p']) ? (int)$_GET['p'] : 0);
//If threadId doesn't exist, or not given, redirect to main forum page //If threadId doesn't exist, or not given, redirect to main forum page
if (!$this->threadId || !$this->threadInfo = $forum->threadGet($this->threadId)) if (!$this->threadId || !$this->threadInfo = $forum->threadGet($this->threadId))
@@ -468,6 +470,7 @@ class e107ForumThread
header('Location:' . $e107->url->getUrl('forum', 'forum', array('func' => 'main'))); header('Location:' . $e107->url->getUrl('forum', 'forum', array('func' => 'main')));
exit; exit;
} }
$this->pages = ceil(($this->threadInfo['thread_total_replies'] + 1) / $this->perPage);
$this->noInc = false; $this->noInc = false;
} }
@@ -510,17 +513,18 @@ class e107ForumThread
$postId = varset($_GET['id']); $postId = varset($_GET['id']);
$postInfo = $forum->postGet($postId,'post'); $postInfo = $forum->postGet($postId,'post');
$postNum = $forum->postGetPostNum($postInfo['post_thread'], $postId); $postNum = $forum->postGetPostNum($postInfo['post_thread'], $postId);
$postPage = ceil($postNum / $pref['forum_postspage']); $postPage = ceil($postNum / $pref['forum_postspage'])-1;
$url = $e107->url->getUrl('forum', 'thread', "func=view&id={$postInfo['post_thread']}&page=$postPage"); $url = $e107->url->getUrl('forum', 'thread', "func=view&id={$postInfo['post_thread']}&page=$postPage");
// echo "url: $url <br />";
header('location: '.$url); header('location: '.$url);
exit; exit;
break; break;
case 'last': case 'last':
// $pref['forum_postspage'] = ($pref['forum_postspage'] ? $pref['forum_postspage'] : 10); // $pref['forum_postspage'] = ($pref['forum_postspage'] ? $pref['forum_postspage'] : 10);
$pages = ceil(($this->threadInfo['thread_total_replies'] + 1) / $this->perPage); // var_dump($thread);
$this->page = ($pages - 1) * $this->perPage; $pages = ceil(($thread->threadInfo['thread_total_replies'] + 1) / $thread->perPage);
echo "pages = $pages<br />";
$thread->page = ($pages - 1);
break; break;
case 'next': case 'next':