public function render(\Zend_View_Abstract $view) { // \MUtil_Echo::r(sprintf('Rendering snippet %s.', get_class($this))); // // TODO: Change snippet workings. // All forms are processed twice if hasHtmlOutput() is called here. This is // a problem when downloading files. // However: not being able to call hasHtmlOutput() twice is not part of the original plan // so I gotta rework the forms. :( // if (!$this->hasHtmlOutput() && $this->getRedirectRoute()) { $this->redirectRoute(); } else { $html = $this->getHtmlOutput($view); if ($html) { if ($html instanceof \MUtil_Html_HtmlInterface) { if ($html instanceof \MUtil_Html_HtmlElement) { $this->applyHtmlAttributes($html); } return $html->render($view); } else { return \MUtil_Html::renderAny($view, $html); } } } }
/** * Renders the element into a html string * * The $view is used to correctly encode and escape the output * * @param \Zend_View_Abstract $view * @return string Correctly encoded and escaped html output */ public function render(\Zend_View_Abstract $view) { $html = ''; $glue = $this->getGlue(); foreach ($this->getIterator() as $key => $item) { $html .= $glue; if ($item instanceof \Gems_Menu_SubMenuItem) { $item = $this->toActionLink($key); } $html .= \MUtil_Html::renderAny($view, $item); } return substr($html, strlen($glue)); }
/** * Function to allow overloading of tag rendering only * * Renders the element tag with it's content into a html string * * The $view is used to correctly encode and escape the output * * @param \Zend_View_Abstract $view * @return string Correctly encoded and escaped html output */ protected function renderElement(\Zend_View_Abstract $view) { $this->_currentContent = array(); // If the label was assigned an element lazy, // now is the time to get it's value. foreach ($this->_content as $key => $value) { if ($value instanceof \MUtil_Lazy_LazyInterface) { $value = \MUtil_Lazy::rise($value); } if ($value instanceof \Zend_Form_Element) { if ($value instanceof \Zend_Form_Element_Hidden) { return null; } // Only a label when a label decorator exists, but we do not use that decorator $decorator = $value->getDecorator('Label'); if ($decorator) { if (false === $decorator->getOption('escape')) { $label = \MUtil_Html::raw($value->getLabel()); } else { $label = $value->getLabel(); } $class = $this->class ? \MUtil_Html::renderAny($view, $this->class) . ' ' : ''; if ($value->isRequired()) { $class .= $this->getRequiredClass(); $this->_currentContent[$key] = array($this->getRequiredPrefix(), $label, $this->getRequiredPostfix()); } else { $class .= $this->getOptionalClass(); $this->_currentContent[$key] = array($this->getOptionalPrefix(), $label, $this->getOptionalPostfix()); } parent::__set('class', $class); // Bypass existing property for drawing if ($id = $value->getId()) { parent::__set('for', $id); // Always overrule } else { parent::__unset('for'); } } } elseif ($value instanceof \Zend_Form_DisplayGroup) { return null; } else { $this->_currentContent[$key] = $value; } } return parent::renderElement($view); }
/** * Generates a fake element that just displays the item with a hidden extra value field. * * @access public * * @param string|array $name If a string, the element name. If an * array, all other parameters are ignored, and the array elements * are extracted in place of added parameters. * * @param mixed $value The element value. * * @param array $attribs Attributes for the element tag. * * @return string The element XHTML. */ public function html($name, $value = null, $attribs = null) { return \MUtil_Html::renderAny($this->view, $value); }