e107 = e107::getInstance();
}
function loadNewsItem()
{
$e107 = e107::getInstance();
$e107->tp->e_sc->scClasses['news_shortcodes']->news_item = getcachedvars('current_news_item');
$e107->tp->e_sc->scClasses['news_shortcodes']->param = getcachedvars('current_news_param');
}
function sc_newstitle()
{
return $this->e107->tp->toHTML($this->news_item['news_title'], TRUE, 'TITLE');
}
function sc_newsbody($parm)
{
$news_body = $this->e107->tp->toHTML($this->news_item['news_body'], true, 'BODY, fromadmin', $this->news_item['news_author']);
if($this->news_item['news_extended'] && (isset($_POST['preview']) || strpos(e_QUERY, 'extend') !== FALSE) && $parm != 'noextend')
{
$news_extended = $this->e107->tp->toHTML($this->news_item['news_extended'], true, 'BODY, fromadmin', $this->news_item['news_author']);
$news_body .= '
'.$news_extended;
}
return $news_body;
}
function sc_newsicon($parm)
{
$category_icon = str_replace('../', '', trim($this->news_item['category_icon']));
if ($category_icon && strstr('images', $category_icon))
{
$category_icon = THEME_ABS.$category_icon;
}
else
{
$category_icon = e_IMAGE_ABS.'icons/'.$category_icon;
}
if (!$category_icon) { return ''; }
return "news_item['news_category'].'&sef='.$this->news_item['news_category_rewrite_string'])."'>";
}
function sc_newsauthor($parm)
{
if($this->news_item['user_id'])
{
if($parm == 'nolink')
{
return $this->news_item['user_name'];
}
else
{
return "news_item['user_id'])."'>".$this->news_item['user_name']."{$parm}";
}
}
return "e107";
}
function sc_newscomments($parm)
{
global $pref, $sql;
if($pref['comments_disabled'] == 1)
{
return;
}
$news_item = $this->news_item;
$param = $this->param;
if (varsettrue($pref['multilanguage']))
{ // Can have multilanguage news table, monlingual comment table. If the comment table is multilingual, it'll only count entries in the current language
$news_item['news_comment_total'] = $sql->db_Select("comments", "*", "comment_item_id='".$news_item['news_id']."' AND comment_type='0' ");
}
if ($pref['comments_icon'] && $news_item['news_comment_total'])
{
$sql->db_Select('comments', 'comment_datestamp', "comment_item_id='".intval($news_item['news_id'])."' AND comment_type='0' ORDER BY comment_datestamp DESC LIMIT 0,1");
list($comments['comment_datestamp']) = $sql->db_Fetch();
$latest_comment = $comments['comment_datestamp'];
if ($latest_comment > USERLV )
{
$NEWIMAGE = $param['image_new_small'];
}
else
{
$NEWIMAGE = $param['image_nonew_small'];
}
}
else
{
$NEWIMAGE = $param['image_nonew_small'];
}
return (!$news_item['news_allow_comments'] ? ''.($pref['comments_icon'] ? $NEWIMAGE : '')." ".$param['commentlink'].$news_item['news_comment_total'].'' : $param['commentoffstring']);
}
function sc_trackback($parm)
{
global $pref;
if(!varsettrue($pref['trackbackEnabled'])) { return ''; }
return ($this->param['trackbackbeforestring'] ? $this->param['trackbackbeforestring'] : '')."".$this->param['trackbackstring'].$this->news_item['tb_count'].''.($this->param['trackbackafterstring'] ? $this->param['trackbackafterstring'] : '');
}
function sc_newsheader($parm)
{
$category_icon = str_replace("../", "", trim($this->news_item['category_icon']));
if (!$category_icon) return '';
if ($category_icon && strstr("images", $category_icon)) {
return THEME_ABS.$category_icon;
} else {
return e_IMAGE_ABS."icons/".$category_icon;
}
}
function sc_newscategory($parm)
{
$category_name = $this->e107->tp->toHTML($this->news_item['category_name'], FALSE ,'defs');
return "param['catlink'] : "#")."' href='".$this->e107->url->getUrl('core:news', 'main', 'action=list&id='.$this->news_item['news_category'].'&sef='.$this->news_item['news_category_rewrite_string'])."'>".$category_name."";
}
function sc_newsdate($parm)
{
$con = new convert;
if($parm == '')
{
return $con->convert_date($this->news_item['news_datestamp'], 'long');
}
switch($parm)
{
case 'long':
return $con->convert_date($this->news_item['news_datestamp'], 'long');
break;
case 'short':
return $con->convert_date($this->news_item['news_datestamp'], 'short');
break;
case 'forum':
return $con->convert_date($this->news_item['news_datestamp'], 'forum');
break;
default :
return date($parm, $this->news_item['news_datestamp']);
break;
}
}
function sc_newscommentlink($parm)
{
return ($this->news_item['news_allow_comments'] ? $this->param['commentoffstring'] : " ".$this->param['commentlink'].'');
}
function sc_newscommentcount($parm)
{
return $this->news_item['news_comment_total'];
}
function sc_emailicon($parm)
{
require_once(e_HANDLER.'emailprint_class.php');
return emailprint::render_emailprint('news', $this->news_item['news_id'], 1);
}
function sc_printicon()
{
require_once(e_HANDLER.'emailprint_class.php');
return emailprint::render_emailprint('news', $this->news_item['news_id'], 2);
}
function sc_pdficon()
{
global $pref;
if (!$pref['plug_installed']['pdf']) { return ''; }
return $this->e107->tp->parseTemplate('{PDF='.LAN_NEWS_24.'^news.'.$this->news_item['news_id'].'}');
}
function sc_newsid()
{
return $this->news_item['news_id'];
}
function sc_adminoptions()
{
if (ADMIN && getperms('H'))
{
$adop_icon = (file_exists(THEME."images/newsedit.png") ? THEME_ABS."images/newsedit.png" : e_IMAGE_ABS."generic/newsedit.png");
return "
\n";
}
else
{
return '';
}
}
function sc_extended($parm)
{
if ($this->news_item['news_extended'] && (strpos(e_QUERY, 'extend') === FALSE || $parm == 'force'))
{
if (defined('PRE_EXTENDEDSTRING'))
{
$es1 = PRE_EXTENDEDSTRING;
}
if (defined('POST_EXTENDEDSTRING'))
{
$es2 = POST_EXTENDEDSTRING;
}
if (isset($_POST['preview']))
{
return $es1.EXTENDEDSTRING.$es2."
".$this->news_item['news_extended'];
}
else
{
return $es1."news_item['news_id'].'&sef='.$this->news_item['news_rewrite_string'])."'>".EXTENDEDSTRING."".$es2;
}
}
return '';
}
function sc_captionclass()
{
$news_title = $this->e107->tp->toHTML($this->news_item['news_title'], TRUE,'no_hook,emotes_off, no_make_clickable');
return "