diff --git a/e107_plugins/forum/shortcodes/batch/forum_shortcodes.php b/e107_plugins/forum/shortcodes/batch/forum_shortcodes.php new file mode 100644 index 000000000..95cafa915 --- /dev/null +++ b/e107_plugins/forum/shortcodes/batch/forum_shortcodes.php @@ -0,0 +1,575 @@ +forum_rules = forum_rules('check'); + } + +// START OF $FVARS + function sc_forumtitle() + { + return e107::pref('forum','title', LAN_PLUGIN_FORUM_NAME); + } + +// LEGACY shortcodes, to be deprecated & directly handled in template file??? + function sc_threadtitle() + { + return LAN_FORUM_0002; + } + function sc_replytitle() + { + return LAN_FORUM_0003; + } + function sc_lastpostitle() + { + return LAN_FORUM_0004; + } + function sc_infotitle() + { + return LAN_FORUM_0009; + } + function sc_newthreadtitle() + { + return LAN_FORUM_0075; + } + function sc_postedtitle() + { + return LAN_FORUM_0074; + } + function sc_tracktitle() + { + return LAN_FORUM_0073; + } + function sc_statlink() + { + return "".LAN_FORUM_0017."\n"; + } + function sc_iconkey() + { + return " +\n + + + + + + +\n
".IMAGE_new_small."".LAN_FORUM_0039."".IMAGE_nonew_small."".LAN_FORUM_0040."".IMAGE_closed_small."".LAN_FORUM_0041."
\n"; + } +// End of LEGACY shortcodes... + + function sc_logo() + { + return IMAGE_e; + } + function sc_newimage() + { + return IMAGE_new_small; + } + + function sc_userinfo() + { +//---- Pass globals via $sc????? + global $forum, $pref; + +$text = "".LAN_FORUM_0010." | ".LAN_FORUM_0011.""; +if(USER) +{ + $text .= " | ".LAN_FORUM_0012." | ".LAN_FORUM_0013." | ".LAN_FORUM_0014.""; +// To be reworked to get the $forum var + if($forum->prefs->get('attach') && (check_class($pref['upload_class']) || getperms('0'))) + { + $text .= " | ".LAN_FORUM_0015.""; + } +} +if(!empty($this->forum_rules)) +{ + $text .= " | ".LAN_FORUM_0016.''; +} + return $text; + } + + + function sc_userinfox() + { + global $forum; + + $uInfo = array(); +$uInfo[0] = "".LAN_FORUM_6013.''; + + if(!empty($this->forum_rules)) +{ + $uInfo[1] = "".LAN_FORUM_0016.''; +} + +// To be reworked to get the $forum var +$trackPref = $forum->prefs->get('track'); +if(!empty($trackPref)) +{ + $uInfo[2] = "".LAN_FORUM_0030.""; +} + return implode(" | ",$uInfo); + } + + function sc_userlist() + { + if(!defined('e_TRACKING_DISABLED')) +{ +// String candidate for USERLIST wrapper + $text = LAN_FORUM_0036.": "; + + global $listuserson; + $c = 0; + if(is_array($listuserson)) + { +//---- foreach($listuserson as $uinfo => $pinfo) + foreach(array_keys($listuserson) as $uinfo) +// foreach($listuserson as $uinfo => &$pinfo) + { + list($oid, $oname) = explode(".", $uinfo, 2); + $c ++; + $text .= "$oname".($c == MEMBERS_ONLINE ? "." :", "); + } + } +// String candidate for USERLIST wrapper + $text .= "
".LAN_FORUM_0037." ".LAN_FORUM_0038; +} + return $text; + } + + function sc_search() + { +// $tp = e107::getParser(); + if(!$srchIcon = e107::getParser()->toGlyph('fa-search')) +{ + $srchIcon = LAN_SEARCH; +} + +// String candidate for USERLIST wrapper +return " +
+
+ + + + + + + +
+ +
\n"; +} + + 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); + } + + function sc_info() + { +//$fVars->INFO = ""; +// global $forum; +//$sql = e107::getDb(); +//$gen = new convert; + if (ANON == TRUE) + { + $text = LAN_FORUM_0049.'
'.LAN_FORUM_0050." ".LAN_FORUM_0051." ".LAN_FORUM_0052; + } + elseif(USER == FALSE) + { + $text = LAN_FORUM_0049.'
'.LAN_FORUM_0053." ".LAN_FORUM_0054." ".LAN_FORUM_0055; + } + +if (USER == TRUE) +{ + $total_new_threads = e107::getDb()->count('forum_thread', '(*)', "WHERE thread_datestamp>'".USERLV."' "); + $total_read_threads = 0; + if (USERVIEWED != "") + { + $tmp = explode(".", USERVIEWED); // List of numbers, separated by single period + $total_read_threads = count($tmp); + } +/* + else + { + $total_read_threads = 0; + } +*/ + +$gen = new convert; + $text = LAN_FORUM_0018." ".USERNAME."
"; + $lastvisit_datestamp = $gen->convert_date(USERLV, 'long'); + $datestamp = $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) + { + $text .= LAN_FORUM_0029; + $allread = TRUE; + } + elseif($total_read_threads != 0) + { + $text .= " (".LAN_FORUM_0027." ".$total_read_threads." ".LAN_FORUM_0028.")"; + } + + $text .= "
+ ".LAN_FORUM_0024." ".$lastvisit_datestamp."
+ ".LAN_FORUM_0025." ".$datestamp; +} +/* +else +{ + $text .= ''; + if (ANON == TRUE) + { + $text .= LAN_FORUM_0049.'
'.LAN_FORUM_0050." ".LAN_FORUM_0051." ".LAN_FORUM_0052; + } + elseif(USER == FALSE) + { + $text .= LAN_FORUM_0049.'
'.LAN_FORUM_0053." ".LAN_FORUM_0054." ".LAN_FORUM_0055; + } +} +*/ + +//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) +{ + $text .= "
".LAN_FORUM_0057.''.(e_QUERY != 'new' ? ", ".LAN_FORUM_0058."" : ''); +} + +$forum = new e107forum; +//$trackPref = $forum->prefs->get('track'); +//if (USER && vartrue($trackPref) && e_QUERY != 'track') +if (USER && vartrue($forum->prefs->get('track')) && e_QUERY != 'track') +{ + $text .= "
".LAN_FORUM_0030.''; +} +return $text; +} + + function sc_foruminfo() + { +$sql = e107::getDb(); + +$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; +} + +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") ? "" : "
".$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).")
".LAN_FORUM_0066." ".$total_members."
".LAN_FORUM_0065." ".$nuser_name.".\n"); // FIXME cannot find other references to e_TRACKING_DISABLED, use pref? + } +// END OF $FVARS + +// START OF $PVARS + function sc_parentstatus() + { +//---- return $this->parentstatus; +// if(!check_class($this->fparent['forum_postclass'])) + if(!check_class($this->var['forum_postclass'])) + { + $status = '('.LAN_FORUM_0056.')'; + } + return vartrue($status); + } + function sc_parentname() + { +//---- return $this->parentname; +// return $this->fparent['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 sc_parentid() + { +//---- return $this->parentname; +// return $this->fparent['forum_id']; + return $this->var['forum_id']; + } + +// START OF parse_forum function $FVARS + + function sc_newflag() + { + global $newflag_list; +// $e107 = e107::getInstance(); + + if(USER && is_array($newflag_list) && in_array($this->var['forum_id'], $newflag_list)) + { + + return "var)."'>".IMAGE_new.''; + } + elseif(empty($this->var['forum_replies']) && defined('IMAGE_noreplies')) + { + return IMAGE_noreplies; + } +//---- else +//---- { + return IMAGE_nonew; +//---- } +} + function sc_forumname() + { +// global $f; +// $tp = e107::getParser(); + if(substr($this->var['forum_name'], 0, 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'); + + $url = e107::url('forum', 'forum', $this->var); + return "{$this->var['forum_name']}"; + } + function sc_forumdescription() + { +// global $f, $restricted_string; + global $restricted_string; +// $tp = e107::getParser(); + $this->var['forum_description'] = e107::getParser()->toHTML($this->var['forum_description'], true, 'no_hook'); + return $this->var['forum_description'].($restricted_string ? "
$restricted_string" : ""); + } + function sc_threads() + { + return $this->var['forum_threads']; + } + function sc_replies() + { + return $this->var['forum_replies']; + } + function sc_threadsx() + { +// global $f; +// return "".$f['forum_threads'].""; + return "".$this->var['forum_threads'].""; + } + function sc_repliesx() + { +// global $f; +// return "".$f['forum_replies'].""; + return "".$this->var['forum_replies'].""; + } + function sc_forumsubforums() + { +// VAR_DUMP ($this->ret); +// return ($this->ret)?"
".LAN_FORUM_0069.": {$this->ret['text']}
":""; + return ($this->var['text'])?"
".LAN_FORUM_0069.": {$this->var['text']}
":""; + } + function sc_lastpostuser() + { +// global $f; +// $e107 = e107::getInstance(); +// $tp = e107::getParser(); + +// if ($f['forum_lastpost_info']) + if ($this->var['forum_lastpost_info']) + { +// list($lastpost_datestamp, $lastpost_thread) = explode('.', $f['forum_lastpost_info']); +// $lastpost_name = $tp->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 = " $f['user_name'], 'id' => $f['forum_lastpost_user']))."'>{$f['user_name']}"; + $lastpost_name = " $this->var['user_name'], 'id' => $this->var['forum_lastpost_user']))."'>{$this->var['user_name']}"; + } +//---- else +//---- { +//---- $lastpost_name = $tp->toHTML($f['forum_lastpost_user_anon']); +//---- } + +// $lastpost = $forum->threadGetLastpost($lastpost_thread); //XXX TODO inefficient to have SQL query here. + + return $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 .= "". $gen->computeLapse($lastpost_datestamp, time(), false, false, 'short').""; +// $lastpost_datestamp = $gen->convert_date($lastpost_datestamp, 'forum'); +// $fVars->LASTPOST = $lastpost_datestamp.'
'.$lastpost_name." $lastpost_name, 'id' => $lastpost_thread))."'>".IMAGE_post2.''; + + } +//---- else +//---- { + return ""; +// $fVars->LASTPOSTDATE = "-"; +// $fVars->LASTPOST = '-'; +//---- } +} + function sc_lastpostdate() + { +// global $f, $forum; + global $forum; +// $e107 = e107::getInstance(); +// $tp = e107::getParser(); +$gen = new convert; + +// if ($f['forum_lastpost_info']) + if ($this->var['forum_lastpost_info']) + { +// list($lastpost_datestamp, $lastpost_thread) = explode('.', $f['forum_lastpost_info']); + list($lastpost_datestamp, $lastpost_thread) = explode('.', $this->var['forum_lastpost_info']); +// if ($f['user_name']) +// { + +// $lastpost_name = " $f['user_name'], 'id' => $f['forum_lastpost_user']))."'>{$f['user_name']}"; +// } +// 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']); + $urlData = array('forum_sef'=>$this->var['forum_sef'], 'thread_id'=>$lastpost['post_thread'],'thread_sef'=>$lastpost['thread_sef']); + $url = e107::url('forum', 'topic', $urlData)."?last=1#post-".$lastpost['post_id']; + return "". $gen->computeLapse($lastpost_datestamp, time(), false, false, 'short').""; +// $lastpost_datestamp = $gen->convert_date($lastpost_datestamp, 'forum'); +// $fVars->LASTPOST = $lastpost_datestamp.'
'.$lastpost_name." $lastpost_name, 'id' => $lastpost_thread))."'>".IMAGE_post2.''; + + } +//---- else +//---- { +// $fVars->LASTPOSTUSER = ""; + return "-"; +// $fVars->LASTPOST = '-'; +//---- } +} + function sc_lastpost() + { +// global $f; + $e107 = e107::getInstance(); +// $tp = e107::getParser(); +$gen = new convert; + +// if ($f['forum_lastpost_info']) + if ($this->var['forum_lastpost_info']) + { +// 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 = " $f['user_name'], 'id' => $f['forum_lastpost_user']))."'>{$f['user_name']}"; + $lastpost_name = " $this->var['user_name'], 'id' => $this->var['forum_lastpost_user']))."'>{$this->var['user_name']}"; + } +//---- 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 .= "". $gen->computeLapse($lastpost_datestamp, time(), false, false, 'short').""; + $lastpost_datestamp = $gen->convert_date($lastpost_datestamp, 'forum'); + return $lastpost_datestamp.'
'.$lastpost_name." $lastpost_name, 'id' => $lastpost_thread))."'>".IMAGE_post2.''; + + } +//---- else +//---- { +// $fVars->LASTPOSTUSER = ""; +// $fVars->LASTPOSTDATE = "-"; + return '-'; +//---- } +} +// END OF parse_forum function $FVARS + +// START OF $NVARS + function sc_startertitle() + { +// global $thread; +$gen = new convert; + + $author_name = ($this->var['user_name'] ? $this->var['user_name'] : $this->var['lastuser_anon']); + +//-- $datestamp = $gen->convert_date($thread['thread_lastpost'], 'forum'); + $datestamp = $gen->convert_date($this->var['thread_lastpost'], 'forum'); + + + if(!$this->var['user_name']) + { + return $author_name.'
'.$datestamp; + } +//---- else +//---- { +// $e107 = e107::getInstance(); +// return " $thread['thread_lastuser'], 'name' => $sc->author_name))."'>{$sc->author_name}
".$sc->datestamp; + return " $this->var['thread_lastuser'], 'name' => $author_name))."'>{$author_name}
".$datestamp; +//---- } + } + function sc_newspostname() + { +// global $thread; +// $e107 = e107::getInstance(); +// $tp = e107::getParser(); + +// return empty($thread)?LAN_FORUM_0029:"".$tp->toHTML($thread['thread_name'], TRUE, 'no_make_clickable, no_hook').''; +// Only $this->var???' + return empty($this->var)?LAN_FORUM_0029:"var)."'>".e107::getParser()->toHTML($this->var['thread_name'], TRUE, 'no_make_clickable, no_hook').''; + } +// END OF $NVARS + + + function sc_forum_breadcrumb() + { + global $breadarray; +$frm = e107::getForm(); +return $frm->breadcrumb($breadarray); + } + +} +?> \ No newline at end of file