From 97ab0f6a93437f99b6c9d7a742cf91f57e7ae543 Mon Sep 17 00:00:00 2001 From: mcfly Date: Sun, 14 Dec 2008 03:18:45 +0000 Subject: [PATCH] Working on breadcrumb, almost there --- e107_files/shortcode/nextprev.sc | 82 ++++++++++++++++--------- e107_plugins/forum/e_url/thread.php | 4 +- e107_plugins/forum/forum_class.php | 85 +++++++++++++------------- e107_plugins/forum/forum_viewforum.php | 37 ++++------- e107_plugins/forum/forum_viewtopic.php | 26 ++++---- 5 files changed, 124 insertions(+), 110 deletions(-) diff --git a/e107_files/shortcode/nextprev.sc b/e107_files/shortcode/nextprev.sc index d3d309f7c..d56b80933 100644 --- a/e107_files/shortcode/nextprev.sc +++ b/e107_files/shortcode/nextprev.sc @@ -1,31 +1,29 @@ - global $pref; +$e107 = e107::getInstance(); -@include_once(e_LANGUAGEDIR.e_LANGUAGE."/lan_np.php"); -@include_once(e_LANGUAGEDIR."English/lan_np.php"); - -$parm_count = substr_count($parm, ","); +include_lan(e_LANGUAGEDIR.'English/lan_np.php'); +$parm_count = substr_count($parm, ','); while($parm_count < 5) { - $parm .= ","; + $parm .= ','; $parm_count++; } -$p = explode(",", $parm, 6); +$p = explode(',', $parm, 6); $total_items = intval($p[0]); $perpage = intval($p[1]); $current_start = intval($p[2]); $url = trim($p[3]); $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." " : $caption; +$caption = (!$caption || $caption == 'off') ? NP_3.' ' : $caption; -while(substr($url, -1) == ".") +while(substr($url, -1) == '.') { $url=substr($url, 0, -1); } @@ -35,16 +33,16 @@ $total_pages = ceil($total_items/$perpage); if($total_pages > 1) { - if(isset($pref['old_np']) && $pref['old_np']) + if(varsettrue($pref['old_np'])) { - $NP_PRE_ACTIVE = ""; - $NP_POST_ACTIVE = ""; - $NP_STYLE = ""; + $NP_PRE_ACTIVE = ''; + $NP_POST_ACTIVE = ''; + $NP_STYLE = ''; - if(!defined("NEXTPREV_NOSTYLE") || NEXTPREV_NOSTYLE==FALSE){ - $NP_PRE_ACTIVE = "["; - $NP_POST_ACTIVE = "] "; + if(!defined('NEXTPREV_NOSTYLE') || NEXTPREV_NOSTYLE==FALSE){ + $NP_PRE_ACTIVE = '['; + $NP_POST_ACTIVE = '] '; $NP_STYLE = "style='text-decoration:underline'"; } @@ -147,8 +145,8 @@ if($total_pages > 1) // Use NEW nextprev method $np_parm['template'] = "[PREV]  [DROPDOWN]  [NEXT]"; - $np_parms['prev'] = "  <<  "; - $np_parms['next'] = "  >>  "; + $np_parms['prev'] = '  <<  '; + $np_parms['next'] = '  >>  '; $np_parms['np_class'] = 'tbox npbutton'; $np_parms['dropdown_class'] = 'tbox npdropdown'; @@ -161,39 +159,67 @@ if($total_pages > 1) } } - $prev=""; - $next=""; + $prev=''; + $next=''; if($current_page > 1) { $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 = "{$np_parms['prev']}"; } if($current_page < $total_pages) { $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 = "{$np_parms['next']}"; } $dropdown = ""; + $dropdown .= ''; $ret = $np_parm['template']; $ret = str_replace('[DROPDOWN]', $dropdown, $ret); $ret = str_replace('[PREV]', $prev, $ret); $ret = str_replace('[NEXT]', $next, $ret); return $caption.$ret; } -return ""; +return ''; diff --git a/e107_plugins/forum/e_url/thread.php b/e107_plugins/forum/e_url/thread.php index 6233d5389..390807ff3 100644 --- a/e107_plugins/forum/e_url/thread.php +++ b/e107_plugins/forum/e_url/thread.php @@ -1,5 +1,5 @@ threadInfo; } +// var_dump($forumInfo); +// var_dump($thread); + if(is_array($FORUM_CRUMB)) { - $search = array("{SITENAME}", "{SITENAME_HREF}"); - $replace = array(SITENAME, "href='".e_BASE."index.php'"); + $search = array('{SITENAME}', '{SITENAME_HREF}'); + $replace = array(SITENAME, "href='".$e107->url->getUrl('core:core', 'main', 'action=index')."'"); $FORUM_CRUMB['sitename']['value'] = str_replace($search, $replace, $FORUM_CRUMB['sitename']['value']); - $search = array("{FORUMS_TITLE}", "{FORUMS_HREF}"); - $replace = array(LAN_01, "href='".e_PLUGIN."forum/forum.php'"); + $search = array('{FORUMS_TITLE}', '{FORUMS_HREF}'); + $replace = array(LAN_01, "href='".$e107->url->getUrl('forum', 'forum', 'func=main')."'"); $FORUM_CRUMB['forums']['value'] = str_replace($search, $replace, $FORUM_CRUMB['forums']['value']); - $search = "{PARENT_TITLE}"; - $replace = $tp->toHTML($forum_info['parent_name']); + $search = '{PARENT_TITLE}'; + $replace = $e107->tp->toHTML($forumInfo['parent_name']); $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}"); - $forum_sub_parent = (substr($forum_info['sub_parent'], 0, 1) == "*" ? substr($forum_info['sub_parent'], 1) : $forum_info['sub_parent']); - $replace = array($forum_sub_parent, "href='".e_PLUGIN."forum/forum_viewforum.php?{$forum_info['forum_sub']}'"); + $search = array('{SUBPARENT_TITLE}', '{SUBPARENT_HREF}'); + $replace = array(ltrim($forumInfo['sub_parent'], '*'), "href='".$e107->url->getUrl('forum', 'forum', "func=view&id={$forumInfo['forum_sub']}")."'"); $FORUM_CRUMB['subparent']['value'] = str_replace($search, $replace, $FORUM_CRUMB['subparent']['value']); } else { - $FORUM_CRUMB['subparent']['value'] = ""; + $FORUM_CRUMB['subparent']['value'] = ''; } - $search = array("{FORUM_TITLE}", "{FORUM_HREF}"); - $tmpFname = $forum_info['forum_name']; - if(substr($tmpFname, 0, 1) == "*") { $tmpFname = substr($tmpFname, 1); } - $replace = array($tmpFname,"href='".e_PLUGIN."forum/forum_viewforum.php?{$forum_info['forum_id']}'"); + $search = array('{FORUM_TITLE}', '{FORUM_HREF}'); + $replace = array(ltrim($forumInfo['forum_name'], '*'),"href='".$e107->url->getUrl('forum', 'forum', "func=view&id={$forumInfo['forum_id']}")."'"); $FORUM_CRUMB['forum']['value'] = str_replace($search, $replace, $FORUM_CRUMB['forum']['value']); - if(strlen($thread_title)) - { - $search = array("{THREAD_TITLE}"); - $replace = array($thread_title); - $FORUM_CRUMB['thread']['value'] = str_replace($search, $replace, $FORUM_CRUMB['thread']['value']); - } - else - { - $FORUM_CRUMB['thread']['value'] = ""; - } - - $FORUM_CRUMB['fieldlist'] = "sitename,forums,parent,subparent,forum,thread"; - $BREADCRUMB = $tp->parseTemplate("{BREADCRUMB=FORUM_CRUMB}", true); + $search = array('{THREAD_TITLE}'); + $replace = array($thread->threadInfo['thread_name']); + $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 { - $dfltsep = " :: "; + $dfltsep = ' :: '; $BREADCRUMB = "".SITENAME."".$dfltsep."".LAN_01."".$dfltsep; 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 .= "{$forum_sub_parent}".$dfltsep; } @@ -1448,35 +1447,35 @@ function img_path($filename) { 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; - 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 { - if(defined("IMODE")) + if(defined('IMODE')) { 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 { - $image = e_PLUGIN."forum/images/".IMODE."/".$filename; + $image = e_PLUGIN.'forum/images/'.IMODE.'/'.$filename; } } else { 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 { - $image = e_PLUGIN."forum/images/lite/".$filename; + $image = e_PLUGIN.'forum/images/lite/'.$filename; } } @@ -1492,7 +1491,7 @@ if (file_exists(THEME.'forum/forum_icons_template.php')) { require_once(THEME.'forum/forum_icons_template.php'); } -else if (file_exists(THEME.'forum_icons_template.php')) +elseif (file_exists(THEME.'forum_icons_template.php')) { require_once(THEME.'forum_icons_template.php'); } diff --git a/e107_plugins/forum/forum_viewforum.php b/e107_plugins/forum/forum_viewforum.php index 7d940d289..70050ff20 100644 --- a/e107_plugins/forum/forum_viewforum.php +++ b/e107_plugins/forum/forum_viewforum.php @@ -9,8 +9,8 @@ * View specific forums * * $Source: /cvs_backup/e107_0.8/e107_plugins/forum/forum_viewforum.php,v $ -* $Revision: 1.8 $ -* $Date: 2008-12-12 03:36:39 $ +* $Revision: 1.9 $ +* $Date: 2008-12-14 03:18:45 $ * $Author: mcfly_e107 $ * */ @@ -33,20 +33,6 @@ if (!e_QUERY) $view = 25; $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'); $forum = new e107forum; @@ -68,6 +54,8 @@ if (!$forum->checkPerm($forumId, 'view')) $forumInfo = $forum->forum_get($forumId); +//var_dump($forumInfo); + if (!$FORUM_VIEW_START) { if (file_exists(THEME.'forum_viewforum_template.php')) @@ -239,11 +227,6 @@ if(is_array($sub_list)) if (count($threadList) ) { -// foreach($threadList as $thread_info) -// { -// $idArray[] = $thread_info['thread_id']; -// } -// $inList = '('.implode(',', $idArray).')'; foreach($threadList as $thread_info) { if($thread_info['thread_options']) @@ -294,7 +277,6 @@ else $forum_view_forum .= "".LAN_58.""; } -//$sql->db_Select('forum', '*', "forum_parent !=0 AND forum_class != '255' "); $FORUMJUMP = forumjump(); $TOPLINK = "".LAN_02.''; @@ -428,13 +410,15 @@ function parse_thread($thread_info) for($a = 0; $a <= 2; $a++) { $PAGES .= $PAGES ? ' ' : ''; - $PAGES .= "".($a+1).""; + $url = $e107->url->getUrl('forum', 'thread', "func=view&id={$thread_info['thread_id']}&page={$a}"); + $PAGES .= "".($a+1).''; } $PAGES .= ' ... '; for($a = $pages-3; $a <= $pages-1; $a++) { - $PAGES .= $PAGES ? " " : ""; - $PAGES .= "".($a+1).""; + $PAGES .= $PAGES ? ' ' : ''; + $url = $e107->url->getUrl('forum', 'thread', "func=view&id={$thread_info['thread_id']}&page={$a}"); + $PAGES .= "".($a+1).''; } } else @@ -442,7 +426,8 @@ function parse_thread($thread_info) for($a = 0; $a <= ($pages-1); $a++) { $PAGES .= $PAGES ? ' ' : ''; - $PAGES .= "".($a+1).""; + $url = $e107->url->getUrl('forum', 'thread', "func=view&id={$thread_info['thread_id']}&page={$a}"); + $PAGES .= "".($a+1).''; } } $PAGES = LAN_316.' [ '.$PAGES.' ]'; diff --git a/e107_plugins/forum/forum_viewtopic.php b/e107_plugins/forum/forum_viewtopic.php index e3306b9e9..27611fb7b 100644 --- a/e107_plugins/forum/forum_viewtopic.php +++ b/e107_plugins/forum/forum_viewtopic.php @@ -12,8 +12,8 @@ | GNU General Public License (http://gnu.org). | | $Source: /cvs_backup/e107_0.8/e107_plugins/forum/forum_viewtopic.php,v $ -| $Revision: 1.14 $ -| $Date: 2008-12-13 21:52:18 $ +| $Revision: 1.15 $ +| $Date: 2008-12-14 03:18:45 $ | $Author: mcfly_e107 $ +----------------------------------------------------------------------------+ */ @@ -59,7 +59,7 @@ if(isset($_POST['track_toggle'])) if(isset($_GET['f'])) { $thread->processFunction(); - $thread->init(); + if($_GET['f'] != 'last') { $thread->init(); } } require_once (e_PLUGIN . 'forum/forum_shortcodes.php'); @@ -84,7 +84,7 @@ if (MODERATOR && isset($_POST['mod'])) $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); 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); +//echo "pages = {$thread->pages}
"; +//var_dump($thread); 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}}"); } @@ -445,7 +447,7 @@ function rpg($user_join, $user_forums) class e107ForumThread { - var $message, $threadId, $threadInfo, $forumId, $perPage, $noInc; + var $message, $threadId, $threadInfo, $forumId, $perPage, $noInc, $pages; function init() { @@ -453,7 +455,7 @@ class e107ForumThread $e107 = e107::getInstance(); $this->threadId = (int)varset($_GET['id']); $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 (!$this->threadId || !$this->threadInfo = $forum->threadGet($this->threadId)) @@ -468,6 +470,7 @@ class e107ForumThread header('Location:' . $e107->url->getUrl('forum', 'forum', array('func' => 'main'))); exit; } + $this->pages = ceil(($this->threadInfo['thread_total_replies'] + 1) / $this->perPage); $this->noInc = false; } @@ -510,17 +513,18 @@ class e107ForumThread $postId = varset($_GET['id']); $postInfo = $forum->postGet($postId,'post'); $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"); -// echo "url: $url
"; header('location: '.$url); exit; break; case 'last': // $pref['forum_postspage'] = ($pref['forum_postspage'] ? $pref['forum_postspage'] : 10); - $pages = ceil(($this->threadInfo['thread_total_replies'] + 1) / $this->perPage); - $this->page = ($pages - 1) * $this->perPage; +// var_dump($thread); + $pages = ceil(($thread->threadInfo['thread_total_replies'] + 1) / $thread->perPage); + echo "pages = $pages
"; + $thread->page = ($pages - 1); break; case 'next':