1
0
mirror of https://github.com/e107inc/e107.git synced 2025-07-30 19:30:25 +02:00

Tablerender: Use uniqueIds to keep setContent() values intact.

This commit is contained in:
Cameron
2019-06-16 12:32:55 -07:00
parent 1cca064f0f
commit 1c7bc92a65
2 changed files with 31 additions and 10 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');
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();
}

View File

@@ -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);
// =========================================================================
?>
?>