1
0
mirror of https://github.com/e107inc/e107.git synced 2025-08-01 12:20:44 +02:00

Issue #1436, Issue #2294 - New Forum Posts Menu template added. Beginnings of "New Forum Posts Main" replacement.

This commit is contained in:
Cameron
2017-03-05 12:03:41 -08:00
parent ccd7560d43
commit 5569516329
4 changed files with 1077 additions and 810 deletions

View File

@@ -27,13 +27,16 @@ class forum_menu
public function config($menu='')
{
$layouts = e107::getLayouts('forum','newforumposts_menu');
$fields = array();
$fields['caption'] = array('title'=> LAN_FORUM_MENU_004, 'type'=>'text', 'multilan'=>true, 'writeParms'=>array('size'=>'xxlarge'));
$fields['display'] = array('title'=> LAN_FORUM_MENU_005, 'type'=>'text', 'writeParms'=>array('size'=>'mini','pattern'=>'[0-9]*'));
$fields['maxage'] = array('title'=> LAN_FORUM_MENU_0012, 'type'=>'text', 'help'=>LAN_FORUM_MENU_0013, 'writeParms'=>array('size'=>'mini','pattern'=>'[0-9]*'));
$fields['characters'] = array('title'=> LAN_FORUM_MENU_006, 'type'=>'text', 'writeParms'=>array('size'=>'mini','pattern'=>'[0-9]*'));
$fields['postfix'] = array('title'=> LAN_FORUM_MENU_007, 'type'=>'text', 'writeParms'=>array('size'=>'mini'));
$fields['title'] = array('title'=> LAN_FORUM_MENU_008, 'type'=>'boolean');
// $fields['title'] = array('title'=> LAN_FORUM_MENU_008, 'type'=>'boolean');
$fields['layout'] = array('title'=> LAN_TEMPLATE, 'type'=>'dropdown', 'writeParms'=>array('optArray'=>$layouts[0]));
return $fields;

View File

@@ -45,7 +45,9 @@ class forum_newforumposts_menu // plugin folder + menu name (without the .php)
$qry = "
SELECT
p.post_user, p.post_id, p.post_datestamp, p.post_user_anon, p.post_entry,
t.thread_id, t.thread_datestamp, t.thread_name, u.user_id, u.user_name, u.user_image, u.user_currentvisit, f.forum_sef
t.*,
u.user_id, u.user_name, u.user_image, u.user_currentvisit,
f.forum_name, f.forum_sef
FROM `#forum_post` as p
LEFT JOIN `#forum_thread` AS t ON t.thread_id = p.post_thread
@@ -73,19 +75,54 @@ class forum_newforumposts_menu // plugin folder + menu name (without the .php)
$list = null;
$text = null;
$layout = 'minimal';
if (!empty($this->menuPref['title']) && intval($this->menuPref['title']) === 1) // legacy pref value
{
$layout = 'default';
}
if(!empty($this->menuPref['layout']))//@todo e_menu add 'layout' dropdown.
{
$layout = $this->menuPref['layout'];
}
$template = e107::getTemplate('forum','newforumposts_menu',$layout);
$param = array();
foreach($this->menuPref as $k=>$v)
{
$param['nfp_'.$k] = $v;
}
if($results = $sql->gen($qry))
{
if($tp->thumbWidth() > 250) // Fix for unset image size.
/* if($tp->thumbWidth() > 250) // Fix for unset image size.
{
$tp->setThumbSize(40,40,true);
}
}*/
$list = "<ul class='media-list newforumposts-menu'>";
$sc = e107::getScBatch('view', 'forum')->setScVar('param',$param);
$list = $tp->parseTemplate($template['start'],true);
while($row = $sql->fetch())
{
$row['thread_sef'] = $this->forumObj->getThreadSef($row);
$sc->setScVar('postInfo', $row);
$sc->setVars($row);
$list .= $tp->parseTemplate($template['item'],false,$sc);
/*
$datestamp = $tp->toDate($row['post_datestamp'], 'relative');
$id = $row['thread_id'];
$topic = ($row['thread_datestamp'] == $row['post_datestamp'] ? '' : 'Re:');
@@ -145,12 +182,15 @@ class forum_newforumposts_menu // plugin folder + menu name (without the .php)
}
$list .= "</div></li>";
*/
}
$list .= "</ul>";
$list .= $tp->parseTemplate($template['end'],true);
$text = $list;
}
@@ -164,7 +204,9 @@ class forum_newforumposts_menu // plugin folder + menu name (without the .php)
{
$caption = !empty($this->menuPref['caption'][e_LANGUAGE]) ? $this->menuPref['caption'][e_LANGUAGE] : $this->menuPref['caption'];
}
else
if(empty($caption))
{
$caption = LAN_PLUGIN_FORUM_LATESTPOSTS;
}

View File

@@ -6,13 +6,19 @@
*
*/
if (!defined('e107_INIT')) { exit; }
if(!defined('e107_INIT'))
{
exit;
}
class plugin_forum_view_shortcodes extends e_shortcode
{
protected $e107;
protected $defaultImgAttachSize = false;
protected $pref;
// $param is sent from nfp menu.
function __construct()
{
@@ -24,6 +30,129 @@ class plugin_forum_view_shortcodes extends e_shortcode
$this->defaultImgAttachSize = e107::pref('forum', 'maxwidth', false); // don't resize here if set to 0.
}
/**
* v2.1.5 - Start of Shortcode rewrite rewrite for use throughout all of the forum plugin..
* return 1 piece of data. (ie. no combining of titles and urls unless absolutely required)
* @param $this->var - table data.
* @param $this->param - dynamic control of shortcode via menu configuration.
* Only by nfp menu at this time.
*/
function sc_post_url($parm=null)
{
$url = e107::url('forum', 'topic', $this->var, array(
'query' => array(
'f' => 'post',
'id' => intval($this->var['post_id']) // proper page number
),
));
return $url;
}
function sc_post_datestamp($parm=null)
{
return $this->sc_threaddatestamp('relative');
}
function sc_post_topic($parm=null)
{
return $this->sc_threadname($parm);
}
function sc_post_content($parm=null)
{
$tp = e107::getParser();
$pref = e107::getPref();
$post = strip_tags($tp->toHTML($this->var['post_entry'], true, 'emotes_off, no_make_clickable', '', $pref['menu_wordwrap']));
$post = $tp->text_truncate($post, varset($this->param['nfp_characters'],120), varset($this->param['nfp_postfix'],'...'));
return $post;
}
function sc_post_author_name($parm=null)
{
return $this->sc_poster();
}
function sc_post_author_avatar($parm=null)
{
return $this->sc_avatar($parm);
}
// thread/topic
function sc_topic_name($parm=null)
{
return $this->sc_threadname($parm);
}
function sc_topic_url($parm=null)
{
return e107::url('forum', 'topic', $this->var);
}
function sc_topic_views($parm=null)
{
$val = ($this->var['thread_views']) ? $this->var['thread_views'] : '0' ;
return e107::getParser()->toBadge($val);
}
function sc_topic_replies($parm=null)
{
$val = ($this->var['thread_total_replies']) ? $this->var['thread_total_replies'] : '0';
return e107::getParser()->toBadge($val);
}
function sc_topic_lastpost_date($parm=null)
{
}
// forum
function sc_forum_name($parm=null)
{
if(substr($this->var['forum_name'], 0, 1) === '*')
{
$this->var['forum_name'] = substr($this->var['forum_name'], 1);
}
$this->var['forum_name'] = e107::getParser()->toHTML($this->var['forum_name'], true, 'no_hook');
return $this->var['forum_name'];
}
function sc_forum_url($parm=null)
{
return e107::url('forum', 'forum', $this->var);
}
// More sc_topic_xxxxx and sc_forum_xxxx in the same format.
// ---------------------------------------
function sc_breadcrumb()
{
return $this->var['breadcrumb'];
@@ -74,15 +203,15 @@ class plugin_forum_view_shortcodes extends e_shortcode
}
/* Preferred - as {POST} may conflict with other shortcodes */
function sc_thread_text()
function sc_thread_text($parm=null)
{
return $this->sc_post();
return $this->sc_post($parm=null);
}
/**
* @DEPRECATED - use {THREAD_TEXT}
*/
function sc_post()
function sc_post($parm)
{
// return print_a($this->postInfo['post_entry'],true);
$emote = (isset($this->postInfo['post_options']['no_emote']) ? ',emotes_off' : '');
@@ -97,6 +226,7 @@ class plugin_forum_view_shortcodes extends e_shortcode
if($this->postInfo['post_status'])
{
$info = unserialize($this->postInfo['post_options']);
return "
" . LAN_FORUM_2037 . ": {$info['deldate']}<br />
" . LAN_FORUM_2038 . ": {$info['delreason']}
@@ -106,8 +236,6 @@ class plugin_forum_view_shortcodes extends e_shortcode
}
function sc_attachments($parm = array())
{
$tp = e107::getParser();
@@ -161,8 +289,6 @@ class plugin_forum_view_shortcodes extends e_shortcode
case 'img': //Always use thumb to hide the hash.
// return $baseDir.$file;
if(file_exists($baseDir . $file))
{
@@ -182,7 +308,6 @@ class plugin_forum_view_shortcodes extends e_shortcode
}
break;
}
@@ -258,6 +383,7 @@ class plugin_forum_view_shortcodes extends e_shortcode
{
return (!$this->postInfo['user_hideemail'] ? e107::getParser()->parseTemplate("{EMAILTO={$this->postInfo['user_email']}}") : '');
}
return '';
}
@@ -280,14 +406,20 @@ class plugin_forum_view_shortcodes extends e_shortcode
function sc_signature($parm = '')
{
if(!USER) { return ''; }
if(!USER)
{
return '';
}
global $forum;
$tp = e107::getParser();
static $forum_sig_shown;
if($forum->prefs->get('sig_once'))
{
$_tmp = 'forum_sig_shown_' . $this->postInfo['post_user'];
if(getcachedvars($_tmp)) { return ''; }
if(getcachedvars($_tmp))
{
return '';
}
cachevars($_tmp, 1);
}
@@ -334,7 +466,8 @@ class plugin_forum_view_shortcodes extends e_shortcode
function sc_website()
{
if (!empty($this->postInfo['user_homepage'])) {
if(!empty($this->postInfo['user_homepage']))
{
return LAN_FORUM_2034 . ': ' . $this->postInfo['user_homepage'] . '<br />';
}
}
@@ -387,7 +520,11 @@ class plugin_forum_view_shortcodes extends e_shortcode
function sc_memberid()
{
if (!$this->postInfo['post_user']) { return FALSE; }
if(!$this->postInfo['post_user'])
{
return false;
}
return "<span class='smalltext'>" . LAN_FORUM_2035 . ' #' . $this->postInfo['post_user'] . '</span>';
}
@@ -400,7 +537,10 @@ class plugin_forum_view_shortcodes extends e_shortcode
}
if (!$this->postInfo['post_user']) { return ''; }
if(!$this->postInfo['post_user'])
{
return '';
}
$rankInfo = e107::getRank()->getRanks($this->postInfo['post_user']);
// FIXME - level handler!!!
@@ -413,7 +553,10 @@ class plugin_forum_view_shortcodes extends e_shortcode
return "<span class='label label-info'>" . $rankInfo['name'] . "</span>";
}
if(!$parm) { $parm = 'name'; }
if(!$parm)
{
$parm = 'name';
}
switch($parm)
@@ -424,11 +567,15 @@ class plugin_forum_view_shortcodes extends e_shortcode
break;
case 'special':
if(isset($rankInfo['special'])) { return $rankInfo['special']; }
if(isset($rankInfo['special']))
{
return $rankInfo['special'];
}
if($this->forum->isModerator($this->postInfo['post_user']))
{
return "<div class='spacer'>" . IMAGE_rank_moderator_image . '</div>';
}
return '';
break;
@@ -439,6 +586,7 @@ class plugin_forum_view_shortcodes extends e_shortcode
{
$text .= $tp->toGlyph('fa-star');
}
return $text;
break;
@@ -472,8 +620,10 @@ class plugin_forum_view_shortcodes extends e_shortcode
if($parm == 'link')
{
$url = e107::getUrl()->create('user/profile/view', array('name' => $this->postInfo['edit_name'], 'id' => $this->postInfo['post_edit_user']));
return "<a href='{$url}'>{$this->postInfo['edit_name']}</a>";
}
return $this->postInfo['edit_name'];
}
}
@@ -483,6 +633,7 @@ class plugin_forum_view_shortcodes extends e_shortcode
if($this->postInfo['thread_start'] == 1)
{
global $pollstr;
return $pollstr;
}
}
@@ -524,7 +675,6 @@ class plugin_forum_view_shortcodes extends e_shortcode
$text .= "<li><a href='#'>" . $this->sc_posts() . "</a></li>";
if(e107::isInstalled('pm') && ($this->postInfo['post_user'] > 0))
{
if($pmButton = $tp->parseTemplate("{SENDPM: user=" . $this->postInfo['post_user'] . "&glyph=envelope&class=pm-send}", true))
@@ -632,7 +782,6 @@ class plugin_forum_view_shortcodes extends e_shortcode
}
$text .= '
</ul>
</div>';
@@ -643,7 +792,7 @@ class plugin_forum_view_shortcodes extends e_shortcode
}
//---- SHORTCODES CONVERTED FROM $tVars....
function sc_threadname()
function sc_threadname($parm=null)
{
return e107::getParser()->toHTML($this->var['thread_name'], true, 'no_hook, emotes_off');
}
@@ -722,6 +871,7 @@ if ($forum->prefs->get('track') && USER)
return "<a id='forum-track-button' href='#' title=\"" . $trackDiz . "\" data-token='" . deftrue('e_TOKEN', '') . "' data-forum-insert='forum-track-button' data-forum-post='" . $this->var['thread_forum_id'] . "' data-forum-thread='" . $this->var['thread_id'] . "' data-forum-action='track' name='track' class='e-tip btn btn-default' >" . $img . "</a>";
}
return '';
}
@@ -752,7 +902,10 @@ return (!$this->var['thread_active'] ? LAN_FORUM_2004 : '');
global $thread;
if($thread->pages > 1)
{
if(!$thread->page) $thread->page = 1;
if(!$thread->page)
{
$thread->page = 1;
}
// $url = rawurlencode(e107::getUrl()->create('forum/thread/view', array('name' => $thread->threadInfo['thread_name'], 'id' => $thread->threadId, 'page' => '[FROM]')));
// $url = e_REQUEST_SELF."?p=[FROM]"; // SEF URL Friendly.
@@ -779,15 +932,18 @@ if ($forum->checkPerm($this->var['thread_forum_id'], 'post') && $this->var['thre
{
// print_a($thread->threadInfo);
$url = e107::url('forum', 'post') . "?f=rp&amp;id=" . $this->var['thread_id'] . "&amp;post=" . $thread->threadId;
// $url = $e107->url->create('forum/thread/reply', array('id' => $thread->threadId));
return "<a href='" . $url . "'>" . IMAGE_reply . "</a>";
}
if($forum->checkPerm($this->var['thread_forum_id'], 'thread'))
{
$ntUrl = e107::url('forum', 'post') . "?f=nt&amp;id=" . $this->var['thread_forum_id'];
// $ntUrl = $e107->url->create('forum/thread/new', array('id' => $thread->threadInfo['thread_forum_id']));
return "<a href='" . $ntUrl . "'>" . IMAGE_newthread . "</a>";
}
return '';
}
@@ -889,12 +1045,14 @@ function sc_forumjump()
$text .= "\n<option value='" . e107::url('forum', 'forum', $val) . "'>" . $val['forum_name'] . "</option>";
}
$text .= "</select> <input class='btn btn-default button' type='submit' name='fjsubmit' value='" . LAN_GO . "' /></p></form>";
return $text;
}
function sc_message()
{
global $thread;
return $thread->message;
}
@@ -934,7 +1092,6 @@ if ($forum->checkPerm($this->var['thread_forum_id'], 'post') && $this->var['thre
}
// Preview should be reserved for the full 'Post reply' page. <input type='submit' name='fpreview' value='" . Preview . "' /> &nbsp;
}
//---- else
@@ -945,4 +1102,6 @@ if ($forum->checkPerm($this->var['thread_forum_id'], 'post') && $this->var['thre
}
}
?>

View File

@@ -0,0 +1,63 @@
<?php
/**
* e107 website system
*
* Copyright (C) 2008-2017 e107 Inc (e107.org)
* Released under the terms and conditions of the
* GNU General Public License (http://www.gnu.org/licenses/gpl.txt)
*
*/
$NEWFORUMPOSTS_MENU_TEMPLATE['default']['start'] = "<ul class='media-list newforumposts-menu'>{SETIMAGE: w=48&h=48&crop=1}";
$NEWFORUMPOSTS_MENU_TEMPLATE['default']['item'] = "<li class='media'>
<div class='media-left'>
<a href='{POST_URL}'>{POST_AUTHOR_AVATAR: shape=circle}</a>
</div>
<div class='media-body'>
<h4 class='media-header'><a href='{POST_URL}'>{POST_TOPIC}</a></h4>{POST_CONTENT}<br /><small class='text-muted muted'>".LAN_FORUM_MENU_001." {POST_AUTHOR} {POST_DATESTAMP}</small>
</div></li>";
$NEWFORUMPOSTS_MENU_TEMPLATE['default']['end'] = "</ul>";
$NEWFORUMPOSTS_MENU_TEMPLATE['minimal']['start'] = "<ul class='media-list newforumposts-menu'>{SETIMAGE: w=48&h=48&crop=1}";
$NEWFORUMPOSTS_MENU_TEMPLATE['minimal']['item'] = "<li class='media'>
<div class='media-left'>
<a href='{POST_URL}'>{POST_AUTHOR_AVATAR: shape=circle}</a>
</div>
<div class='media-body'>
<a href='{POST_URL}'>".LAN_FORUM_MENU_001."</a> {POST_AUTHOR_NAME} <small class='text-muted muted'>{POST_DATESTAMP}</small><br />{POST_CONTENT}<br />
</div></li>";
$NEWFORUMPOSTS_MENU_TEMPLATE['minimal']['end'] = "</ul>";
$NEWFORUMPOSTS_MENU_TEMPLATE['main']['start'] = "<!-- newforumposts -->
<table class='table table-bordered table-striped fborder'>
<tr>
<td style='width:5%' class='forumheader'>&nbsp;</td>
<td style='width:45%' class='forumheader'>".LAN_FORUM_1003."</td>
<td style='width:15%; text-align:center' class='forumheader'>".LAN_USER."</td>
<td style='width:5%; text-align:center' class='forumheader'>".LAN_FORUM_1005."</td>
<td style='width:5%; text-align:center' class='forumheader'>".LAN_FORUM_0003."</td>
<td style='width:25%; text-align:center' class='forumheader'>".LAN_FORUM_0004."</td>
</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: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>
<td style='width:25%; text-align:center' class='forumheader3'>{TOPIC_LASTPOST_AUTHOR}<br /><span class='smalltext'>{TOPIC_LASTPOST_DATE}&nbsp;</span></td>
</tr>";
$NEWFORUMPOSTS_MENU_TEMPLATE['main']['end'] = "<tr>
<td colspan='6' style='text-align:center' class='forumheader2'>
<span class='smalltext'>".LAN_FORUM_0002.": <b>{TOTAL_TOPICS}</b> | ".LAN_FORUM_0003.": <b>{TOTAL_REPLIES}</b> | ".LAN_FORUM_1005.": <b>{TOTAL_VIEWS}</b></span>
</td>
</tr>
</table>
";