1
0
mirror of https://github.com/e107inc/e107.git synced 2025-08-11 17:14:42 +02: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

@@ -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()
{