From 3001462e7be52640220de7433f345313add4840e Mon Sep 17 00:00:00 2001 From: Cameron <e107inc@gmail.com> Date: Fri, 22 Sep 2017 12:47:37 -0700 Subject: [PATCH] #2785 NewForumPosts Menu shortcode fixes. --- e107_plugins/forum/newforumposts_menu.php | 6 +- .../shortcodes/batch/view_shortcodes.php | 70 +++++++++++++++++-- .../templates/newforumposts_menu_template.php | 4 +- 3 files changed, 69 insertions(+), 11 deletions(-) diff --git a/e107_plugins/forum/newforumposts_menu.php b/e107_plugins/forum/newforumposts_menu.php index 6c2e9f27f..574f634f4 100755 --- a/e107_plugins/forum/newforumposts_menu.php +++ b/e107_plugins/forum/newforumposts_menu.php @@ -48,12 +48,14 @@ if(!class_exists('forum_newforumposts_menu')) p.post_user, p.post_id, p.post_datestamp, p.post_user_anon, p.post_entry, t.*, u.user_id, u.user_name, u.user_image, u.user_currentvisit, + lu.user_name as thread_lastuser_username, f.forum_name, f.forum_sef FROM `#forum_post` as p LEFT JOIN `#forum_thread` AS t ON t.thread_id = p.post_thread LEFT JOIN `#forum` as f ON f.forum_id = t.thread_forum_id LEFT JOIN `#user` AS u ON u.user_id = p.post_user + LEFT JOIN `#user` AS lu ON t.thread_lastuser = lu.user_id WHERE {$max_age} p.post_forum IN ({$forumList}) ORDER BY p.post_datestamp DESC LIMIT 0, ".vartrue($this->menuPref['display'],10); @@ -83,7 +85,7 @@ if(!class_exists('forum_newforumposts_menu')) $layout = 'default'; } - if(!empty($this->menuPref['layout']))//@todo e_menu add 'layout' dropdown. + if(!empty($this->menuPref['layout'])) // @see e_menu { $layout = $this->menuPref['layout']; } @@ -190,7 +192,7 @@ if(!class_exists('forum_newforumposts_menu')) - $list .= $tp->parseTemplate($template['end'], true); + $list .= $tp->parseTemplate($template['end'], true, $sc); $text = $list; diff --git a/e107_plugins/forum/shortcodes/batch/view_shortcodes.php b/e107_plugins/forum/shortcodes/batch/view_shortcodes.php index 8e4a17167..3245c7bee 100644 --- a/e107_plugins/forum/shortcodes/batch/view_shortcodes.php +++ b/e107_plugins/forum/shortcodes/batch/view_shortcodes.php @@ -39,6 +39,8 @@ * Only by nfp menu at this time. */ + // @todo new post shortcodes + function sc_post_url($parm=null) { $url = e107::url('forum', 'topic', $this->var, array( @@ -81,13 +83,14 @@ return $this->sc_avatar($parm); } - // thread/topic + // @todo new thread/topic shortcodes function sc_topic_name($parm=null) { return $this->sc_threadname($parm); } + function sc_topic_url($parm=null) { return e107::url('forum', 'topic', $this->var); @@ -109,11 +112,69 @@ function sc_topic_lastpost_date($parm=null) { + $mode = empty($parm['format']) ? 'forum' : $parm['format']; + return e107::getParser()->toDate($this->var['thread_lastpost'], $mode); + } + function sc_topic_lastpost_author($parm=null) + { + if($this->var['thread_views'] || $this->var['thread_total_replies'] > 0) + { + + if($this->var['thread_lastuser_username']) + { + $url = e107::getUrl()->create('user/profile/view', "name={$this->var['thread_lastuser_username']}&id={$this->var['thread_lastuser']}"); + return "<a href='{$url}'>" . $this->var['thread_lastuser_username'] . "</a>"; + } + elseif($this->var['thread_lastuser_anon']) + { + return e107::getParser()->toHTML($this->var['thread_lastuser_anon']); + } + else + { + return LAN_FORUM_1015; + + } + } + } - // forum + + function sc_topic_icon($parm=null) + { + + $newflag = (USER && $this->var['thread_lastpost'] > USERLV && !in_array($this->var['thread_id'], $this->forum->threadGetUserViewed())); + + $ICON = ($newflag ? IMAGE_new : IMAGE_nonew); + + if($this->var['thread_total_replies'] >= vartrue($this->pref['popular'], 10)) + { + $ICON = ($newflag ? IMAGE_new_popular : IMAGE_nonew_popular); + } + elseif(empty($this->var['thread_total_replies']) && defined('IMAGE_noreplies')) + { + $ICON = IMAGE_noreplies; + } + + if($this->var['thread_sticky'] == 1) + { + $ICON = ($this->var['thread_active'] ? IMAGE_sticky : IMAGE_stickyclosed); + } + elseif($this->var['thread_sticky'] == 2) + { + $ICON = IMAGE_announce; + } + elseif(!$this->var['thread_active']) + { + $ICON = IMAGE_closed; + } + + return $ICON; + } + + + // @todo new forum shortcodes function sc_forum_name($parm=null) { @@ -148,11 +209,6 @@ - - - - - function sc_breadcrumb() { return $this->var['breadcrumb']; diff --git a/e107_plugins/forum/templates/newforumposts_menu_template.php b/e107_plugins/forum/templates/newforumposts_menu_template.php index b066f5654..3e7e3a155 100644 --- a/e107_plugins/forum/templates/newforumposts_menu_template.php +++ b/e107_plugins/forum/templates/newforumposts_menu_template.php @@ -46,8 +46,8 @@ </tr>"; $NEWFORUMPOSTS_MENU_TEMPLATE['main']['item'] = "<tr> - <td style='width:5%; text-align:center' class='forumheader3'>{ICON}</td> - <td style='width:45%' class='forumheader3'><a href='{TOPIC_URL}'>{TOPIC_NAME}</a> <small class='smalltext'>(<a href='{FORUM_URL}'>{FORUM_NAME}</a>)</small></td> + <td style='width:5%; text-align:center' class='forumheader3'>{TOPIC_ICON}</td> + <td style='width:45%' class='forumheader3'><a href='{POST_URL}'>{TOPIC_NAME}</a> <small class='smalltext'>(<a href='{FORUM_URL}'>{FORUM_NAME}</a>)</small></td> <td style='width:15%; text-align:center' class='forumheader3'>{POST_AUTHOR_NAME}</td> <td style='width:5%; text-align:center' class='forumheader3'>{TOPIC_VIEWS}</td> <td style='width:5%; text-align:center' class='forumheader3'>{TOPIC_REPLIES}</td>