1
0
mirror of https://github.com/e107inc/e107.git synced 2025-08-04 13:47:31 +02:00

Forum code formatting and cleanup.

This commit is contained in:
Cameron
2016-05-31 13:22:52 -07:00
parent d2d1478f7b
commit 347a17823e

View File

@@ -14,10 +14,10 @@ class forum_shortcodes extends e_shortcode
function __construct() function __construct()
{ {
$this->forum_rules = forum_rules('check'); $this->forum_rules = forum_rules('check');
} }
// START OF $FVARS // START OF $FVARS
function sc_forumtitle() function sc_forumtitle()
{ {
return e107::pref('forum','title', LAN_PLUGIN_FORUM_NAME); return e107::pref('forum','title', LAN_PLUGIN_FORUM_NAME);
@@ -28,52 +28,61 @@ class forum_shortcodes extends e_shortcode
{ {
return LAN_FORUM_0002; return LAN_FORUM_0002;
} }
function sc_replytitle() function sc_replytitle()
{ {
return LAN_FORUM_0003; return LAN_FORUM_0003;
} }
function sc_lastpostitle() function sc_lastpostitle()
{ {
return LAN_FORUM_0004; return LAN_FORUM_0004;
} }
function sc_infotitle() function sc_infotitle()
{ {
return LAN_FORUM_0009; return LAN_FORUM_0009;
} }
function sc_newthreadtitle() function sc_newthreadtitle()
{ {
return LAN_FORUM_0075; return LAN_FORUM_0075;
} }
function sc_postedtitle() function sc_postedtitle()
{ {
return LAN_FORUM_0074; return LAN_FORUM_0074;
} }
function sc_tracktitle() function sc_tracktitle()
{ {
return LAN_FORUM_0073; return LAN_FORUM_0073;
} }
function sc_statlink() function sc_statlink()
{ {
return "<a href='".e_PLUGIN."forum/forum_stats.php'>".LAN_FORUM_0017."</a>\n"; return "<a href='".e_PLUGIN."forum/forum_stats.php'>".LAN_FORUM_0017."</a>\n";
} }
function sc_iconkey() function sc_iconkey()
{ {
return " return "
<table class='table table-bordered' style='width:100%'>\n<tr> <table class='table table-bordered' style='width:100%'>\n<tr>
<td style='width:2%'>".IMAGE_new_small."</td> <td style='width:2%'>".IMAGE_new_small."</td>
<td style='width:10%'><span class='smallblacktext'>".LAN_FORUM_0039."</span></td> <td style='width:10%'><span class='smallblacktext'>".LAN_FORUM_0039."</span></td>
<td style='width:2%'>".IMAGE_nonew_small."</td> <td style='width:2%'>".IMAGE_nonew_small."</td>
<td style='width:10%'><span class='smallblacktext'>".LAN_FORUM_0040."</span></td> <td style='width:10%'><span class='smallblacktext'>".LAN_FORUM_0040."</span></td>
<td style='width:2%'>".IMAGE_closed_small."</td> <td style='width:2%'>".IMAGE_closed_small."</td>
<td style='width:10%'><span class='smallblacktext'>".LAN_FORUM_0041."</span></td> <td style='width:10%'><span class='smallblacktext'>".LAN_FORUM_0041."</span></td>
</tr>\n</table>\n"; </tr>\n</table>\n";
} }
// End of LEGACY shortcodes... // End of LEGACY shortcodes...
function sc_logo() function sc_logo()
{ {
return IMAGE_e; return IMAGE_e;
} }
function sc_newimage() function sc_newimage()
{ {
return IMAGE_new_small; return IMAGE_new_small;
@@ -81,246 +90,245 @@ class forum_shortcodes extends e_shortcode
function sc_userinfo() function sc_userinfo()
{ {
//---- Pass globals via $sc????? //---- 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>"; $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) 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>"; $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 // To be reworked to get the $forum var
if($forum->prefs->get('attach') && (check_class($pref['upload_class']) || getperms('0'))) if($forum->prefs->get('attach') && (check_class($pref['upload_class']) || getperms('0')))
{ {
$text .= " | <a href='".e_PLUGIN."forum/forum_uploads.php'>".LAN_FORUM_0015."</a>"; $text .= " | <a href='".e_PLUGIN."forum/forum_uploads.php'>".LAN_FORUM_0015."</a>";
}
}
if(!empty($this->forum_rules))
{
$text .= " | <a href='".e107::url('forum','rules')."'>".LAN_FORUM_0016.'</a>';
}
return $text;
} }
}
if(!empty($this->forum_rules))
{
$text .= " | <a href='".e107::url('forum','rules')."'>".LAN_FORUM_0016.'</a>';
}
return $text;
}
function sc_userinfox() function sc_userinfox()
{ {
global $forum; global $forum;
$uInfo = array(); $uInfo = array();
$uInfo[0] = "<a href='".e107::url('forum','stats')."'>".LAN_FORUM_6013.'</a>'; $uInfo[0] = "<a href='".e107::url('forum','stats')."'>".LAN_FORUM_6013.'</a>';
if(!empty($this->forum_rules)) if(!empty($this->forum_rules))
{ {
$uInfo[1] = "<a href='".e107::url('forum','rules')."'>".LAN_FORUM_0016.'</a>'; $uInfo[1] = "<a href='".e107::url('forum','rules')."'>".LAN_FORUM_0016.'</a>';
} }
// To be reworked to get the $forum var // To be reworked to get the $forum var
$trackPref = $forum->prefs->get('track'); $trackPref = $forum->prefs->get('track');
if(!empty($trackPref)) if(!empty($trackPref))
{ {
$uInfo[2] = "<a href='".e107::url('forum','track')."'>".LAN_FORUM_0030."</a>"; $uInfo[2] = "<a href='".e107::url('forum','track')."'>".LAN_FORUM_0030."</a>";
} }
return implode(" | ",$uInfo);
} return implode(" | ",$uInfo);
}
function sc_userlist() function sc_userlist()
{ {
if(!defined('e_TRACKING_DISABLED')) if(!defined('e_TRACKING_DISABLED'))
{ {
// String candidate for USERLIST wrapper // String candidate for USERLIST wrapper
$text = LAN_FORUM_0036.": "; $text = LAN_FORUM_0036.": ";
global $listuserson; global $listuserson;
$c = 0; $c = 0;
if(is_array($listuserson)) if(is_array($listuserson))
{ {
//---- foreach($listuserson as $uinfo => $pinfo) //---- foreach($listuserson as $uinfo => $pinfo)
foreach(array_keys($listuserson) as $uinfo) foreach(array_keys($listuserson) as $uinfo)
// foreach($listuserson as $uinfo => &$pinfo) // foreach($listuserson as $uinfo => &$pinfo)
{ {
list($oid, $oname) = explode(".", $uinfo, 2); list($oid, $oname) = explode(".", $uinfo, 2);
$c ++; $c ++;
$text .= "<a href='".e_HTTP."user.php ?id.$oid'>$oname</a>".($c == MEMBERS_ONLINE ? "." :", "); $text .= "<a href='".e_HTTP."user.php ?id.$oid'>$oname</a>".($c == MEMBERS_ONLINE ? "." :", ");
}
}
// String candidate for USERLIST wrapper
$text .= "<br /><a rel='external' href='".e_BASE."online.php'>".LAN_FORUM_0037."</a> ".LAN_FORUM_0038;
}
return $text;
} }
}
// String candidate for USERLIST wrapper
$text .= "<br /><a rel='external' href='".e_BASE."online.php'>".LAN_FORUM_0037."</a> ".LAN_FORUM_0038;
}
return $text;
}
function sc_search() function sc_search()
{ {
// $tp = e107::getParser();
if(!$srchIcon = e107::getParser()->toGlyph('fa-search'))
{
$srchIcon = LAN_SEARCH;
}
// String candidate for USERLIST wrapper if(!$srchIcon = e107::getParser()->toGlyph('fa-search'))
return " {
<form method='get' class='form-inline input-append' action='".e_BASE."search.php'> $srchIcon = LAN_SEARCH;
<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"; // String candidate for USERLIST wrapper
} return "
<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";
}
function sc_perms() function sc_perms()
{ {
return (USER == TRUE || ANON == TRUE ? LAN_FORUM_0043." - ".LAN_FORUM_0045." - ".LAN_FORUM_0047 : LAN_FORUM_0044." - ".LAN_FORUM_0046." - ".LAN_FORUM_0048); return (USER == TRUE || ANON == TRUE ? LAN_FORUM_0043." - ".LAN_FORUM_0045." - ".LAN_FORUM_0047 : LAN_FORUM_0044." - ".LAN_FORUM_0046." - ".LAN_FORUM_0048);
} }
function sc_info() function sc_info()
{ {
//$fVars->INFO = ""; //$fVars->INFO = "";
// global $forum; // global $forum;
//$sql = e107::getDb(); //$sql = e107::getDb();
//$gen = new convert; //$gen = new convert;
if (ANON == TRUE) 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_new_threads = e107::getDb()->count('forum_thread', '(*)', "WHERE thread_datestamp>'".USERLV."' ");
$total_read_threads = 0; $total_read_threads = 0;
if (USERVIEWED != "") if (USERVIEWED != "")
{ {
$tmp = explode(".", USERVIEWED); // List of numbers, separated by single period $tmp = explode(".", USERVIEWED); // List of numbers, separated by single period
$total_read_threads = count($tmp); $total_read_threads = count($tmp);
} }
/* /*
else else
{ {
$total_read_threads = 0; $total_read_threads = 0;
} }
*/ */
$gen = new convert; $gen = new convert;
$text = LAN_FORUM_0018." ".USERNAME."<br />"; $text = LAN_FORUM_0018." ".USERNAME."<br />";
$lastvisit_datestamp = $gen->convert_date(USERLV, 'long'); $lastvisit_datestamp = $gen->convert_date(USERLV, 'long');
$datestamp = $gen->convert_date(time(), "long"); $datestamp = $gen->convert_date(time(), "long");
/* /*
if (!$total_new_threads) if (!$total_new_threads)
{ {
$text .= LAN_FORUM_0019." "; $text .= LAN_FORUM_0019." ";
} }
elseif($total_new_threads == 1) elseif($total_new_threads == 1)
{ {
$text .= LAN_FORUM_0020; $text .= LAN_FORUM_0020;
} }
else else
{ {
$text .= LAN_FORUM_0021." ".$total_new_threads." ".LAN_FORUM_0022." "; $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 .= (!$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; // $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 == $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 != 0 && $total_read_threads >= $total_new_threads)
{ {
$text .= LAN_FORUM_0029; $text .= LAN_FORUM_0029;
$allread = TRUE; $allread = TRUE;
} }
elseif($total_read_threads != 0) 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 /> $text .= "<br />
".LAN_FORUM_0024." ".$lastvisit_datestamp."<br /> ".LAN_FORUM_0024." ".$lastvisit_datestamp."<br />
".LAN_FORUM_0025." ".$datestamp; ".LAN_FORUM_0025." ".$datestamp;
} }
/* /*
else else
{ {
$text .= ''; $text .= '';
if (ANON == TRUE) 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 && vartrue($allread) != TRUE && $total_new_threads && $total_new_threads >= $total_read_threads) //if (USER && vartrue($allread) != TRUE && $total_new_threads && $total_new_threads >= $total_read_threads)
if (USER && !$allread && $total_new_threads && $total_new_threads >= $total_read_threads) if (USER && !$allread && $total_new_threads && $total_new_threads >= $total_read_threads)
{ {
$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>" : ''); $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; $forum = new e107forum;
//$trackPref = $forum->prefs->get('track'); //$trackPref = $forum->prefs->get('track');
//if (USER && vartrue($trackPref) && e_QUERY != 'track') //if (USER && vartrue($trackPref) && e_QUERY != 'track')
if (USER && vartrue($forum->prefs->get('track')) && e_QUERY != 'track') if (USER && vartrue($forum->prefs->get('track')) && e_QUERY != 'track')
{ {
$text .= "<br /><a href='".e107::url('forum','track')."'>".LAN_FORUM_0030.'</a>'; $text .= "<br /><a href='".e107::url('forum','track')."'>".LAN_FORUM_0030.'</a>';
} }
return $text; return $text;
} }
function sc_foruminfo() function sc_foruminfo()
{ {
$sql = e107::getDb(); $sql = e107::getDb();
$total_topics = $sql->count("forum_thread", "(*)"); $total_topics = $sql->count("forum_thread", "(*)");
$total_replies = $sql->count("forum_post", "(*)"); $total_replies = $sql->count("forum_post", "(*)");
$total_members = $sql->count("user"); $total_members = $sql->count("user");
//----$newest_member = $sql->select("user", "*", "user_ban='0' ORDER BY user_join DESC LIMIT 0,1"); //----$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. 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;
}
return 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(!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;
}
return 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?
}
// END OF $FVARS
// START OF $PVARS
function sc_parentstatus() function sc_parentstatus()
{ {
//---- return $this->parentstatus; //---- return $this->parentstatus;
// if(!check_class($this->fparent['forum_postclass'])) // if(!check_class($this->fparent['forum_postclass']))
if(!check_class($this->var['forum_postclass'])) if(!check_class($this->var['forum_postclass']))
{ {
$status = '('.LAN_FORUM_0056.')'; $status = '('.LAN_FORUM_0056.')';
} }
return vartrue($status); return vartrue($status);
} }
function sc_parentname() function sc_parentname()
{ {
//---- return $this->parentname;
// return $this->fparent['forum_name'];
return $this->var['forum_name']; return $this->var['forum_name'];
} }
// END OF $PVARS
// Function to show the retrieval of parent ID, not really needed by core template // Function to show the retrieval of parent ID, not really needed by core template
function sc_parentid() function sc_parentid()
{ {
//---- return $this->parentname;
// return $this->fparent['forum_id'];
return $this->var['forum_id']; return $this->var['forum_id'];
} }
@@ -328,70 +336,78 @@ return str_replace("[x]", ($total_topics+$total_replies), LAN_FORUM_0031)." ($to
function sc_newflag() function sc_newflag()
{ {
global $newflag_list; global $newflag_list;
// $e107 = e107::getInstance();
if(USER && is_array($newflag_list) && in_array($this->var['forum_id'], $newflag_list))
{
return "<a href='".e107::getInstance()->url->create('forum/forum/mfar', $this->var)."'>".IMAGE_new.'</a>'; if(USER && is_array($newflag_list) && in_array($this->var['forum_id'], $newflag_list))
} {
elseif(empty($this->var['forum_replies']) && defined('IMAGE_noreplies'))
{ return "<a href='".e107::getInstance()->url->create('forum/forum/mfar', $this->var)."'>".IMAGE_new.'</a>';
return IMAGE_noreplies; }
} elseif(empty($this->var['forum_replies']) && defined('IMAGE_noreplies'))
//---- else {
//---- { return IMAGE_noreplies;
}
return IMAGE_nonew; return IMAGE_nonew;
//---- }
} }
function sc_forumname() function sc_forumname()
{ {
// global $f; // global $f;
// $tp = e107::getParser(); // $tp = e107::getParser();
if(substr($this->var['forum_name'], 0, 1) == '*') if(substr($this->var['forum_name'], 0, 1) == '*')
{ {
$this->var['forum_name'] = substr($this->var['forum_name'], 1); $this->var['forum_name'] = substr($this->var['forum_name'], 1);
} }
$this->var['forum_name'] = e107::getParser()->toHTML($this->var['forum_name'], true, 'no_hook'); $this->var['forum_name'] = e107::getParser()->toHTML($this->var['forum_name'], true, 'no_hook');
$url = e107::url('forum', 'forum', $this->var);
return "<a href='".$url."'>{$this->var['forum_name']}</a>";
}
$url = e107::url('forum', 'forum', $this->var);
return "<a href='".$url."'>{$this->var['forum_name']}</a>";
}
function sc_forumdescription() function sc_forumdescription()
{ {
// global $f, $restricted_string; // global $f, $restricted_string;
global $restricted_string; global $restricted_string;
// $tp = e107::getParser(); // $tp = e107::getParser();
$this->var['forum_description'] = e107::getParser()->toHTML($this->var['forum_description'], true, 'no_hook'); $this->var['forum_description'] = e107::getParser()->toHTML($this->var['forum_description'], true, 'no_hook');
return $this->var['forum_description'].($restricted_string ? "<br /><span class='smalltext'><i>$restricted_string</i></span>" : ""); return $this->var['forum_description'].($restricted_string ? "<br /><span class='smalltext'><i>$restricted_string</i></span>" : "");
} }
function sc_threads() function sc_threads()
{ {
return $this->var['forum_threads']; return $this->var['forum_threads'];
} }
function sc_replies() function sc_replies()
{ {
return $this->var['forum_replies']; return $this->var['forum_replies'];
} }
function sc_threadsx() function sc_threadsx()
{ {
// global $f; // global $f;
// return "<span class='badge ".(($f['forum_threads']) ? "badge-info" : "")."'>".$f['forum_threads']."</span>"; // return "<span class='badge ".(($f['forum_threads']) ? "badge-info" : "")."'>".$f['forum_threads']."</span>";
return "<span class='badge ".(($this->var['forum_threads']) ? "badge-info" : "")."'>".$this->var['forum_threads']."</span>"; return "<span class='badge ".(($this->var['forum_threads']) ? "badge-info" : "")."'>".$this->var['forum_threads']."</span>";
} }
function sc_repliesx() function sc_repliesx()
{ {
// global $f; // global $f;
// return "<span class='badge ".(($f['forum_replies']) ? "badge-info" : "")."'>".$f['forum_replies']."</span>"; // return "<span class='badge ".(($f['forum_replies']) ? "badge-info" : "")."'>".$f['forum_replies']."</span>";
return "<span class='badge ".(($this->var['forum_replies']) ? "badge-info" : "")."'>".$this->var['forum_replies']."</span>"; return "<span class='badge ".(($this->var['forum_replies']) ? "badge-info" : "")."'>".$this->var['forum_replies']."</span>";
} }
function sc_forumsubforums() function sc_forumsubforums()
{ {
// VAR_DUMP ($this->ret); // VAR_DUMP ($this->ret);
// return ($this->ret)?"<br /><div class='smalltext'>".LAN_FORUM_0069.": {$this->ret['text']}</div>":""; // return ($this->ret)?"<br /><div class='smalltext'>".LAN_FORUM_0069.": {$this->ret['text']}</div>":"";
return ($this->var['text'])?"<br /><div class='smalltext'>".LAN_FORUM_0069.": {$this->var['text']}</div>":""; return ($this->var['text'])?"<br /><div class='smalltext'>".LAN_FORUM_0069.": {$this->var['text']}</div>":"";
} }
function sc_lastpostuser() function sc_lastpostuser()
{ {
// global $f; // global $f;
@@ -411,7 +427,7 @@ return str_replace("[x]", ($total_topics+$total_replies), LAN_FORUM_0031)." ($to
{ {
// $lastpost_name = "<a href='".$e107->url->create('user/profile/view', array('name' => $f['user_name'], 'id' => $f['forum_lastpost_user']))."'>{$f['user_name']}</a>"; // $lastpost_name = "<a href='".$e107->url->create('user/profile/view', array('name' => $f['user_name'], 'id' => $f['forum_lastpost_user']))."'>{$f['user_name']}</a>";
$lastpost_name = "<a href='".e107::getInstance()->url->create('user/profile/view', array('name' => $this->var['user_name'], 'id' => $this->var['forum_lastpost_user']))."'>{$this->var['user_name']}</a>"; $lastpost_name = "<a href='".e107::getUrl()->create('user/profile/view', array('name' => $this->var['user_name'], 'id' => $this->var['forum_lastpost_user']))."'>{$this->var['user_name']}</a>";
} }
//---- else //---- else
//---- { //---- {
@@ -482,57 +498,55 @@ $gen = new convert;
} }
function sc_lastpost() function sc_lastpost()
{ {
// global $f;
$e107 = e107::getInstance();
// $tp = e107::getParser();
$gen = new convert;
// if ($f['forum_lastpost_info']) $e107 = e107::getInstance();
if ($this->var['forum_lastpost_info']) $gen = new convert;
{
// list($lastpost_datestamp, $lastpost_thread) = explode('.', $f['forum_lastpost_info']);
list($lastpost_datestamp, $lastpost_thread) = explode('.', $this->var['forum_lastpost_info']);
// $lastpost_name = $tp->toHTML($f['forum_lastpost_user_anon']);
// $lastpost_name = e107::getParser()->toHTML($f['forum_lastpost_user_anon']);
// if ($f['user_name'])
$lastpost_name = e107::getParser()->toHTML($this->var['forum_lastpost_user_anon']);
if ($this->var['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>"; // if ($f['forum_lastpost_info'])
$lastpost_name = "<a href='".$e107->url->create('user/profile/view', array('name' => $this->var['user_name'], 'id' => $this->var['forum_lastpost_user']))."'>{$this->var['user_name']}</a>"; if ($this->var['forum_lastpost_info'])
} {
//---- else // list($lastpost_datestamp, $lastpost_thread) = explode('.', $f['forum_lastpost_info']);
//---- { list($lastpost_datestamp, $lastpost_thread) = explode('.', $this->var['forum_lastpost_info']);
//---- $lastpost_name = $tp->toHTML($f['forum_lastpost_user_anon']); // $lastpost_name = $tp->toHTML($f['forum_lastpost_user_anon']);
//---- } // $lastpost_name = e107::getParser()->toHTML($f['forum_lastpost_user_anon']);
// if ($f['user_name'])
$lastpost_name = e107::getParser()->toHTML($this->var['forum_lastpost_user_anon']);
// $lastpost = $forum->threadGetLastpost($lastpost_thread); //XXX TODO inefficient to have SQL query here. if ($this->var['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>";
$lastpost_name = "<a href='".e107::getUrl()->create('user/profile/view', array('name' => $this->var['user_name'], 'id' => $this->var['forum_lastpost_user']))."'>{$this->var['user_name']}</a>";
}
//---- else
//---- {
//---- $lastpost_name = $tp->toHTML($f['forum_lastpost_user_anon']);
//---- }
// $fVars->LASTPOSTUSER = $lastpost_name; // $lastpost = $forum->threadGetLastpost($lastpost_thread); //XXX TODO inefficient to have SQL query here.
// {forum_sef}/{thread_id}-{thread_sef}
// $urlData = array('forum_sef'=>$f['forum_sef'], 'thread_id'=>$lastpost['post_thread'],'thread_sef'=>$lastpost['thread_sef']); // $fVars->LASTPOSTUSER = $lastpost_name;
// $url = e107::url('forum', 'topic', $urlData)."?last=1#post-".$lastpost['post_id']; // {forum_sef}/{thread_id}-{thread_sef}
// $fVars->LASTPOSTDATE .= "<a href='".$url."'>". $gen->computeLapse($lastpost_datestamp, time(), false, false, 'short')."</a>";
$lastpost_datestamp = $gen->convert_date($lastpost_datestamp, 'forum');
return $lastpost_datestamp.'<br />'.$lastpost_name." <a href='".$e107->url->create('forum/thread/last', array('name' => $lastpost_name, 'id' => $lastpost_thread))."'>".IMAGE_post2.'</a>';
} // $urlData = array('forum_sef'=>$f['forum_sef'], 'thread_id'=>$lastpost['post_thread'],'thread_sef'=>$lastpost['thread_sef']);
//---- else // $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>";
// $fVars->LASTPOSTUSER = ""; $lastpost_datestamp = $gen->convert_date($lastpost_datestamp, 'forum');
// $fVars->LASTPOSTDATE = "-"; return $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 = "-";
return '-'; return '-';
//---- } //---- }
} }
// END OF parse_forum function $FVARS
// START OF $NVARS
function sc_startertitle() function sc_startertitle()
{ {
// global $thread; // global $thread;
$gen = new convert; $gen = new convert;
$author_name = ($this->var['user_name'] ? $this->var['user_name'] : $this->var['lastuser_anon']); $author_name = ($this->var['user_name'] ? $this->var['user_name'] : $this->var['lastuser_anon']);
@@ -548,9 +562,10 @@ $gen = new convert;
//---- { //---- {
// $e107 = e107::getInstance(); // $e107 = e107::getInstance();
// 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->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::getInstance()->url->create('user/profile/view', array('id' => $this->var['thread_lastuser'], 'name' => $author_name))."'>{$author_name}</a><br />".$datestamp; return "<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() function sc_newspostname()
{ {
// global $thread; // global $thread;
@@ -559,17 +574,16 @@ $gen = new convert;
// 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>'; // 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???' // Only $this->var???'
return empty($this->var)?LAN_FORUM_0029:"<a href='".e107::getInstance()->url->create('forum/thread/last', $this->var)."'>".e107::getParser()->toHTML($this->var['thread_name'], TRUE, 'no_make_clickable, no_hook').'</a>'; 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>';
} }
// END OF $NVARS // END OF $NVARS
function sc_forum_breadcrumb() function sc_forum_breadcrumb()
{ {
global $breadarray; global $breadarray;
$frm = e107::getForm(); $frm = e107::getForm();
return $frm->breadcrumb($breadarray); return $frm->breadcrumb($breadarray);
} }
} }
?>