/**
* The required files
*/
require_once(HTML_BASE_COMMON_PATH.'/Html.php');
require_once(HTML_BASIC_UTIL_PATH.'/Message.php');
require_once(HTML_BASE_UTIL_PATH.'/Image.php');
require_once(HTML_BASE_UTIL_PATH.'/Link.php');
if (defined('HTML_LOG_UTIL_PATH')) {
require_once(HTML_LOG_UTIL_PATH.'/Log.php');
}
/**
* Returns a complete Image surronded by a link as HTML
* <code>
* <a class="$class" href="$href" title="$title">
* <img class="$class" src="$src" width="$width" height="$height" border="$border" alt="$alt" />
* linkText
* </a>
*
* Usage:
* $imagelink = new Imagelink($image,$link); // Objects
* print $imagelink->getHtml();
* Or
* ImageLink::display($image,$link);
* </code>
* @package base
*/
class ImageLink extends Html {
var $image = NULL; // The image object
var $link = NULL; // The link object
/**
* Constructor
* @param Object $image The image object to show
* @param Object $link The link object to go to
*/
function ImageLink($image='', $link='') {
$this->Html();
if (!is_object($link)) {
$msg = $this->getClassName().'(), $link must be a Link object, found='.$link;
if (defined('HTML_LOG_UTIL_PATH')) {
Log::error(__FILE__,__LINE__,$msg);
} else {
Message::add($msg,__FILE__,__LINE__);
}
$link = new Link('',LINK_HREF_HOME,CSS_LINK_COLOR,$msg);
}
if (!is_object($image)) {
$msg = $this->getClassName().'(), $image must be an Image object, found='.$image;
if (defined('HTML_LOG_UTIL_PATH')) {
Log::error(__FILE__,__LINE__,$msg);
} else {
Message::add($msg,__FILE__,__LINE__);
}
$image = new Image('/aniBee.gif','15','15',$msg,CSS_LINK_COLOR);
}
$this->setObject('image',$image);
$this->setObject('link', $link);
$this->link->add($this->image); // <a href="" ...><img ... />text</a>
}
/**
* Get the complete html for an image-link pair
* @return String the html
*/
function getHtml() {
$html = $this->html;
if ($this->link!=NULL && $this->image!=NULL) {
$html .= $this->link->getHtml();
} else {
$html .= '<!-- '.$this->getClassName()."->getHtml() link==NULL && image==NULL -->\r\n";
}
return $html;
}
/**
* Display html
* <code>
* Usage:
* ImageLink::display($image, $link);
* </code>
* @static
* @param Object $image The image object to show
* @param Object $link The link object to go to
*/
function display($image='', $link='') {
$html = new ImageLink($image, $link);
$html->addHtml();
}
}
?>