* @access public
*/
class HTML_Image extends HTML_Common {
- /**
- * List of valid HTML attributes for an Image.
- *
- * @var array $validAttrs
- * @access protected
- */
- var $_validAttrs = array('src', 'alt', 'longdesc', 'width', 'height', 'usemap', 'ismap', 'align', 'border', 'hspace', 'vspace', 'id', 'class', 'style', 'title', 'lang', 'dir', 'onclick', 'ondblclick', 'onmousedown', 'onmouseup', 'onmouseover', 'onmousemove', 'onmouseout', 'onkeypress', 'onkeydown', 'onkeyup');
// ~X2C
*/
function HTML_Image($src = '', $alt = '', $attrs = array())// ~X2C
{
- $attrs['src'] = $src;
- $attrs['alt'] = $alt;
+ if (is_array($attrs)) {
+ $attrs['src'] = $src;
+ $attrs['alt'] = $alt;
+ } else {
+ $attrs .= " src=$src alt=$alt";
+ }
parent::HTML_Common($attrs);
}
// -X2C
function toHtml()// ~X2C
{
$attrs = '';
- foreach ($this->getAttributes() as $key => $val) {
+ $attributes = $this->getAttributes() + array('border' => 0, 'align' => 'middle');
+ foreach ($attributes as $key => $val) {
$attrs .= ' ' . $key . '="' . htmlentities($val) . '"';
}
return "<IMG$attrs/>";
*/
function setSrc($src)// ~X2C
{
- $this->updateAttributes('src' => $src);
+ $this->updateAttributes(array('src' => $src));
}
// -X2C
*/
function setAlt($alt)// ~X2C
{
- $this->updateAttributes('alt' => $alt);
+ $this->updateAttributes(array('alt' => $alt));
}
// -X2C