mirror of
https://github.com/e107inc/e107.git
synced 2025-08-05 22:27:34 +02:00
Improved news shortcode handlingImplemented new shortcode override/ directory. Any .sc file found here will override any other shortcode anywhere.
This commit is contained in:
@@ -1,13 +1,14 @@
|
||||
<?php
|
||||
/*
|
||||
* Copyright e107 Inc e107.org, Licensed under GNU GPL (http://www.gnu.org/licenses/gpl.txt)
|
||||
* $Id: news_shortcodes.php,v 1.17 2009-01-15 15:42:24 secretr Exp $
|
||||
* $Id: news_shortcodes.php,v 1.18 2009-01-16 01:02:41 mcfly_e107 Exp $
|
||||
*
|
||||
* News shortcode batch
|
||||
*/
|
||||
if (!defined('e107_INIT')) { exit; }
|
||||
include_once(e_HANDLER.'shortcode_handler.php');
|
||||
//include_once(e_HANDLER.'shortcode_handler.php');
|
||||
|
||||
/*
|
||||
$codes = array(
|
||||
'newstitle', 'newsbody', 'newsicon','newsauthor', 'newscomments',
|
||||
'trackback', 'newsheader', 'newscategory', 'newsdate', 'newscommentlink',
|
||||
@@ -15,7 +16,21 @@ $codes = array(
|
||||
'extended', 'captionclass', 'admincaption', 'adminbody', 'newssummary',
|
||||
'newsthumbnail', 'newsimage', 'sticky_icon', 'newstitlelink', 'newscaticon', 'newsinfo'
|
||||
);
|
||||
*/
|
||||
|
||||
$codes = array();
|
||||
$tmp = get_class_methods('news_shortcodes');
|
||||
foreach($tmp as $c)
|
||||
{
|
||||
if(strpos($c, 'get_') === 0)
|
||||
{
|
||||
$codes[] = substr($c, 4);
|
||||
}
|
||||
}
|
||||
unset($tmp);
|
||||
|
||||
register_shortcode('news_shortcodes', $codes);
|
||||
initShortcodeClass('news_shortcodes');
|
||||
|
||||
class news_shortcodes
|
||||
{
|
||||
@@ -26,26 +41,20 @@ class news_shortcodes
|
||||
$this->e107 = e107::getInstance();
|
||||
}
|
||||
|
||||
function load_news_item()
|
||||
function loadNewsItem()
|
||||
{
|
||||
global $newsItemBegin;
|
||||
if($newsItemBegin == true)
|
||||
{
|
||||
$this->news_item = getcachedvars('current_news_item');
|
||||
$this->param = getcachedvars('current_news_param');
|
||||
$newsItemBegin = false;
|
||||
}
|
||||
$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 get_newstitle()
|
||||
{
|
||||
$this->load_news_item();
|
||||
return $this->e107->tp->toHTML($this->news_item['news_title'], TRUE, 'TITLE');
|
||||
}
|
||||
|
||||
function get_newsbody($parm)
|
||||
{
|
||||
$this->load_news_item();
|
||||
$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')
|
||||
{
|
||||
@@ -57,7 +66,6 @@ class news_shortcodes
|
||||
|
||||
function get_newsicon($parm)
|
||||
{
|
||||
$this->load_news_item();
|
||||
$category_icon = str_replace('../', '', trim($this->news_item['category_icon']));
|
||||
if ($category_icon && strstr('images', $category_icon))
|
||||
{
|
||||
@@ -74,7 +82,6 @@ class news_shortcodes
|
||||
|
||||
function get_newsauthor($parm)
|
||||
{
|
||||
$this->load_news_item();
|
||||
if($this->news_item['user_id'])
|
||||
{
|
||||
if($parm == 'nolink')
|
||||
@@ -91,7 +98,6 @@ class news_shortcodes
|
||||
|
||||
function get_newscomments($parm)
|
||||
{
|
||||
$this->load_news_item();
|
||||
global $pref, $sql;
|
||||
if($pref['comments_disabled'] == 1)
|
||||
{
|
||||
@@ -129,14 +135,12 @@ class news_shortcodes
|
||||
function get_trackback($parm)
|
||||
{
|
||||
global $pref;
|
||||
$this->load_news_item();
|
||||
if(!varsettrue($pref['trackbackEnabled'])) { return ''; }
|
||||
return ($this->param['trackbackbeforestring'] ? $this->param['trackbackbeforestring'] : '')."<a href='".e_HTTP."comment.php?comment.news.".$this->news_item['news_id']."#track'>".$this->param['trackbackstring'].$this->news_item['tb_count'].'</a>'.($this->param['trackbackafterstring'] ? $this->param['trackbackafterstring'] : '');
|
||||
}
|
||||
|
||||
function get_newsheader($parm)
|
||||
{
|
||||
$this->load_news_item();
|
||||
$category_icon = str_replace("../", "", trim($this->news_item['category_icon']));
|
||||
if (!$category_icon) return '';
|
||||
if ($category_icon && strstr("images", $category_icon)) {
|
||||
@@ -149,14 +153,12 @@ class news_shortcodes
|
||||
|
||||
function get_newscategory($parm)
|
||||
{
|
||||
$this->load_news_item();
|
||||
$category_name = $this->e107->tp->toHTML($this->news_item['category_name'], FALSE ,'defs');
|
||||
return "<a class='".$GLOBALS['NEWS_CSSMODE']."_category' style='".(isset($this->param['catlink']) ? $this->param['catlink'] : "#")."' href='".$e107->url->getUrl('core:news', 'main', 'action=cat&value='.$this->news_item['news_category'])."'>".$category_name."</a>";
|
||||
}
|
||||
|
||||
function get_newsdate($parm)
|
||||
{
|
||||
$this->load_news_item();
|
||||
$con = new convert;
|
||||
if($parm == '')
|
||||
{
|
||||
@@ -181,26 +183,22 @@ class news_shortcodes
|
||||
|
||||
function get_newscommentlink($parm)
|
||||
{
|
||||
$this->load_news_item();
|
||||
return ($this->news_item['news_allow_comments'] ? $this->param['commentoffstring'] : " <a href='".e_HTTP."comment.php?comment.news.".$this->news_item['news_id']."'>".$this->param['commentlink'].'</a>');
|
||||
}
|
||||
|
||||
function get_newscommentcount($parm)
|
||||
{
|
||||
$this->load_news_item();
|
||||
return $this->news_item['news_comment_total'];
|
||||
}
|
||||
|
||||
function get_emailicon($parm)
|
||||
{
|
||||
$this->load_news_item();
|
||||
require_once(e_HANDLER.'emailprint_class.php');
|
||||
return emailprint::render_emailprint('news', $this->news_item['news_id'], 1);
|
||||
}
|
||||
|
||||
function get_printicon()
|
||||
{
|
||||
$this->load_news_item();
|
||||
require_once(e_HANDLER.'emailprint_class.php');
|
||||
return emailprint::render_emailprint('news', $this->news_item['news_id'], 2);
|
||||
}
|
||||
@@ -208,21 +206,18 @@ class news_shortcodes
|
||||
function get_pdficon()
|
||||
{
|
||||
global $pref;
|
||||
$this->load_news_item();
|
||||
if (!$pref['plug_installed']['pdf']) { return ''; }
|
||||
return $this->e107->tp->parseTemplate('{PDF='.LAN_NEWS_24.'^news.'.$this->news_item['news_id'].'}');
|
||||
}
|
||||
|
||||
function get_newsid()
|
||||
{
|
||||
$this->load_news_item();
|
||||
return $this->news_item['news_id'];
|
||||
}
|
||||
|
||||
function get_adminoptions()
|
||||
{
|
||||
global $imode;
|
||||
$this->load_news_item();
|
||||
if (ADMIN && getperms('H'))
|
||||
{
|
||||
$adop_icon = (file_exists(THEME."images/newsedit.png") ? THEME_ABS."images/newsedit.png" : e_IMAGE_ABS."packs/".$imode."/generic/newsedit.png");
|
||||
@@ -236,7 +231,6 @@ class news_shortcodes
|
||||
|
||||
function get_extended($parm)
|
||||
{
|
||||
$this->load_news_item();
|
||||
if ($this->news_item['news_extended'] && (strpos(e_QUERY, 'extend') === FALSE || $parm == 'force'))
|
||||
{
|
||||
if (defined('PRE_EXTENDEDSTRING'))
|
||||
@@ -261,58 +255,49 @@ class news_shortcodes
|
||||
|
||||
function get_captionclass()
|
||||
{
|
||||
$this->load_news_item();
|
||||
$news_title = $this->e107->tp->toHTML($this->news_item['news_title'], TRUE,'no_hook,emotes_off, no_make_clickable');
|
||||
return "<div class='category".$this->news_item['news_category']."'>".($this->news_item['news_render_type'] == 1 ? "<a href='".e_HTTP."comment.php?comment.news.".$this->news_item['news_id']."'>".$news_title."</a>" : $news_title)."</div>";
|
||||
}
|
||||
|
||||
function get_admincaption()
|
||||
{
|
||||
$this->load_news_item();
|
||||
$news_title = $this->e107->tp->toHTML($this->news_item['news_title'], TRUE,'no_hook,emotes_off, no_make_clickable');
|
||||
return "<div class='".(defined(ADMINNAME) ? ADMINNAME : "null")."'>".($this->news_item['news_render_type'] == 1 ? "<a href='".e_HTTP."comment.php?comment.news.".$this->news_item['news_id']."'>".$news_title."</a>" : $news_title)."</div>";
|
||||
}
|
||||
|
||||
function get_adminbody($parm)
|
||||
{
|
||||
$this->load_news_item();
|
||||
$news_body = $this->get_newsbody($parm);
|
||||
return "<div class='".(defined(ADMINNAME) ? ADMINNAME : 'null')."'>".$news_body.'</div>';
|
||||
}
|
||||
|
||||
function get_newssummary()
|
||||
{
|
||||
$this->load_news_item();
|
||||
return ($this->news_item['news_summary']) ? $this->news_item['news_summary'].'<br />' : '';
|
||||
}
|
||||
|
||||
function get_newsthumbnail()
|
||||
{
|
||||
$this->load_news_item();
|
||||
return (isset($this->news_item['news_thumbnail']) && $this->news_item['news_thumbnail']) ? "<a href='".$this->e107->url->getUrl('core:news', 'main', "action=item&value1={$this->news_item['news_id']}&value2={$this->news_item['news_category']}")."'><img class='news_image' src='".e_IMAGE_ABS."newspost_images/".$this->news_item['news_thumbnail']."' alt='' style='".$this->param['thumbnail']."' /></a>" : '';
|
||||
}
|
||||
|
||||
function get_newsimage()
|
||||
{
|
||||
$this->load_news_item();
|
||||
return (isset($this->news_item['news_thumbnail']) && $this->news_item['news_thumbnail']) ? "<a href='".$this->e107->url->getUrl('core:news', 'main', "action=item&value1={$this->news_item['news_id']}&value2={$this->news_item['news_category']}")."'><img class='news_image' src='".e_IMAGE_ABS."newspost_images/".$this->news_item['news_thumbnail']."' alt='' style='".$this->param['thumbnail']."' /></a>" : '';
|
||||
}
|
||||
|
||||
function get_sticky_icon()
|
||||
{
|
||||
$this->load_news_item();
|
||||
return $this->news_item['news_sticky'] ? $this->param['image_sticky'] : '';
|
||||
}
|
||||
|
||||
function get_newstitlelink()
|
||||
{
|
||||
$this->load_news_item();
|
||||
return "<a style='".(isset($this->param['itemlink']) ? $this->param['itemlink'] : 'null')."' href='".$this->e107->url->getUrl('core:news', 'main', "action=item&value1={$this->news_item['news_id']}&value2={$this->news_item['news_category']}")."'>".$this->news_item['news_title'].'</a>';
|
||||
}
|
||||
|
||||
function get_newscaticon()
|
||||
{
|
||||
$this->load_news_item();
|
||||
$category_icon = str_replace('../', '', trim($this->news_item['category_icon']));
|
||||
if (!$category_icon) { return ''; }
|
||||
if ($category_icon && strstr('images', $category_icon))
|
||||
@@ -330,7 +315,6 @@ class news_shortcodes
|
||||
|
||||
function get_newsinfo()
|
||||
{
|
||||
$this->load_news_item();
|
||||
$news_item = $this->news_item;
|
||||
$param = $this->param;
|
||||
$con = new convert;
|
||||
|
Reference in New Issue
Block a user