X-Git-Url: https://git.llucax.com/mecon/meconlib.git/blobdiff_plain/43bd40b6445e74534133d1080dd6ba2dcdab579a..4b08135a35b4ba9f3e87dfdb4cdc427800e359ac:/lib/MECON/HTML/Icon.php diff --git a/lib/MECON/HTML/Icon.php b/lib/MECON/HTML/Icon.php index 82b1764..2b5001d 100644 --- a/lib/MECON/HTML/Icon.php +++ b/lib/MECON/HTML/Icon.php @@ -60,6 +60,12 @@ class MECON_HTML_Icon extends MECON_HTML_Image { */ var $_link; + /** + * Alineacion de la imagen con respecto al texto. + * @private + */ + var $_align; + /** * Constructor. * @@ -68,18 +74,25 @@ class MECON_HTML_Icon extends MECON_HTML_Image { Puede ser un link o un MECON_HTML_Link. * @param $alt Texto alternativo para la imagen. * @param $attrs Atributos de la imágen. + * @param $align Alineación de la imagen con respecto al texto. */ - function MECON_HTML_Icon($nombre, $link = null, $alt = null, $attrs = array()) + function MECON_HTML_Icon($nombre, $link = null, $alt = null, $attrs = + array(), $align = 'right') { - switch ($nombre) { - default: - $src = "/MECON/images/general_$nombre"; + if (is_readable($nombre)) + { + $src = $nombre; + } + else + { + $src = "/MECON/images/general_$nombre"; } if (is_null($alt)) { $alt = '(' . strtoupper($nombre{0}) . ')'; } parent::MECON_HTML_Image($src, $alt, $attrs); $this->setLink($link); + $this->_align = $align; } /** @@ -148,8 +161,15 @@ class MECON_HTML_Icon extends MECON_HTML_Image { if (!$full or is_null($link)) { return $link; } - $link->addContents(new MECON_HTML_Image($this->getSrc(), - $this->getAlt(), $this->getAttributes())); + + if ($this->_align == 'left') { + $link->addContents(new MECON_HTML_Image($this->getSrc(), + $this->getAlt(), $this->getAttributes()), true); + } + elseif ($this->_align == 'right') { + $link->addContents(new MECON_HTML_Image($this->getSrc(), + $this->getAlt(), $this->getAttributes())); + } return $link; }