/**
* The required files
*/
require_once(HTML_BASE_COMMON_PATH.'/Html.php');
/**
* Generates a <div class="$class" align="$align" id="$id">$text</div>
* <code>
* Usage:
* $html = new Div($text, $class, $align, $id);
* print $html->getHtml();
* Or
* Div::display($text ,$class, $align, $id);
* Or
* Div::start($text, $class, $align, $id);
* Link::display();
* Div::end();
* </code>
* @package base
*/
class Div extends Html {
/**
* @var String $text The Text or an object
*/
var $text = '';
/**
* @var String $class The CSS class name for an object
*/
var $class = '';
/**
* @var String $align The align attribute
*/
var $align = '';
/**
* @var String $id The ID attribute
*/
var $id = '';
/**
* Constructor
* @param String $text The text for the Div tag or an object
* @param String $class The css class name
* @param String $align The align attribute
* @param String $id The ID attribute
*/
function Div($text='',$class='',$align='', $id='') {
$this->Html();
$this->text = $text;
$this->class = $class;
$this->align = $align;
$this->id = $id;
}
/**
* Returns the start for the div html element
* @return String the complete html
*/
function getStart() {
$html = '';
$html .= '<div';
$html .= $this->getAttribute('id');
$html .= $this->getAttribute('class');
$html .= $this->getAttribute('align');
$html .= '>';
if (is_object($this->text)) {
$html .= $this->text->getHtml();
} else {
$html .= $this->text;
}
$html .= $this->getElements();
return $html;
}
/**
* Returns the end for the div html element
* @return String the complete html
*/
function getEnd() {
return "</div>\r\n";
}
/**
* Returns the html for the div html element
* @return String the complete html
*/
function getHtml() {
$html = '';
$html .= $this->getStart();
$html .= $this->getEnd();
return $html;
}
/**
* Display start
* <code>
* Usage:
* Div::start($text, $class, $align, $id);
* </code>
* @static
* @param String $text The text for the div or an object
* @param String $class The css class of the div
* @param String $align The align attribute
* @param String $id The ID attribute
*/
function start($text='',$class='', $align='', $id='') {
$html = new Div($text, $class, $align, $id);
$html->addHtml($html->getStart());
}
/**
* Display end
* <code>
* Usage:
* Div::end();
* </code>
* @static
*/
function end() {
$html = new Html();
$html->addHtml(Div::getEnd());
}
/**
* Display html
* <code>
* Usage:
* Div::display($text, $class, $align, $id);
* </code>
* @static
* @param String $text The text for the div or an object
* @param String $class The css class of the div
* @param String $align The align attribute
* @param String $id The ID attribute
*/
function display($text='',$class='',$align='', $id='') {
$html = new Div($text, $class, $align, $id);
$html->addHtml();
}
}
?>