1
0
mirror of https://github.com/e107inc/e107.git synced 2025-07-30 19:30:25 +02:00

Add files via upload

This commit is contained in:
rica-carv
2016-06-14 13:36:07 +01:00
committed by GitHub
parent fe54bd0377
commit 17ebeec991
3 changed files with 1126 additions and 6 deletions

View File

@@ -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."<br />";
$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'])?"<br /><div class='smalltext'>".LAN_FORUM_0069.": {$this->var['text']}</div>":"";
}
//----- ########################################################
//----- 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 = "<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>";
}
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 .= "<a href='".$url."'>". $gen->computeLapse($lastpost_datestamp, time(), false, false, 'short')."</a>";
$lastpost_datestamp = $this->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>';
/*----
$fVars->LASTPOSTUSER = $lastpost_name;
$fVars->LASTPOSTDATE .= "<a href='".$url."'>". $gen->computeLapse($lastpost_datestamp, time(), false, false, 'short')."</a>";
$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>';
-----*/
return ($caller == 'sc_lastpostuser'?$lastpost_name:($caller == 'sc_lastpostdate'?"<a href='".$url."'>". $this->gen->computeLapse($lastpost_datestamp, time(), false, false, 'short')."</a>":($caller == 'sc_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 ($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'])

View File

@@ -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[] = "<a class='btn btn-default btn-sm btn-small' href='" . e107::url('forum','topic', $prev) . "'>&laquo; " . LAN_FORUM_2001 . "</a>";
}
if($next !== false)
{
$options[] = "<a class='btn btn-default btn-sm btn-small' href='" . e107::url('forum','topic', $next) . "'>" . LAN_FORUM_2002 . " &raquo;</a>";
}
//---- $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', '<img src="'.img_path('track.png').'" alt="'.LAN_FORUM_4009.'" title="'.LAN_FORUM_4009.'" class="icon S16 action" />');
}
if(!defined('IMAGE_untrack'))
{
define('IMAGE_untrack', '<img src="'.img_path('untrack.png').'" alt="'.LAN_FORUM_4010.'" title="'.LAN_FORUM_4010.'" class="icon S16 action" />');
}
$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 .= "
<span id='forum-track-trigger-container'>
<a class='btn btn-default btn-sm btn-small e-ajax' data-target='forum-track-trigger' href='{$url}' id='forum-track-trigger'>{$img}</a>
</span>
<script type='text/javascript'>
e107.runOnLoad(function(){
$('forum-track-trigger').observe('click', function(e) {
e.stop();
new e107Ajax.Updater('forum-track-trigger-container', '{$url}', {
method: 'post',
parameters: { //send query parameters here
'track_toggle': 1
},
overlayPage: $(document.body)
});
});
}, document, true);
</script>
";*/
$trackDiz = ($forum->prefs->get('trackemail',true)) ? LAN_FORUM_3040 : LAN_FORUM_3041;
// $tVars->TRACK = "<a id='forum-track-button' href='#' title=\"".$trackDiz."\" data-token='".deftrue('e_TOKEN','')."' data-forum-insert='forum-track-button' data-forum-post='".$thread->threadInfo['thread_forum_id']."' data-forum-thread='".$thread->threadInfo['thread_id']."' data-forum-action='track' name='track' class='e-tip btn btn-default' >".$img."</a>";
return "<a id='forum-track-button' href='#' title=\"".$trackDiz."\" data-token='".deftrue('e_TOKEN','')."' data-forum-insert='forum-track-button' data-forum-post='".$this->var['thread_forum_id']."' data-forum-thread='".$this->var['thread_id']."' data-forum-action='track' name='track' class='e-tip btn btn-default' >".$img."</a>";
}
return '';
}
function sc_moderators()
{
global $forum;
$modUser = array();
foreach ( $forum->modArray as $user)
{
$modUser[] = "<a href='".e107::getUrl()->create('user/profile/view', $user)."'>".$user['user_name']."</a>";
}
//$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)."&amp;p=[FROM]";
$parms = "total={$thread->pages}&type=page&current={$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&amp;id=".$this->var['thread_id']."&amp;post=".$thread->threadId;
// $url = $e107->url->create('forum/thread/reply', array('id' => $thread->threadId));
return "<a href='" . $url . "'>" . IMAGE_reply . "</a>";
}
if ($forum->checkPerm($this->var['thread_forum_id'], 'thread'))
{
$ntUrl = e107::url('forum','post')."?f=nt&amp;id=". $this->var['thread_forum_id'];
// $ntUrl = $e107->url->create('forum/thread/new', array('id' => $thread->threadInfo['thread_forum_id']));
return "<a href='" . $ntUrl . "'>" . IMAGE_newthread . "</a>";
}
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&amp;id=".$this->var['thread_id']."&amp;post=".$thread->threadId;
// $url = e107::getUrl()->create('forum/thread/reply', array('id' => $thread->threadId));
$replyUrl = "<a class='btn btn-primary' href='".$url."'>".LAN_FORUM_2006."</a>";
}
if ($forum->checkPerm($this->var['thread_forum_id'], 'thread'))
{
$ntUrl = e107::url('forum','post')."?f=nt&amp;id=". $this->var['thread_forum_id'];
// $ntUrl = e107::getUrl()->create('forum/thread/new', array('id' => $thread->threadInfo['thread_forum_id']));
$options[] = " <a href='".$ntUrl."'>".LAN_FORUM_2005."</a>";
}
// $options[] = "<a href='" . e107::getUrl()->create('forum/thread/prev', array('id' => $thread->threadId)) . "'>".LAN_FORUM_1017." ".LAN_FORUM_2001."</a>";
// $options[] = "<a href='" . e107::getUrl()->create('forum/thread/prev', array('id' => $thread->threadId)) . "'>".LAN_FORUM_1017." ".LAN_FORUM_2002."</a>";
//---- 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[] = "<a href='" . e107::url('forum','topic', $prev) . "'>".LAN_FORUM_1017." ".LAN_FORUM_2001."</a>";
}
if($next !== false)
{
$options[] = "<a href='" . e107::url('forum','topic', $next) . "'>".LAN_FORUM_1017." ".LAN_FORUM_2002."</a>";
}
$text = '<div class="btn-group">
'.$replyUrl.'
<button class="btn btn-primary dropdown-toggle" data-toggle="dropdown">
<span class="caret"></span>
</button>
<ul class="dropdown-menu pull-right">
';
foreach($options as $key => $val)
{
$text .= '<li>'.$val.'</li>';
}
$jumpList = $forum->forumGetAllowed();
$text .= "<li class='divider'></li>";
foreach($jumpList as $key=>$val)
{
$text .= '<li><a href ="'.e107::url('forum','forum',$val).'">'.LAN_FORUM_1017." ".$val['forum_name'].'</a></li>';
}
$text .= '
</ul>
</div>';
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 = "<form method='post' action='".e_SELF."'><p>".LAN_FORUM_1017.": <select name='forumjump' class='tbox'>";
foreach ($jumpList as $key => $val)
{
$text .= "\n<option value='" . e107::url('forum','forum',$val) . "'>" . $val['forum_name'] . "</option>";
}
$text .= "</select> <input class='btn btn-default button' type='submit' name='fjsubmit' value='" . LAN_GO . "' /></p></form>";
return $text;
}
function sc_message()
{
global $thread;
return $thread->message;
}
}
?>

View File

@@ -0,0 +1,809 @@
<?php
/*
* Copyright e107 Inc e107.org, Licensed under GNU GPL (http://www.gnu.org/licenses/gpl.txt)
*
* Forum plugin - view shortcodess
*
*/
if (!defined('e107_INIT')) { exit; }
class plugin_forum_viewforum_shortcodes extends e_shortcode
{
private $gen;
function __construct()
{
$this->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 "<a href='".$this->var['ntUrl']."'>".IMAGE_newthread.'</a>';
}
function sc_newthreadbuttonx()
{
if(!BOOTSTRAP)
{
return sc_newthreadbutton;
}
//--function newthreadjump($url)
//--{
global $forum;
$jumpList = $forum->forumGetAllowed('view');
$text = '<div class="btn-group">
<a href="'.$this->var['ntUrl'].'" class="btn btn-primary">'.LAN_FORUM_1018.'</a>
<button class="btn btn-primary dropdown-toggle" data-toggle="dropdown">
<span class="caret"></span>
</button>
<ul class="dropdown-menu pull-right">
';
foreach($jumpList as $key => $val)
{
$text .= '<li><a href="'.e107::url('forum','forum',$val).'">'.LAN_FORUM_1017.': '.$val['forum_name'].'</a></li>';
}
$text .= '
</ul>
</div>';
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 "
<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>";
}
function sc_viewable_by()
{
global $forum, $forumId;
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))
{
return "
<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
//{
return '';
//}
}
function sc_search()
{
return "
<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>";
}
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("<span class='forum-perms-separator'><!-- --></span>", $permDisplay);
}
function sc_forumjump()
{
global $forum;
$jumpList = $forum->forumGetAllowed('view');
$text = "<form method='post' action='".e_SELF."'><p>".LAN_FORUM_1017.": <select name='forumjump' class='tbox'>";
foreach($jumpList as $key => $val)
{
$text .= "\n<option value='".e107::url('forum','forum',$val, 'full')."'>".$val['forum_name']."</option>";
}
$text .= "</select> <input class='btn btn-default button' type='submit' name='fjsubmit' value='".LAN_GO."' /></form>";
return $text;
}
// FIXME - TOPLINK not used anymore?
function sc_toplink()
{
return "<a href='".e_SELF.'?'.e_QUERY."#top' onclick=\"window.scrollTo(0,0);\">".LAN_GO.'</a>';
}
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'] = "<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';
//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 "<a href='".e107::getUrl()->create('forum/forum/view', $this->var)."'>{$forumName}</a>";
}
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 "<span class='badge {$badgeThreads}'>".$this->var['forum_threads']."</span>";
}
function sc_sub_repliesx()
{
$badgeReplies = ($this->var['forum_replies']) ? "badge-info" : "";
return "<span class='badge {$badgeReplies}'>".$this->var['forum_replies']."</span>";
}
function sc_newflag()
{
global $newflag_list;
if(USER && is_array($newflag_list) && in_array($this->var['forum_id'], $newflag_list))
{
return "<a href='".e107::getUrl()->create('forum/forum/mfar', 'id='.$this->var['forum_id'])."'>".IMAGE_new.'</a>';
}
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 = "<a href='".e107::getUrl()->create('forum/thread/last', array('id' => $tmp[1]))."'>".IMAGE_post2.'</a>';
$lp_date = $this->gen->convert_date($tmp[0], 'forum');
if($this->var['user_name'])
{
$lp_name = "<a href='".e107::getUrl()->create('user/profile/view', array('id' => $this->var['forum_lastpost_user'], 'name' => $this->var['user_name']))."'>{$this->var['user_name']}</a>";
}
else
{
$lp_name = $this->var['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;
----*/
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.'<br />'.$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 "<span class='badge {$badge}'>".$this->sc_views."</span>";
}
function sc_repliesx()
{
if(!deftrue('BOOTSTRAP'))
{
return $this->sc_replies;
}
$badge = ($this->var['thread_total_replies'] > 0) ? "badge-info" : "";
return "<span class='badge {$badge}'>".$this->sc_replies."</span>";
}
// 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'] = "<a href='{$url}'>".$this->var['lastpost_username']."</a>";
//---- $tVars['LASTPOSTUSER'] = "<a href='{$url}'>".$this->var['lastpost_username']."</a>";
$LASTPOST = $LASTPOSTUSER = "<a href='{$url}'>".$this->var['lastpost_username']."</a>";
}
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'] .= '<br />'.$lastpost_datestamp;
$LASTPOST .= '<br />'.$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'] .= "<a href='".$url."'>". $gen->computeLapse($thread_info['thread_lastpost'],time(), false, false, 'short')."</a>";
return ($caller == 'sc_lastpostuser'?$LASTPOSTUSER:($caller == 'sc_lastpostdate'?"<a href='".$url."'>".$this->gen->computeLapse($thread_info['thread_lastpost'],time(), false, false, 'short')."</a>":($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.']<br />';
}
elseif($this->var['thread_sticky'] == 2)
{
return '['.LAN_FORUM_1013.']<br />';
}
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("'", '&#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($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 "<a {$title} href='".$url."'>{$thread_name}</a>";
}
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 "
<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})\" />
".($this->var['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' /> ")."
".($this->var['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='".e107::url('forum','move', $this->var)."'>".IMAGE_admin_move.'</a>
</div></form>
';
}
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 "<a href='".e107::getUrl()->create('user/profile/view', array('id' => $thread_info['thread_user'], 'name' => $this->var['user_name']))."'>".$this->var['user_name']."</a>";
}
// 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 "<span class='badge {$badgeThreads}'>".$this->var['forum_threads']."</span>";
}
function sc_sub_repliesx()
{
$badgeReplies = ($this->var['forum_replies']) ? "badge-info" : "";
return "<span class='badge {$badgeReplies}'>".$this->var['forum_replies']."</span>";
}
function sc_newflag()
{
global $newflag_list;
if(USER && is_array($newflag_list) && in_array($this->var['forum_id'], $newflag_list))
{
return "<a href='".e107::getUrl()->create('forum/forum/mfar', 'id='.$this->var['forum_id'])."'>".IMAGE_new.'</a>';
}
return IMAGE_nonew;
}
*/
}
?>