/**
* The required files
*/
require_once(HTML_BASE_UTIL_PATH.'/Image.php');
if (defined('HTML_LOG_UTIL_PATH')) {
require_once(HTML_LOG_UTIL_PATH.'/Log.php');
}
/**
* Returns a complete Image as HTML
* The Src, Width, Height and Alt attributes are fetched from global storage, if defined
* @see $GLOBALS[IMAGE_NAME_ALT][IMAGE_PRINT] = LINK_TITLE_PRINT;
* <code>
* Usage:
* $name = IMAGE_PRINT;
* $images = new Images($name,$width,$height,$alt,$class,$border,$aux);
* print $images->getHtml();
* Or
* Images::display($name,$width,$height,$alt,$class,$border,$aux);
* </code>
* @package base
*/
class Images extends Image {
/**
* Constructor
* @param String $name The name of the image i.e. IMAGE_PRINT
* @param String $width The width
* @param String $height The height
* @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 Images($name='',$width='',$height='',$alt='',$class='',$border='',$aux='') {
$src = ''; // Assume default /images/*.gif
$theSrc = $this->getSrc($src,$name);
$theWidth = $this->getWidth($width,$name);
$theHeight = $this->getHeight($height,$name);
$theAlt = $this->getAlt($alt,$name);
$theClass = $this->getClass($class,$name);
$this->Image($theSrc,$theWidth,$theHeight,$theAlt,$theClass,$border,$aux);
}
/**
* Get the image attribute for the specified key or use the default value
* <code>
* Usage:
* $value = '';
* $text = $this->getImageName($value, IMAGE_PRINT, IMAGE_NAME_SRC);
* </code>
* @see $GLOBALS[IMAGE_NAME_ALT][IMAGE_PRINT] = LINK_TITLE_PRINT;
* @param String $value The value to use, if supplied
* @param String $name The name of the image to use
* @param String $key The key attribute for the image to use
* @return String The attribute of the image for the specified key
*/
function getImageName($value, $name, $key) {
$attribute = $value;
if ($value == '') {
$imagename = $GLOBALS[$key];
if (is_array($imagename)) {
if (array_key_exists($name,$imagename)) {
$attribute = $GLOBALS[$key][$name];
} else {
// TODO what
}
} else {
// TODO what
}
} else {
// TODO what
}
return $attribute;
}
/**
* Get the image attribute for the Src or use the name of the image
* @param String $src The Src to use, if supplied
* @param String $name The name of the image to use
* @return String The value of the image Src attribute
*/
function getSrc($src, $name) {
$value = $src;
switch ($name) {
case IMAGE_DENMARK:
case IMAGE_GERMANY:
case IMAGE_ENGLAND:
case IMAGE_FRANCE:
case IMAGE_ITALY:
case IMAGE_NORWAY:
case IMAGE_SWEDEN:
case IMAGE_USA:
$value .= IMAGE_FLAG_PATH;
break;
default:
break;
}
$value .= '/'.$name.'.gif';
return $this->getImageName($value,$name,IMAGE_NAME_SRC);
}
/**
* Get the image attribute for the Width or use the name of the image
* @param String $width The Width to use, if supplied
* @param String $name The name of the image to use
* @return String The value of the image Width attribute
*/
function getWidth($width, $name) {
return $this->getImageName($width,$name,IMAGE_NAME_WIDTH);
}
/**
* Get the image attribute for the Height or use the name of the image
* @param String $height The Height to use, if supplied
* @param String $name The name of the image to use
* @return String The value of the image Height attribute
*/
function getHeight($height, $name) {
return $this->getImageName($height,$name,IMAGE_NAME_HEIGHT);
}
/**
* Get the image attribute for the Alt or use the name of the image
* @param String $alt The Alt to use, if supplied
* @param String $name The name of the image to use
* @return String The value of the image Alt attribute
*/
function getAlt($alt, $name) {
return $this->getImageName($alt,$name,IMAGE_NAME_ALT);
}
/**
* Get the image attribute for the Class or use the name of the image
* @param String $class The Class to use, if supplied
* @param String $name The name of the image to use
* @return String The value of the image Alt attribute
*/
function getClass($class, $name) {
return $this->getImageName($class,$name,IMAGE_NAME_CLASS);
}
/**
* Get a new Images object from the specified Image name
* <code>
* Usage:
* $image = Images::newImage($name,$width,$height,$alt,$class,$border,$aux);
* </code>
* @static
* @param String $name The name of the image i.e. IMAGE_PRINT
* @param String $width The width
* @param String $height The height
* @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)
* @return Images Return a new instance of the Images object
*/
function newImage($name='',$width='',$height='',$alt='',$class='',$border='',$aux='') {
return new Images($name,$width,$height,$alt,$class,$border,$aux);
}
/**
* Display html
* <code>
* Usage:
* $name = IMAGE_PRINT;
* Images::display($name,$width,$height,$alt,$class,$border,$aux);
* </code>
* @static
* @param String $name The name of the image i.e. IMAGE_PRINT
* @param String $width The width
* @param String $height The height
* @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($name='',$width='',$height='',$alt='',$class='',$border='',$aux='') {
$html = new Images($name,$width,$height,$alt,$class,$border,$aux);
$html->addHtml();
}
}
?>