From 5cb899f8af1e57a73d4b58f5294bee43b4e7d379 Mon Sep 17 00:00:00 2001 From: Cameron Date: Tue, 12 Mar 2013 04:22:09 -0700 Subject: [PATCH] Forum template work. --- e107_core/shortcodes/single/breadcrumb.sc | 17 ++ e107_handlers/date_handler.php | 6 +- e107_handlers/e_ranks_class.php | 8 +- e107_plugins/forum/forum.php | 36 ++++ e107_plugins/forum/forum_class.php | 1 + e107_plugins/forum/forum_post.php | 2 +- e107_plugins/forum/forum_viewforum.php | 190 +++++++++++++++++- e107_plugins/forum/forum_viewtopic.php | 84 +++++++- .../shortcodes/batch/view_shortcodes.php | 71 ++++++- .../forum/templates/forum_template.php | 56 ++++++ .../templates/forum_viewforum_template.php | 66 ++++++ .../templates/forum_viewtopic_template.php | 100 +++++++++ e107_web/css/e107.css | 2 + 13 files changed, 617 insertions(+), 22 deletions(-) diff --git a/e107_core/shortcodes/single/breadcrumb.sc b/e107_core/shortcodes/single/breadcrumb.sc index 51f09f5ec..776d30c2d 100755 --- a/e107_core/shortcodes/single/breadcrumb.sc +++ b/e107_core/shortcodes/single/breadcrumb.sc @@ -1,3 +1,5 @@ +// + +
  • Home /
  • +
  • Library /
  • +
  • Data
  • + '; +} + + return $ret; \ No newline at end of file diff --git a/e107_handlers/date_handler.php b/e107_handlers/date_handler.php index faaa34060..4b7e6b725 100644 --- a/e107_handlers/date_handler.php +++ b/e107_handlers/date_handler.php @@ -494,10 +494,12 @@ class convert { if (($i > 4) || ($result[$i] != 0)) { // Only show non-zero values, except always show minutes/seconds - $outputArray[] = $result[$i]." ".($result[$i] == 1 ? $params[$i][2] : $params[$i][3]); + $outputArray[] = $result[$i]." ".($result[$i] == 1 ? $params[$i][2] : $params[$i][3]) ; + + if($format == 'short' && $i == 1) { break; } } } - return ($mode ? $outputArray : implode(", ", $outputArray)); + return ($mode ? $outputArray : implode(", ", $outputArray) . " ago"); //XXX LAN } diff --git a/e107_handlers/e_ranks_class.php b/e107_handlers/e_ranks_class.php index bc104a2c8..ca288aaa7 100644 --- a/e107_handlers/e_ranks_class.php +++ b/e107_handlers/e_ranks_class.php @@ -218,16 +218,19 @@ class e_ranks { //Main Site Admin $data['special'] = "".$this->_getName($this->ranks["; + $data['name'] = $this->_getName($this->ranks['special'][1]); } else { //Site Admin $data['special'] = "".$this->_getName($this->ranks["; + $data['name'] = $this->_getName($this->ranks['special'][2]); } } elseif($moderator) { $data['special'] = "".$this->_getName($this->ranks["; + $data['name'] = $this->_getName($this->ranks['special'][3]); } $userData['user_daysregged'] = max(1, round((time() - $userData['user_join']) / 86400)); @@ -256,7 +259,10 @@ class e_ranks } if($rank !== false) { - $data['name'] = $this->_getName($this->ranks['data'][$rank]); + if(!isset($data['name'])) + { + $data['name'] = $this->_getName($this->ranks['data'][$rank]); + } $img_title = ($this->ranks['data'][$rank]['name'] ? " alt='{$data['name']}' title='{$data['name']}'" : ' alt = ""'); $data['pic'] = ""; } diff --git a/e107_plugins/forum/forum.php b/e107_plugins/forum/forum.php index d4b11dc71..2501a5bae 100644 --- a/e107_plugins/forum/forum.php +++ b/e107_plugins/forum/forum.php @@ -211,6 +211,28 @@ if (!isset($FORUM_MAIN_START)) } } include(e_PLUGIN.'forum/templates/forum_template.php'); + + +if(is_array($FORUM_TEMPLATE)) // new v2.x format. +{ + + $FORUM_MAIN_START = $FORUM_TEMPLATE['main-start']; + $FORUM_MAIN_PARENT = $FORUM_TEMPLATE['main-parent']; + $FORUM_MAIN_FORUM = $FORUM_TEMPLATE['main-forum']; + $FORUM_MAIN_END = $FORUM_TEMPLATE['main-end']; + + $FORUM_NEWPOSTS_START = $FORUM_TEMPLATE['main-start']; // $FORUM_TEMPLATE['new-start']; + $FORUM_NEWPOSTS_MAIN = $FORUM_TEMPLATE['main-forum']; // $FORUM_TEMPLATE['new-main']; + $FORUM_NEWPOSTS_END = $FORUM_TEMPLATE['main-end']; // $FORUM_TEMPLATE['new-end']; + + $FORUM_TRACK_START = $FORUM_TEMPLATE['main-start']; // $FORUM_TEMPLATE['track-start']; + $FORUM_TRACK_MAIN = $FORUM_TEMPLATE['main-forum']; // $FORUM_TEMPLATE['track-main']; + $FORUM_TRACK_END = $FORUM_TEMPLATE['main-end']; // $FORUM_TEMPLATE['track-end']; + +} + + + require_once(HEADERF); $forumList = $forum->forumGetForumList(); @@ -306,6 +328,15 @@ function parse_forum($f, $restricted_string = '') $fVars->THREADS = $f['forum_threads']; $fVars->REPLIES = $f['forum_replies']; $fVars->FORUMSUBFORUMS = ''; + + + $badgeReplies = ($f['forum_replies']) ? "badge-info" : ""; + $badgeThreads = ($f['forum_threads']) ? "badge-info" : ""; + + $fVars->THREADSX = "".$f['forum_threads'].""; + $fVars->REPLIESX = "".$f['forum_replies'].""; + + if(is_array($forumList['subs'][$f['forum_id']])) { @@ -335,11 +366,16 @@ function parse_forum($f, $restricted_string = '') { $lastpost_name = $e107->tp->toHTML($f['forum_lastpost_user_anon']); } + $fVars->LASTPOSTUSER = $lastpost_name; + $fVars->LASTPOSTDATE .= $gen->computeLapse($lastpost_datestamp, time(), false, false, 'short'); $lastpost_datestamp = $gen->convert_date($lastpost_datestamp, 'forum'); $fVars->LASTPOST = $lastpost_datestamp.'
    '.$lastpost_name." $lastpost_name, 'id' => $lastpost_thread))."'>".IMAGE_post2.''; + } else { + $fVars->LASTPOSTUSER = ""; + $fVars->LASTPOSTDATE = "-"; $fVars->LASTPOST = '-'; } return $e107->tp->simpleParse($FORUM_MAIN_FORUM, $fVars); diff --git a/e107_plugins/forum/forum_class.php b/e107_plugins/forum/forum_class.php index 17ad3b28e..88ec26cd1 100644 --- a/e107_plugins/forum/forum_class.php +++ b/e107_plugins/forum/forum_class.php @@ -1202,6 +1202,7 @@ class e107forum $FORUM_CRUMB['thread']['value'] = str_replace($search, $replace, $FORUM_CRUMB['thread']['value']); $FORUM_CRUMB['fieldlist'] = 'sitename,forums,parent,subparent,forum,thread'; + // $FORUM_CRUMB['style'] = 'bootstrap'; $BREADCRUMB = $e107->tp->parseTemplate('{BREADCRUMB=FORUM_CRUMB}', true); } else diff --git a/e107_plugins/forum/forum_post.php b/e107_plugins/forum/forum_post.php index e52513786..709dc26ac 100644 --- a/e107_plugins/forum/forum_post.php +++ b/e107_plugins/forum/forum_post.php @@ -513,7 +513,7 @@ $text = $tp->parseTemplate($FORUMPOST, true); // ------------------------------------------------------------------------------------------------------------------------------------------------------------- -if ($forum->prefs->get('forum_enclose')) +if ($forum->prefs->get('enclose')) { $ns->tablerender($forum->prefs->get('title'), $text); } diff --git a/e107_plugins/forum/forum_viewforum.php b/e107_plugins/forum/forum_viewforum.php index 72ea4317e..7247aeb44 100644 --- a/e107_plugins/forum/forum_viewforum.php +++ b/e107_plugins/forum/forum_viewforum.php @@ -80,6 +80,27 @@ if (!vartrue($FORUM_VIEW_START)) } } + +if(is_array($FORUMVIEW_TEMPLATE)) // New Template. +{ + +$FORUM_VIEW_START_CONTAINER = $FORUMVIEW_TEMPLATE['start']; +$FORUM_VIEW_START = $FORUMVIEW_TEMPLATE['header']; +$FORUM_VIEW_FORUM = $FORUMVIEW_TEMPLATE['item']; +$FORUM_VIEW_FORUM_STICKY = $FORUMVIEW_TEMPLATE['item-sticky']; +$FORUM_VIEW_FORUM_ANNOUNCE = $FORUMVIEW_TEMPLATE['item-announce']; +$FORUM_VIEW_END = $FORUMVIEW_TEMPLATE['footer']; +$FORUM_VIEW_END_CONTAINER = $FORUMVIEW_TEMPLATE['end']; +$FORUM_VIEW_SUB_START = $FORUMVIEW_TEMPLATE['sub-header']; +$FORUM_VIEW_SUB = $FORUMVIEW_TEMPLATE['sub-item']; +$FORUM_VIEW_SUB_END = $FORUMVIEW_TEMPLATE['sub-footer']; +$FORUM_IMPORTANT_ROW = $FORUMVIEW_TEMPLATE['divider-important']; +$FORUM_NORMAL_ROW = $FORUMVIEW_TEMPLATE['divider-normal']; + +} + + + $forumInfo['forum_name'] = $e107->tp->toHTML($forumInfo['forum_name'], true, 'no_hook, emotes_off'); $forumInfo['forum_description'] = $e107->tp->toHTML($forumInfo['forum_description'], true, 'no_hook'); @@ -156,6 +177,7 @@ if ($pages) if($forum->checkPerm($forumId, 'post')) { $fVars->NEWTHREADBUTTON = " $forumId))."'>".IMAGE_newthread.''; + $fVars->NEWTHREADBUTTONX = newthreadjump($e107->url->create('forum/thread/new', array('id' => $forumId))); // "New Thread"; } if(substr($forumInfo['forum_name'], 0, 1) == '*') @@ -209,12 +231,12 @@ $fVars->ICONKEY = " "; $fVars->SEARCH = " -
    +

    + - - +

    "; @@ -313,10 +335,9 @@ if($container_only) $forum_view_start = $tp->simpleParse($FORUM_VIEW_START, $fVars); $forum_view_end = $tp->simpleParse($FORUM_VIEW_END, $fVars); - -if ($forum->prefs->get('forum_enclose')) -{ - $ns->tablerender($forum->prefs->get('forum_title'), $forum_view_start.$forum_view_subs.$forum_view_forum.$forum_view_end, array('forum_viewforum', 'main1')); +if ($forum->prefs->get('enclose')) +{ + $ns->tablerender($forum->prefs->get('title'), $forum_view_start.$forum_view_subs.$forum_view_forum.$forum_view_end, array('forum_viewforum', 'main1')); } else { @@ -346,6 +367,11 @@ function parse_thread($thread_info) $tVars->VIEWS = $thread_info['thread_views']; $tVars->REPLIES = $thread_info['thread_total_replies']; + + $badge = ($thread_info['thread_views'] > 0) ? "badge-info" : ""; + + $tVars->REPLIESX = "".$thread_info['thread_total_replies'].""; + $tVars->VIEWSX = "".$thread_info['thread_views'].""; if ($tVars->REPLIES) { @@ -355,24 +381,31 @@ function parse_thread($thread_info) // XXX hopefully & is not allowed in user name - it would break parsing of url parameters, change to array if something wrong happens $url = $e107->url->create('user/profile/view', "name={$thread_info['lastpost_username']}&id={$thread_info['thread_lastuser']}"); $tVars->LASTPOST = "".$thread_info['lastpost_username'].""; + $tVars->LASTPOSTUSER = "".$thread_info['lastpost_username'].""; } else { if(!$thread_info['thread_lastuser']) { $tVars->LASTPOST = $e107->tp->toHTML($thread_info['thread_lastuser_anon']); + $tVars->LASTPOSTUSER = $e107->tp->toHTML($thread_info['thread_lastuser_anon']); } else { $tVars->LASTPOST = FORLAN_19; + $tVars->LASTPOSTUSER = FORLAN_19; } } $tVars->LASTPOST .= '
    '.$lastpost_datestamp; + $tVars->LASTPOSTDATE .= $gen->computeLapse($thread_info['thread_lastpost'],time(), false, false, 'short'); } $newflag = (USER && $thread_info['thread_lastpost'] > USERLV && !in_array($thread_info['thread_id'], $threadsViewed)); $tVars->THREADDATE = $gen->convert_date($thread_info['thread_datestamp'], 'forum'); + + $tVars->THREADTIMELAPSE = $gen->computeLapse($thread_info['thread_datestamp'],time(), false, false, 'short'); // convert_date($thread_info['thread_datestamp'], 'forum'); + $tVars->ICON = ($newflag ? IMAGE_new : IMAGE_nonew); if ($tVars->REPLIES >= $forum->prefs->get('popular', 10)) { @@ -463,6 +496,8 @@ function parse_thread($thread_info) { $tVars->PAGES = ''; } + + $tVars->PAGESX = fpages($thread_info, $tVars->REPLIES); if (MODERATOR) { @@ -477,6 +512,8 @@ function parse_thread($thread_info) ".IMAGE_admin_move.' '; + + $tVars->ADMINOPTIONS = fadminoptions($thread_info); } $text .= " @@ -502,7 +539,9 @@ function parse_thread($thread_info) if (!$tVars->REPLIES) { $tVars->REPLIES = LAN_317; // 'None' + $tVars->REPLIESX = "0"; $tVars->LASTPOST = ' - '; + $tVars->LASTPOSTDATE = ' - '; } switch($thread_info['thread_sticky']) @@ -533,6 +572,16 @@ function parse_sub($subInfo) $tVars->SUB_DESCRIPTION = $e107->tp->toHTML($subInfo['forum_description'], false, 'no_hook'); $tVars->SUB_THREADS = $subInfo['forum_threads']; $tVars->SUB_REPLIES = $subInfo['forum_replies']; + + $badgeReplies = ($subInfo['forum_replies']) ? "badge-info" : ""; + $badgeThreads = ($subInfo['forum_replies']) ? "badge-info" : ""; + + $tVars->SUB_THREADSX = "".$subInfo['forum_threads'].""; + $tVars->SUB_REPLIESX = "".$subInfo['forum_replies'].""; + +// $tVars->REPLIESX = "".$thread_info['thread_total_replies'].""; +// $tVars->VIEWSX = "".$thread_info['thread_views'].""; + if(USER && is_array($newflag_list) && in_array($subInfo['forum_id'], $newflag_list)) { @@ -579,4 +628,131 @@ function forumjump() return $text; } + +function fadminoptions($thread_info) +{ + $tVars = new e_vars; + $e107 = e107::getInstance(); + +// $text = "
    "; + $text .= '
    +
    "; +// $text .= "
    "; + return $text; +} + + +function fpages($thread_info, $replies) +{ + global $forum; + + $pages = ceil(($replies)/$forum->prefs->get('postspage')); + $urlparms = $thread_info; + + if ($pages > 1) + { + if($pages > 6) + { + for($a = 0; $a <= 2; $a++) + { + $aa = $a + 1; + $text .= $text ? ' ' : ''; + $urlparms['page'] = $aa; + $url = e107::getUrl()->create('forum/thread/view', $urlparms); + $opts[] = "{$aa}"; + } + $text .= ' ... '; + for($a = $pages-3; $a <= $pages-1; $a++) + { + $aa = $a + 1; + $text .= $text ? ' ' : ''; + $urlparms['page'] = $aa; + $url = e107::getUrl()->create('forum/thread/view', $urlparms); + $opts[] = "{$aa}"; + } + } + else + { + for($a = 0; $a <= ($pages-1); $a++) + { + $aa = $a + 1; + $text .= $text ? ' ' : ''; + $urlparms['page'] = $aa; + $url = e107::getUrl()->create('forum/thread/view', $urlparms); + $opts[] = "{$aa}"; + } + } + + + $text = implode("",$opts); // .""; + + } + else + { + $text = ''; + } + + + + + + + return $text; +} + + + + + +function newthreadjump($url) +{ + global $forum; + $jumpList = $forum->forumGetAllowed('view'); + $text = '
    + New Thread + + +
    '; + + return $text; + +} + ?> \ No newline at end of file diff --git a/e107_plugins/forum/forum_viewtopic.php b/e107_plugins/forum/forum_viewtopic.php index be2337f50..0d7286f99 100644 --- a/e107_plugins/forum/forum_viewtopic.php +++ b/e107_plugins/forum/forum_viewtopic.php @@ -154,6 +154,19 @@ if (!vartrue($FORUMSTART)) } } + +// New in v2.x +if(is_array($FORUMTOPIC_TEMPLATE)) +{ + $FORUMSTART = $FORUMTOPIC_TEMPLATE['start']; + $FORUMTHREADSTYLE = $FORUMTOPIC_TEMPLATE['thread']; + $FORUMEND = $FORUMTOPIC_TEMPLATE['end']; + $FORUMREPLYSTYLE = $FORUMTOPIC_TEMPLATE['replies']; +} + + + + // get info for main thread ------------------------------------------------------------------------------------------------------------------------------------------------------------------- $tVars = new e_vars; $forum->set_crumb(true, '', $tVars); // Set $BREADCRUMB (and BACKLINK) @@ -161,9 +174,9 @@ $forum->set_crumb(true, '', $tVars); // Set $BREADCRUMB (and BACKLINK) //$tVars->BACKLINK = $tVars->BREADCRUMB; //$tVars->FORUM_CRUMB = $crumbs['forum_crumb']; $tVars->THREADNAME = $e107->tp->toHTML($thread->threadInfo['thread_name'], true, 'no_hook, emotes_off'); -$tVars->NEXTPREV = "<< $thread->threadId)) . "'>" . LAN_389 . ""; -$tVars->NEXTPREV .= ' | '; -$tVars->NEXTPREV .= " $thread->threadId)) . "'>" . LAN_390 . " >>"; +$tVars->NEXTPREV = " $thread->threadId)) . "'>« " . LAN_389 . ""; +// $tVars->NEXTPREV .= ' | '; +$tVars->NEXTPREV .= " $thread->threadId)) . "'>" . LAN_390 . " »"; if ($forum->prefs->get('track') && USER) { @@ -171,7 +184,7 @@ if ($forum->prefs->get('track') && USER) $url = $e107->url->create('forum/thread/view', array('id' => $thread->threadId), 'encode=0'); // encoding could break AJAX call $tVars->TRACK .= " - {$img} + {$img}