diff --git a/class2.php b/class2.php
index bff09997c..f67dd274e 100755
--- a/class2.php
+++ b/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
* @param string $style
@@ -1121,11 +1152,11 @@ if (!class_exists('e107table', false))
$options['menuCount'] = $this->eMenuCount;
$options['menuTotal'] = varset($this->eMenuTotal[$this->eMenuArea]);
$options['setStyle'] = $this->eSetStyle;
- $options['caption'] = $caption;
+ $options['caption'] = strip_tags($caption);
$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)))
{
diff --git a/e107_core/shortcodes/single/menu.php b/e107_core/shortcodes/single/menu.php
index 948e5f186..0b1cff2ce 100644
--- a/e107_core/shortcodes/single/menu.php
+++ b/e107_core/shortcodes/single/menu.php
@@ -43,4 +43,3 @@ function menu_shortcode($parm, $mode='')
}
-?>
diff --git a/e107_core/templates/footer_default.php b/e107_core/templates/footer_default.php
index cfcf9e276..8dfc3916e 100644
--- a/e107_core/templates/footer_default.php
+++ b/e107_core/templates/footer_default.php
@@ -18,6 +18,9 @@ if (!defined('e107_INIT'))
}
$In_e107_Footer = TRUE; // For registered shutdown function
+$magicSC = e107::getRender()->getMagicShortcodes(); // support for {---CAPTION1---} etc.
+
+
global $error_handler,$db_time,$FOOTER;
@@ -171,9 +174,15 @@ if (varset($e107_popup) != 1)
//
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("Magic Shortcodes Replace [ ] with { }
".print_a($tmp,true));
echo "\n\n
";
- $db_debug->Show_All();
+ e107::getDebug()->Show_All();
echo "
\n";
}
@@ -289,7 +298,7 @@ if (!empty($pref['e_footer_list']) && is_array($pref['e_footer_list']))
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();
//$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
$ehd = new e_http_header;
@@ -407,8 +417,6 @@ $ehd->send();
// $ehd->debug();
$page = $ehd->getOutput();
-//$ehd->setContent($page);
-//$ehd->send($length);
// real output
diff --git a/e107_handlers/news_class.php b/e107_handlers/news_class.php
index f7c140e61..38c84960c 100644
--- a/e107_handlers/news_class.php
+++ b/e107_handlers/news_class.php
@@ -406,7 +406,7 @@ class news {
$text = e107::getParser()->parseTemplate($NEWS_PARSE, true, $sc);
- if ($mode == 'return')
+ if ($mode == 'return' || !empty($param['return']))
{
return $text;
}
diff --git a/e107_plugins/news/news.php b/e107_plugins/news/news.php
index 37b192569..26ddb4fa9 100644
--- a/e107_plugins/news/news.php
+++ b/e107_plugins/news/news.php
@@ -1082,43 +1082,6 @@ class news_front
//More SEO
$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'].="";
- $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'].="";
- }
- $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'].="";
- }
- $news['news_extended'].="
";
- }*/
$currentNewsAction = $this->action;
@@ -1127,6 +1090,10 @@ class news_front
$param = array();
$param['current_action'] = $action;
$param['template_key'] = 'news/view';
+ $param['return'] = true;
+
+ $caption = null;
+ $render = false;
if(!empty($NEWSSTYLE))
{
@@ -1150,25 +1117,45 @@ class news_front
$template = $tmp['item'];
+
+
if(isset($tmp['caption']) && $tmp['caption'] !== null) // to initiate tablerender() usage.
{
$this->addDebug('Internal Route', $this->route);
$this->route = 'news/view'; // 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);
}
- ob_start();
- $this->ix->render_newsitem($news, 'extend', '', $template, $param);
- $cache_data = ob_get_contents();
- ob_end_clean();
+
+
+ $cache_data = $this->ix->render_newsitem($news, 'extend', '', $template, $param);
$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);
return $text;