_helper) { #require_once 'Zend/Form/Decorator/Exception.php'; throw new Zend_Form_Decorator_Exception('No view helper specified fo DijitContainer decorator'); } return $this->_helper; } /** * Get element attributes * * @return array */ public function getAttribs() { if (null === $this->_attribs) { $attribs = $this->getElement()->getAttribs(); if (array_key_exists('dijitParams', $attribs)) { unset($attribs['dijitParams']); } $this->_attribs = $attribs; } return $this->_attribs; } /** * Get dijit option parameters * * @return array */ public function getDijitParams() { if (null === $this->_dijitParams) { $attribs = $this->getElement()->getAttribs(); if (array_key_exists('dijitParams', $attribs)) { $this->_dijitParams = $attribs['dijitParams']; } else { $this->_dijitParams = array(); } $options = $this->getOptions(); if (array_key_exists('dijitParams', $options)) { $this->_dijitParams = array_merge($this->_dijitParams, $options['dijitParams']); $this->removeOption('dijitParams'); } } // Ensure we have a title param if (!array_key_exists('title', $this->_dijitParams)) { $this->_dijitParams['title'] = $this->getTitle(); } return $this->_dijitParams; } /** * Get title * * @return string */ public function getTitle() { if (null === $this->_title) { $title = null; if (null !== ($element = $this->getElement())) { if (method_exists($element, 'getLegend')) { $title = $element->getLegend(); } } if (empty($title) && (null !== ($title = $this->getOption('legend')))) { $this->removeOption('legend'); } if (empty($title) && (null !== ($title = $this->getOption('title')))) { $this->removeOption('title'); } if (!empty($title)) { if (null !== ($translator = $element->getTranslator())) { $title = $translator->translate($title); } $this->_title = $title; } } return (empty($this->_title) ? '' : $this->_title); } /** * Render a dijit layout container * * Replaces $content entirely from currently set element. * * @param string $content * @return string */ public function render($content) { $element = $this->getElement(); $view = $element->getView(); if (null === $view) { return $content; } $dijitParams = $this->getDijitParams(); $attribs = array_merge($this->getAttribs(), $this->getOptions()); if (array_key_exists('legend', $attribs)) { if (!array_key_exists('title', $dijitParams) || empty($dijitParams['title'])) { $dijitParams['title'] = $attribs['legend']; } unset($attribs['legend']); } $helper = $this->getHelper(); $id = $element->getId() . '-' . $helper; if ($view->dojo()->hasDijit($id)) { trigger_error(sprintf('Duplicate dijit ID detected for id "%s; temporarily generating uniqid"', $id), E_USER_WARNING); $base = $id; do { $id = $base . '-' . uniqid(); } while ($view->dojo()->hasDijit($id)); } return $view->$helper($id, $content, $dijitParams, $attribs); } }