From 8ef3981f6437f25e182d046527fb68cf8c21bbb4 Mon Sep 17 00:00:00 2001 From: diosmosis Date: Sat, 8 Feb 2014 12:17:31 +0000 Subject: Fix infinite recursion issue w/ {% render %}-ing UIControl instances, move dashboard settings HTML rendering to new UIControl object, and slight improvement to error message in screenshot capture script. --- core/View/UIControl.php | 60 ++++++++++++++++++++++++++++++++----------------- 1 file changed, 39 insertions(+), 21 deletions(-) (limited to 'core/View') diff --git a/core/View/UIControl.php b/core/View/UIControl.php index 39994aa828..0590fe2552 100644 --- a/core/View/UIControl.php +++ b/core/View/UIControl.php @@ -72,21 +72,41 @@ class UIControl extends \Piwik\View public $cssClass = ""; /** - * Whether we are currently rendering the containing div or not. + * The inner view that renders the actual control content. + * + * @var View */ - private $renderingContainer = false; + private $innerView = null; /** * Constructor. */ public function __construct() { - parent::__construct(static::TEMPLATE); + $this->innerView = new View(static::TEMPLATE); + + parent::__construct("@CoreHome\_uiControl"); $this->clientSideProperties = array(); $this->clientSideParameters = array(); } + /** + * Sets a variable. See {@link View::__set()}. + */ + public function __set($key, $val) + { + $this->innerView->__set($key, $val); + } + + /** + * Gets a view variable. See {@link View::__get()}. + */ + public function &__get($key) + { + return $this->innerView->__get($key); + } + /** * Renders the control view within a containing
that is used by the UIControl JavaScript * class. @@ -103,24 +123,22 @@ class UIControl extends \Piwik\View throw new Exception("All UIControls must set a jsClass property"); } - if ($this->renderingContainer) { - return parent::render(); - } else { - $this->renderingContainer = true; - - $surroundingDivView = new View("@CoreHome\_uiControl"); - $surroundingDivView->clientSideProperties = $this->clientSideProperties; - $surroundingDivView->clientSideParameters = $this->clientSideParameters; - $surroundingDivView->implView = $this; - $surroundingDivView->cssIdentifier = $this->cssIdentifier; - $surroundingDivView->cssClass = $this->cssClass; - $surroundingDivView->jsClass = $this->jsClass; - - $result = $surroundingDivView->render(); - - $this->renderingContainer = false; + $this->getTemplateVars(); + return parent::render(); + } - return $result; - } + /** + * See {@link View::getTemplateVars()}. + */ + public function getTemplateVars($override = array()) + { + $this->templateVars['implView'] = $this->innerView; + $this->templateVars['clientSideProperties'] = $this->clientSideProperties; + $this->templateVars['clientSideParameters'] = $this->clientSideParameters; + $this->templateVars['cssIdentifier'] = $this->cssIdentifier; + $this->templateVars['cssClass'] = $this->cssClass; + $this->templateVars['jsClass'] = $this->jsClass; + + return parent::getTemplateVars($override); } } \ No newline at end of file -- cgit v1.2.3