mirror of
https://github.com/e107inc/e107.git
synced 2025-08-11 00:54:49 +02:00
PHP8 Fixes and shortcode tests for chatbox_menu, download, faqs, forum and forum-post
This commit is contained in:
@@ -8,22 +8,27 @@
|
||||
|
||||
if (!defined('e107_INIT')) { exit; }
|
||||
|
||||
e107::plugLan('forum', 'front', true);
|
||||
|
||||
class forum_shortcodes extends e_shortcode
|
||||
{
|
||||
private $forum_rules, $gen;
|
||||
private $forum_rules;
|
||||
private $gen;
|
||||
private $prefs;
|
||||
|
||||
public $newFlagList;
|
||||
|
||||
function __construct()
|
||||
{
|
||||
$this->forum_rules = forum_rules('check');
|
||||
$this->gen = new convert;
|
||||
$this->forum_rules = function_exists('forum_rules') ? forum_rules('check') : '';
|
||||
$this->gen = e107::getDate();
|
||||
$this->prefs = e107::pref('forum');
|
||||
}
|
||||
|
||||
// START OF $FVARS
|
||||
function sc_forumtitle()
|
||||
{
|
||||
return e107::pref('forum','title', LAN_PLUGIN_FORUM_NAME);
|
||||
return e107::pref('forum','title', defset('LAN_PLUGIN_FORUM_NAME'));
|
||||
}
|
||||
|
||||
// LEGACY shortcodes, to be deprecated & directly handled in template file???
|
||||
@@ -69,6 +74,16 @@ class forum_shortcodes extends e_shortcode
|
||||
|
||||
function sc_iconkey()
|
||||
{
|
||||
if(!defined('IMAGE_new_small'))
|
||||
{
|
||||
if(ADMIN)
|
||||
{
|
||||
return "<div class='alert'>IMAGE_new_small has not been defined</div>";
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
return "
|
||||
<table class='table table-bordered' style='width:100%'>\n<tr>
|
||||
<td style='width:2%'>".IMAGE_new_small."</td>
|
||||
@@ -83,25 +98,35 @@ class forum_shortcodes extends e_shortcode
|
||||
|
||||
function sc_logo()
|
||||
{
|
||||
if(!defined('IMAGE_e'))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
return IMAGE_e;
|
||||
}
|
||||
|
||||
function sc_newimage()
|
||||
{
|
||||
if(!defined('IMAGE_new_small'))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
return IMAGE_new_small;
|
||||
}
|
||||
|
||||
function sc_userinfo()
|
||||
{
|
||||
//---- Pass globals via $sc?????
|
||||
global $forum, $pref;
|
||||
global $forum, $pref;
|
||||
|
||||
$text = "<a href='".e_BASE."top.php?0.top.forum.10'>".LAN_FORUM_0010."</a> | <a href='".e_BASE."top.php?0.active'>".LAN_FORUM_0011."</a>";
|
||||
if(USER)
|
||||
{
|
||||
$text .= " | <a href='".e_BASE.'userposts.php?0.forums.'.USERID."'>".LAN_FORUM_0012."</a> | <a href='".e_BASE."usersettings.php'>".LAN_FORUM_0013."</a> | <a href='".e_HTTP."user.php?id.".USERID."'>".LAN_FORUM_0014."</a>";
|
||||
// To be reworked to get the $forum var
|
||||
if($forum->prefs->get('attach') && (check_class($pref['upload_class']) || getperms('0')))
|
||||
if(!empty($this->prefs['attach']) && (check_class($pref['upload_class']) || getperms('0')))
|
||||
{
|
||||
$text .= " | <a href='".e_PLUGIN."forum/forum_uploads.php'>".LAN_FORUM_0015."</a>";
|
||||
}
|
||||
@@ -127,8 +152,8 @@ class forum_shortcodes extends e_shortcode
|
||||
}
|
||||
|
||||
// To be reworked to get the $forum var
|
||||
$trackPref = $forum->prefs->get('track');
|
||||
//var_dump($forum->checkPerm($this->var['forum_id'], 'post'));
|
||||
$trackPref = varset($this->prefs['track']);
|
||||
|
||||
if(!empty($trackPref) && $forum->checkPerm($this->var['forum_id'], 'post'))
|
||||
{
|
||||
$uInfo[2] = "<a href='".e107::url('forum','track')."'>".LAN_FORUM_0030."</a>";
|
||||
@@ -139,6 +164,7 @@ class forum_shortcodes extends e_shortcode
|
||||
|
||||
function sc_userlist()
|
||||
{
|
||||
$text = '';
|
||||
if(!defined('e_TRACKING_DISABLED'))
|
||||
{
|
||||
// String candidate for USERLIST wrapper
|
||||
@@ -202,70 +228,73 @@ class forum_shortcodes extends e_shortcode
|
||||
|
||||
function sc_info()
|
||||
{
|
||||
//$fVars->INFO = "";
|
||||
// global $forum;
|
||||
//$sql = e107::getDb();
|
||||
//$gen = new convert;
|
||||
if (ANON == TRUE)
|
||||
// global $forum;
|
||||
$allread = false;
|
||||
$total_new_threads = 0;
|
||||
$total_read_threads = 0;
|
||||
$text = '';
|
||||
|
||||
if(ANON == true)
|
||||
{
|
||||
$text = LAN_FORUM_0049.'<br />'.LAN_FORUM_0050." <a href='".e_SIGNUP."'>".LAN_FORUM_0051."</a> ".LAN_FORUM_0052;
|
||||
$text = LAN_FORUM_0049 . '<br />' . LAN_FORUM_0050 . " <a href='" . e_SIGNUP . "'>" . LAN_FORUM_0051 . "</a> " . LAN_FORUM_0052;
|
||||
}
|
||||
elseif(USER == FALSE)
|
||||
elseif(USER == false)
|
||||
{
|
||||
$text = LAN_FORUM_0049.'<br />'.LAN_FORUM_0053." <a href='".e_SIGNUP."'>".LAN_FORUM_0054."</a> ".LAN_FORUM_0055;
|
||||
$text = LAN_FORUM_0049 . '<br />' . LAN_FORUM_0053 . " <a href='" . e_SIGNUP . "'>" . LAN_FORUM_0054 . "</a> " . LAN_FORUM_0055;
|
||||
}
|
||||
|
||||
if (USER == TRUE)
|
||||
if(USER == true)
|
||||
{
|
||||
$total_new_threads = e107::getDb()->count('forum_thread', '(*)', "WHERE thread_datestamp>'".USERLV."' ");
|
||||
$total_read_threads = 0;
|
||||
if (defset('USERVIEWED') != "")
|
||||
$total_new_threads = defined('USERLV') ? e107::getDb()->count('forum_thread', '(*)', "WHERE thread_datestamp>'" . USERLV . "' ") : 0;
|
||||
$total_read_threads = 0;
|
||||
|
||||
if(defset('USERVIEWED') != "")
|
||||
{
|
||||
$tmp = explode(".", USERVIEWED); // List of numbers, separated by single period
|
||||
$total_read_threads = count($tmp);
|
||||
}
|
||||
/*
|
||||
else
|
||||
{
|
||||
$total_read_threads = 0;
|
||||
}
|
||||
*/
|
||||
/*
|
||||
else
|
||||
{
|
||||
$total_read_threads = 0;
|
||||
}
|
||||
*/
|
||||
|
||||
// $gen = new convert;
|
||||
$text = LAN_FORUM_0018." ".USERNAME."<br />";
|
||||
$lastvisit_datestamp = $this->gen->convert_date(USERLV, 'long'); //FIXME Use e107::getParser()->toDate();
|
||||
// $gen = new convert;
|
||||
$text = LAN_FORUM_0018 . " " . USERNAME . "<br />";
|
||||
$lastvisit_datestamp = defined('USERLV') ? $this->gen->convert_date(USERLV, 'long') : '';
|
||||
$datestamp = $this->gen->convert_date(time(), "long");
|
||||
|
||||
/*
|
||||
if (!$total_new_threads)
|
||||
{
|
||||
$text .= LAN_FORUM_0019." ";
|
||||
}
|
||||
elseif($total_new_threads == 1)
|
||||
{
|
||||
$text .= LAN_FORUM_0020;
|
||||
}
|
||||
else
|
||||
{
|
||||
$text .= LAN_FORUM_0021." ".$total_new_threads." ".LAN_FORUM_0022." ";
|
||||
}
|
||||
*/
|
||||
$text .= (!$total_new_threads?LAN_FORUM_0019." ":($total_new_threads == 1?LAN_FORUM_0020:LAN_FORUM_0021." ".$total_new_threads." ".LAN_FORUM_0022." ")).LAN_FORUM_0023;
|
||||
// $text .= LAN_FORUM_0023;
|
||||
// if ($total_new_threads == $total_read_threads && $total_new_threads != 0 && $total_read_threads >= $total_new_threads)
|
||||
if ($total_new_threads != 0 && $total_read_threads >= $total_new_threads)
|
||||
/*
|
||||
if (!$total_new_threads)
|
||||
{
|
||||
$text .= LAN_FORUM_0019." ";
|
||||
}
|
||||
elseif($total_new_threads == 1)
|
||||
{
|
||||
$text .= LAN_FORUM_0020;
|
||||
}
|
||||
else
|
||||
{
|
||||
$text .= LAN_FORUM_0021." ".$total_new_threads." ".LAN_FORUM_0022." ";
|
||||
}
|
||||
*/
|
||||
$text .= (!$total_new_threads ? LAN_FORUM_0019 . " " : ($total_new_threads == 1 ? LAN_FORUM_0020 : LAN_FORUM_0021 . " " . $total_new_threads . " " . LAN_FORUM_0022 . " ")) . LAN_FORUM_0023;
|
||||
// $text .= LAN_FORUM_0023;
|
||||
// if ($total_new_threads == $total_read_threads && $total_new_threads != 0 && $total_read_threads >= $total_new_threads)
|
||||
if($total_new_threads != 0 && $total_read_threads >= $total_new_threads)
|
||||
{
|
||||
$text .= LAN_FORUM_0029;
|
||||
$allread = TRUE;
|
||||
$allread = true;
|
||||
}
|
||||
elseif($total_read_threads != 0)
|
||||
{
|
||||
$text .= " (".LAN_FORUM_0027." ".$total_read_threads." ".LAN_FORUM_0028.")";
|
||||
$text .= " (" . LAN_FORUM_0027 . " " . $total_read_threads . " " . LAN_FORUM_0028 . ")";
|
||||
}
|
||||
|
||||
$text .= "<br />
|
||||
".LAN_FORUM_0024." ".$lastvisit_datestamp."<br />
|
||||
".LAN_FORUM_0025." ".$datestamp;
|
||||
" . LAN_FORUM_0024 . " " . $lastvisit_datestamp . "<br />
|
||||
" . LAN_FORUM_0025 . " " . $datestamp;
|
||||
}
|
||||
/*
|
||||
else
|
||||
@@ -288,10 +317,7 @@ class forum_shortcodes extends e_shortcode
|
||||
$text .= "<br /><a href='".e_SELF."?mark.all.as.read'>".LAN_FORUM_0057.'</a>'.(e_QUERY != 'new' ? ", <a href='".e_SELF."?new'>".LAN_FORUM_0058."</a>" : '');
|
||||
}
|
||||
|
||||
$forum = new e107forum;
|
||||
//$trackPref = $forum->prefs->get('track');
|
||||
//if (USER && vartrue($trackPref) && e_QUERY != 'track')
|
||||
if (USER && !empty($forum->prefs->get('track')) && e_QUERY != 'track')
|
||||
if (USER && !empty($this->prefs['track']) && e_QUERY != 'track')
|
||||
{
|
||||
$text .= "<br /><a href='".e107::url('forum','track')."'>".LAN_FORUM_0030.'</a>';
|
||||
}
|
||||
@@ -304,6 +330,10 @@ class forum_shortcodes extends e_shortcode
|
||||
{
|
||||
$sql = e107::getDb();
|
||||
|
||||
$users = 0;
|
||||
$member_users = 0;
|
||||
$guest_users = 0;
|
||||
|
||||
$total_topics = $sql->count("forum_thread", "(*)");
|
||||
$total_replies = $sql->count("forum_post", "(*)");
|
||||
$total_members = $sql->count("user");
|
||||
@@ -367,14 +397,14 @@ class forum_shortcodes extends e_shortcode
|
||||
{
|
||||
|
||||
$url = $this->sc_lastpost(array('type'=>'url'));
|
||||
return "<a href='".$url."'>".IMAGE_new.'</a>';
|
||||
return "<a href='".$url."'>".defset('IMAGE_new').'</a>';
|
||||
}
|
||||
elseif(empty($this->var['forum_replies']) && defined('IMAGE_noreplies'))
|
||||
{
|
||||
return IMAGE_noreplies;
|
||||
return defset('IMAGE_noreplies');
|
||||
}
|
||||
|
||||
return IMAGE_nonew;
|
||||
return defset('IMAGE_nonew');
|
||||
|
||||
}
|
||||
|
||||
@@ -541,32 +571,25 @@ class forum_shortcodes extends e_shortcode
|
||||
function sc_startertitle()
|
||||
{
|
||||
|
||||
$author_name = ($this->var['user_name'] ? $this->var['user_name'] : $this->var['lastuser_anon']);
|
||||
$author_name = (!empty($this->var['user_name']) ? $this->var['user_name'] : varset($this->var['lastuser_anon']));
|
||||
|
||||
//-- $datestamp = $gen->convert_date($thread['thread_lastpost'], 'forum');
|
||||
$datestamp = $this->gen->convert_date($this->var['thread_lastpost'], 'forum');
|
||||
$datestamp = !empty($this->var['thread_lastpost']) ? $this->gen->convert_date($this->var['thread_lastpost'], 'forum') : '';
|
||||
|
||||
|
||||
if(!$this->var['user_name'])
|
||||
if(!empty($this->var['user_name']))
|
||||
{
|
||||
return $author_name.'<br />'.$datestamp;
|
||||
}
|
||||
|
||||
// return "<a href='".$e107->url->create('user/profile/view', array('id' => $thread['thread_lastuser'], 'name' => $sc->author_name))."'>{$sc->author_name}</a><br />".$sc->datestamp;
|
||||
return "<a href='".e107::getUrl()->create('user/profile/view', array('id' => $this->var['thread_lastuser'], 'name' => $author_name))."'>{$author_name}</a><br />".$datestamp;
|
||||
return isset($this->var['thread_lastuser']) ? "<a href='".e107::getUrl()->create('user/profile/view', array('id' => $this->var['thread_lastuser'], 'name' => $author_name))."'>{$author_name}</a><br />".$datestamp : '';
|
||||
//---- }
|
||||
}
|
||||
|
||||
|
||||
function sc_newspostname()
|
||||
{
|
||||
// global $thread;
|
||||
// $e107 = e107::getInstance();
|
||||
// $tp = e107::getParser();
|
||||
|
||||
// return empty($thread)?LAN_FORUM_0029:"<a href='".$e107->url->create('forum/thread/last', $thread)."'>".$tp->toHTML($thread['thread_name'], TRUE, 'no_make_clickable, no_hook').'</a>';
|
||||
// Only $this->var???'
|
||||
return empty($this->var) ? LAN_FORUM_0029:"<a href='".e107::getUrl()->create('forum/thread/last', $this->var)."'>".e107::getParser()->toHTML($this->var['thread_name'], TRUE, 'no_make_clickable, no_hook').'</a>';
|
||||
return empty($this->var) || empty($this->var['thread_name']) ? LAN_FORUM_0029 : "<a href='".e107::getUrl()->create('forum/thread/last', $this->var)."'>".e107::getParser()->toHTML($this->var['thread_name'], TRUE, 'no_make_clickable, no_hook').'</a>';
|
||||
}
|
||||
|
||||
|
||||
@@ -578,7 +601,7 @@ class forum_shortcodes extends e_shortcode
|
||||
return $frm->breadcrumb($breadarray);
|
||||
}
|
||||
|
||||
function sc_avatar($opts)
|
||||
function sc_avatar($opts=null)
|
||||
{
|
||||
return e107::getParser()->toAvatar(e107::user($this->var['forum_lastpost_user']),$opts);
|
||||
}
|
||||
|
@@ -8,9 +8,13 @@
|
||||
|
||||
if (!defined('e107_INIT')) { exit; }
|
||||
|
||||
e107::plugLan('forum', 'front', true);
|
||||
|
||||
class plugin_forum_post_shortcodes extends e_shortcode
|
||||
{
|
||||
protected $e107;
|
||||
public $threadInfo = array();
|
||||
//public $forum;
|
||||
|
||||
function __construct()
|
||||
{
|
||||
@@ -18,15 +22,22 @@ class plugin_forum_post_shortcodes extends e_shortcode
|
||||
$this->e107 = e107::getInstance();
|
||||
}
|
||||
|
||||
function sc_latestposts($parm) //TODO move elsewhere?
|
||||
function sc_latestposts($parm=null) //TODO move elsewhere?
|
||||
{
|
||||
$parm = ($parm ? $parm : 10);
|
||||
$parm = !empty($parm) ? (int) $parm : 10;
|
||||
|
||||
global $LATESTPOSTS_START, $LATESTPOSTS_END, $LATESTPOSTS_POST;
|
||||
|
||||
if(empty($LATESTPOSTS_POST))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
$tp = e107::getParser();
|
||||
|
||||
$txt = $tp->parseTemplate($LATESTPOSTS_START, true);
|
||||
$start = max($this->threadInfo['thread_total_replies'] - $parm, 0);
|
||||
$num = min($this->threadInfo['thread_total_replies'], $parm);
|
||||
$start = isset($this->threadInfo['thread_total_replies']) ? max($this->threadInfo['thread_total_replies'] - $parm, 0) : 0;
|
||||
$num = isset($this->threadInfo['thread_total_replies']) ? min($this->threadInfo['thread_total_replies'], $parm) : 0;
|
||||
|
||||
$tmp = $this->forum->postGet($this->threadInfo['thread_id'], $start, $num);
|
||||
|
||||
@@ -43,6 +54,12 @@ class plugin_forum_post_shortcodes extends e_shortcode
|
||||
function sc_threadtopic()
|
||||
{
|
||||
global $THREADTOPIC_REPLY;
|
||||
|
||||
if(empty($THREADTOPIC_REPLY))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
$tmp = $this->forum->postGet($this->threadInfo['thread_id'], 0, 1);
|
||||
e107::getScBatch('view', 'forum')->setScVar('postInfo', $tmp[0]);
|
||||
return e107::getParser()->parseTemplate($THREADTOPIC_REPLY, true);
|
||||
@@ -56,11 +73,16 @@ class plugin_forum_post_shortcodes extends e_shortcode
|
||||
function sc_forum_post_form_end()
|
||||
{
|
||||
$frm = e107::getForm();
|
||||
return $frm->hidden('action',$this->var['action']).$frm->close();
|
||||
return $frm->hidden('action', varset($this->var['action'])).$frm->close();
|
||||
}
|
||||
|
||||
function sc_forumjump()
|
||||
{
|
||||
if(!is_object($this->forum))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
$jumpList = $this->forum->forumGetAllowed('view');
|
||||
$text = "<form class='form-inline' method='post' action='".e_REQUEST_URI."'><div class='btn-group'><p>".LAN_FORUM_1017.": <select name='forumjump' class='tbox form-control'>";
|
||||
foreach($jumpList as $key => $val)
|
||||
@@ -135,9 +157,9 @@ class plugin_forum_post_shortcodes extends e_shortcode
|
||||
// {
|
||||
// $_POST['subject'] = $this->varp;
|
||||
// }
|
||||
|
||||
$value = varset($_POST['subject']);
|
||||
$tp = e107::getParser();
|
||||
return e107::getForm()->text('subject',$tp->post_toForm($_POST['subject']), 100, $opts);
|
||||
return e107::getForm()->text('subject',$tp->post_toForm($value), 100, $opts);
|
||||
|
||||
|
||||
// <input class='tbox form-control' type='text' name='subject' size='71' value='".vartrue($subject)."' maxlength='100' style='width:95%' />
|
||||
@@ -183,7 +205,7 @@ class plugin_forum_post_shortcodes extends e_shortcode
|
||||
$text = '';
|
||||
}
|
||||
|
||||
$editor = $this->forum->prefs->get('editor');
|
||||
$editor = is_object($this->forum) ? $this->forum->prefs->get('editor') : null;
|
||||
|
||||
//$wysiwyg = ($editor === 'bbcode') ? false : null;
|
||||
$wysiwyg = is_null($editor) ? 'default' : $editor;
|
||||
@@ -230,7 +252,7 @@ class plugin_forum_post_shortcodes extends e_shortcode
|
||||
|
||||
$uploadClass = e107::pref('core','upload_class');
|
||||
|
||||
if ($this->forum->prefs->get('attach') && (check_class($uploadClass) || getperms('0')))
|
||||
if (is_object($this->forum) && $this->forum->prefs->get('attach') && (check_class($uploadClass) || getperms('0')))
|
||||
{
|
||||
if (is_writable(e_PLUGIN.'forum/attachments'))
|
||||
{
|
||||
@@ -276,7 +298,7 @@ class plugin_forum_post_shortcodes extends e_shortcode
|
||||
|
||||
";
|
||||
//<input class='btn btn-default button' type='button' name='addoption' value=".LAN_FORUM_3020." />
|
||||
if( $this->forum->prefs->get('attach') && (check_class($pref['upload_class']) || getperms('0')))
|
||||
if(is_object($this->forum) && $this->forum->prefs->get('attach') && (check_class($pref['upload_class']) || getperms('0')))
|
||||
{
|
||||
return $fileattach;
|
||||
}
|
||||
@@ -416,7 +438,7 @@ class plugin_forum_post_shortcodes extends e_shortcode
|
||||
function sc_postthreadas()
|
||||
{
|
||||
// Show when creating new topic or when editing the original starting post (make sure post is not a reply)
|
||||
if (MODERATOR && $this->var['action'] == "nt" || $this->var['thread_datestamp'] == $this->var['post_datestamp'])
|
||||
if (deftrue('MODERATOR') && $this->var['action'] == "nt" || varset($this->var['thread_datestamp']) == $this->var['post_datestamp'])
|
||||
{
|
||||
$thread_sticky = (isset($_POST['threadtype']) ? $_POST['threadtype'] : vartrue($this->var['thread_sticky'], 0)); // no reference of 'head' $threadInfo['head']['thread_sticky']
|
||||
|
||||
@@ -441,6 +463,11 @@ class plugin_forum_post_shortcodes extends e_shortcode
|
||||
$_tmp = array();
|
||||
// no reference of 'head' $threadInfo['head']['thread_name']
|
||||
$eaction = ($this->var['action'] == 'edit');
|
||||
if(!is_object($this->forum))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
$this->forum->set_crumb(true, ($this->var['action'] == 'nt' ? ($eaction ? LAN_FORUM_3023 : LAN_FORUM_1018) : ($eaction ? LAN_FORUM_3024 : $this->var['thread_name'])), $_tmp);
|
||||
//---- return $_tmp->BREADCRUMB;
|
||||
return $_tmp['breadcrumb'];
|
||||
@@ -451,6 +478,10 @@ class plugin_forum_post_shortcodes extends e_shortcode
|
||||
|
||||
|
||||
$tp = e107::getParser();
|
||||
$url = '';
|
||||
$name = '';
|
||||
$pre = '';
|
||||
$post = '';
|
||||
|
||||
if($this->var['action'] == "rp")
|
||||
{
|
||||
|
Reference in New Issue
Block a user