Třída TImageButton je komponentou ke třídě TForm a je potomkem třídy TButton. TImageButton generuje HTML kód pro zobrazení obrázkového tlačítka ve formuláři.
<?php
class TImageButton extends TButton {
protected $imagefile;
public function __construct(){
$this->style = "TImageButton";
}
public function SetImageFile($filename){
if (!file_exists($filename)) throw new exception("File was not found.");
$this->imagefile = $filename;
}
public function Render(){
if ($this->name == "") throw new exception("Name is empty.");
if ($this->imagefile == "") throw new exception("Image file is not defined.");
if ($this->submit) $this->onclick = "submit();";
if ($this->reset) $this->onclick = "reset();";
$code = "<A name="$this->name" ";
if ($this->alttext !="") $code .= "title="$this->alttext" ";
if ($this->style !="") $code .= "class="$this->style" ";
if ($this->onclick !="") $code .= "onclick="$this->onclick" ";
if ($this->accesskey !="") $code .= "accesskey="$this->accesskey" ";
$code .= "><IMG src="$this->imagefile" align="middle" alt="$this->alttext"></A>";
return $code;
}
}
?>