/**
* The required files
*/
require_once(HTML_BASE_UTIL_PATH.'/Img.php');
if (defined('HTML_UTIL_COMPONENT_PATH')) {
require_once(HTML_UTIL_COMPONENT_PATH.'/Url.php');
}
if (defined('HTML_LOG_UTIL_PATH')) {
require_once(HTML_LOG_UTIL_PATH.'/Log.php');
}
/**
* Returns a complete Image as HTML
* The images are expected to be located here: /images/*.gif
* Note: If you specify "\r\n" in the alt tag, then a break is automatically added
* <code>
* <img name="$name" src="$src" width="$width" height="$height"
* alt="$alt" class="$class" border="$border" />
* Usage:
* $image = new Image($src,$width,$height,$alt,$class,$border,$aux);
* print $image->getHtml();
* Or
* Image::display($src,$width,$height,$alt,$class,$border,$aux);
* </code>
* @package base
*/
class Image extends Img {
/**
* Constructor
* @param String $src The source path for the image i.e. /logo.gif
* @param String $width The width or null or ''
* @param String $height The height or null or ''
* @param String $alt The alt text
* @param String $class The css class for the image
* @param String $border The border of an image
* @param String $aux The new line indicator (nl)
*
* @global String IMAGE_SKIN_URL Defines the relative sub url from docroot
* @global String PROJECT_PATH Defines the full path on the disk to the Project docroot
*/
function Image($src='',$width='',$height='',$alt='',$class='',$border='',$aux='') {
$theSrc = $src;
$strHttp = 'http:/'.'/';
$strHttps = 'https:/'.'/';
if (strpos($src,$strHttp)!==false || strpos($src,$strHttps)!==false) {
// remote server
} else {
$domainname = '';
if (defined('HTML_UTIL_COMPONENT_PATH')) {
$domainname = Url::subdomain(DOMAIN_NAME); // Strip off subdomain names
}
$theSrc = $domainname.IMAGE_SKIN_URL.$src; // Local server
}
$this->Img($theSrc,$width,$height,$alt,$class,$border,$aux);
}
/**
* Get the name of the src file, where the IMAGE_SKIN_URL is stripped off
* Except if the domain name is part of the src
* @return String The name of the gif file
*/
function getSrcName() {
// $srcName = $this->get('src');
// if (strpos($srcName, DOMAIN_NAME) === false) {
$srcName = str_replace(IMAGE_SKIN_URL,'',$this->get('src'));
// }
return $srcName;
}
/**
* Display html
* <code>
* Usage:
* Image::display($src,$width,$height,$alt,$class,$border,$aux);
* </code>
* @static
* @param String $src The source path for the image
* @param String $width The width or null or ''
* @param String $height The height or null or ''
* @param String $alt The alt text
* @param String $class The css class for the image
* @param String $border The border of an image
* @param String $aux The new line indicator (nl)
*/
function display($src='',$width='',$height='',$alt='',$class='',$border='',$aux='') {
$html = new Image($src,$width,$height,$alt,$class,$border,$aux);
$html->addHtml();
}
}
?>