mirror of
https://github.com/e107inc/e107.git
synced 2025-07-31 20:00:37 +02:00
Magic Shortcodes added. Fix for news 'view' rendering.
This commit is contained in:
35
class2.php
35
class2.php
@@ -957,6 +957,37 @@ if (!class_exists('e107table', false))
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function getMagicShortcodes()
|
||||||
|
{
|
||||||
|
$ret = array();
|
||||||
|
|
||||||
|
// $ret['{---CAPTION1---}'] = varset($this->renders[0]['caption']);
|
||||||
|
// $ret['{---CAPTION2---}'] = varset($this->renders[1]['caption']);
|
||||||
|
|
||||||
|
$types = array('caption') + $this->contentTypes;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
$c = 1;
|
||||||
|
|
||||||
|
foreach($this->renders as $k => $val)
|
||||||
|
{
|
||||||
|
|
||||||
|
foreach($types as $var)
|
||||||
|
{
|
||||||
|
$sc = '{---'.strtoupper($var).$c.'---}';
|
||||||
|
$ret[$sc] = $val[$var];
|
||||||
|
}
|
||||||
|
|
||||||
|
$c++;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
return $ret;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the style mode for use in tablestyle() method/function
|
* Set the style mode for use in tablestyle() method/function
|
||||||
* @param string $style
|
* @param string $style
|
||||||
@@ -1121,11 +1152,11 @@ if (!class_exists('e107table', false))
|
|||||||
$options['menuCount'] = $this->eMenuCount;
|
$options['menuCount'] = $this->eMenuCount;
|
||||||
$options['menuTotal'] = varset($this->eMenuTotal[$this->eMenuArea]);
|
$options['menuTotal'] = varset($this->eMenuTotal[$this->eMenuArea]);
|
||||||
$options['setStyle'] = $this->eSetStyle;
|
$options['setStyle'] = $this->eSetStyle;
|
||||||
$options['caption'] = $caption;
|
$options['caption'] = strip_tags($caption);
|
||||||
|
|
||||||
$this->renders[] = $options;
|
$this->renders[] = $options;
|
||||||
|
|
||||||
|
//XXX Optional feature may be added if needed - define magic shortcodes inside $thm class. eg. function msc_custom();
|
||||||
|
|
||||||
if(is_object(vartrue($thm)))
|
if(is_object(vartrue($thm)))
|
||||||
{
|
{
|
||||||
|
@@ -43,4 +43,3 @@ function menu_shortcode($parm, $mode='')
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
?>
|
|
||||||
|
@@ -18,6 +18,9 @@ if (!defined('e107_INIT'))
|
|||||||
}
|
}
|
||||||
$In_e107_Footer = TRUE; // For registered shutdown function
|
$In_e107_Footer = TRUE; // For registered shutdown function
|
||||||
|
|
||||||
|
$magicSC = e107::getRender()->getMagicShortcodes(); // support for {---CAPTION1---} etc.
|
||||||
|
|
||||||
|
|
||||||
global $error_handler,$db_time,$FOOTER;
|
global $error_handler,$db_time,$FOOTER;
|
||||||
|
|
||||||
|
|
||||||
@@ -171,9 +174,15 @@ if (varset($e107_popup) != 1)
|
|||||||
//
|
//
|
||||||
if ((ADMIN || $pref['developer']) && E107_DEBUG_LEVEL)
|
if ((ADMIN || $pref['developer']) && E107_DEBUG_LEVEL)
|
||||||
{
|
{
|
||||||
global $db_debug;
|
$tmp = array();
|
||||||
|
foreach($magicSC as $k=>$v)
|
||||||
|
{
|
||||||
|
$k = str_replace(array('{','}'),'',$k);
|
||||||
|
$tmp[$k] = $v;
|
||||||
|
}
|
||||||
|
e107::getDebug()->log("<b>Magic Shortcodes</b><small> Replace [ ] with { }</small><br />".print_a($tmp,true));
|
||||||
echo "\n<!-- DEBUG -->\n<div class='e-debug debug-info'>";
|
echo "\n<!-- DEBUG -->\n<div class='e-debug debug-info'>";
|
||||||
$db_debug->Show_All();
|
e107::getDebug()->Show_All();
|
||||||
echo "</div>\n";
|
echo "</div>\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -289,7 +298,7 @@ if (!empty($pref['e_footer_list']) && is_array($pref['e_footer_list']))
|
|||||||
if(is_readable($fname))
|
if(is_readable($fname))
|
||||||
{
|
{
|
||||||
|
|
||||||
$ret = ($e107_debug || isset($_E107['debug'])) ? include_once($fname) : @include_once($fname);
|
$ret = (!empty($e107_debug) || isset($_E107['debug'])) ? include_once($fname) : @include_once($fname);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -397,8 +406,9 @@ if (!empty($pref['e_output_list']) && is_array($pref['e_output_list']))
|
|||||||
//$length = ob_get_length();
|
//$length = ob_get_length();
|
||||||
//$page = ob_get_clean();
|
//$page = ob_get_clean();
|
||||||
|
|
||||||
$search = array('{---CAPTION---}');
|
|
||||||
$replace = array(print_a(e107::getRender()->renders,true));
|
$search = array_keys($magicSC);
|
||||||
|
$replace = array_values($magicSC);
|
||||||
|
|
||||||
// New - see class2.php
|
// New - see class2.php
|
||||||
$ehd = new e_http_header;
|
$ehd = new e_http_header;
|
||||||
@@ -407,8 +417,6 @@ $ehd->send();
|
|||||||
// $ehd->debug();
|
// $ehd->debug();
|
||||||
|
|
||||||
$page = $ehd->getOutput();
|
$page = $ehd->getOutput();
|
||||||
//$ehd->setContent($page);
|
|
||||||
//$ehd->send($length);
|
|
||||||
|
|
||||||
|
|
||||||
// real output
|
// real output
|
||||||
|
@@ -406,7 +406,7 @@ class news {
|
|||||||
|
|
||||||
$text = e107::getParser()->parseTemplate($NEWS_PARSE, true, $sc);
|
$text = e107::getParser()->parseTemplate($NEWS_PARSE, true, $sc);
|
||||||
|
|
||||||
if ($mode == 'return')
|
if ($mode == 'return' || !empty($param['return']))
|
||||||
{
|
{
|
||||||
return $text;
|
return $text;
|
||||||
}
|
}
|
||||||
|
@@ -1082,43 +1082,6 @@ class news_front
|
|||||||
|
|
||||||
//More SEO
|
//More SEO
|
||||||
$this->setNewsFrontMeta($news);
|
$this->setNewsFrontMeta($news);
|
||||||
/*
|
|
||||||
if($news['news_title'])
|
|
||||||
{
|
|
||||||
if($this->pref['meta_news_summary'] && $news['news_title'])
|
|
||||||
{
|
|
||||||
define("META_DESCRIPTION",SITENAME.": ".$news['news_title']." - ".$news['news_summary']);
|
|
||||||
}
|
|
||||||
define("e_PAGETITLE",$news['news_title']);
|
|
||||||
}*/
|
|
||||||
/* FIXME - better implementation: cache, shortcodes, do it inside the model/shortcode class itself.
|
|
||||||
if (TRUE)
|
|
||||||
{
|
|
||||||
// Added by nlStart - show links to previous and next news
|
|
||||||
if (!isset($news['news_extended'])) $news['news_extended'] = '';
|
|
||||||
$news['news_extended'].="<div style='text-align:center;'><a href='".e_SELF."?cat.".$id."'>".LAN_NEWS_85."</a> <a href='".e_SELF."'>".LAN_NEWS_84."</a></div>";
|
|
||||||
$prev_query = "SELECT news_id, news_title FROM `#news`
|
|
||||||
WHERE `news_id` < ".intval($sub_action)." AND `news_category`=".$id." AND `news_class` REGEXP '".e_CLASS_REGEXP."'
|
|
||||||
AND NOT (`news_class` REGEXP ".$nobody_regexp.")
|
|
||||||
AND `news_start` < ".time()." AND (`news_end`=0 || `news_end` > ".time().') ORDER BY `news_id` DESC LIMIT 1';
|
|
||||||
$sql->db_Select_gen($prev_query);
|
|
||||||
$prev_news = $sql->db_Fetch();
|
|
||||||
if ($prev_news)
|
|
||||||
{
|
|
||||||
$news['news_extended'].="<div style='float:right;'><a href='".e_SELF."?extend.".$prev_news['news_id']."'>".LAN_NEWS_86."</a></div>";
|
|
||||||
}
|
|
||||||
$next_query = "SELECT news_id, news_title FROM `#news` AS n
|
|
||||||
WHERE `news_id` > ".intval($sub_action)." AND `news_category` = ".$id." AND `news_class` REGEXP '".e_CLASS_REGEXP."'
|
|
||||||
AND NOT (`news_class` REGEXP ".$nobody_regexp.")
|
|
||||||
AND `news_start` < ".time()." AND (`news_end`=0 || `news_end` > ".time().') ORDER BY `news_id` ASC LIMIT 1';
|
|
||||||
$sql->db_Select_gen($next_query);
|
|
||||||
$next_news = $sql->db_Fetch();
|
|
||||||
if ($next_news)
|
|
||||||
{
|
|
||||||
$news['news_extended'].="<div style='float:left;'><a href='".e_SELF."?extend.".$next_news['news_id']."'>".LAN_NEWS_87."</a></div>";
|
|
||||||
}
|
|
||||||
$news['news_extended'].="<br /><br />";
|
|
||||||
}*/
|
|
||||||
|
|
||||||
$currentNewsAction = $this->action;
|
$currentNewsAction = $this->action;
|
||||||
|
|
||||||
@@ -1127,6 +1090,10 @@ class news_front
|
|||||||
$param = array();
|
$param = array();
|
||||||
$param['current_action'] = $action;
|
$param['current_action'] = $action;
|
||||||
$param['template_key'] = 'news/view';
|
$param['template_key'] = 'news/view';
|
||||||
|
$param['return'] = true;
|
||||||
|
|
||||||
|
$caption = null;
|
||||||
|
$render = false;
|
||||||
|
|
||||||
if(!empty($NEWSSTYLE))
|
if(!empty($NEWSSTYLE))
|
||||||
{
|
{
|
||||||
@@ -1150,25 +1117,45 @@ class news_front
|
|||||||
|
|
||||||
$template = $tmp['item'];
|
$template = $tmp['item'];
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if(isset($tmp['caption']) && $tmp['caption'] !== null) // to initiate tablerender() usage.
|
if(isset($tmp['caption']) && $tmp['caption'] !== null) // to initiate tablerender() usage.
|
||||||
{
|
{
|
||||||
$this->addDebug('Internal Route', $this->route);
|
$this->addDebug('Internal Route', $this->route);
|
||||||
$this->route = 'news/view'; // used for tablerender id.
|
$this->route = 'news/view'; // used for tablerender id.
|
||||||
$this->templateKey = $newsViewTemplate; // used for tablerender id.
|
$this->templateKey = $newsViewTemplate; // used for tablerender id.
|
||||||
$this->caption = e107::getParser()->parseTemplate($tmp['caption'], true, $news);
|
|
||||||
|
$nsc = e107::getScBatch('news')->setScVar('news_item', $news); // Allow any news shortcode to be used in the 'caption'.
|
||||||
|
$caption = e107::getParser()->parseTemplate($tmp['caption'], true, $nsc);
|
||||||
|
$render = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
unset($tmp);
|
unset($tmp);
|
||||||
}
|
}
|
||||||
|
|
||||||
ob_start();
|
|
||||||
$this->ix->render_newsitem($news, 'extend', '', $template, $param);
|
|
||||||
$cache_data = ob_get_contents();
|
$cache_data = $this->ix->render_newsitem($news, 'extend', '', $template, $param);
|
||||||
ob_end_clean();
|
|
||||||
|
|
||||||
$this->setNewsCache($this->cacheString, $cache_data, $news);
|
$this->setNewsCache($this->cacheString, $cache_data, $news);
|
||||||
|
|
||||||
$text = $cache_data;
|
if($render === true)
|
||||||
|
{
|
||||||
|
$unique = $this->getRenderId();
|
||||||
|
|
||||||
|
$ns = e107::getRender();
|
||||||
|
$ns->setUniqueId($unique);
|
||||||
|
$ns->setContent('title', e107::getParser()->toText($news['news_title']));
|
||||||
|
$ns->setContent('text', e107::getParser()->toText($news['news_summary']));
|
||||||
|
|
||||||
|
// TODO add 'image' and 'icon'?
|
||||||
|
$text = $ns->tablerender($caption, $cache_data, 'news', true);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$text = $cache_data;
|
||||||
|
}
|
||||||
|
|
||||||
$text .= $this->renderComments($news);
|
$text .= $this->renderComments($news);
|
||||||
|
|
||||||
return $text;
|
return $text;
|
||||||
|
Reference in New Issue
Block a user