From 17ebeec9915dd85c18fc35d0a843fd0384c79d7e Mon Sep 17 00:00:00 2001 From: rica-carv Date: Tue, 14 Jun 2016 13:36:07 +0100 Subject: [PATCH] Add files via upload --- .../shortcodes/batch/forum_shortcodes.php | 83 +- .../shortcodes/batch/view_shortcodes.php | 240 ++++++ .../shortcodes/batch/viewforum_shortcodes.php | 809 ++++++++++++++++++ 3 files changed, 1126 insertions(+), 6 deletions(-) create mode 100644 e107_plugins/forum/shortcodes/batch/viewforum_shortcodes.php diff --git a/e107_plugins/forum/shortcodes/batch/forum_shortcodes.php b/e107_plugins/forum/shortcodes/batch/forum_shortcodes.php index 95152d0bb..b218d1b7c 100644 --- a/e107_plugins/forum/shortcodes/batch/forum_shortcodes.php +++ b/e107_plugins/forum/shortcodes/batch/forum_shortcodes.php @@ -10,11 +10,12 @@ if (!defined('e107_INIT')) { exit; } class forum_shortcodes extends e_shortcode { - private $forum_rules; + private $forum_rules, $gen; function __construct() { $this->forum_rules = forum_rules('check'); + $this->gen = new convert; } // START OF $FVARS @@ -220,10 +221,10 @@ class forum_shortcodes extends e_shortcode } */ - $gen = new convert; +// $gen = new convert; $text = LAN_FORUM_0018." ".USERNAME."
"; - $lastvisit_datestamp = $gen->convert_date(USERLV, 'long'); - $datestamp = $gen->convert_date(time(), "long"); + $lastvisit_datestamp = $this->gen->convert_date(USERLV, 'long'); + $datestamp = $this->gen->convert_date(time(), "long"); /* if (!$total_new_threads) @@ -408,6 +409,10 @@ class forum_shortcodes extends e_shortcode return ($this->var['text'])?"
".LAN_FORUM_0069.": {$this->var['text']}
":""; } +//----- ######################################################## +//----- Functions sc_latspostuser, sc_lastpostdate & sc_lastpost to be rewritten, since they pratically use the same code??? +//----- Also, viewforum_shortcodes uses similar shortcodes definitions...... +/*----- function sc_lastpostuser() { // global $f; @@ -541,17 +546,83 @@ $gen = new convert; return '-'; //---- } } +-----*/ + function lastpostdata () + { + $caller = debug_backtrace()[1]['function']; + if ($this->var['forum_lastpost_info']) + { + $e107 = e107::getInstance(); +// $gen = new convert; + global $forum; + list($lastpost_datestamp, $lastpost_thread) = explode('.', $this->var['forum_lastpost_info']); + if ($this->var['user_name']) + { + + $lastpost_name = " $this->var['user_name'], 'id' => $this->var['forum_lastpost_user']))."'>{$this->var['user_name']}"; + } + else + { + $lastpost_name = e107::getParser()->toHTML($this->var['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'=>$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']; +// $fVars->LASTPOSTDATE .= "". $gen->computeLapse($lastpost_datestamp, time(), false, false, 'short').""; + $lastpost_datestamp = $this->gen->convert_date($lastpost_datestamp, 'forum'); +// $fVars->LASTPOST = $lastpost_datestamp.'
'.$lastpost_name." $lastpost_name, 'id' => $lastpost_thread))."'>".IMAGE_post2.''; + +/*---- + $fVars->LASTPOSTUSER = $lastpost_name; + $fVars->LASTPOSTDATE .= "". $gen->computeLapse($lastpost_datestamp, time(), false, false, 'short').""; + $fVars->LASTPOST = $lastpost_datestamp.'
'.$lastpost_name." $lastpost_name, 'id' => $lastpost_thread))."'>".IMAGE_post2.''; +-----*/ + + return ($caller == 'sc_lastpostuser'?$lastpost_name:($caller == 'sc_lastpostdate'?"". $this->gen->computeLapse($lastpost_datestamp, time(), false, false, 'short')."":($caller == 'sc_lastpost'?$lastpost_datestamp.'
'.$lastpost_name." $lastpost_name, 'id' => $lastpost_thread))."'>".IMAGE_post2.'':''))); + } +/*---- + else + { + $fVars->LASTPOSTUSER = ""; + $fVars->LASTPOSTDATE = "-"; + $fVars->LASTPOST = '-'; + } +----*/ + return ($caller == 'sc_lastpostuser'?'':'-'); +// echo debug_backtrace()[1]['function']; + } + + function sc_lastpostuser() + { + return $this->lastpostdata(); + } + + function sc_lastpostdate() + { + return $this->lastpostdata(); + } + + function sc_lastpost() + { + return $this->lastpostdata(); + } + function sc_startertitle() { // global $thread; - $gen = new convert; +// $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'); + $datestamp = $this->gen->convert_date($this->var['thread_lastpost'], 'forum'); if(!$this->var['user_name']) diff --git a/e107_plugins/forum/shortcodes/batch/view_shortcodes.php b/e107_plugins/forum/shortcodes/batch/view_shortcodes.php index 51b187e2b..cc625123c 100644 --- a/e107_plugins/forum/shortcodes/batch/view_shortcodes.php +++ b/e107_plugins/forum/shortcodes/batch/view_shortcodes.php @@ -632,7 +632,247 @@ class plugin_forum_view_shortcodes extends e_shortcode } +//---- SHORTCODES CONVERTED FROM $tVars.... + function sc_threadname() + { + return e107::getParser()->toHTML($this->var['thread_name'], true, 'no_hook, emotes_off'); + } + + function sc_nextprev() + { + global $forum, $thread; + $prev = $forum->threadGetNextPrev('prev', $thread->threadId,$this->var['forum_id'], $this->var['thread_lastpost']); + $next = $forum->threadGetNextPrev('next', $thread->threadId,$this->var['forum_id'], $this->var['thread_lastpost']); + + $options = array(); + + if($prev !== false) + { + $options[] = "« " . LAN_FORUM_2001 . ""; + } + if($next !== false) + { + $options[] = "" . LAN_FORUM_2002 . " »"; + } + +//---- $tVars->NEXTPREV = implode(" | ", $options); + return implode(" | ", $options); +} + + + function sc_track() + { + global $forum; +if ($forum->prefs->get('track') && USER) +{ + // BC Fix for old template. + if(!defined('IMAGE_track')) + { + define('IMAGE_track', ''.LAN_FORUM_4009.''); + } + + if(!defined('IMAGE_untrack')) + { + define('IMAGE_untrack', ''.LAN_FORUM_4010.''); + } + + + $img = ($this->var['track_userid'] ? IMAGE_track : IMAGE_untrack); + + +/* + $url = $e107->url->create('forum/thread/view', array('id' => $thread->threadId), 'encode=0'); // encoding could break AJAX call + + $url = e107::url('forum','index'); + + $tVars->TRACK .= " + + {$img} + + + ";*/ + + + $trackDiz = ($forum->prefs->get('trackemail',true)) ? LAN_FORUM_3040 : LAN_FORUM_3041; + +// $tVars->TRACK = "".$img.""; + return "".$img.""; + +} + return ''; +} + + function sc_moderators() + { + global $forum; + +$modUser = array(); +foreach ( $forum->modArray as $user) +{ + $modUser[] = "".$user['user_name'].""; +} + +//$tVars->MODERATORS = LAN_FORUM_2003.": ". implode(', ', $modUser); +return LAN_FORUM_2003.": ". implode(', ', $modUser); +//unset($modUser); +} + + function sc_threadstatus() + { +//$tVars->THREADSTATUS = (!$thread->threadInfo['thread_active'] ? LAN_FORUM_2004 : ''); +return (!$this->var['thread_active'] ? LAN_FORUM_2004 : ''); +} + + + function sc_gotopages() + { + global $thread; +if ($thread->pages > 1) +{ + if(!$thread->page) $thread->page = 1; +// $url = rawurlencode(e107::getUrl()->create('forum/thread/view', array('name' => $thread->threadInfo['thread_name'], 'id' => $thread->threadId, 'page' => '[FROM]'))); + +// $url = e_REQUEST_SELF."?p=[FROM]"; // SEF URL Friendly. + $url = e107::url('forum','topic', $this->var)."&p=[FROM]"; + + $parms = "total={$thread->pages}&type=page¤t={$thread->page}&url=".urlencode($url)."&caption=off&tmpl=default&navcount=4&glyphs=1"; + + //XXX FIXME - pull-down template not practical here. Can we force another? + +// $tVars->GOTOPAGES = $tp->parseTemplate("{NEXTPREV={$parms}}"); + return e107::getParser()->parseTemplate("{NEXTPREV={$parms}}"); +/* + $parms = ($thread->pages).",1,{$thread->page},url::forum::thread::func=view&id={$thread->threadId}&page=[FROM],off"; + $tVars->GOTOPAGES = $tp->parseTemplate("{NEXTPREV={$parms}}");*/ +} +} + + + function sc_buttons() + { + global $forum, $thread; +//----$tVars->BUTTONS = ''; +if ($forum->checkPerm($this->var['thread_forum_id'], 'post') && $this->var['thread_active']) +{ + // print_a($thread->threadInfo); + $url = e107::url('forum','post')."?f=rp&id=".$this->var['thread_id']."&post=".$thread->threadId; +// $url = $e107->url->create('forum/thread/reply', array('id' => $thread->threadId)); + return "" . IMAGE_reply . ""; +} +if ($forum->checkPerm($this->var['thread_forum_id'], 'thread')) +{ + $ntUrl = e107::url('forum','post')."?f=nt&id=". $this->var['thread_forum_id']; +// $ntUrl = $e107->url->create('forum/thread/new', array('id' => $thread->threadInfo['thread_forum_id'])); + return "" . IMAGE_newthread . ""; +} +return ''; +} + +//$tVars->BUTTONSX = forumbuttons($thread); + +function sc_buttonsx() +{ + global $forum, $thread; + + + if ($forum->checkPerm($this->var['thread_forum_id'], 'post') && $this->var['thread_active']) + { + $url = e107::url('forum','post')."?f=rp&id=".$this->var['thread_id']."&post=".$thread->threadId; + // $url = e107::getUrl()->create('forum/thread/reply', array('id' => $thread->threadId)); + $replyUrl = "".LAN_FORUM_2006.""; + } + if ($forum->checkPerm($this->var['thread_forum_id'], 'thread')) + { + $ntUrl = e107::url('forum','post')."?f=nt&id=". $this->var['thread_forum_id']; + // $ntUrl = e107::getUrl()->create('forum/thread/new', array('id' => $thread->threadInfo['thread_forum_id'])); + $options[] = " ".LAN_FORUM_2005.""; + } + +// $options[] = " $thread->threadId)) . "'>".LAN_FORUM_1017." ".LAN_FORUM_2001.""; +// $options[] = " $thread->threadId)) . "'>".LAN_FORUM_1017." ".LAN_FORUM_2002.""; + +//---- SIMILAR CODE AS SC_NEXTPREV!!!!!!! + $prev = $forum->threadGetNextPrev('prev', $thread->threadId,$this->var['forum_id'], $this->var['thread_lastpost']); + $next = $forum->threadGetNextPrev('next', $thread->threadId,$this->var['forum_id'], $this->var['thread_lastpost']); + + if($prev !== false) + { + $options[] = "".LAN_FORUM_1017." ".LAN_FORUM_2001.""; + } + if($next !== false) + { + $options[] = "".LAN_FORUM_1017." ".LAN_FORUM_2002.""; + } + + + $text = '
+ '.$replyUrl.' + + +
'; + return $text; +} + +/*---- Function redeclared, this one came directly from forum_viewtopic.php..... +function sc_poll() +{ + global $pollstr; +return vartrue($pollstr); +} +----*/ +function sc_forumjump() +{ + global $forum; + $jumpList = $forum->forumGetAllowed(); + $text = "

".LAN_FORUM_1017.":

"; + return $text; +} + +function sc_message() +{ + global $thread; +return $thread->message; +} + } ?> \ No newline at end of file diff --git a/e107_plugins/forum/shortcodes/batch/viewforum_shortcodes.php b/e107_plugins/forum/shortcodes/batch/viewforum_shortcodes.php new file mode 100644 index 000000000..59289d4b3 --- /dev/null +++ b/e107_plugins/forum/shortcodes/batch/viewforum_shortcodes.php @@ -0,0 +1,809 @@ +gen = new convert; +// $this->forum_rules = forum_rules('check'); + } + +// LEGACY shortcodes, to be deprecated & directly handled in template file??? + function sc_startertitle() {return LAN_FORUM_1004;} + + function sc_threadtitle() {return LAN_FORUM_1003;} + + function sc_replytitle() {return LAN_FORUM_0003;} + + function sc_lastpostitle() {return LAN_FORUM_0004;} + + function sc_viewtitle() {return LAN_FORUM_1005;} +// End of LEGACY shortcodes... + + function sc_message() {return $this->var['message'];} + + function sc_threadpages() {return e107::getParser()->parseTemplate("{NEXTPREV={$this->var['parms']}}");} + + function sc_newthreadbutton() + { + return "".IMAGE_newthread.''; + } + + function sc_newthreadbuttonx() + { + +if(!BOOTSTRAP) +{ + return sc_newthreadbutton; +} +//--function newthreadjump($url) +//--{ + global $forum; + $jumpList = $forum->forumGetAllowed('view'); + + + $text = '
+ '.LAN_FORUM_1018.' + + +
'; + + return $text; + +//} + + + } + + function sc_breadcrumb() + { +// var_dump ($this->var); + return $this->var['breadcrumb']; + } + + function sc_backlink() + { + return $this->var['breadcrumb']; + } + + function sc_forum_crumb() + { + return $this->var['forum_crumb']; + } + + function sc_forumtitle() + { + return $this->var['forum_name']; + } + + function sc_moderators() + { + return $this->var['modUser']; + } + + function sc_browsers() + { + +if($this->var['track_online']) +{ + return $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).')'; +} + } + + function sc_iconkey() + { +global $FORUM_VIEWFORUM_TEMPLATE; + +if(defset('BOOTSTRAP')==3 && !empty($FORUM_VIEWFORUM_TEMPLATE['iconkey'])) // v2.x +{ + return e107::getParser()->parseTemplate($FORUM_VIEWFORUM_TEMPLATE['iconkey'],true); +} +// v1.x + + return " + + + + + + + + + + + + + + + + + + + + + +
".IMAGE_new_small."".LAN_FORUM_0039."".IMAGE_nonew_small."".LAN_FORUM_0040."".IMAGE_sticky_small."".LAN_FORUM_1011."".IMAGE_announce_small."".LAN_FORUM_1013."
".IMAGE_new_popular_small."".LAN_FORUM_0039." ".LAN_FORUM_1010."".IMAGE_nonew_popular_small."".LAN_FORUM_0040." ".LAN_FORUM_1010."".IMAGE_stickyclosed_small."".LAN_FORUM_1012."".IMAGE_closed_small."".LAN_FORUM_1014."
"; + +} + + function sc_viewable_by() + { +global $forum, $forumId; + +if($users = $forum->getForumClassMembers($forumId)) +{ + $userList = array(); + if(is_array($users)) + { + foreach($users as $user) + { + $userList[] = "".$user['user_name'].""; + } + + $viewable = implode(', ', $userList);; + } + elseif($users == 0) + { + $viewable = '' ; + } + else + { + $viewable = e107::getUserClass()->getFixedClassDescription($users); + } + +} + +if(!empty($viewable)) +{ + + return " + +
+
Viewable by
+
+ ".$viewable." +
+
+ + "; +} +//else +//{ + return ''; +//} + +} + + function sc_search() + { +return " +
+

+ + + + +

+
"; + +} + + function sc_perms() + { +global $forum, $forumId; + + // ----- 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; + } + + + return implode("", $permDisplay); + +} + +function sc_forumjump() +{ + global $forum; + $jumpList = $forum->forumGetAllowed('view'); + $text = "

".LAN_FORUM_1017.":

"; + return $text; +} + + +// FIXME - TOPLINK not used anymore? + function sc_toplink() + { + return "".LAN_GO.''; +} + + function sc_subforums() + { + +// echo "subforums"; + +// Initial ideia, to have a separate shortcode var ($subsc).... +//global $forum, $forumId, $threadFrom, $view; +global $sc, $forum, $forumId; +// var_dump ($forumId); +// var_dump (vartrue($forumId)); +//var_dump ($forum->forumGetSubs(vartrue($forum_id))); + +// var_dump ($FORUM_VIEW_SUB); +// $tp = e107::getParser(); + +// Initial ideia, to have a separate shortcode var ($subsc).... +// $subsc = e107::getScBatch('viewforum', 'forum', 'viewsubforum'); +//var_dump ($subsc); + +//-- $forum_id ?????? +$subList = $forum->forumGetSubs(vartrue($forum_id)); + +// var_dump ($forum); + +if(is_array($subList) && isset($subList[$this->var['forum_parent']][$forumId])) +{ + $newflag_list = $forum->forumGetUnreadForums(); + $sub_info = ''; +global $FORUM_VIEW_SUB, $FORUM_VIEW_SUB_START, $FORUM_VIEW_SUB_END; + foreach($subList[$this->var['forum_parent']][$forumId] as $subInfo) + { + +//---- global $FORUM_VIEW_SUB, $gen, $newflag_list; +// var_dump ($FORUM_VIEW_SUB); + +//-- $tp = e107::getParser(); +// $tVars = new e_vars; + +//---- $forumName = $tp->toHTML($subInfo['forum_name'], true); +//---- $tVars['SUB_FORUMTITLE'] = "{$forumName}"; +//---- $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'] = "".$subInfo['forum_threads'].""; +//---- $tVars['SUB_REPLIESX'] = "".$subInfo['forum_replies'].""; + +// $tVars['REPLIESX'] = "".$thread_info['thread_total_replies'].""; +// $tVars['VIEWSX'] = "".$thread_info['thread_views'].""; + +/*---- + if(USER && is_array($newflag_list) && in_array($subInfo['forum_id'], $newflag_list)) + { + + $tVars['NEWFLAG'] = "".IMAGE_new.''; + } + else + { + $tVars['NEWFLAG'] = IMAGE_nonew; + } +----*/ +/*---- + if($subInfo['forum_lastpost_info']) + { + $tmp = explode('.', $subInfo['forum_lastpost_info']); + $lp_thread = " $tmp[1]))."'>".IMAGE_post2.''; + $lp_date = $gen->convert_date($tmp[0], 'forum'); + + if($subInfo['user_name']) + { + $lp_name = " $subInfo['forum_lastpost_user'], 'name' => $subInfo['user_name']))."'>{$subInfo['user_name']}"; + } + else + { + $lp_name = $subInfo['forum_lastpost_user_anon']; + } + $tVars['SUB_LASTPOST'] = $lp_date.'
'.$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'; +//var_dump ($subInfo); + +// Initial ideia, to have a separate shortcode var ($subsc).... +// $subsc->setVars($subInfo); +// Use setVars or addVars??? + $sc->setVars($subInfo); +//echo "--------------------------------------"; + +// Initial ideia, to have a separate shortcode var ($subsc).... +// $sub_info .= e107::getParser()->parseTemplate($FORUM_VIEW_SUB, false, $subsc); + $sub_info .= e107::getParser()->parseTemplate($FORUM_VIEW_SUB, false, $sc); + +//var_dump ($sc); + + + + } +//var_dump ("----------->".$FORUM_VIEW_SUB_START.$sub_info.$FORUM_VIEW_SUB_END."<-----------"); + + return $FORUM_VIEW_SUB_START.$sub_info.$FORUM_VIEW_SUB_END; +} + +return ''; + +} + + +// Initial ideia, to have a separate shortcode var ($subsc).... +/*------ +} + +class plugin_forum_viewsubforum_shortcodes extends plugin_forum_viewforum_shortcodes +//-- or ??? +//--class plugin_forum_viewsubforum_shortcodes extends e_shortcode +{ + + function __construct() + { +// $this->forum_rules = forum_rules('check'); + } +------*/ + function sc_sub_forumtitle() + { + $forumName = e107::getParser()->toHTML($this->var['forum_name'], true); + return "var)."'>{$forumName}"; + } + + function sc_sub_description() + { + return e107::getParser()->toHTML($this->var['forum_description'], false, 'no_hook'); + } + + function sc_sub_threads() + { + return $this->var['forum_threads']; + } + + function sc_sub_replies() + { + return $this->var['forum_replies']; + } + + function sc_sub_threadsx() + { + $badgeThreads = ($this->var['forum_replies']) ? "badge-info" : ""; + return "".$this->var['forum_threads'].""; + } + + function sc_sub_repliesx() + { + $badgeReplies = ($this->var['forum_replies']) ? "badge-info" : ""; + return "".$this->var['forum_replies'].""; + } + + function sc_newflag() + { + global $newflag_list; + if(USER && is_array($newflag_list) && in_array($this->var['forum_id'], $newflag_list)) + { + return "".IMAGE_new.''; + } + return IMAGE_nonew; + + } + + function sc__wrapper_() { return 'forum_viewforum';} + + + function subinfo() { + $caller = debug_backtrace()[1]['function']; + if($this->var['forum_lastpost_info']) + { +// global $gen; + $tmp = explode('.', $this->var['forum_lastpost_info']); + $lp_thread = " $tmp[1]))."'>".IMAGE_post2.''; + $lp_date = $this->gen->convert_date($tmp[0], 'forum'); + + if($this->var['user_name']) + { + $lp_name = " $this->var['forum_lastpost_user'], 'name' => $this->var['user_name']))."'>{$this->var['user_name']}"; + } + else + { + $lp_name = $this->var['forum_lastpost_user_anon']; + } + +/*---- + $tVars['SUB_LASTPOST'] = $lp_date.'
'.$lp_name.' '.$lp_thread; + + $tVars['SUB_LASTPOSTDATE'] = $gen->computeLapse($tmp[0], time(), false, false, 'short'); + $tVars['SUB_LASTPOSTUSER'] = $lp_name; +----*/ + return ($caller == 'sc_sub_lastpostuser'?$lp_name:($caller == 'sc_sub_lastpostdate'?$this->gen->computeLapse($tmp[0], time(), false, false, 'short'):($caller == 'sc_sub_lastpost'?$lp_date.'
'.$lp_name.' '.$lp_thread:''))); + + } +/*---- + else + { + $tVars['SUB_LASTPOST'] = '-'; + $tVars['SUB_LASTPOSTUSER'] = ''; + $tVars['SUB_LASTPOSTDATE'] = ''; + } +----*/ + return ($caller == 'sc_sub_lastpost'?'-':''); +} + + function sc_sub_lastpostuser() + { + return $this->subinfo(); + } + + function sc_sub_lastpostdate() + { + return $this->subinfo(); + } + + function sc_sub_lastpost() + { + return $this->subinfo(); + } + +// Initial ideia, to have a separate shortcode var ($threadsc).... +/*------ +} + +class plugin_forum_viewforumthread_shortcodes extends plugin_forum_viewforum_shortcodes +//-- or ??? +//--class plugin_forum_viewforumthread_shortcodes extends e_shortcode +{ + + function __construct() + { +// $this->forum_rules = forum_rules('check'); + } +------*/ + + function sc_views() + { + return $this->var['thread_views']; + } + + function sc_replies() + { + return ($this->var['thread_total_replies']?:"0"); + } + + function sc_viewsx() + { + if(!deftrue('BOOTSTRAP')) + { + return $this->sc_views; + } + $badge = ($this->var['thread_views'] > 0) ? "badge-info" : ""; + return "".$this->sc_views.""; + } + + function sc_repliesx() + { + if(!deftrue('BOOTSTRAP')) + { + return $this->sc_replies; + } + $badge = ($this->var['thread_total_replies'] > 0) ? "badge-info" : ""; + return "".$this->sc_replies.""; + } + +// function sc__wrapper_() { return 'forum_viewforum';} + + function threadlastpostdata() { + $caller = debug_backtrace()[1]['function']; +// if($this->var['thread_views']) +//($this->var['thread_total_replies']?:"0") + if($this->var['thread_views'] || $this->var['thread_total_replies']>0) + { +// global $gen; +//---- $lastpost_datestamp = $gen->convert_date($this->var['thread_lastpost'], 'forum'); + if($this->var['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={$this->var['lastpost_username']}&id={$this->var['thread_lastuser']}"); +//---- $tVars['LASTPOST'] = "".$this->var['lastpost_username'].""; +//---- $tVars['LASTPOSTUSER'] = "".$this->var['lastpost_username'].""; +$LASTPOST = $LASTPOSTUSER = "".$this->var['lastpost_username'].""; + } + else + { + if(!$this->var['thread_lastuser']) + { +//---- $tVars['LASTPOST'] = $tp->toHTML($this->var['thread_lastuser_anon']); +//---- $tVars['LASTPOSTUSER'] = $tp->toHTML($this->var['thread_lastuser_anon']); +$LASTPOST = $LASTPOSTUSER = e107::getParser()->toHTML($this->var['thread_lastuser_anon']); + } + else + { +//---- $tVars['LASTPOST'] = LAN_FORUM_1015; +//---- $tVars['LASTPOSTUSER'] = LAN_FORUM_1015; +$LASTPOST = $LASTPOSTUSER = LAN_FORUM_1015; + } + } +//---- $tVars['LASTPOST'] .= '
'.$lastpost_datestamp; +$LASTPOST .= '
'.$this->gen->convert_date($this->var['thread_lastpost'], 'forum'); + +//---- $tVars['LASTPOSTUSER'] = $this->var['lastpost_username']; // $lastpost_name; +$LASTPOSTUSER = $this->var['lastpost_username']; + +//----- ??????? + $temp['thread_sef'] = eHelper::title2sef($this->var['thread_name'],'dashl'); + $this->addVars($temp); + + $urlData = array('forum_sef'=>$this->var['forum_sef'], 'thread_id'=>$this->var['thread_id'],'thread_sef'=>$this->var['thread_sef']); + $url = e107::url('forum', 'topic', $urlData); + $url .= (strpos($url,'?')!==false) ? '&' : '?'; + $url .= "last=1#post-".$this->var['lastpost_id']; + +//---- $tVars['LASTPOSTDATE'] .= "". $gen->computeLapse($thread_info['thread_lastpost'],time(), false, false, 'short').""; + + + return ($caller == 'sc_lastpostuser'?$LASTPOSTUSER:($caller == 'sc_lastpostdate'?"".$this->gen->computeLapse($thread_info['thread_lastpost'],time(), false, false, 'short')."":($caller == 'sc_lastpost'?$LASTPOST:''))); + + } + + return ($caller == 'sc_lastpostuser'?'':'-'); +} + + function sc_lastpostuser() + { + return $this->threadlastpostdata(); + } + + function sc_lastpostdate() + { + return $this->threadlastpostdata(); + } + + function sc_lastpost() + { + return $this->threadlastpostdata(); + } + + function sc_threaddate() + { +// global $gen; + return $this->gen->convert_date($this->var['thread_datestamp'], 'forum'); + } + + function sc_threadtimelapse() + { +// global $gen; + return $this->gen->computeLapse($this->var['thread_datestamp'],time(), false, false, 'short'); // convert_date($thread_info['thread_datestamp'], 'forum'); + } + + function sc_icon() + { + global $forum; +// global $forum, $FORUM_VIEW_FORUM, $FORUM_VIEW_FORUM_STICKY, $FORUM_VIEW_FORUM_ANNOUNCE, $gen, $menu_pref, +//$threadsViewed = $forum->threadGetUserViewed(); +// $newflag = (USER && $this->var['thread_lastpost'] > USERLV && !in_array($this->var['thread_id'], $threadsViewed)); + $newflag = (USER && $this->var['thread_lastpost'] > USERLV && !in_array($this->var['thread_id'], $forum->threadGetUserViewed())); + $ICON = ($newflag ? IMAGE_new : IMAGE_nonew); + if ($this->var['thread_total_replies'] >= $forum->prefs->get('popular', 10)) + { + $ICON = ($newflag ? IMAGE_new_popular : IMAGE_nonew_popular); + } + elseif(empty($this->var['thread_total_replies']) && defined('IMAGE_noreplies')) + { + $ICON = IMAGE_noreplies; + } + + if ($this->var['thread_sticky'] == 1) + { + $ICON = ($this->var['thread_active'] ? IMAGE_sticky : IMAGE_stickyclosed); + } + elseif($this->var['thread_sticky'] == 2) + { + $ICON = IMAGE_announce; + } + elseif(!$this->var['thread_active']) + { + $ICON = IMAGE_closed; + } + + return $ICON; + } + + function sc_threadtype() + { + if ($this->var['thread_sticky'] == 1) + { + return '['.LAN_FORUM_1011.']
'; + } + elseif($this->var['thread_sticky'] == 2) + { + return '['.LAN_FORUM_1013.']
'; + } + + return ''; +} + + function sc_threadname() + { + global $menu_pref, $forum; + $tp = e107::getParser(); + $thread_name = strip_tags($tp->toHTML($this->var['thread_name'], false, 'no_hook, emotes_off')); + if(isset($this->var['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($this->var['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("'", ''', $thread_thread); + $title = "title='".$thread_thread."'"; + } + else + { + $title = ''; + } + // $tVars['THREADNAME'] = " $threadId, 'name' => $thread_name))."'>{$thread_name}"; + +// $url = e107::getUrl()->create('forum/thread/view', array('id' => $threadId, 'name' => $thread_name)); + +// $thread_info['thread_sef'] = eHelper::title2sef($this->var['thread_name'],'dashl'); + $temp['thread_sef'] = eHelper::title2sef($this->var['thread_name'],'dashl'); + $this->addVars($temp); + + $url = e107::url('forum','topic', $this->var); + return "{$thread_name}"; + } + + function sc_pages() + { +// $tVars['PAGES'] = fpages($thread_info, $tVars['REPLIES']); + return fpages($this->var, $this->sc_replies); + } + + function sc_pagesx() + { +// $tVars['PAGESX'] = fpages($thread_info, $tVars['REPLIES']); + return $this->sc_pages; + } + + function sc_admin_icons() + { + + if (MODERATOR) + { + $threadId = $this->var['thread_id']; + $forumId = $this->var['thread_forum_id']; + // FIXME _URL_ thread name + // e107::getUrl()->create('forum/forum/view', "id={$thread_info['thread_forum_id']}") + // USED self instead + +// $moveUrl = e107::url('forum','move', $this->var); + + return " +
+ + ".($this->var['thread_sticky'] == 1 ? " " : " ")." + ".($this->var['thread_active'] ? " " : " "). " + var)."'>".IMAGE_admin_move.' +
+ '; + } + return ''; +} + + function sc_adminoptions() + { + if(!deftrue('BOOTSTRAP')) + { + return $this->sc_admin_icons; + } + if (MODERATOR) + { + return fadminoptions($this->var); + } + return ''; + } + + function sc_poster() +{ + if ($this->var['user_name']) + { + return " $thread_info['thread_user'], 'name' => $this->var['user_name']))."'>".$this->var['user_name'].""; + } +// else +// { + elseif($this->var['thread_user_anon']) + { + return e107::getParser()->toHTML($this->var['thread_user_anon']); + } +// else +// { + return LAN_FORUM_1015; +// } +// } +} +//////////////////////////////////////////////// +/* + + function sc_sub_description() + { + return e107::getParser()->toHTML($this->var['forum_description'], false, 'no_hook'); + } + + + function sc_sub_threadsx() + { + $badgeThreads = ($this->var['forum_replies']) ? "badge-info" : ""; + return "".$this->var['forum_threads'].""; + } + + function sc_sub_repliesx() + { + $badgeReplies = ($this->var['forum_replies']) ? "badge-info" : ""; + return "".$this->var['forum_replies'].""; + } + + function sc_newflag() + { + global $newflag_list; + if(USER && is_array($newflag_list) && in_array($this->var['forum_id'], $newflag_list)) + { + return "".IMAGE_new.''; + } + return IMAGE_nonew; + + } + +*/ +} +?> \ No newline at end of file