From 1c7bc92a650ad7500b5041eb8b03651f46a648b7 Mon Sep 17 00:00:00 2001 From: Cameron Date: Sun, 16 Jun 2019 12:32:55 -0700 Subject: [PATCH] Tablerender: Use uniqueIds to keep setContent() values intact. --- class2.php | 33 ++++++++++++++++++++++++++------- e107_plugins/news/news.php | 8 +++++--- 2 files changed, 31 insertions(+), 10 deletions(-) diff --git a/class2.php b/class2.php index b1cb27235..34037d0ee 100755 --- a/class2.php +++ b/class2.php @@ -947,7 +947,7 @@ if (!class_exists('e107table', false)) private $uniqueId = null; private $content = array(); private $contentTypes = array('header','footer','text','title','image', 'list'); - private $mainRenders = array(); // all renderered with style = 'default' or 'main'. + private $mainRenders = array(); // all renderered with style = 'default' or 'main'. function __construct() @@ -1026,10 +1026,14 @@ if (!class_exists('e107table', false)) */ public function setUniqueId($id) { - $this->uniqueId = $id; + $this->uniqueId = !empty($id) ? $id : null; return $this; } + public function debugContent() + { + return $this->content; + } /** * Set Advanced Page/Menu content (beyond just $caption and $text) @@ -1054,7 +1058,17 @@ if (!class_exists('e107table', false)) return false; } - $this->content[$type] = (string) $val; + if($this->uniqueId !== null) + { + $key = $this->uniqueId; + } + else + { + $key = '_generic_'; + e107::getMessage()->addDebug("Possible issue: Missing a Unique Tablerender ID. Use \$ns->setUniqueId() in the plugin script prior to setContent(). "); // debug only, no LAN. + } + + $this->content[$key][$type] = (string) $val; return $this; } @@ -1067,12 +1081,15 @@ if (!class_exists('e107table', false)) */ public function getContent($type='') { + $key = ($this->uniqueId !== null) ? $this->uniqueId : '_generic_'; + if(empty($type)) { - return $this->content; + return $this->content[$key]; } - return $this->content[$type]; + + return $this->content[$key][$type]; } @@ -1175,7 +1192,7 @@ if (!class_exists('e107table', false)) $thm = new $this->themeClass(); } - $options = $this->content; + $options = $this->getContent(); $options['uniqueId'] = $this->uniqueId; $options['menuArea'] = $this->eMenuArea; @@ -1201,8 +1218,10 @@ if (!class_exists('e107table', false)) tablestyle($caption, $text, $mode, $options); } + $key = ($this->uniqueId !== null) ? $this->uniqueId : '_generic_'; + $this->content[$key] = array(); $this->uniqueId = null; - $this->content = array(); + } diff --git a/e107_plugins/news/news.php b/e107_plugins/news/news.php index fe503199e..a409f3e04 100644 --- a/e107_plugins/news/news.php +++ b/e107_plugins/news/news.php @@ -1231,10 +1231,12 @@ class news_front $unique = $this->getRenderId(); + $ns = e107::getRender(); $ns->setUniqueId($unique); $ns->setContent('title', $news['news_title']); $ns->setContent('text', $news['news_summary']); + $ns->setUniqueId(null); // prevent other tablerenders from using this content. // TODO add 'image' and 'icon'? $this->caption = $caption; @@ -1851,9 +1853,9 @@ class news_front } $newsObj = new news_front; -$content = e107::getRender()->getContent(); // get tablerender content +//$content = e107::getRender()->getContent(); // get tablerender content require_once(HEADERF); -e107::getRender()->setContent($content,null); // reassign tablerender content if HEADERF uses render. +//e107::getRender()->setContent($content,null); // reassign tablerender content if HEADERF uses render. $newsObj->render(); if(E107_DBG_BASIC && ADMIN) { @@ -1935,4 +1937,4 @@ require_once(FOOTERF); // ========================================================================= -?> +?> \ No newline at end of file