1
0
mirror of https://github.com/e107inc/e107.git synced 2025-07-31 03:40:37 +02:00

BC Fallback for breadcrumb() generator. Magix shortcode fix for news-view. Magic shortcodes are defined by the first render with {SETSTYLE=default} or {SETSTYLE=main} encountered in the template.

This commit is contained in:
Cameron
2019-06-15 16:45:03 -07:00
parent 3ccc01fae3
commit 346d42bdfb
4 changed files with 94 additions and 27 deletions

View File

@@ -947,7 +947,7 @@ if (!class_exists('e107table', false))
private $uniqueId = null;
private $content = array();
private $contentTypes = array('header','footer','text','title','image', 'list');
public $renders = array(); // all render vars.
private $mainRenders = array(); // all renderered with style = 'default' or 'main'.
function __construct()
@@ -957,30 +957,39 @@ if (!class_exists('e107table', false))
}
/**
* Return content options for the main render that uses {SETSTYLE=default} or {SETSTYLE=main}
* @return array
*/
private function getMainRender()
{
if(isset($this->mainRenders[0]))
{
return $this->mainRenders[0];
}
return array();
}
function getMagicShortcodes()
{
$ret = array();
$val = $this->getMainRender();
$types = array('caption') + $this->contentTypes;
$c = 1;
foreach($this->renders as $k => $val)
foreach($types as $var)
{
foreach($types as $var)
{
$sc = '{---'.strtoupper($var).$c.'---}';
$ret[$sc] = varset($val[$var]);
}
$c++;
$sc = '{---'.strtoupper($var).'---}';
$ret[$sc] = isset($val[$var]) ? (string) $val[$var] : null;
}
return $ret;
}
@@ -1010,12 +1019,21 @@ if (!class_exists('e107table', false))
/**
* Set Advanced Page/Menu content (beyond just $caption and $text)
*
* @param string $type header|footer|text|title|image|list
* @param string|array $type header|footer|text|title|image|list
* @param string $val
* @return bool|e107table
*/
public function setContent($type, $val)
{
if(is_array($type))
{
foreach($this->contentTypes as $t)
{
$this->content[$t] = (string) $type[$t];
}
}
if(!in_array($type,$this->contentTypes))
{
return false;
@@ -1149,9 +1167,13 @@ if (!class_exists('e107table', false))
$options['menuCount'] = $this->eMenuCount;
$options['menuTotal'] = varset($this->eMenuTotal[$this->eMenuArea]);
$options['setStyle'] = $this->eSetStyle;
$options['caption'] = strip_tags($caption);
$this->renders[] = $options;
$options['caption'] = $caption; // TODO FIXME strip HTML but retain text that may be inside tags.
if($this->eSetStyle === 'default' || $this->eSetStyle === 'main')
{
$this->mainRenders[] = $options;
}
//XXX Optional feature may be added if needed - define magic shortcodes inside $thm class. eg. function msc_custom();

View File

@@ -18,7 +18,7 @@ if (!defined('e107_INIT'))
}
$In_e107_Footer = TRUE; // For registered shutdown function
$magicSC = e107::getRender()->getMagicShortcodes(); // support for {---CAPTION1---} etc.
$magicSC = e107::getRender()->getMagicShortcodes(); // support for {---TITLE---} etc.
global $error_handler,$db_time,$FOOTER;

View File

@@ -3360,12 +3360,31 @@ class e107
*/
public static function breadcrumb($array = array())
{
if(empty($array))
if(empty($array)) // read
{
if(empty(self::$_breadcrumb)) //Guess what it should be..
{
if(defined('PAGE_NAME')) // BC search for "PAGE_NAME"
{
return array(0=> array('text'=>PAGE_NAME, 'url'=>null));
}
elseif($caption = e107::getRender()->getPrimaryCaption()) // BC search for primary render caption
{
return array(0=> array('text'=>$caption, 'url'=>null));
}
}
return self::$_breadcrumb;
}
self::$_breadcrumb = $array;
self::$_breadcrumb = $array; // write.
return null;
}

View File

@@ -42,6 +42,7 @@ class news_front
private $currentRow = array();
private $dayMonth = null;
private $tagAuthor = null;
private $comments = array();
// private $interval = 1;
function __construct()
@@ -217,6 +218,7 @@ class news_front
*/
public function render($return = false)
{
$unique = $this->getRenderId();
if($this->caption !== null)
@@ -225,13 +227,27 @@ class news_front
$this->addDebug("tablerender ID", $unique);
e107::getRender()->setUniqueId($unique)->tablerender($this->caption, $this->text, 'news');
if(!empty($this->comments))
{
echo $this->renderComments($this->comments);
}
return true;
}
$this->addDebug("tablerender ID (not used)", $unique);
echo $this->text;
if(!empty($this->comments))
{
echo $this->renderComments($this->comments);
}
}
private function setActions()
@@ -1074,6 +1090,7 @@ class news_front
{
global $NEWSSTYLE; // v1.x backward compatibility.
$this->addDebug("Method",'renderViewTemplate()');
if($newsCachedPage = $this->checkCache($this->cacheString))
@@ -1085,7 +1102,7 @@ class news_front
$this->addDebug("Event-triggered:user_news_item_viewed", $rows);
$this->setNewsFrontMeta($rows);
$text = $this->renderCache($caption, $newsCachedPage); // This exits if cache used
$text .= $this->renderComments($rows);
$this->comments = $rows;
return $text;
}
else
@@ -1194,6 +1211,7 @@ class news_front
$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;
}
@@ -1203,30 +1221,36 @@ class news_front
$this->currentRow = $news;
$cache_data = $this->ix->render_newsitem($news, 'extend', '', $template, $param);
$this->setNewsCache($this->cacheString, $cache_data, $news);
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']));
$ns->setContent('title', $news['news_title']);
$ns->setContent('text', $news['news_summary']);
// TODO add 'image' and 'icon'?
$text = $ns->tablerender($caption, $cache_data, 'news', true);
$this->caption = $caption;
$text = $cache_data;
$this->comments = $news;
//$text = $ns->tablerender($caption, $cache_data, 'news', true);
}
else
{
$text = $cache_data;
$text .= $news;
}
$text .= $this->renderComments($news);
return $text;
}
@@ -1827,7 +1851,9 @@ class news_front
}
$newsObj = new news_front;
$content = e107::getRender()->getContent(); // get tablerender content
require_once(HEADERF);
e107::getRender()->setContent($content,null); // reassign tablerender content if HEADERF uses render.
$newsObj->render();
if(E107_DBG_BASIC && ADMIN)
{