From: <gem...@li...> - 2012-02-16 11:00:45
|
Revision: 492 http://gemstracker.svn.sourceforge.net/gemstracker/?rev=492&view=rev Author: matijsdejong Date: 2012-02-16 11:00:36 +0000 (Thu, 16 Feb 2012) Log Message: ----------- Image tags are rendered only with a source. Added documentation Modified Paths: -------------- trunk/library/classes/MUtil/Html/HtmlElement.php trunk/library/classes/MUtil/Html/ImgElement.php Modified: trunk/library/classes/MUtil/Html/HtmlElement.php =================================================================== --- trunk/library/classes/MUtil/Html/HtmlElement.php 2012-02-16 10:52:09 UTC (rev 491) +++ trunk/library/classes/MUtil/Html/HtmlElement.php 2012-02-16 11:00:36 UTC (rev 492) @@ -553,6 +553,12 @@ return $elem; } + /** + * Make an element with the specified tag name. + * + * @param string $tagName + * @param mixed $arg_array MUtil_Ra::args arguments + */ public function __construct($tagName, $arg_array = null) { $args = MUtil_Ra::args(func_get_args(), 1); Modified: trunk/library/classes/MUtil/Html/ImgElement.php =================================================================== --- trunk/library/classes/MUtil/Html/ImgElement.php 2012-02-16 10:52:09 UTC (rev 491) +++ trunk/library/classes/MUtil/Html/ImgElement.php 2012-02-16 11:00:36 UTC (rev 492) @@ -1,6 +1,5 @@ <?php - /** * Copyright (c) 2011, Erasmus MC * All rights reserved. @@ -74,6 +73,13 @@ protected $_contentToTag = 'alt'; /** + * By default this element is not generated when the 'src' is empty. + * + * @var boolean The element is rendered even without content when true. + */ + public $renderWithoutSrc = false; + + /** * Converts an associative array to a string of tag attributes. * * @access public @@ -219,6 +225,29 @@ } /** + * 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) + { + if (isset($this->_attribs['src'])) { + $src = MUtil_Html::renderAny($view, $this->_attribs['src']); + } else { + $src = false; + } + + if ($src || $this->renderWithoutSrc) { + return parent::renderElement($view); + } + } + + /** * Sets the list of search directories. The last directory in the list is the first directory searched for the file. * * @param array $dirs Directory names. Slashes added when needed. This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |