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

Code cleanup

This commit is contained in:
Cameron
2019-05-26 17:05:29 -07:00
parent f1081c2b21
commit eb6401385e
8 changed files with 510 additions and 1385 deletions

View File

@@ -16,7 +16,7 @@ foreach($flist as $f)
if($bc[$f]['sep']) if(isset($bc[$f]['sep']))
{ {
$ret .= $bc[$f]['sep']; $ret .= $bc[$f]['sep'];
} }
@@ -31,7 +31,7 @@ if(deftrue('BOOTSTRAP'))
foreach($flist as $f) foreach($flist as $f)
{ {
if($bc[$f]['value']) if(isset($bc[$f]['value']))
{ {
$opt[] = $bc[$f]['value']; $opt[] = $bc[$f]['value'];
} }

View File

@@ -78,10 +78,10 @@ class e107
/** /**
* User login name * User login name
* *
* @var string * @var array
* @see init_session() * @see init_session()
*/ */
public $currentUser = ''; public $currentUser;
/** /**
* Run once load core shortcodes * Run once load core shortcodes

View File

@@ -2,7 +2,7 @@
/* /*
* e107 website system * e107 website system
* *
* Copyright (C) 2008-2013 e107 Inc (e107.org) * Copyright (C) 2008-2019 e107 Inc (e107.org)
* Released under the terms and conditions of the * Released under the terms and conditions of the
* GNU General Public License (http://www.gnu.org/licenses/gpl.txt) * GNU General Public License (http://www.gnu.org/licenses/gpl.txt)
* *
@@ -19,12 +19,11 @@ $sql = e107::getDb();
if (!$e107->isInstalled('forum')) if (!$e107->isInstalled('forum'))
{ {
// FIXME GLOBAL - get rid of all e_BASE|e_HTTP|Whatever/index.php - just point to SITEURL
e107::redirect(); e107::redirect();
exit; exit;
} }
e107::lan('forum', "front", true); e107::lan('forum', "front", true);
// include_lan(e_PLUGIN.'forum/languages/'.e_LANGUAGE.'/lan_forum.php'); // using English_front.php now
if(!deftrue('BOOTSTRAP')) if(!deftrue('BOOTSTRAP'))
{ {
@@ -92,228 +91,14 @@ if(isset($_GET['f']))
} }
} }
//echo "<hr><hr><hr>";
/** @var forum_shortcodes $sc */
$sc = e107::getScBatch('forum', true); $sc = e107::getScBatch('forum', true);
//echo "<hr>";
//var_dump ($sc);
// $sc->forum = $forum;
//var_dump ($sc);
//echo $tp->parseTemplate("====>{FORUMTITLE}<====", false, $sc);
//echo "<hr>";
//var_dump (is_object($sc));
//var_dump (is_array($sc));
//--$fVars = new e_vars;
//--$gen = new convert;
/*--
// Gonne directly to shortcode file
$fVars->FORUMTITLE = e107::pref('forum','title', LAN_PLUGIN_FORUM_NAME);
// Gonne directly to template file
$fVars->THREADTITLE = LAN_FORUM_0002;
// Gonne directly to template file
$fVars->REPLYTITLE = LAN_FORUM_0003;
// Gonne directly to template file
$fVars->LASTPOSTITLE = LAN_FORUM_0004;
// Gonne directly to template file
$fVars->INFOTITLE = LAN_FORUM_0009;
// Gonne directly to shortcode file
$fVars->LOGO = IMAGE_e;
// Gonne directly to template file
$fVars->NEWTHREADTITLE = LAN_FORUM_0075;
// Gonne directly to template file
$fVars->POSTEDTITLE = LAN_FORUM_0074;
// Gonne directly to shortcode file
$fVars->NEWIMAGE = IMAGE_new_small;
// Gonne directly to template file
$fVars->TRACKTITLE = LAN_FORUM_0073;
--*/
/*--
// Gonne directly to shortcode file
$rules_text = forum_rules('check');
$fVars->USERINFO = "<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)
{
$fVars->USERINFO .= " | <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>";
if($forum->prefs->get('attach') && (check_class($pref['upload_class']) || getperms('0')))
{
$fVars->USERINFO .= " | <a href='".e_PLUGIN."forum/forum_uploads.php'>".LAN_FORUM_0015."</a>";
}
}
if(!empty($rules_text))
{
$fVars->USERINFO .= " | <a href='".e107::url('forum','rules')."'>".LAN_FORUM_0016.'</a>';
}
// v2.x --------------------
$uInfo = array();
$uInfo[0] = "<a href='".e107::url('forum','stats')."'>".LAN_FORUM_6013.'</a>';
if(!empty($rules_text))
{
$uInfo[1] = "<a href='".e107::url('forum','rules')."'>".LAN_FORUM_0016.'</a>';
}
$trackPref = $forum->prefs->get('track');
if(!empty($trackPref))
{
$uInfo[2] = "<a href='".e107::url('forum','track')."'>".LAN_FORUM_0030."</a>";
}
$fVars->USERINFOX = implode(" | ",$uInfo);
// -----------
--*/
/*--
// Gonne to foruminfo shortcode
$total_topics = $sql->count("forum_thread", "(*)");
$total_replies = $sql->count("forum_post", "(*)");
$total_members = $sql->count("user");
$newest_member = $sql->select("user", "*", "user_ban='0' ORDER BY user_join DESC LIMIT 0,1");
list($nuser_id, $nuser_name) = $sql->fetch('num'); // FIXME $nuser_id & $user_name return empty even though print_a($newest_member); returns proper result.
if(!defined('e_TRACKING_DISABLED'))
{
$member_users = $sql->select("online", "*", "online_location REGEXP('forum.php') AND online_user_id!='0' ");
$guest_users = $sql->select("online", "*", "online_location REGEXP('forum.php') AND online_user_id='0' ");
$users = $member_users+$guest_users;
// Gonne to shortcode file
/*--
$fVars->USERLIST = LAN_FORUM_0036.": ";
global $listuserson;
$c = 0;
if(is_array($listuserson))
{
foreach($listuserson as $uinfo => $pinfo)
{
list($oid, $oname) = explode(".", $uinfo, 2);
$c ++;
$fVars->USERLIST .= "<a href='".e_HTTP."user.php ?id.$oid'>$oname</a>".($c == MEMBERS_ONLINE ? "." :", ");
}
}
$fVars->USERLIST .= "<br /><a rel='external' href='".e_BASE."online.php'>".LAN_FORUM_0037."</a> ".LAN_FORUM_0038;
}
--*/
// Gonne directly to shortcode file
/*--
$fVars->STATLINK = "<a href='".e_PLUGIN."forum/forum_stats.php'>".LAN_FORUM_0017."</a>\n";
$fVars->ICONKEY = "
<table class='table table-bordered' style='width:100%'>\n<tr>
<td style='width:2%'>".IMAGE_new_small."</td>
<td style='width:10%'><span class='smallblacktext'>".LAN_FORUM_0039."</span></td>
<td style='width:2%'>".IMAGE_nonew_small."</td>
<td style='width:10%'><span class='smallblacktext'>".LAN_FORUM_0040."</span></td>
<td style='width:2%'>".IMAGE_closed_small."</td>
<td style='width:10%'><span class='smallblacktext'>".LAN_FORUM_0041."</span></td>
</tr>\n</table>\n";
if(!$srchIcon = $tp->toGlyph('fa-search'))
{
$srchIcon = LAN_SEARCH;
}
$fVars->SEARCH = "
<form method='get' class='form-inline input-append' action='".e_BASE."search.php'>
<div class='input-group'>
<input class='tbox form-control' type='text' name='q' size='20' value='' maxlength='50' />
<span class='input-group-btn'>
<button class='btn btn-default button' type='submit' name='s' value='search' />".$srchIcon."</button>
</span>
<input type='hidden' name='r' value='0' />
<input type='hidden' name='t' value='forum' />
<input type='hidden' name='forum' value='all' />
</div>
</form>\n";
$fVars->PERMS = (USER == TRUE || ANON == TRUE ? LAN_FORUM_0043." - ".LAN_FORUM_0045." - ".LAN_FORUM_0047 : LAN_FORUM_0044." - ".LAN_FORUM_0046." - ".LAN_FORUM_0048);
$fVars->INFO = "";
if (USER == TRUE)
{
$total_new_threads = $sql->count('forum_thread', '(*)', "WHERE thread_datestamp>'".USERLV."' ");
if (USERVIEWED != "")
{
$tmp = explode(".", USERVIEWED); // List of numbers, separated by single period
$total_read_threads = count($tmp);
}
else
{
$total_read_threads = 0;
}
$fVars->INFO = LAN_FORUM_0018." ".USERNAME."<br />";
$lastvisit_datestamp = $gen->convert_date(USERLV, 'long');
$datestamp = $gen->convert_date(time(), "long");
if (!$total_new_threads)
{
$fVars->INFO .= LAN_FORUM_0019." ";
}
elseif($total_new_threads == 1)
{
$fVars->INFO .= LAN_FORUM_0020;
}
else
{
$fVars->INFO .= LAN_FORUM_0021." ".$total_new_threads." ".LAN_FORUM_0022." ";
}
$fVars->INFO .= LAN_FORUM_0023;
if ($total_new_threads == $total_read_threads && $total_new_threads != 0 && $total_read_threads >= $total_new_threads)
{
$fVars->INFO .= LAN_FORUM_0029;
$allread = TRUE;
}
elseif($total_read_threads != 0)
{
$fVars->INFO .= " (".LAN_FORUM_0027." ".$total_read_threads." ".LAN_FORUM_0028.")";
}
$fVars->INFO .= "<br />
".LAN_FORUM_0024." ".$lastvisit_datestamp."<br />
".LAN_FORUM_0025." ".$datestamp;
}
else
{
$fVars->INFO .= '';
if (ANON == TRUE)
{
$fVars->INFO .= LAN_FORUM_0049.'<br />'.LAN_FORUM_0050." <a href='".e_SIGNUP."'>".LAN_FORUM_0051."</a> ".LAN_FORUM_0052;
}
elseif(USER == FALSE)
{
$fVars->INFO .= LAN_FORUM_0049.'<br />'.LAN_FORUM_0053." <a href='".e_SIGNUP."'>".LAN_FORUM_0054."</a> ".LAN_FORUM_0055;
}
}
if (USER && vartrue($allread) != TRUE && $total_new_threads && $total_new_threads >= $total_read_threads)
{
$fVars->INFO .= "<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>" : '');
}
$trackPref = $forum->prefs->get('track');
if (USER && vartrue($trackPref) && e_QUERY != 'track')
{
$fVars->INFO .= "<br /><a href='".e107::url('forum','track')."'>".LAN_FORUM_0030.'</a>';
}
$fVars->FORUMINFO =
str_replace("[x]", ($total_topics+$total_replies), LAN_FORUM_0031)." ($total_topics ".($total_topics == 1 ? LAN_FORUM_0032 : LAN_FORUM_0033).", $total_replies ".($total_replies == 1 ? LAN_FORUM_0034 : LAN_FORUM_0035).")
".(!defined("e_TRACKING_DISABLED") ? "" : "<br />".$users." ".($users == 1 ? LAN_FORUM_0059 : LAN_FORUM_0060)." (".$member_users." ".($member_users == 1 ? LAN_FORUM_0061 : LAN_FORUM_0062).", ".$guest_users." ".($guest_users == 1 ? LAN_FORUM_0063 : LAN_FORUM_0064).")<br />".LAN_FORUM_0066." ".$total_members."<br />".LAN_FORUM_0065." <a href='".e_HTTP."user.php ?id.".$nuser_id."'>".$nuser_name."</a>.\n"); // FIXME cannot find other references to e_TRACKING_DISABLED, use pref?
--*/
if(empty($FORUM_TEMPLATE)) if(empty($FORUM_TEMPLATE))
{ {
// include(e_PLUGIN.'forum/templates/forum_template.php');
// Override with theme template // Override with theme template
if(THEME_LEGACY !== true) //v2.x if(THEME_LEGACY !== true) //v2.x
{ {
@@ -348,7 +133,7 @@ if(is_array($FORUM_TEMPLATE) && THEME_LEGACY !== true) // new v2.x format.
$FORUM_MAIN_START = $FORUM_TEMPLATE['main']['start']; $FORUM_MAIN_START = $FORUM_TEMPLATE['main']['start'];
$FORUM_MAIN_PARENT = $FORUM_TEMPLATE['main']['parent']; $FORUM_MAIN_PARENT = $FORUM_TEMPLATE['main']['parent'];
$FORUM_MAIN_PARENT_END = $FORUM_TEMPLATE['main']['parent_end']; $FORUM_MAIN_PARENT_END = varset($FORUM_TEMPLATE['main']['parent_end']);
$FORUM_MAIN_FORUM = $FORUM_TEMPLATE['main']['forum']; $FORUM_MAIN_FORUM = $FORUM_TEMPLATE['main']['forum'];
$FORUM_MAIN_END = $FORUM_TEMPLATE['main']['end']; $FORUM_MAIN_END = $FORUM_TEMPLATE['main']['end'];
@@ -373,28 +158,20 @@ if (!$forumList)
} }
$forum_string = ''; $forum_string = '';
//--$pVars = new e_vars;
//--$frm = e107::getForm();
foreach ($forumList['parents'] as $parent) foreach ($forumList['parents'] as $parent)
{ {
// Gonne directly to shortcode file
//-- $status = parse_parent($parent);
//-- $pVars->PARENTSTATUS = $status;
//---- $sc->parentstatus = parse_parent($parent);
// Gonne directly to shortcode file $parent = (array) $parent;
// $pVars->PARENTNAME = "<a id='".$frm->name2id($parent['forum_name'])."'>".$parent['forum_name']."</a>";
// $pVars->PARENTNAME = $parent['forum_name'];
//---- $sc->parentname = $parent['forum_name'];
//-- $forum_string .= $tp->simpleParse($FORUM_MAIN_PARENT, $pVars);
// $sc->fparent = $parent;
$sc->setVars($parent); $sc->setVars($parent);
$sc->setScVar('forumParent', $parent); // $sc->setScVar('forumParent', $parent);
$sc->wrapper('forum/main/parent'); $sc->wrapper('forum/main/parent');
$forum_string .= $tp->parseTemplate($FORUM_MAIN_PARENT, true, $sc); $forum_string .= $tp->parseTemplate($FORUM_MAIN_PARENT, true, $sc);
if (!count($forumList['forums'][$parent['forum_id']]))
$fid = $parent['forum_id'];
if (empty($forumList['forums'][$parent['forum_id']]))
{ {
$text .= "<td colspan='5' style='text-align:center' class='forumheader3'>".LAN_FORUM_0068."</td>"; $text .= "<td colspan='5' style='text-align:center' class='forumheader3'>".LAN_FORUM_0068."</td>";
} }
@@ -432,79 +209,20 @@ foreach ($forumList['parents'] as $parent)
} }
} }
/*----
function parse_parent($parent)
{
if(!check_class($parent['forum_postclass']))
{
$status = '('.LAN_FORUM_0056.')';
}
return vartrue($status);
}
*/
function parse_forum($f, $restricted_string = '') function parse_forum($f, $restricted_string = '')
{ {
//---- global $FORUM_MAIN_FORUM, $gen, $forum, $newflag_list, $forumList, $sc;
global $FORUM_MAIN_FORUM, $forumList, $sc; global $FORUM_MAIN_FORUM, $forumList, $sc;
//-- $fVars = new e_vars;
//---- $e107 = e107::getInstance();
$tp = e107::getParser(); $tp = e107::getParser();
// Gonne directly to shortcode file
/*--
if(USER && is_array($newflag_list) && in_array($f['forum_id'], $newflag_list))
{
$fVars->NEWFLAG = "<a href='".$e107->url->create('forum/forum/mfar', $f)."'>".IMAGE_new.'</a>';
}
elseif(empty($f['forum_replies']) && defined('IMAGE_noreplies'))
{
$fVars->NEWFLAG = IMAGE_noreplies;
}
else
{
$fVars->NEWFLAG = IMAGE_nonew;
}
--*/
// Gonne directly to shortcode file
/*--
if(substr($f['forum_name'], 0, 1) == '*')
{
$f['forum_name'] = substr($f['forum_name'], 1);
}
$f['forum_name'] = $tp->toHTML($f['forum_name'], true, 'no_hook');
$f['forum_description'] = $tp->toHTML($f['forum_description'], true, 'no_hook');
//$url= $e107->url->create('forum/forum/view', $f);
$url = e107::url('forum', 'forum', $f);
$fVars->FORUMNAME = "<a href='".$url."'>{$f['forum_name']}</a>";
$fVars->FORUMDESCRIPTION = $f['forum_description'].($restricted_string ? "<br /><span class='smalltext'><i>$restricted_string</i></span>" : "");
--*/
//-- $fVars->THREADS = $f['forum_threads'];
//---- $sc->threads = $f['forum_threads'];
//-- $fVars->REPLIES = $f['forum_replies'];
//---- $sc->replies = $f['forum_replies'];
//-- $fVars->FORUMSUBFORUMS = '';
//-- $badgeReplies = ($f['forum_replies']) ? "badge-info" : "";
//-- $badgeThreads = ($f['forum_threads']) ? "badge-info" : "";
//-- $fVars->THREADSX = "<span class='badge {$badgeThreads}'>".$f['forum_threads']."</span>";
//-- $fVars->REPLIESX = "<span class='badge {$badgeReplies}'>".$f['forum_replies']."</span>";
//---- $subId = $f['forum_id'];
//---- if(!empty($forumList['subs']) && is_array($forumList['subs'][$subId]))
if(!empty($forumList['subs']) && is_array($forumList['subs'][$f['forum_id']])) if(!empty($forumList['subs']) && is_array($forumList['subs'][$f['forum_id']]))
{ {
//---- list($lastpost_datestamp, $lastpost_thread) = explode('.', $f['forum_lastpost_info']);
$lastpost_datestamp = reset(explode('.', $f['forum_lastpost_info'])); $lastpost_datestamp = reset(explode('.', $f['forum_lastpost_info']));
$ret = parse_subs($forumList, $f['forum_id'], $lastpost_datestamp); $ret = parse_subs($forumList, $f['forum_id'], $lastpost_datestamp);
// $fVars->FORUMSUBFORUMS = "<br /><div class='smalltext'>".LAN_FORUM_0069.": {$ret['text']}</div>";
//-- $fVars->THREADS += $ret['threads'];
//-- $fVars->REPLIES += $ret['replies'];
$f['forum_threads'] += $ret['threads']; $f['forum_threads'] += $ret['threads'];
$f['forum_replies'] += $ret['replies']; $f['forum_replies'] += $ret['replies'];
if(isset($ret['lastpost_info'])) if(isset($ret['lastpost_info']))
@@ -514,45 +232,12 @@ function parse_forum($f, $restricted_string = '')
$f['forum_lastpost_user_anon'] = $ret['lastpost_user_anon']; $f['forum_lastpost_user_anon'] = $ret['lastpost_user_anon'];
$f['user_name'] = $ret['user_name']; $f['user_name'] = $ret['user_name'];
} }
$f['text'] = $ret['text']; $f['text'] = $ret['text'];
} }
$sc->setVars($f); $sc->setVars($f);
/*--
if ($f['forum_lastpost_info'])
{
list($lastpost_datestamp, $lastpost_thread) = explode('.', $f['forum_lastpost_info']);
if ($f['user_name'])
{
$lastpost_name = "<a href='".$e107->url->create('user/profile/view', array('name' => $f['user_name'], 'id' => $f['forum_lastpost_user']))."'>{$f['user_name']}</a>";
}
else
{
$lastpost_name = $tp->toHTML($f['forum_lastpost_user_anon']);
}
$lastpost = $forum->threadGetLastpost($lastpost_thread); //XXX TODO inefficient to have SQL query here.
$fVars->LASTPOSTUSER = $lastpost_name;
// {forum_sef}/{thread_id}-{thread_sef}
$urlData = array('forum_sef'=>$f['forum_sef'], 'thread_id'=>$lastpost['post_thread'],'thread_sef'=>$lastpost['thread_sef']);
$url = e107::url('forum', 'topic', $urlData)."?last=1#post-".$lastpost['post_id'];
$fVars->LASTPOSTDATE .= "<a href='".$url."'>". $gen->computeLapse($lastpost_datestamp, time(), false, false, 'short')."</a>";
$lastpost_datestamp = $gen->convert_date($lastpost_datestamp, 'forum');
$fVars->LASTPOST = $lastpost_datestamp.'<br />'.$lastpost_name." <a href='".$e107->url->create('forum/thread/last', array('name' => $lastpost_name, 'id' => $lastpost_thread))."'>".IMAGE_post2.'</a>';
}
else
{
$fVars->LASTPOSTUSER = "";
$fVars->LASTPOSTDATE = "-";
$fVars->LASTPOST = '-';
}
--*/
//-- return $tp->simpleParse($FORUM_MAIN_FORUM, $fVars);
$sc->wrapper('forum/main/forum'); $sc->wrapper('forum/main/forum');
return $tp->parseTemplate($FORUM_MAIN_FORUM, true, $sc); return $tp->parseTemplate($FORUM_MAIN_FORUM, true, $sc);
@@ -612,38 +297,16 @@ if (e_QUERY == 'new')
$newThreadList = $forum->threadGetNew(10); $newThreadList = $forum->threadGetNew(10);
foreach($newThreadList as $thread) foreach($newThreadList as $thread)
{ {
//-- $author_name = ($thread['user_name'] ? $thread['user_name'] : $thread['lastuser_anon']);
//---- $sc->author_name = ($thread['user_name'] ? $thread['user_name'] : $thread['lastuser_anon']);
//-- $datestamp = $gen->convert_date($thread['thread_lastpost'], 'forum');
//---- $sc->datestamp = $gen->convert_date($thread['thread_lastpost'], 'forum');
/*--
if(!$thread['user_name'])
{
$nVars->STARTERTITLE = $author_name.'<br />'.$datestamp;
}
else
{
$nVars->STARTERTITLE = "<a href='".$e107->url->create('user/profile/view', array('id' => $thread['thread_lastuser'], 'name' => $author_name))."'>{$author_name}</a><br />".$datestamp;
}
$nVars->NEWSPOSTNAME = "<a href='".$e107->url->create('forum/thread/last', $thread)."'>".$tp->toHTML($thread['thread_name'], TRUE, 'no_make_clickable, no_hook').'</a>';
--*/
//-- $forum_newstring .= $tp->simpleParse($FORUM_NEWPOSTS_MAIN, $nVars);
$sc->setVars($thread); $sc->setVars($thread);
$forum_newstring .= $tp->parseTemplate($FORUM_NEWPOSTS_MAIN, true, $sc); $forum_newstring .= $tp->parseTemplate($FORUM_NEWPOSTS_MAIN, true, $sc);
} }
if (empty($newThreadList)) if (empty($newThreadList))
{ {
//-- $nVars->NEWSPOSTNAME = LAN_FORUM_0029;
//-- $forum_newstring = $tp->simpleParse($FORUM_NEWPOSTS_MAIN, $nVars);
$forum_newstring = $tp->parseTemplate($FORUM_NEWPOSTS_MAIN, true, $sc); $forum_newstring = $tp->parseTemplate($FORUM_NEWPOSTS_MAIN, true, $sc);
} }
//-- $forum_new_start = $tp->simpleParse($FORUM_NEWPOSTS_START, $nVars);
//-- $forum_new_end = $tp->simpleParse($FORUM_NEWPOSTS_END, $nVars);
$forum_new_start = $tp->parseTemplate($FORUM_NEWPOSTS_START, true, $sc); $forum_new_start = $tp->parseTemplate($FORUM_NEWPOSTS_START, true, $sc);
$forum_new_end = $tp->parseTemplate($FORUM_NEWPOSTS_END, true, $sc); $forum_new_end = $tp->parseTemplate($FORUM_NEWPOSTS_END, true, $sc);
@@ -657,15 +320,13 @@ if (e_QUERY == 'new')
} }
} }
//$frm = e107::getForm();
$breadarray = array( $breadarray = array(
array('text'=> $forum->prefs->get('title'), 'url' => e107::url('forum','index') ) array('text'=> $forum->prefs->get('title'), 'url' => e107::url('forum','index') )
); );
//-- $fVars->FORUM_BREADCRUMB = $frm->breadcrumb($breadarray);
//-- $forum_main_start = $tp->simpleParse($FORUM_MAIN_START, $fVars);
$sc->wrapper('forum/main/start'); $sc->wrapper('forum/main/start');
$forum_main_start = $tp->parseTemplate($FORUM_MAIN_START, true, $sc); $forum_main_start = $tp->parseTemplate($FORUM_MAIN_START, true, $sc);
//-- $forum_main_end = $tp->simpleParse($FORUM_MAIN_END, $fVars); //-- $forum_main_end = $tp->simpleParse($FORUM_MAIN_END, $fVars);
@@ -683,12 +344,6 @@ else
} }
require_once(FOOTERF); require_once(FOOTERF);
function forum_rules($action = 'check') function forum_rules($action = 'check')
@@ -871,7 +526,7 @@ function forum_track()
e107::getRender()->tablerender(LAN_FORUM_0030, $text, 'forum-track'); e107::getRender()->tablerender(LAN_FORUM_0030, $text, 'forum-track');
return null;
} }

View File

@@ -455,8 +455,8 @@ class e107forum
/** /**
* get user ids with moderator permissions for the given $forumId * get user ids with moderator permissions for the given $forumId
* @param $forumId id of a forum * @param int $forumId id of a forum
* @return an array with user ids how have moderator permissions for the $forumId * @return array with user ids how have moderator permissions for the $forumId
*/ */
public function getModeratorUserIdsByForumId($forumId) public function getModeratorUserIdsByForumId($forumId)
{ {
@@ -980,7 +980,7 @@ class e107forum
} }
$this->threadMarkAsRead($newThreadId); $this->threadMarkAsRead($newThreadId);
$threadInfo['thread_sef'] = $this->getThreadsef($threadInfo); $threadInfo['thread_sef'] = $this->getThreadSef($threadInfo);
$triggerData = $info['data']; $triggerData = $info['data'];
$triggerData['thread_id'] = $newThreadId; $triggerData['thread_id'] = $newThreadId;
@@ -1377,45 +1377,6 @@ class e107forum
// Empty the post_attachments field for this post in the database (prevents loop when deleting entire thread) // Empty the post_attachments field for this post in the database (prevents loop when deleting entire thread)
$sql->update("forum_post", "post_attachments = NULL WHERE post_id = ".$id); $sql->update("forum_post", "post_attachments = NULL WHERE post_id = ".$id);
/* Old code when attachments were still stored in plugin folder.
Left for review but may be deleted in future.
foreach($attachments as $k => $a)
{
$info = explode('*', $a);
if('' == $f || $info[1] == $f)
{
$fname = e_PLUGIN."forum/attachments/{$info[1]}";
@unlink($fname);
//If attachment is an image and there is a thumb, remove it
if('img' == $info[0] && $info[2])
{
$fname = e_PLUGIN."forum/attachments/thumb/{$info[2]}";
@unlink($fname);
}
}
unset($attachments[$k]);
}
$tmp = array();
if(count($attachments))
{
$tmp['post_attachments'] = implode(',', $attachments);
}
else
{
$tmp['post_attachments'] = '_NULL_';
}
$info = array();
$info['data'] = $tmp;
$info['_FILE_TYPES']['post_attachments'] = 'array';
$info['WHERE'] = 'post_id = '.$id;
$sql->update('forum_post', $info);
*/
} }
} }
@@ -1747,7 +1708,7 @@ class e107forum
* Get a list of forum IDs that have unread threads. * Get a list of forum IDs that have unread threads.
* If a forum is a subforum, also ensure the parent is in the list. * If a forum is a subforum, also ensure the parent is in the list.
* *
* @return type description * @return array|bool description
* @access public * @access public
*/ */
function forumGetUnreadForums() function forumGetUnreadForums()
@@ -2215,7 +2176,7 @@ class e107forum
$this->forumUpdateCounts($fid); $this->forumUpdateCounts($fid);
} }
return FORLAN_8." ( ".$thread_count." ".FORLAN_92.", ".$reply_count." ".FORLAN_93." )"; return FORLAN_8." ( ".$thread_count." ".FORLAN_92.", ".$reply_count." ".FORLAN_93." )";
return FORLAN_8." ( ".count($threadList)." ".FORLAN_92.", ".$reply_count." ".FORLAN_93." )"; // return FORLAN_8." ( ".count($threadList)." ".FORLAN_92.", ".$reply_count." ".FORLAN_93." )";
} }
else else
{ {
@@ -2357,7 +2318,10 @@ class e107forum
$threadInfo['thread_id'] = intval($threadInfo['thread_id']); $threadInfo['thread_id'] = intval($threadInfo['thread_id']);
$search = array('{THREAD_TITLE}', '{THREAD_HREF}'); $search = array('{THREAD_TITLE}', '{THREAD_HREF}');
$replace = array(vartrue($threadInfo['thread_name']), ''); // $thread->threadInfo - no reference found $replace = array(vartrue($threadInfo['thread_name']), ''); // $thread->threadInfo - no reference found
$FORUM_CRUMB['thread']['value'] = str_replace($search, $replace, $FORUM_CRUMB['thread']['value']);
$FORUM_CRUMB['thread']['value'] = str_replace($search, $replace, varset($FORUM_CRUMB['thread']['value']));
$FORUM_CRUMB['fieldlist'] = 'sitename,forums,parent,subparent,forum,thread'; $FORUM_CRUMB['fieldlist'] = 'sitename,forums,parent,subparent,forum,thread';
@@ -2416,13 +2380,12 @@ class e107forum
if($forumInfo['forum_sub']) if($forumInfo['forum_sub'])
{ {
$breadcrumb[] = array('text'=> ltrim($forumInfo['sub_parent'], '*') , 'url'=> e107::url('forum','forum', array('forum_sef'=> $forumInfo['parent_sef']))); $breadcrumb[] = array('text'=> ltrim($forumInfo['sub_parent'], '*') , 'url'=> e107::url('forum','forum', array('forum_sef'=> $forumInfo['parent_sef'])));
$breadcrumb[] = array('text'=>ltrim($forumInfo['forum_name'], '*') , 'url'=> (e_PAGE !='forum_viewforum.php') ? e107::url('forum', 'forum', $forumInfo) : null); $breadcrumb[] = array('text'=>ltrim($forumInfo['forum_name'], '*') , 'url'=> (defset('e_PAGE') !='forum_viewforum.php') ? e107::url('forum', 'forum', $forumInfo) : null);
} }
else else
{ {
$breadcrumb[] = array('text'=>ltrim($forumInfo['forum_name'], '*') , 'url'=> (e_PAGE !='forum_viewforum.php') ? e107::url('forum', 'forum', $forumInfo) : null); $breadcrumb[] = array('text'=>ltrim($forumInfo['forum_name'], '*') , 'url'=> (defset('e_PAGE') !='forum_viewforum.php') ? e107::url('forum', 'forum', $forumInfo) : null);
} }
if(vartrue($forumInfo['thread_name'])) if(vartrue($forumInfo['thread_name']))

View File

@@ -49,8 +49,6 @@ if(!deftrue('BOOTSTRAP'))
define('NAVIGATION_ACTIVE', 'forum'); define('NAVIGATION_ACTIVE', 'forum');
if(!e_QUERY && empty($_GET)) if(!e_QUERY && empty($_GET))
{ {
if(E107_DEBUG_LEVEL > 0) if(E107_DEBUG_LEVEL > 0)
@@ -77,7 +75,10 @@ $forum = new e107forum;
//$view = 25; //$view = 25;
$view = $forum->prefs->get('threadspage', 25); $view = $forum->prefs->get('threadspage', 25);
if(!$view) { $view = 25; } if(!$view)
{
$view = 25;
}
$page = (varset($_GET['p']) ? $_GET['p'] : 1); $page = (varset($_GET['p']) ? $_GET['p'] : 1);
$threadFrom = ($page - 1) * $view; $threadFrom = ($page - 1) * $view;
@@ -85,16 +86,6 @@ global $forum_info, $FORUM_CRUMB;
$sc = e107::getScBatch('viewforum', 'forum'); $sc = e107::getScBatch('viewforum', 'forum');
//----$fVars = new e_vars;
/*--
$fVars->STARTERTITLE = LAN_FORUM_1004;
$fVars->THREADTITLE = LAN_FORUM_1003;
$fVars->REPLYTITLE = LAN_FORUM_0003;
$fVars->LASTPOSTITLE = LAN_FORUM_0004;
$fVars->VIEWTITLE = LAN_FORUM_1005;
--*/
$forumId = (int) $_REQUEST['id']; $forumId = (int) $_REQUEST['id'];
if(!$forumId && e_QUERY) // BC Fix for old links. if(!$forumId && e_QUERY) // BC Fix for old links.
@@ -183,7 +174,6 @@ if(!empty($FORUM_VIEWFORUM_TEMPLATE) && is_array($FORUM_VIEWFORUM_TEMPLATE) && T
} }
$forumInfo['forum_name'] = $tp->toHTML($forumInfo['forum_name'], true, 'no_hook, emotes_off'); $forumInfo['forum_name'] = $tp->toHTML($forumInfo['forum_name'], true, 'no_hook, emotes_off');
$forumInfo['forum_description'] = $tp->toHTML($forumInfo['forum_description'], true, 'no_hook'); $forumInfo['forum_description'] = $tp->toHTML($forumInfo['forum_description'], true, 'no_hook');
@@ -219,12 +209,8 @@ if(e_AJAX_REQUEST && MODERATOR) // see javascript above.
if(varset($pref['track_online'])) if(varset($pref['track_online']))
{ {
// $member_users = $sql->count('online', '(*)', "WHERE online_location REGEXP('viewforum.php.id=$forumId\$') AND online_user_id != 0");
// $guest_users = $sql->count('online', '(*)', "WHERE online_location REGEXP('viewforum.php.id=$forumId\$') AND online_user_id = 0");
$member_users = $sql->count('online', '(*)', "WHERE online_location LIKE('" . $tp->filter(e_REQUEST_URI, 'url') . "%') AND online_user_id != 0"); $member_users = $sql->count('online', '(*)', "WHERE online_location LIKE('" . $tp->filter(e_REQUEST_URI, 'url') . "%') AND online_user_id != 0");
$guest_users = $sql->count('online', '(*)', "WHERE online_location LIKE('" . $tp->filter(e_REQUEST_URI, 'url') . "%') AND online_user_id = 0"); $guest_users = $sql->count('online', '(*)', "WHERE online_location LIKE('" . $tp->filter(e_REQUEST_URI, 'url') . "%') AND online_user_id = 0");
$users = $member_users + $guest_users; $users = $member_users + $guest_users;
} }
@@ -270,13 +256,8 @@ if ($pages)
// issue #3087 url need to be decoded first (because the [FROM] get's encoded in url()) // issue #3087 url need to be decoded first (because the [FROM] get's encoded in url())
// and to encode the full url to not loose the id param when being used in the $forumSCvars['parms'] // and to encode the full url to not loose the id param when being used in the $forumSCvars['parms']
$url = rawurlencode(rawurldecode(e107::url('forum', 'forum', $forumInfo, array('query' => array('p' => '[FROM]'))))); $url = rawurlencode(rawurldecode(e107::url('forum', 'forum', $forumInfo, array('query' => array('p' => '[FROM]')))));
/*--
$parms = "total={$pages}&type=page&current={$page}&url=".$url."&caption=off";
$fVars->THREADPAGES = $tp->parseTemplate("{NEXTPREV={$parms}}");
--*/
$forumSCvars['parms'] = "total={$pages}&type=page&current={$page}&url=" . $url . "&caption=off"; $forumSCvars['parms'] = "total={$pages}&type=page&current={$page}&url=" . $url . "&caption=off";
//-- ?????????? unset $ulrparms????
unset($urlparms); unset($urlparms);
} }
} }
@@ -285,18 +266,6 @@ if ($pages)
if($forum->checkPerm($forumId, 'post')) //new thread access only. if($forum->checkPerm($forumId, 'post')) //new thread access only.
{ {
$forumSCvars['ntUrl'] = e107::url('forum', 'post') . "?f=nt&amp;id=" . $forumId; $forumSCvars['ntUrl'] = e107::url('forum', 'post') . "?f=nt&amp;id=" . $forumId;
/*--
$ntUrl = e107::url('forum','post')."?f=nt&amp;id=". $forumId;
$fVars->NEWTHREADBUTTON = "<a href='".$ntUrl."'>".IMAGE_newthread.'</a>';
$fVars->NEWTHREADBUTTONX = newthreadjump($ntUrl);
}
if(!BOOTSTRAP)
{
$fVars->NEWTHREADBUTTONX = $fVars->NEWTHREADBUTTON;
}
--*/
} }
//XXX What is this? //XXX What is this?
@@ -321,145 +290,19 @@ if(substr($forum_info['sub_parent'], 0, 1) == '*')
$forum->set_crumb(true, '', $forumSCvars); // set $BREADCRUMB (and $BACKLINK) $forum->set_crumb(true, '', $forumSCvars); // set $BREADCRUMB (and $BACKLINK)
$modUser = array(); $modUser = array();
$modArray = $forum->forumGetMods();
foreach($modArray as $user) foreach($modArray as $user)
{ {
$modUser[] = "<a href='" . e107::getUrl()->create('user/profile/view', $user) . "'>" . $user['user_name'] . "</a>"; $modUser[] = "<a href='" . e107::getUrl()->create('user/profile/view', $user) . "'>" . $user['user_name'] . "</a>";
} }
/*--
$fVars->FORUMTITLE = $forumInfo['forum_name'];
$fVars->MODERATORS = LAN_FORUM_1009.': '.implode(', ', $modUser);
$fVars->BROWSERS = '';
--*/
$forumSCvars['forum_name'] = $forumInfo['forum_name']; $forumSCvars['forum_name'] = $forumInfo['forum_name'];
$forumSCvars['forum_description'] = $forumInfo['forum_description']; $forumSCvars['forum_description'] = $forumInfo['forum_description'];
$forumSCvars['forum_image'] = $forumInfo['forum_image']; $forumSCvars['forum_image'] = $forumInfo['forum_image'];
$forumSCvars['modUser'] = $modUser; $forumSCvars['modUser'] = $modUser;
$forumSCvars['track_online'] = varset($pref['track_online']); $forumSCvars['track_online'] = varset($pref['track_online']);
/*--
if(varset($pref['track_online']))
{
$fVars->BROWSERS = $users.' '.($users == 1 ? LAN_FORUM_0059 : LAN_FORUM_0060).' ('.$member_users.' '.($member_users == 1 ? LAN_FORUM_0061 : LAN_FORUM_0062).", ".$guest_users." ".($guest_users == 1 ? LAN_FORUM_0063 : LAN_FORUM_0064).')';
}
if(defset('BOOTSTRAP')==3 && !empty($FORUM_VIEWFORUM_TEMPLATE['iconkey'])) // v2.x
{
$fVars->ICONKEY = $tp->parseTemplate($FORUM_VIEWFORUM_TEMPLATE['iconkey'],true);
}
else // v1.x
{
$fVars->ICONKEY = "
<table class='table table-bordered' style='width:100%'>
<tr>
<td style='vertical-align:middle; text-align:center; width:2%'>".IMAGE_new_small."</td>
<td style='width:10%' class='smallblacktext'>".LAN_FORUM_0039."</td>
<td style='vertical-align:middle; text-align:center; width:2%'>".IMAGE_nonew_small."</td>
<td style='width:10%' class='smallblacktext'>".LAN_FORUM_0040."</td>
<td style='vertical-align:middle; text-align:center; width:2%'>".IMAGE_sticky_small."</td>
<td style='width:10%' class='smallblacktext'>".LAN_FORUM_1011."</td>
<td style='vertical-align:middle; text-align:center; width:2%'>".IMAGE_announce_small."</td>
<td style='width:10%' class='smallblacktext'>".LAN_FORUM_1013."</td>
</tr>
<tr>
<td style='vertical-align:middle; text-align:center; width:2%'>".IMAGE_new_popular_small."</td>
<td style='width:2%' class='smallblacktext'>".LAN_FORUM_0039." ".LAN_FORUM_1010."</td>
<td style='vertical-align:middle; text-align:center; width:2%'>".IMAGE_nonew_popular_small."</td>
<td style='width:10%' class='smallblacktext'>".LAN_FORUM_0040." ".LAN_FORUM_1010."</td>
<td style='vertical-align:middle; text-align:center; width:2%'>".IMAGE_stickyclosed_small."</td>
<td style='width:10%' class='smallblacktext'>".LAN_FORUM_1012."</td>
<td style='vertical-align:middle; text-align:center; width:2%'>".IMAGE_closed_small."</td>
<td style='width:10%' class='smallblacktext'>".LAN_FORUM_1014."</td>
</tr>
</table>";
}
--*/
// ----------------- { VIEWABLE_BY } ---------------------------
/*--
if($users = $forum->getForumClassMembers($forumId))
{
$userList = array();
if(is_array($users))
{
foreach($users as $user)
{
$userList[] = "<a href='".e107::getUrl()->create('user/profile/view', $user)."'>".$user['user_name']."</a>";
}
$viewable = implode(', ', $userList);;
}
elseif($users == 0)
{
$viewable = '' ;
}
else
{
$viewable = e107::getUserClass()->getFixedClassDescription($users);
}
}
if(!empty($viewable))
{
$fVars->VIEWABLE_BY = "
<div class='panel panel-default' style='margin-top:10px'>
<div class='panel-heading'>Viewable by</div>
<div class='panel-body'>
".$viewable."
</div>
</div>
</div>
";
}
else
{
$fVars->VIEWABLE_BY = '';
}
--*/
// ------------------------------------------------------------
///TODO XXX All these $fVars items need to be put into a shortcode class so they can be parsed with parms and wrappers. Big Job!
/*--
$fVars->SEARCH = "
<form method='get' class='form-inline input-append' action='".e_BASE."search.php'>
<p>
<input class='tbox' type='text' name='q' size='20' value='' maxlength='50' />
<button class='btn btn-default button' type='submit' name='s' >".LAN_SEARCH."</button>
<input type='hidden' name='r' value='0' />
<input type='hidden' name='ref' value='forum' />
</p>
</form>";
--*/
/*--
// ----- Perm Display ---
$permDisplay = array();
$permDisplay['topics'] = ($forum->checkPerm($forumId, 'thread')) ? LAN_FORUM_0043 : LAN_FORUM_0044;
if($forum->checkPerm($forumId, 'post'))
{
$permDisplay['post'] =LAN_FORUM_0045;
$permDisplay['edit'] = LAN_FORUM_0047;
}
else
{
$permDisplay['post'] =LAN_FORUM_0046;
$permDisplay['edit'] = LAN_FORUM_0048;
}
$fVars->PERMS = implode("<span class='forum-perms-separator'><!-- --></span>", $permDisplay);
--*/
// -------------------------------
$sticky_threads = 0; $sticky_threads = 0;
$stuck = false; $stuck = false;
@@ -474,24 +317,10 @@ if(!empty($_GET['srch']))
} }
$threadList = $forum->forumGetThreads($forumId, $threadFrom, $view, $threadFilter); $threadList = $forum->forumGetThreads($forumId, $threadFrom, $view, $threadFilter);
/*--
$subList = $forum->forumGetSubs(vartrue($forum_id));
--*/
//------$gen = new convert;
$forumSCvars['forum_parent'] = $forumInfo['forum_parent']; $forumSCvars['forum_parent'] = $forumInfo['forum_parent'];
/*--
$fVars->SUBFORUMS = ''; $forum_view_forum = '';
if(is_array($subList) && isset($subList[$forumInfo['forum_parent']][$forumId]))
{
$newflag_list = $forum->forumGetUnreadForums();
$sub_info = '';
foreach($subList[$forumInfo['forum_parent']][$forumId] as $sub)
{
$sub_info .= parse_sub($sub);
}
$fVars->SUBFORUMS = $FORUM_VIEW_SUB_START.$sub_info.$FORUM_VIEW_SUB_END;
}
--*/
if(count($threadList)) if(count($threadList))
{ {
foreach($threadList as $thread_info) foreach($threadList as $thread_info)
@@ -569,22 +398,17 @@ if($container_only)
$sc->setVars($forumSCvars); $sc->setVars($forumSCvars);
//var_dump ($FORUM_VIEW_START);
// var_dump ($FORUM_VIEW_SUB);
$forum_view_start = $tp->parseTemplate($FORUM_VIEW_START_CONTAINER . $FORUM_VIEW_START, true, $sc); $forum_view_start = $tp->parseTemplate($FORUM_VIEW_START_CONTAINER . $FORUM_VIEW_START, true, $sc);
$forum_view_forum = $tp->parseTemplate($forum_view_forum, true, $sc); $forum_view_forum = $tp->parseTemplate($forum_view_forum, true, $sc);
$forum_view_end = $tp->parseTemplate($FORUM_VIEW_END . $FORUM_VIEW_END_CONTAINER, true, $sc); $forum_view_end = $tp->parseTemplate($FORUM_VIEW_END . $FORUM_VIEW_END_CONTAINER, true, $sc);
//$forum_view_start .= "<hr><hr>FVARS FORUM<hr><hr>".$tp->simpleParse($FORUM_VIEW_START, $fVars);
//$forum_view_end = $tp->simpleParse($FORUM_VIEW_END, $fVars);
if($forum->prefs->get('enclose')) if($forum->prefs->get('enclose'))
{ {
// $forum_view_subs???? // $forum_view_subs????
$caption = varset($FORUM_VIEW_CAPTION) ? $tp->parseTemplate($FORUM_VIEW_CAPTION, true, $sc) : $forum->prefs->get('title'); $caption = varset($FORUM_VIEW_CAPTION) ? $tp->parseTemplate($FORUM_VIEW_CAPTION, true, $sc) : $forum->prefs->get('title');
$ns->tablerender($caption, $forum_view_start.$forum_view_subs.$forum_view_forum.$forum_view_end, 'forum-viewforum'); $ns->tablerender($caption, $forum_view_start . /*$forum_view_subs.*/ $forum_view_forum . $forum_view_end, 'forum-viewforum');
} }
else else
{ {
@@ -600,277 +424,15 @@ echo "<script type=\"text/javascript\">
require_once(FOOTERF); require_once(FOOTERF);
function parse_thread($thread_info) function parse_thread($thread_info)
{ {
//var_dump ($thread_info);
/* OLD CODE
global $forum, $FORUM_VIEW_FORUM, $FORUM_VIEW_FORUM_STICKY, $FORUM_VIEW_FORUM_ANNOUNCE, $gen, $menu_pref, $threadsViewed;
$tp = e107::getParser();
$tVars = new e_vars;
$threadId = $thread_info['thread_id']; // TODO Remove globals.
$forumId = $thread_info['thread_forum_id'];
$tVars = array();
$tVars['VIEWS'] = $thread_info['thread_views'];
$tVars['REPLIES'] = $thread_info['thread_total_replies'];
$badge = ($thread_info['thread_views'] > 0) ? "badge-info" : "";
$tVars['REPLIESX'] = "<span class='badge badge-info'>".$thread_info['thread_total_replies']."</span>";
$tVars['VIEWSX'] = "<span class='badge {$badge}'>".$thread_info['thread_views']."</span>";
if ($tVars['REPLIES'])
{
$lastpost_datestamp = $gen->convert_date($thread_info['thread_lastpost'], 'forum');
if($thread_info['lastpost_username'])
{
// XXX hopefully & is not allowed in user name - it would break parsing of url parameters, change to array if something wrong happens
$url = e107::getUrl()->create('user/profile/view', "name={$thread_info['lastpost_username']}&id={$thread_info['thread_lastuser']}");
$tVars['LASTPOST'] = "<a href='{$url}'>".$thread_info['lastpost_username']."</a>";
$tVars['LASTPOSTUSER'] = "<a href='{$url}'>".$thread_info['lastpost_username']."</a>";
}
else
{
if(!$thread_info['thread_lastuser'])
{
$tVars['LASTPOST'] = $tp->toHTML($thread_info['thread_lastuser_anon']);
$tVars['LASTPOSTUSER'] = $tp->toHTML($thread_info['thread_lastuser_anon']);
}
else
{
$tVars['LASTPOST'] = LAN_FORUM_1015;
$tVars['LASTPOSTUSER'] = LAN_FORUM_1015;
}
}
$tVars['LASTPOST'] .= '<br />'.$lastpost_datestamp;
$tVars['LASTPOSTUSER'] = $thread_info['lastpost_username']; // $lastpost_name;
$thread_info['thread_sef'] = eHelper::title2sef($thread_info['thread_name'],'dashl');
$urlData = array('forum_sef'=>$thread_info['forum_sef'], 'thread_id'=>$thread_info['thread_id'],'thread_sef'=>$thread_info['thread_sef']);
$url = e107::url('forum', 'topic', $urlData);
$url .= (strpos($url,'?')!==false) ? '&' : '?';
$url .= "last=1#post-".$thread_info['lastpost_id'];
$tVars['LASTPOSTDATE'] .= "<a href='".$url."'>". $gen->computeLapse($thread_info['thread_lastpost'],time(), false, false, 'short')."</a>";
}
$newflag = (USER && $thread_info['thread_lastpost'] > USERLV && !in_array($thread_info['thread_id'], $threadsViewed));
$tVars['THREADDATE'] = $gen->convert_date($thread_info['thread_datestamp'], 'forum');
$tVars['THREADTIMELAPSE'] = $gen->computeLapse($thread_info['thread_datestamp'],time(), false, false, 'short'); // convert_date($thread_info['thread_datestamp'], 'forum');
/// ---------- Icon ----------------
$tVars['ICON'] = ($newflag ? IMAGE_new : IMAGE_nonew);
if ($tVars['REPLIES'] >= $forum->prefs->get('popular', 10))
{
$tVars['ICON'] = ($newflag ? IMAGE_new_popular : IMAGE_nonew_popular);
}
elseif(empty($tVars['REPLIES']) && defined('IMAGE_noreplies'))
{
$tVars['ICON'] = IMAGE_noreplies;
}
$tVars['THREADTYPE'] = '';
if ($thread_info['thread_sticky'] == 1)
{
$tVars['ICON'] = ($thread_info['thread_active'] ? IMAGE_sticky : IMAGE_stickyclosed);
$tVars['THREADTYPE'] = '['.LAN_FORUM_1011.']<br />';
}
elseif($thread_info['thread_sticky'] == 2)
{
$tVars['ICON'] = IMAGE_announce;
$tVars['THREADTYPE'] = '['.LAN_FORUM_1013.']<br />';
}
elseif(!$thread_info['thread_active'])
{
$tVars['ICON'] = IMAGE_closed;
}
// $tVars['ICON'] = $tVars['REPLIES'];
// ------------------------------------------------------
$thread_name = strip_tags($tp->toHTML($thread_info['thread_name'], false, 'no_hook, emotes_off'));
if(isset($thread_info['thread_options']['poll']))
{
$thread_name = '['.LAN_FORUM_1016.'] ' . $thread_name;
}
// if (strtoupper($THREADTYPE) == strtoupper(substr($thread_name, 0, strlen($THREADTYPE))))
// {
// $thread_name = substr($thread_name, strlen($THREADTYPE));
// }
if ($forum->prefs->get('tooltip'))
{
$thread_thread = strip_tags($tp->toHTML($thread_info['thread_thread'], true, 'no_hook'));
$tip_length = $forum->prefs->get('tiplength', 400);
if (strlen($thread_thread) > $tip_length)
{
//$thread_thread = substr($thread_thread, 0, $tip_length).' '.$menu_pref['newforumposts_postfix'];
$thread_thread = $tp->text_truncate($thread_thread, $tip_length, $menu_pref['newforumposts_postfix']); // Doesn't split entities
}
$thread_thread = str_replace("'", '&#39;', $thread_thread);
$title = "title='".$thread_thread."'";
}
else
{
$title = '';
}
// $tVars['THREADNAME'] = "<a {$title} href='".e107::getUrl()->create('forum/thread/view', array('id' => $threadId, 'name' => $thread_name))."'>{$thread_name}</a>";
// $url = e107::getUrl()->create('forum/thread/view', array('id' => $threadId, 'name' => $thread_name));
$thread_info['thread_sef'] = eHelper::title2sef($thread_info['thread_name'],'dashl');
$url = e107::url('forum','topic', $thread_info);
$tVars['THREADNAME'] = "<a {$title} href='".$url."'>{$thread_name}</a>";
// FIXME - pages -> convert to nextprev shortcode
/*
$pages = ceil(($tVars['REPLIES'])/$forum->prefs->get('postspage'));
$urlparms = $thread_info;
if ($pages > 1)
{
if($pages > 6)
{
for($a = 0; $a <= 2; $a++)
{
$aa = $a + 1;
$tVars['PAGES'] .= $tVars['PAGES'] ? ' ' : '';
$urlparms['page'] = $aa;
$url = e107::getUrl()->create('forum/thread/view', $urlparms);
$tVars['PAGES'] .= "<a href='{$url}'>{$aa}</a>";
}
$tVars['PAGES'] .= ' ... ';
for($a = $pages-3; $a <= $pages-1; $a++)
{
$aa = $a + 1;
$tVars['PAGES'] .= $tVars['PAGES'] ? ' ' : '';
$urlparms['page'] = $aa;
$url = e107::getUrl()->create('forum/thread/view', $urlparms);
$tVars['PAGES'] .= "<a href='{$url}'>{$aa}</a>";
}
}
else
{
for($a = 0; $a <= ($pages-1); $a++)
{
$aa = $a + 1;
$tVars['PAGES'] .= $tVars['PAGES'] ? ' ' : '';
$urlparms['page'] = $aa;
$url = e107::getUrl()->create('forum/thread/view', $urlparms);
$tVars['PAGES'] .= "<a href='{$url}'>{$aa}</a>";
}
}
$tVars['PAGES'] = LAN_GOTO.' [&nbsp;'.$tVars['PAGES'].'&nbsp;]';
}
else
{
$tVars['PAGES'] = '';
}
*/
/* OLD CODE
$tVars['PAGES'] = fpages($thread_info, $tVars['REPLIES']);
$tVars['PAGESX'] = fpages($thread_info, $tVars['REPLIES']);
if (MODERATOR)
{
// FIXME _URL_ thread name
// e107::getUrl()->create('forum/forum/view', "id={$thread_info['thread_forum_id']}")
// USED self instead
$moveUrl = e107::url('forum','move', $thread_info);
$tVars['ADMIN_ICONS'] = "
<form method='post' action='".e_REQUEST_URI."' id='frmMod_{$forumId}_{$threadId}' style='margin:0;'><div class='forum-viewforum-admin-icons'>
<input type='image' ".IMAGE_admin_delete." name='deleteThread_{$threadId}' value='thread_action' onclick=\"return confirm_({$threadId})\" />
".($thread_info['thread_sticky'] == 1 ? "<input type='image' ".IMAGE_admin_unstick." name='unstick_{$threadId}' value='thread_action' /> " : "<input type='image' ".IMAGE_admin_stick." name='stick_{$threadId}' value='thread_action' /> ")."
".($thread_info['thread_active'] ? "<input type='image' ".IMAGE_admin_lock." name='lock_{$threadId}' value='thread_action' /> " : "<input type='image' ".IMAGE_admin_unlock." name='unlock_{$threadId}' value='thread_action' /> "). "
<a class='e-tip' title=\"".LAN_FORUM_5019."\" href='".$moveUrl."'>".IMAGE_admin_move.'</a>
</div></form>
';
$tVars['ADMINOPTIONS'] = fadminoptions($thread_info);
}
if($thread_info['user_name'])
{
$tVars['POSTER'] = "<a href='".e107::getUrl()->create('user/profile/view', array('id' => $thread_info['thread_user'], 'name' => $thread_info['user_name']))."'>".$thread_info['user_name']."</a>";
}
else
{
if($thread_info['thread_user_anon'])
{
$tVars['POSTER'] = $tp->toHTML($thread_info['thread_user_anon']);
}
else
{
$tVars['POSTER'] = LAN_FORUM_1015;
}
}
if (!$tVars['REPLIES'])
{
$tVars['REPLIES'] = '0';
$tVars['REPLIESX'] = "<span class='badge'>0</span>";
$tVars['LASTPOST'] = ' - ';
$tVars['LASTPOSTDATE'] = ' - ';
}
switch($thread_info['thread_sticky'])
{
case 1:
$_TEMPLATE = ($FORUM_VIEW_FORUM_STICKY ? $FORUM_VIEW_FORUM_STICKY : $FORUM_VIEW_FORUM);
break;
case 2:
$_TEMPLATE = ($FORUM_VIEW_FORUM_ANNOUNCE ? $FORUM_VIEW_FORUM_ANNOUNCE : $FORUM_VIEW_FORUM);
break;
default:
$_TEMPLATE = $FORUM_VIEW_FORUM;
break;
}
if(substr($_TEMPLATE,0,4) == '<tr>') // Inject id into table row. //XXX Find a better way to do this without placing in template. .
{
$_TEMPLATE = "<tr id='thread-{$threadId}'>".substr($_TEMPLATE,4);
}
if(!deftrue('BOOTSTRAP'))
{
$tVars['REPLIESX'] = $tVars['REPLIES'];
$tVars['VIEWSX'] = $tVars['VIEWS'];
$tVars['ADMINOPTIONS'] = $tVars['ADMIN_ICONS'];
}
$tVars['_WRAPPER_'] = 'forum_viewforum';
return $tp->parseTemplate($_TEMPLATE, true, $tVars);
*/
// NEW REWRITTEN CODE
global $sc, $FORUM_VIEW_FORUM, $FORUM_VIEW_FORUM_STICKY, $FORUM_VIEW_FORUM_ANNOUNCE; global $sc, $FORUM_VIEW_FORUM, $FORUM_VIEW_FORUM_STICKY, $FORUM_VIEW_FORUM_ANNOUNCE;
$tp = e107::getParser(); $tp = e107::getParser();
// Initial ideia, to have a separate shortcode var ($threadsc)....
// $threadsc = e107::getScBatch('viewforum', 'forum', 'viewforumthread');
// $threadsc->setVars($thread_info);
$sc->setVars($thread_info); $sc->setVars($thread_info);
switch($thread_info['thread_sticky']) switch($thread_info['thread_sticky'])
@@ -901,72 +463,10 @@ function parse_thread($thread_info)
} }
/*----
function parse_sub($subInfo)
{
global $FORUM_VIEW_SUB, $gen, $newflag_list;
$tp = e107::getParser();
// $tVars = new e_vars;
$forumName = $tp->toHTML($subInfo['forum_name'], true);
$tVars['SUB_FORUMTITLE'] = "<a href='".e107::getUrl()->create('forum/forum/view', $subInfo)."'>{$forumName}</a>";
$tVars['SUB_DESCRIPTION'] = $tp->toHTML($subInfo['forum_description'], false, 'no_hook');
$tVars['SUB_THREADS'] = $subInfo['forum_threads'];
$tVars['SUB_REPLIES'] = $subInfo['forum_replies'];
$badgeReplies = ($subInfo['forum_replies']) ? "badge-info" : "";
$badgeThreads = ($subInfo['forum_replies']) ? "badge-info" : "";
$tVars['SUB_THREADSX'] = "<span class='badge {$badgeThreads}'>".$subInfo['forum_threads']."</span>";
$tVars['SUB_REPLIESX'] = "<span class='badge {$badgeReplies}'>".$subInfo['forum_replies']."</span>";
// $tVars['REPLIESX'] = "<span class='badge badge-info'>".$thread_info['thread_total_replies']."</span>";
// $tVars['VIEWSX'] = "<span class='badge {$badge}'>".$thread_info['thread_views']."</span>";
if(USER && is_array($newflag_list) && in_array($subInfo['forum_id'], $newflag_list))
{
$tVars['NEWFLAG'] = "<a href='".e107::getUrl()->create('forum/forum/mfar', 'id='.$subInfo['forum_id'])."'>".IMAGE_new.'</a>';
}
else
{
$tVars['NEWFLAG'] = IMAGE_nonew;
}
if($subInfo['forum_lastpost_info'])
{
$tmp = explode('.', $subInfo['forum_lastpost_info']);
$lp_thread = "<a href='".e107::getUrl()->create('forum/thread/last', array('id' => $tmp[1]))."'>".IMAGE_post2.'</a>';
$lp_date = $gen->convert_date($tmp[0], 'forum');
if($subInfo['user_name'])
{
$lp_name = "<a href='".e107::getUrl()->create('user/profile/view', array('id' => $subInfo['forum_lastpost_user'], 'name' => $subInfo['user_name']))."'>{$subInfo['user_name']}</a>";
}
else
{
$lp_name = $subInfo['forum_lastpost_user_anon'];
}
$tVars['SUB_LASTPOST'] = $lp_date.'<br />'.$lp_name.' '.$lp_thread;
$tVars['SUB_LASTPOSTDATE'] = $gen->computeLapse($tmp[0], time(), false, false, 'short');
$tVars['SUB_LASTPOSTUSER'] = $lp_name;
}
else
{
$tVars['SUB_LASTPOST'] = '-';
$tVars['SUB_LASTPOSTUSER'] = '';
$tVars['SUB_LASTPOSTDATE'] = '';
}
$tVars['_WRAPPER_'] = 'forum_viewforum';
return $tp->parseTemplate($FORUM_VIEW_SUB, true, $tVars);
}
----*/
function forumjump() function forumjump()
{ {
global $forum; global $forum;
$jumpList = $forum->forumGetAllowed('view'); $jumpList = $forum->forumGetAllowed('view');
$text = "<form method='post' action='" . e_SELF . "'><p>" . LAN_FORUM_1017 . ": <select name='forumjump' class='tbox'>"; $text = "<form method='post' action='" . e_SELF . "'><p>" . LAN_FORUM_1017 . ": <select name='forumjump' class='tbox'>";
@@ -975,11 +475,15 @@ function forumjump()
$text .= "\n<option value='" . e107::url('forum', 'forum', $val, 'full') . "'>" . $val['forum_name'] . "</option>"; $text .= "\n<option value='" . e107::url('forum', 'forum', $val, 'full') . "'>" . $val['forum_name'] . "</option>";
} }
$text .= "</select> <input class='btn btn-default btn-secondary button' type='submit' name='fjsubmit' value='" . LAN_GO . "' /></form>"; $text .= "</select> <input class='btn btn-default btn-secondary button' type='submit' name='fjsubmit' value='" . LAN_GO . "' /></form>";
return $text; return $text;
} }
function fadminoptions($thread_info) function fadminoptions($thread_info)
{ {
//-- $tVars here??? //-- $tVars here???
//---- $tVars = new e_vars; //---- $tVars = new e_vars;
$e107 = e107::getInstance(); $e107 = e107::getInstance();
@@ -1011,7 +515,6 @@ function fadminoptions($thread_info)
); );
$text .= "<li class='text-right'><a class='dropdown-item' href='" . e_REQUEST_URI . "' data-forum-action='delete' 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='delete' 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='" . $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='" . e_REQUEST_URI . "' data-forum-action='" . $lockUnlock . "' data-forum-thread='" . $id . "'>" . $lan[$lockUnlock] . " " . $icon[$lockUnlock] . "</a></li>";
@@ -1037,6 +540,7 @@ function fadminoptions($thread_info)
*/ */
$text .= "</ul></div>"; $text .= "</ul></div>";
// $text .= "</form>"; // $text .= "</form>";
return $text; return $text;
} }
@@ -1044,6 +548,7 @@ function fadminoptions($thread_info)
function fpages($thread_info, $replies) function fpages($thread_info, $replies)
{ {
global $forum; global $forum;
$tp = e107::getParser(); $tp = e107::getParser();
@@ -1125,6 +630,7 @@ function fpages($thread_info, $replies)
function newthreadjump($url) function newthreadjump($url)
{ {
global $forum; global $forum;
$jumpList = $forum->forumGetAllowed('view'); $jumpList = $forum->forumGetAllowed('view');
@@ -1147,4 +653,6 @@ function newthreadjump($url)
return $text; return $text;
} }
?> ?>

View File

@@ -400,10 +400,7 @@ class forum_shortcodes extends e_shortcode
$this->var['forum_name'] = e107::getParser()->toHTML($this->var['forum_name'], true, 'no_hook'); $this->var['forum_name'] = e107::getParser()->toHTML($this->var['forum_name'], true, 'no_hook');
if(!empty($parm['class'])) $class = !empty($parm['class']) ? "class='".$parm['class']."'" : '';
{
$class = "class='".$parm['class']."'";
}
$url = e107::url('forum', 'forum', $this->var); $url = e107::url('forum', 'forum', $this->var);
return "<a href='".$url."' ".$class.">{$this->var['forum_name']}</a>"; return "<a href='".$url."' ".$class.">{$this->var['forum_name']}</a>";

View File

@@ -178,14 +178,16 @@ $FORUMEND = "<tr><td colspan='2' class='forumheader3' style='text-align:center'>
</td> </td>
</tr> </tr>
</table> </table>
</div> </div>";
<!--
/*
<div style='text-align:center' class='spacer'> <div style='text-align:center' class='spacer'>
<a href='".e_PLUGIN."rss_menu/rss.php?8.1.".e_QUERY."'><img src='".e_PLUGIN."rss_menu/images/rss1.png' alt='".LAN_431."' style='vertical-align: middle; border: 0;' /></a> <a href='".e_PLUGIN."rss_menu/rss.php?8.2.".e_QUERY."'><img src='".e_PLUGIN."rss_menu/images/rss2.png' alt='".LAN_432."' style='vertical-align: middle; border: 0;' /></a> <a href='".e_PLUGIN."rss_menu/rss.php?8.3.".e_QUERY."'><img src='".e_PLUGIN."rss_menu/images/rss3.png' alt='".LAN_433."' style='vertical-align: middle; border: 0;' /></a> <a href='".e_PLUGIN."rss_menu/rss.php?8.1.".e_QUERY."'><img src='".e_PLUGIN."rss_menu/images/rss1.png' alt='".LAN_FORUM_0012."' style='vertical-align: middle; border: 0;' /></a> <a href='".e_PLUGIN."rss_menu/rss.php?8.2.".e_QUERY."'><img src='".e_PLUGIN."rss_menu/images/rss2.png' alt='".LAN_FORUM_0013."' style='vertical-align: middle; border: 0;' /></a> <a href='".e_PLUGIN."rss_menu/rss.php?8.3.".e_QUERY."'><img src='".e_PLUGIN."rss_menu/images/rss3.png' alt='".LAN_433."' style='vertical-align: middle; border: 0;' /></a>
</div> </div>
--> */
$FORUMEND .= "
<div class='nforumdisclaimer' style='text-align:center'>Powered by <b>e107 Forum System</b></div>"; <div class='nforumdisclaimer' style='text-align:center'>Powered by <b>e107 Forum System</b></div>";
$FORUMREPLYSTYLE = "<tr> $FORUMREPLYSTYLE = "<tr>

View File

@@ -88,7 +88,7 @@ class siteinfo_shortcodes // must match the folder name of the plugin.
return SITETAG; return SITETAG;
} }
function sc_sitelogo($parm='') function sc_sitelogo($parm=null)
{ {
return $this->sc_logo($parm); return $this->sc_logo($parm);
} }
@@ -168,7 +168,7 @@ class siteinfo_shortcodes // must match the folder name of the plugin.
{ {
// //
$dimensions[0] = $parm['w']; $dimensions[0] = $parm['w'];
$dimensions[1] = $parm['h']; $dimensions[1] = !empty($parm['h']) ? $parm['h'] : 0;
if(empty($parm['noresize']) && !empty($logopref)) // resize by default - avoiding large files. if(empty($parm['noresize']) && !empty($logopref)) // resize by default - avoiding large files.
{ {