- <?
- /**
- * @package page
- * @filesource
- * @see HTML_PAGE_UTIL_PATH.'/Div.php'
- * @copyright (c) http://Finn-Rasmussen.com
- * @license http://Finn-Rasmussen.com/license/ myPHP License conditions
- * @author http://Finn-Rasmussen.com
- * @version 1.9
- * @since 21-oct-2005
- */
-
- /**
- * The required files
- */
- require_once(HTML_PATH.'/Html.php');
-
- /**
- * Generates a <div class="$class" align="$align">$text</div>
- * <code>
- * Usage:
- * $html = new Div($text, $class,$align);
- * print $html->getHtml();
- * Or
- * Div::display($text,$class,$align);
- * Or
- * Div::start($class, $align);
- * Link::display();
- * Div::end();
- * </code>
- * @package page
- */
-
- 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 = '';
-
- /**
- * 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
- */
- function Div($text='',$class='',$align='') {
- $this->Html();
- $this->text = $text;
- $this->class = $class;
- $this->align = $align;
- }
-
- /**
- * Returns the start for the div html element
- * @return String the complete html
- */
- function getStart() {
- $html = '';
- $html .= '<div';
- $html .= $this->getAttribute('class');
- $html .= $this->getAttribute('align');
- $html .= '>';
- 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();
- if (is_object($this->text)) {
- $html .= $this->text->getHtml();
- } else {
- $html .= $this->text;
- }
- $html .= $this->getElements();
- $html .= $this->getEnd();
- return $html;
- }
-
- /**
- * Display start
- * <code>
- * Usage:
- * Div::start($class,$align);
- * </code>
- * @static
- * @param $class, The css class of the div
- * @param $align The align attribute
- */
- function start($class='',$align='') {
- $html = new Div('',$class,$align);
- $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);
- * </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
- */
- function display($text='',$class='',$align='') {
- $html = new Div($text,$class,$align);
- $html->addHtml();
- }
- }
- ?>