1
0
mirror of https://github.com/e107inc/e107.git synced 2025-01-16 20:28:28 +01:00

PHP8 Forum code cleanup

This commit is contained in:
Cameron 2021-01-22 06:31:23 -08:00
parent aafd277331
commit 4a9cf379a6
5 changed files with 266 additions and 466 deletions

View File

@ -82,7 +82,8 @@ if(!defined('IMAGE_new') && !defined('IMAGE_e'))
class e107forum
{
// var $fieldTypes = array();
private $userViewed, $permList;
private $userViewed;
private $permList = array();
public $modArray, $prefs;
private $forumData = array();
@ -680,7 +681,12 @@ class e107forum
public function getForumPermList($what = null)
{
if(null !== $what) return (isset($this->permList[$what]) ? $this->permList[$what] : null);
if(null !== $what)
{
return (isset($this->permList[$what]) ? $this->permList[$what] : array());
}
return $this->permList;
}

View File

@ -10,43 +10,70 @@
*
*/
if(!defined('e107_INIT'))
{
require_once(__DIR__.'/../../class2.php');
}
$e107 = e107::getInstance();
if(!e107::isInstalled('forum'))
{
e107::redirect();
exit;
}
e107::lan('forum', "front", true);
//include_lan(e_PLUGIN.'forum/languages/'.e_LANGUAGE.'/lan_forum_viewforum.php'); // now uses English_front.php
if(!defined('e107_INIT'))
{
require_once(__DIR__ . '/../../class2.php');
}
$e107 = e107::getInstance();
if(!e107::isInstalled('forum'))
{
e107::redirect();
exit;
}
e107::lan('forum', "front", true);
if(!deftrue('BOOTSTRAP'))
if(!deftrue('BOOTSTRAP'))
{
$bcDefs = array(
'FORLAN_11' => 'LAN_FORUM_0039',
'FORLAN_12' => 'LAN_FORUM_0040',
'FORLAN_13' => 'LAN_FORUM_0040',
'FORLAN_14' => 'LAN_FORUM_0040',
'FORLAN_16' => 'LAN_FORUM_1012',
'FORLAN_17' => 'LAN_FORUM_1013',
'FORLAN_18' => 'LAN_FORUM_1014',
'LAN_435' => 'LAN_DELETE',
'LAN_401' => 'LAN_FORUM_4011',
'LAN_398' => 'LAN_FORUM_4012',
'LAN_399' => 'LAN_FORUM_4013',
'LAN_400' => 'LAN_FORUM_4014',
'LAN_402' => 'LAN_FORUM_5019',
);
e107::getLanguage()->bcDefs($bcDefs);
}
define('NAVIGATION_ACTIVE', 'forum');
class forum_viewforum_front
{
function __construct()
{
$bcDefs = array(
'FORLAN_11' => 'LAN_FORUM_0039',
'FORLAN_12' => 'LAN_FORUM_0040',
'FORLAN_13' => 'LAN_FORUM_0040',
'FORLAN_14' => 'LAN_FORUM_0040',
'FORLAN_16' => 'LAN_FORUM_1012',
'FORLAN_17' => 'LAN_FORUM_1013',
'FORLAN_18' => 'LAN_FORUM_1014',
'LAN_435' => 'LAN_DELETE',
'LAN_401' => 'LAN_FORUM_4011',
'LAN_398' => 'LAN_FORUM_4012',
'LAN_399' => 'LAN_FORUM_4013',
'LAN_400' => 'LAN_FORUM_4014',
'LAN_402' => 'LAN_FORUM_5019',
$this->init();
);
e107::getLanguage()->bcDefs($bcDefs);
}
/**
* @param $FORUM_VIEW_START
* @param $urlparms
* @param $doNothing
* @return array
*/
function init()
{
// todo - remove all these globals.
global $FORUM_VIEW_START, $urlparms, $doNothing;
global $sc, $FORUM_VIEW_FORUM, $FORUM_VIEW_FORUM_STICKY, $FORUM_VIEW_FORUM_ANNOUNCE;
global $forum_info, $FORUM_CRUMB;
global $forum;
define('NAVIGATION_ACTIVE', 'forum');
$sql = e107::getDb();
$tp = e107::getParser();
$ns = e107::getRender();
$pref = e107::getPref();
if(!e_QUERY && empty($_GET))
@ -54,12 +81,14 @@
if(E107_DEBUG_LEVEL > 0)
{
echo __FILE__ . ' Line: ' . __LINE__;
exit;
return null;
}
$url = e107::url('forum', 'index', null, ['mode'=>'full']);
$url = e107::url('forum', 'index', null, ['mode' => 'full']);
e107::getRedirect()->go($url);
//header('Location:'.e107::getUrl()->create('forum/forum/main', array(), 'full=1&encode=0'));
exit;
return null;
}
if(!empty($_GET['sef']))
@ -82,7 +111,7 @@
$page = (varset($_GET['p']) ? $_GET['p'] : 1);
$threadFrom = ($page - 1) * $view;
global $forum_info, $FORUM_CRUMB;
$sc = e107::getScBatch('viewforum', 'forum');
@ -98,21 +127,21 @@
if(!$forum->checkPerm($forumId, 'view'))
{
$url = e107::url('forum', 'index', null, ['mode'=>'full']);
/*
if(E107_DEBUG_LEVEL > 0)
{
print_a($_REQUEST);
print_a($_GET);
echo __FILE__ . ' Line: ' . __LINE__;
echo " forumId: " . $forumId;
exit;
}
*/
$url = e107::url('forum', 'index', null, ['mode' => 'full']);
/*
if(E107_DEBUG_LEVEL > 0)
{
print_a($_REQUEST);
print_a($_GET);
echo __FILE__ . ' Line: ' . __LINE__;
echo " forumId: " . $forumId;
exit;
}
*/
e107::getRedirect()->go($url);
exit;
return null;
}
$forumInfo = $forum->forumGet($forumId);
@ -178,7 +207,9 @@
$forumInfo['forum_description'] = $tp->toHTML($forumInfo['forum_description'], true, 'no_hook');
$_forum_name = (substr($forumInfo['forum_name'], 0, 1) == '*' ? substr($forumInfo['forum_name'], 1) : $forumInfo['forum_name']);
define('e_PAGETITLE', $_forum_name . ' / ' . LAN_FORUM_1001);
e107::title($_forum_name . ' / ' . LAN_FORUM_1001);
// define('e_PAGETITLE', $_forum_name . ' / ' . LAN_FORUM_1001);
// SEO - meta description (auto)
if(!empty($forumInfo['forum_description']))
@ -376,7 +407,7 @@
$unstuck = true;
}
$forum_view_forum .= parse_thread($thread_info);
$forum_view_forum .= $this->parse_thread($thread_info);
}
}
else
@ -422,7 +453,8 @@
}
</script>";
require_once(FOOTERF);
return array($forum_info, $FORUM_CRUMB, $forumSCvars, $FORUM_VIEW_CAPTION);
}
@ -463,7 +495,7 @@
}
/*
function forumjump()
{
@ -478,155 +510,12 @@
return $text;
}
*/
function fadminoptions($thread_info)
{
//-- $tVars here???
//---- $tVars = new e_vars;
$e107 = e107::getInstance();
$tp = e107::getParser();
// $text = "<form method='post' action='".e_REQUEST_URI."' id='frmMod_{$forumId}_{$threadId}' style='margin:0;'>";
$text = '<div class="btn-group"><button class="btn btn-default btn-secondary btn-sm btn-mini dropdown-toggle" data-toggle="dropdown">
<span class="caret"></span>
</button>
<ul class="dropdown-menu pull-right float-right">
';
//FIXME - not fully working.
$moveUrl = e107::url('forum', 'move', $thread_info);
// What's the use of $splitUrl?????
$splitUrl = e107::url('forum', 'split', $thread_info);
$lockUnlock = ($thread_info['thread_active']) ? 'lock' : 'unlock';
$stickUnstick = ($thread_info['thread_sticky'] == 1) ? 'unstick' : 'stick';
$id = intval($thread_info['thread_id']);
$lan = array('stick' => LAN_FORUM_8007, 'unstick' => LAN_FORUM_8008, 'lock' => LAN_FORUM_8009, 'unlock' => LAN_FORUM_8010);
$icon = array(
'unstick' => $tp->toGlyph('fa-chevron-down'),
'stick' => $tp->toGlyph('fa-chevron-up'),
'lock' => $tp->toGlyph('fa-lock'),
'unlock' => $tp->toGlyph('fa-unlock'),
);
$text .= "<li class='text-right'><a class='dropdown-item' href='" . e_REQUEST_URI . "' data-forum-action='delete' data-confirm='".LAN_JSCONFIRM."' data-forum-thread='" . $id . "'>" . LAN_DELETE . " " . $tp->toGlyph('trash') . "</a></li>";
$text .= "<li class='text-right'><a class='dropdown-item' href='" . e_REQUEST_URI . "' data-forum-action='" . $stickUnstick . "' data-forum-thread='" . $id . "'>" . $lan[$stickUnstick] . " " . $icon[$stickUnstick] . "</a></li>";
$text .= "<li class='text-right'><a class='dropdown-item' href='" . e_REQUEST_URI . "' data-forum-action='" . $lockUnlock . "' data-forum-thread='" . $id . "'>" . $lan[$lockUnlock] . " " . $icon[$lockUnlock] . "</a></li>";
$text .= "<li class='text-right'><a class='dropdown-item' href='{$moveUrl}'>" . LAN_FORUM_2042 . " " . $tp->toGlyph('move') . "</a></li>";
//if(e_DEVELOPER)
// {
// $text .= "<li class='text-right'><a href='{$splitUrl}'>Split ".$tp->toGlyph('scissors')."</i></a></li>";
// print_a($thread_info);
// }
/*
$text .= "<li><input type='image' ".IMAGE_admin_delete." name='deleteThread_{$threadId}' value='thread_action' onclick=\"return confirm_({$threadId})\" /> Delete</li>";
$text .= "<li>".($thread_info['thread_sticky'] == 1 ? "<input type='image' ".IMAGE_admin_unstick." name='unstick_{$threadId}' value='thread_action' /> Unstick" : "<input type='image' ".IMAGE_admin_stick." name='stick_{$threadId}' value='thread_action' /> Stick")."
</li>";
$text .= "<li>".($thread_info['thread_active'] ? "<input type='image' ".IMAGE_admin_lock." name='lock_{$threadId}' value='thread_action' /> Lock" : "<input type='image' ".IMAGE_admin_unlock." name='unlock_{$threadId}' value='thread_action' /> Unlock"). "
</li>";
$text .= "<li><a href='".e107::getUrl()->create('forum/thread/move', "id={$thread_info['thread_id']}")."'>Move</a></li>";
*/
$text .= "</ul></div>";
// $text .= "</form>";
return $text;
}
function fpages($thread_info, $replies)
{
global $forum;
$tp = e107::getParser();
$replies = (int) $replies;
$postsPerPage = (int) $forum->prefs->get('postspage');
// Add 1 for the first post in the topic (which technically is not a reply), to make it consistent with the nextprev in the forum_viewtopic page
$replies = $replies + 1;
$pages = ceil(($replies) / $postsPerPage);
$thread_info['thread_sef'] = eHelper::title2sef($thread_info['thread_name'], 'dashl');
$urlparms = $thread_info;
$text = '';
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);
$title = $tp->lanVars(LAN_GOTOPAGEX, $aa);
$url = e107::url('forum', 'topic', $urlparms) . '&amp;p=' . $aa;
$opts[] = "<a data-toggle='tooltip' title=\"" . $title . "\" href='{$url}'>{$aa}</a>";
}
$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);
$title = $tp->lanVars(LAN_GOTOPAGEX, $aa);
$url = e107::url('forum', 'topic', $urlparms) . '&amp;p=' . $aa;
$opts[] = "<a data-toggle='tooltip' title=\"" . $title . "\" href='{$url}'>{$aa}</a>";
}
}
else
{
for($a = 0; $a <= ($pages - 1); $a++)
{
$aa = $a + 1;
$text .= $text ? ' ' : '';
// $urlparms['page'] = $aa;
// $url = e107::getUrl()->create('forum/thread/view', $urlparms);
$title = $tp->lanVars(LAN_GOTOPAGEX, $aa);
$url = e107::url('forum', 'topic', $urlparms) . '&amp;p=' . $aa;
$opts[] = "<a data-toggle='tooltip' title=\"" . $title . "\" href='{$url}'>{$aa}</a>";
}
}
if(deftrue('BOOTSTRAP'))
{
$text = "<ul class='pagination pagination-sm forum-viewforum-pagination'>
<li>";
$text .= implode("</li><li>", $opts); // ."</div>";
$text .= "</li></ul>";
}
else
{
$text = implode(" ", $opts); // ."</div>";
}
}
else
{
$text = '';
}
return $text;
}
/*
function newthreadjump($url)
{
@ -653,5 +542,15 @@
return $text;
}
*/
}
//list($forum_info, $FORUM_CRUMB, $forumSCvars, $FORUM_VIEW_CAPTION) = init();
new forum_viewforum_front();
require_once(FOOTERF);

View File

@ -33,8 +33,10 @@ if(!deftrue('BOOTSTRAP'))
e107::getLanguage()->bcDefs($bcDefs);
}
define('NAVIGATION_ACTIVE','forum');
if(!defined('NAVIGATION_ACTIVE'))
{
define('NAVIGATION_ACTIVE','forum');
}
$e107 = e107::getInstance();
$tp = e107::getParser();
@ -52,7 +54,7 @@ $highlight_search = isset($_POST['highlight_search']);
if (!e_QUERY)
{
//No parameters given, redirect to forum home
$url = e107::url('forum','index','full');
$url = e107::url('forum','index', null, ['mode'=>'full']);
e107::getRedirect()->go($url);
exit;
}
@ -254,220 +256,14 @@ else
//TODO Clean up this mess!!
// get info for main thread -------------------------------------------------------------------------------------------------------------------------------------------------------------------
//---- Moved here to enclose $tVars.....
$sc = e107::getScBatch('view', 'forum');
//---- $tVars = new e_vars;
//---- $forum->set_crumb(true, '', $tVars); // Set $BREADCRUMB (and BACKLINK)
$forum->set_crumb(true, '', $thread->threadInfo); // Set $BREADCRUMB (and BACKLINK)
//$tVars->BREADCRUMB = $crumbs['breadcrumb'];
//$tVars->BACKLINK = $tVars->BREADCRUMB;
//$tVars->FORUM_CRUMB = $crumbs['forum_crumb'];
//---- $tVars->THREADNAME = $tp->toHTML($thread->threadInfo['thread_name'], true, 'no_hook, emotes_off');
/*----
$prev = $forum->threadGetNextPrev('prev', $thread->threadId,$thread->threadInfo['forum_id'], $thread->threadInfo['thread_lastpost']);
$next = $forum->threadGetNextPrev('next', $thread->threadId,$thread->threadInfo['forum_id'], $thread->threadInfo['thread_lastpost']);
$options = array();
if($prev !== false)
{
$options[] = "<a class='btn btn-default btn-sm btn-small' href='" . e107::url('forum','topic', $prev) . "'>&laquo; " . LAN_FORUM_2001 . "</a>";
}
if($next !== false)
{
$options[] = "<a class='btn btn-default btn-sm btn-small' href='" . e107::url('forum','topic', $next) . "'>" . LAN_FORUM_2002 . " &raquo;</a>";
}
$tVars->NEXTPREV = implode(" | ", $options);
----*/
/*
$tVars->NEXTPREV = "<a class='btn btn-default btn-sm btn-small' href='" . $e107->url->create('forum/thread/prev', array('id' => $thread->threadId)) . "'>&laquo; " . LAN_FORUM_2001 . "</a>";
$tVars->NEXTPREV .= ' | '; // enabled to make it look better on v1 templates
$tVars->NEXTPREV .= "<a class='btn btn-default btn-sm btn-small' href='" . $e107->url->create('forum/thread/prev', array('id' => $thread->threadId)) . "'>" . LAN_FORUM_2002 . " &raquo;</a>";
*/
/*----
if ($forum->prefs->get('track') && USER)
{
// BC Fix for old template.
if(!defined('IMAGE_track'))
{
define('IMAGE_track', '<img src="'.img_path('track.png').'" alt="'.LAN_FORUM_4009.'" title="'.LAN_FORUM_4009.'" class="icon S16 action" />');
}
if(!defined('IMAGE_untrack'))
{
define('IMAGE_untrack', '<img src="'.img_path('untrack.png').'" alt="'.LAN_FORUM_4010.'" title="'.LAN_FORUM_4010.'" class="icon S16 action" />');
}
$img = ($thread->threadInfo['track_userid'] ? IMAGE_track : IMAGE_untrack);
/*
$url = $e107->url->create('forum/thread/view', array('id' => $thread->threadId), 'encode=0'); // encoding could break AJAX call
$url = e107::url('forum','index');
$tVars->TRACK .= "
<span id='forum-track-trigger-container'>
<a class='btn btn-default btn-sm btn-small e-ajax' data-target='forum-track-trigger' href='{$url}' id='forum-track-trigger'>{$img}</a>
</span>
<script type='text/javascript'>
e107.runOnLoad(function(){
$('forum-track-trigger').observe('click', function(e) {
e.stop();
new e107Ajax.Updater('forum-track-trigger-container', '{$url}', {
method: 'post',
parameters: { //send query parameters here
'track_toggle': 1
},
overlayPage: $(document.body)
});
});
}, document, true);
</script>
";*/
/*----
$trackDiz = ($forum->prefs->get('trackemail',true)) ? LAN_FORUM_3040 : LAN_FORUM_3041;
$tVars->TRACK = "<a id='forum-track-button' href='#' title=\"".$trackDiz."\" data-token='".deftrue('e_TOKEN','')."' data-forum-insert='forum-track-button' data-forum-post='".$thread->threadInfo['thread_forum_id']."' data-forum-thread='".$thread->threadInfo['thread_id']."' data-forum-action='track' name='track' class='e-tip btn btn-default' >".$img."</a>
";
}
----*/
/*----
$modUser = array();
foreach ( $forum->modArray as $user)
{
$modUser[] = "<a href='".e107::getUrl()->create('user/profile/view', $user)."'>".$user['user_name']."</a>";
}
$tVars->MODERATORS = LAN_FORUM_2003.": ". implode(', ', $modUser);
unset($modUser);
----*/
//---- $tVars->THREADSTATUS = (!$thread->threadInfo['thread_active'] ? LAN_FORUM_2004 : '');
/*----
if ($thread->pages > 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.
$url = e107::url('forum','topic', $thread->threadInfo)."&amp;p=[FROM]";
$parms = "total={$thread->pages}&type=page&current={$thread->page}&url=".urlencode($url)."&caption=off&tmpl=default&navcount=4&glyphs=1";
//XXX FIXME - pull-down template not practical here. Can we force another?
$tVars->GOTOPAGES = $tp->parseTemplate("{NEXTPREV={$parms}}");
/*
$parms = ($thread->pages).",1,{$thread->page},url::forum::thread::func=view&id={$thread->threadId}&page=[FROM],off";
$tVars->GOTOPAGES = $tp->parseTemplate("{NEXTPREV={$parms}}");
}
----*/
/*----
$tVars->BUTTONS = '';
if ($forum->checkPerm($thread->threadInfo['thread_forum_id'], 'post') && $thread->threadInfo['thread_active'])
{
// print_a($thread->threadInfo);
$url = e107::url('forum','post')."?f=rp&amp;id=".$thread->threadInfo['thread_id']."&amp;post=".$thread->threadId;
// $url = $e107->url->create('forum/thread/reply', array('id' => $thread->threadId));
$tVars->BUTTONS .= "<a href='" . $url . "'>" . IMAGE_reply . "</a>";
}
if ($forum->checkPerm($thread->threadInfo['thread_forum_id'], 'thread'))
{
$ntUrl = e107::url('forum','post')."?f=nt&amp;id=". $thread->threadInfo['thread_forum_id'];
// $ntUrl = $e107->url->create('forum/thread/new', array('id' => $thread->threadInfo['thread_forum_id']));
$tVars->BUTTONS .= "<a href='" . $ntUrl . "'>" . IMAGE_newthread . "</a>";
}
----*/
/*----
$tVars->BUTTONSX = forumbuttons($thread);
function forumbuttons($thread)
{
global $forum;
if ($forum->checkPerm($thread->threadInfo['thread_forum_id'], 'post') && $thread->threadInfo['thread_active'])
{
$url = e107::url('forum','post')."?f=rp&amp;id=".$thread->threadInfo['thread_id']."&amp;post=".$thread->threadId;
// $url = e107::getUrl()->create('forum/thread/reply', array('id' => $thread->threadId));
$replyUrl = "<a class='btn btn-primary' href='".$url."'>".LAN_FORUM_2006."</a>";
}
if ($forum->checkPerm($thread->threadInfo['thread_forum_id'], 'thread'))
{
$ntUrl = e107::url('forum','post')."?f=nt&amp;id=". $thread->threadInfo['thread_forum_id'];
// $ntUrl = e107::getUrl()->create('forum/thread/new', array('id' => $thread->threadInfo['thread_forum_id']));
$options[] = " <a href='".$ntUrl."'>".LAN_FORUM_2005."</a>";
}
// $options[] = "<a href='" . e107::getUrl()->create('forum/thread/prev', array('id' => $thread->threadId)) . "'>".LAN_FORUM_1017." ".LAN_FORUM_2001."</a>";
// $options[] = "<a href='" . e107::getUrl()->create('forum/thread/prev', array('id' => $thread->threadId)) . "'>".LAN_FORUM_1017." ".LAN_FORUM_2002."</a>";
$prev = $forum->threadGetNextPrev('prev', $thread->threadId,$thread->threadInfo['forum_id'], $thread->threadInfo['thread_lastpost']);
$next = $forum->threadGetNextPrev('next', $thread->threadId,$thread->threadInfo['forum_id'], $thread->threadInfo['thread_lastpost']);
if($prev !== false)
{
$options[] = "<a href='" . e107::url('forum','topic', $prev) . "'>".LAN_FORUM_1017." ".LAN_FORUM_2001."</a>";
}
if($next !== false)
{
$options[] = "<a href='" . e107::url('forum','topic', $next) . "'>".LAN_FORUM_1017." ".LAN_FORUM_2002."</a>";
}
$text = '<div class="btn-group">
'.$replyUrl.'
<button class="btn btn-primary dropdown-toggle" data-toggle="dropdown">
<span class="caret"></span>
</button>
<ul class="dropdown-menu pull-right">
';
foreach($options as $key => $val)
{
$text .= '<li>'.$val.'</li>';
}
$jumpList = $forum->forumGetAllowed();
$text .= "<li class='divider'></li>";
foreach($jumpList as $key=>$val)
{
$text .= '<li><a href ="'.e107::url('forum','forum',$val).'">'.LAN_FORUM_1017." ".$val['forum_name'].'</a></li>';
}
$text .= '
</ul>
</div>';
return $text;
}
----*/
//---- $tVars->POLL = vartrue($pollstr);
//---- $tVars->FORUMJUMP = forumjump();
//---- $tVars->MESSAGE = $thread->message;
$sc->setVars($thread->threadInfo);
$sc->setScVar('threadInfo', $thread->threadInfo);
@ -482,12 +278,9 @@ $alt = false;
$i = $thread->page;
//---- Moved upwards, to enclose $tVars...
//---- $sc = e107::getScBatch('view', 'forum');
$mes = e107::getMessage();
// $sc->setVars($thread->threadInfo);
//--->$forend = $tp->simpleParse($FORUMEND, $tVars);
$sc->wrapper('forum_viewtopic/end');
$forend = $tp->parseTemplate($FORUMEND, true, $sc);
@ -560,55 +353,9 @@ foreach ($postList as $c => $postInfo)
}
unset($loop_uid);
/*---->
if ($forum->checkPerm($thread->threadInfo['thread_forum_id'], 'post') && $thread->threadInfo['thread_active'])
{
//XXX Show only on the last page??
if (!vartrue($forum_quickreply))
{
$ajaxInsert = ($thread->pages == $thread->page || $thread->pages == 0) ? 1 : 0;
// $ajaxInsert = 1;
// echo "AJAX-INSERT=".$ajaxInsert ."(".$thread->pages." vs ".$thread->page.")";
$frm = e107::getForm();
$urlParms = array('f'=>'rp','id'=>$thread->threadInfo['thread_id'], 'post'=>$thread->threadInfo['thread_id']);
$url = e107::url('forum','post', null, array('query'=>$urlParms));; // ."?f=rp&amp;id=".$thread->threadInfo['thread_id']."&amp;post=".$thread->threadInfo['thread_id'];
$tVars->QUICKREPLY = "
<form action='" . $url . "' method='post'>
<div class='form-group'>
<textarea cols='80' placeholder='".LAN_FORUM_2007."' rows='4' id='forum-quickreply-text' class='tbox input-xxlarge form-control' name='post' onselect='storeCaret(this);' onclick='storeCaret(this);' onkeyup='storeCaret(this);'></textarea>
</div>
<div class='center text-center form-group'>
<input type='submit' data-token='".e_TOKEN."' data-forum-insert='".$ajaxInsert."' data-forum-post='".$thread->threadInfo['thread_forum_id']."' data-forum-thread='".$threadId."' data-forum-action='quickreply' name='reply' value='".LAN_FORUM_2006. "' class='btn btn-success button' />
<input type='hidden' name='thread_id' value='".$threadId."' />
</div>
</form>";
if(E107_DEBUG_LEVEL > 0)
{
// echo "<div class='alert alert-info'>Thread id: ".$threadId."</div>";
// print_a($this);
}
// Preview should be reserved for the full 'Post reply' page. <input type='submit' name='fpreview' value='" . Preview . "' /> &nbsp;
}
else
{
$tVars->QUICKREPLY = $forum_quickreply;
}
}
<----*/
/*--->
$mes = e107::getMessage();
$sc->setVars($thread->threadInfo);
//--->$forend = $tp->simpleParse($FORUMEND, $tVars);
$forend = $tp->parseTemplate($FORUMEND, true, $sc);
<---*/
$forumstring = $forstr . $forthr . vartrue($forrep) . $forend;
//If last post came after USERLV and not yet marked as read, mark the thread id as read

View File

@ -59,10 +59,11 @@ if(!class_exists('forum_newforumposts_menu'))
$this->total['topics'] = $sql->count("forum_thread");
$this->total['replies'] = $sql->count("forum_post");
$sql->gen("SELECT sum(thread_views) as sum FROM #forum_thread");
$tmp = $sql->fetch();
$this->total['views'] = intval($tmp["sum"]);
if($sql->gen("SELECT sum(thread_views) as sum FROM #forum_thread"))
{
$tmp = $sql->fetch();
$this->total['views'] = intval($tmp["sum"]);
}
$this->render();
@ -76,7 +77,8 @@ if(!class_exists('forum_newforumposts_menu'))
$max_age = vartrue($this->menuPref['maxage'], 0);
$max_age = ($max_age == 0) ? '' : '(p.post_datestamp > '.(time()-(int)$max_age*86400).') AND ';
$forumList = implode(',', $this->forumObj->getForumPermList('view'));
$viewPerm = $this->forumObj->getForumPermList('view');
$forumList = implode(',', $viewPerm);
// if forumlist is empty (no forum categories created yet), return false;
if(!$forumList)

View File

@ -985,7 +985,7 @@
function sc_pages()
{
// $tVars['PAGES'] = fpages($thread_info, $tVars['REPLIES']);
$ret = fpages($this->var, $this->var['thread_total_replies']);
$ret = $this->fpages($this->var, $this->var['thread_total_replies']);
if(!empty($ret))
{
@ -995,6 +995,87 @@
return null;
}
function fpages($thread_info, $replies)
{
global $forum;
$tp = e107::getParser();
$replies = (int) $replies;
$postsPerPage = (int) $forum->prefs->get('postspage');
// Add 1 for the first post in the topic (which technically is not a reply), to make it consistent with the nextprev in the forum_viewtopic page
$replies = $replies + 1;
$pages = ceil(($replies) / $postsPerPage);
$thread_info['thread_sef'] = eHelper::title2sef($thread_info['thread_name'], 'dashl');
$urlparms = $thread_info;
$text = '';
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);
$title = $tp->lanVars(LAN_GOTOPAGEX, $aa);
$url = e107::url('forum', 'topic', $urlparms) . '&amp;p=' . $aa;
$opts[] = "<a data-toggle='tooltip' title=\"" . $title . "\" href='{$url}'>{$aa}</a>";
}
$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);
$title = $tp->lanVars(LAN_GOTOPAGEX, $aa);
$url = e107::url('forum', 'topic', $urlparms) . '&amp;p=' . $aa;
$opts[] = "<a data-toggle='tooltip' title=\"" . $title . "\" href='{$url}'>{$aa}</a>";
}
}
else
{
for($a = 0; $a <= ($pages - 1); $a++)
{
$aa = $a + 1;
$text .= $text ? ' ' : '';
// $urlparms['page'] = $aa;
// $url = e107::getUrl()->create('forum/thread/view', $urlparms);
$title = $tp->lanVars(LAN_GOTOPAGEX, $aa);
$url = e107::url('forum', 'topic', $urlparms) . '&amp;p=' . $aa;
$opts[] = "<a data-toggle='tooltip' title=\"" . $title . "\" href='{$url}'>{$aa}</a>";
}
}
if(deftrue('BOOTSTRAP'))
{
$text = "<ul class='pagination pagination-sm forum-viewforum-pagination'>
<li>";
$text .= implode("</li><li>", $opts); // ."</div>";
$text .= "</li></ul>";
}
else
{
$text = implode(" ", $opts); // ."</div>";
}
}
else
{
$text = '';
}
return $text;
}
function sc_pagesx()
{
@ -1037,7 +1118,7 @@
}
else if (MODERATOR)
{
return fadminoptions($this->var);
return $this->fadminoptions($this->var);
}
else
{
@ -1045,6 +1126,71 @@
}
}
function fadminoptions($thread_info)
{
//-- $tVars here???
//---- $tVars = new e_vars;
$e107 = e107::getInstance();
$tp = e107::getParser();
// $text = "<form method='post' action='".e_REQUEST_URI."' id='frmMod_{$forumId}_{$threadId}' style='margin:0;'>";
$text = '<div class="btn-group"><button class="btn btn-default btn-secondary btn-sm btn-mini dropdown-toggle" data-toggle="dropdown">
<span class="caret"></span>
</button>
<ul class="dropdown-menu pull-right float-right">
';
//FIXME - not fully working.
$moveUrl = e107::url('forum', 'move', $thread_info);
// What's the use of $splitUrl?????
$splitUrl = e107::url('forum', 'split', $thread_info);
$lockUnlock = ($thread_info['thread_active']) ? 'lock' : 'unlock';
$stickUnstick = ($thread_info['thread_sticky'] == 1) ? 'unstick' : 'stick';
$id = intval($thread_info['thread_id']);
$lan = array('stick' => LAN_FORUM_8007, 'unstick' => LAN_FORUM_8008, 'lock' => LAN_FORUM_8009, 'unlock' => LAN_FORUM_8010);
$icon = array(
'unstick' => $tp->toGlyph('fa-chevron-down'),
'stick' => $tp->toGlyph('fa-chevron-up'),
'lock' => $tp->toGlyph('fa-lock'),
'unlock' => $tp->toGlyph('fa-unlock'),
);
$text .= "<li class='text-right'><a class='dropdown-item' href='" . e_REQUEST_URI . "' data-forum-action='delete' data-confirm='".LAN_JSCONFIRM."' data-forum-thread='" . $id . "'>" . LAN_DELETE . " " . $tp->toGlyph('trash') . "</a></li>";
$text .= "<li class='text-right'><a class='dropdown-item' href='" . e_REQUEST_URI . "' data-forum-action='" . $stickUnstick . "' data-forum-thread='" . $id . "'>" . $lan[$stickUnstick] . " " . $icon[$stickUnstick] . "</a></li>";
$text .= "<li class='text-right'><a class='dropdown-item' href='" . e_REQUEST_URI . "' data-forum-action='" . $lockUnlock . "' data-forum-thread='" . $id . "'>" . $lan[$lockUnlock] . " " . $icon[$lockUnlock] . "</a></li>";
$text .= "<li class='text-right'><a class='dropdown-item' href='{$moveUrl}'>" . LAN_FORUM_2042 . " " . $tp->toGlyph('move') . "</a></li>";
//if(e_DEVELOPER)
// {
// $text .= "<li class='text-right'><a href='{$splitUrl}'>Split ".$tp->toGlyph('scissors')."</i></a></li>";
// print_a($thread_info);
// }
/*
$text .= "<li><input type='image' ".IMAGE_admin_delete." name='deleteThread_{$threadId}' value='thread_action' onclick=\"return confirm_({$threadId})\" /> Delete</li>";
$text .= "<li>".($thread_info['thread_sticky'] == 1 ? "<input type='image' ".IMAGE_admin_unstick." name='unstick_{$threadId}' value='thread_action' /> Unstick" : "<input type='image' ".IMAGE_admin_stick." name='stick_{$threadId}' value='thread_action' /> Stick")."
</li>";
$text .= "<li>".($thread_info['thread_active'] ? "<input type='image' ".IMAGE_admin_lock." name='lock_{$threadId}' value='thread_action' /> Lock" : "<input type='image' ".IMAGE_admin_unlock." name='unlock_{$threadId}' value='thread_action' /> Unlock"). "
</li>";
$text .= "<li><a href='".e107::getUrl()->create('forum/thread/move', "id={$thread_info['thread_id']}")."'>Move</a></li>";
*/
$text .= "</ul></div>";
// $text .= "</form>";
return $text;
}
function sc_poster()
{