| 85 |
*/ |
*/ |
| 86 |
var $_charset = "iso-8859-1"; |
var $_charset = "iso-8859-1"; |
| 87 |
|
|
| 88 |
|
|
| 89 |
|
/** |
| 90 |
|
* The encoding of the XHTML |
| 91 |
|
* XML tag |
| 92 |
|
*/ |
| 93 |
|
var $_xml_encoding = "UTF-8"; |
| 94 |
|
|
| 95 |
/** |
/** |
| 96 |
* BODYtag object that holds all content |
* BODYtag object that holds all content |
| 97 |
* for the body tag. |
* for the body tag. |
| 174 |
*/ |
*/ |
| 175 |
var $_indent_style = 0; |
var $_indent_style = 0; |
| 176 |
|
|
| 177 |
|
/** |
| 178 |
|
* keeps track of the html |
| 179 |
|
* render type. |
| 180 |
|
* |
| 181 |
|
* @var string |
| 182 |
|
*/ |
| 183 |
|
var $_html_render_type = HTML; |
| 184 |
|
|
| 185 |
|
/** |
| 186 |
|
* The favicon params |
| 187 |
|
* @var array |
| 188 |
|
*/ |
| 189 |
|
var $_favicon = array("href" => "/favicon.ico", |
| 190 |
|
"type" => "images/x-ico", |
| 191 |
|
"enabled" => FALSE); |
| 192 |
|
|
| 193 |
|
|
| 194 |
|
|
| 195 |
/** |
/** |
| 221 |
switch ($html_type) { |
switch ($html_type) { |
| 222 |
case HTML: |
case HTML: |
| 223 |
default: |
default: |
| 224 |
$this->build_doctype("-//W3C//DTD HTML 4.01 Transitional//EN"); |
$this->build_doctype("-//W3C//DTD HTML 4.01 Transitional//EN", |
| 225 |
define("HTML_RENDER_TYPE", HTML); |
"http://www.w3.org/TR/html4/loose.dtd"); |
| 226 |
|
$this->_html_render_type = $GLOBALS["HTML_RENDER_TYPE"] = HTML; |
| 227 |
break; |
break; |
| 228 |
|
|
| 229 |
case XHTML_STRICT: |
case XHTML_STRICT: |
| 230 |
$this->build_doctype("-//W3C//DTD XHTML 1.0 Strict//EN", |
$this->build_doctype("-//W3C//DTD XHTML 1.0 Strict//EN", |
| 231 |
"DTD/xhtml1-strict.dtd"); |
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"); |
| 232 |
define("HTML_RENDER_TYPE", XHTML_STRICT); |
$this->_html_render_type = $GLOBALS["HTML_RENDER_TYPE"] = XHTML_STRICT; |
| 233 |
$this->set_html_attributes( array( "xmlns" => "http://www.w3.org/1999/xhtml", |
$this->set_html_attributes( array( "xmlns" => "http://www.w3.org/1999/xhtml", |
| 234 |
"xml:lang" => "en", |
"xml:lang" => "en", |
| 235 |
"lang" => "en") ); |
"lang" => "en") ); |
| 238 |
case XHTML: |
case XHTML: |
| 239 |
case XHTML_TRANSITIONAL: |
case XHTML_TRANSITIONAL: |
| 240 |
$this->build_doctype("-//W3C//DTD XHTML 1.0 Transitional//EN", |
$this->build_doctype("-//W3C//DTD XHTML 1.0 Transitional//EN", |
| 241 |
"DTD/xhtml1-transitional.dtd"); |
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"); |
| 242 |
define("HTML_RENDER_TYPE", XHTML); |
$this->_html_render_type = $GLOBALS["HTML_RENDER_TYPE"] = XHTML; |
| 243 |
$this->set_html_attributes( array( "xmlns" => "http://www.w3.org/1999/xhtml", |
$this->set_html_attributes( array( "xmlns" => "http://www.w3.org/1999/xhtml", |
| 244 |
"xml:lang" => "en", |
"xml:lang" => "en", |
| 245 |
"lang" => "en") ); |
"lang" => "en") ); |
| 249 |
//XHTML frameset? TODO LIST for 1.1 |
//XHTML frameset? TODO LIST for 1.1 |
| 250 |
case XHTML_FRAMESET: |
case XHTML_FRAMESET: |
| 251 |
$this->build_doctype("-//W3C//DTD XHTML 1.0 Frameset//EN", |
$this->build_doctype("-//W3C//DTD XHTML 1.0 Frameset//EN", |
| 252 |
"DTD/xhtml1-frameset.dtd"); |
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd"); |
| 253 |
define("HTML_RENDER_TYPE", XHTML_FRAMESET); |
$this->_html_render_type = $GLOBALS["HTML_RENDER_TYPE"] = XHTML_FRAMESET; |
| 254 |
break; |
break; |
| 255 |
} |
} |
| 256 |
|
|
| 367 |
} |
} |
| 368 |
|
|
| 369 |
/** |
/** |
| 370 |
* pushes an link to an externally referenced javascript |
* This adds a link to an external Javascript |
| 371 |
* file, which will get rendered in the head. |
* file, which will get rendered in the head. |
|
* @param mixed $link - script tag object or $url of .js file. |
|
| 372 |
* |
* |
| 373 |
|
* @param mixed $link - script tag object or $url of .js file. |
| 374 |
*/ |
*/ |
| 375 |
function push_js_link( $link ) { |
function add_js_link( $link ) { |
| 376 |
if (is_object($link)) { |
if (is_object($link)) { |
| 377 |
$js = $link; |
$js = $link; |
| 378 |
} else { |
} else { |
| 382 |
} |
} |
| 383 |
|
|
| 384 |
/** |
/** |
| 385 |
|
* same as add_js_link() |
| 386 |
|
* |
| 387 |
|
* @deprecated |
| 388 |
|
*/ |
| 389 |
|
function push_js_link( $link ) { |
| 390 |
|
$this->add_js_link( $link ); |
| 391 |
|
} |
| 392 |
|
|
| 393 |
|
/** |
| 394 |
* Automatically set a page meta tag refresh |
* Automatically set a page meta tag refresh |
| 395 |
* @param int $time - time in seconds to refresh |
* @param int $time - time in seconds to refresh |
| 396 |
* @param string $url - the url to go to. |
* @param string $url - the url to go to. |
| 412 |
} |
} |
| 413 |
|
|
| 414 |
/** |
/** |
| 415 |
|
* This sets the encoding type for |
| 416 |
|
* XHTML documents |
| 417 |
|
* |
| 418 |
|
* @param string - the encoding parameter |
| 419 |
|
*/ |
| 420 |
|
function set_encoding( $encoding ) { |
| 421 |
|
$this->_xml_encoding = $encoding; |
| 422 |
|
} |
| 423 |
|
|
| 424 |
|
/** |
| 425 |
|
* This method sets the lang, and xml:lang |
| 426 |
|
* setting in the HTML tag. |
| 427 |
|
* |
| 428 |
|
* @param string - the language |
| 429 |
|
*/ |
| 430 |
|
function set_language( $language ) { |
| 431 |
|
$this->_html_attributes["xml:lang"] = $language; |
| 432 |
|
$this->_html_attributes["lang"] = $language; |
| 433 |
|
} |
| 434 |
|
|
| 435 |
|
/** |
| 436 |
* This function is used to set the FRAMSETtag |
* This function is used to set the FRAMSETtag |
| 437 |
* object for this page. This automatically |
* object for this page. This automatically |
| 438 |
* sets the output for this page object to |
* sets the output for this page object to |
| 470 |
*/ |
*/ |
| 471 |
function set_html_attributes( $attributes ) { |
function set_html_attributes( $attributes ) { |
| 472 |
$this->_html_attributes = $attributes; |
$this->_html_attributes = $attributes; |
| 473 |
} |
} |
| 474 |
|
|
| 475 |
|
|
| 476 |
/** |
/** |
| 482 |
return html_meta($content_type, "Content-Type"); |
return html_meta($content_type, "Content-Type"); |
| 483 |
} |
} |
| 484 |
|
|
| 485 |
|
/** |
| 486 |
|
* This is used to enable the ability to add the |
| 487 |
|
* favicon link in the head of the document. |
| 488 |
|
* By default it is off. |
| 489 |
|
* |
| 490 |
|
* @param boolean TRUE = enable |
| 491 |
|
*/ |
| 492 |
|
function set_favicon_flag($flag=TRUE) { |
| 493 |
|
$this->_favicon["enabled"] = $flag; |
| 494 |
|
} |
| 495 |
|
|
| 496 |
|
/** |
| 497 |
|
* This allows you to change the default url/path |
| 498 |
|
* for where the favicon.ico lives. |
| 499 |
|
* NOTE: calling this method automatically enables the |
| 500 |
|
* link in the head to be created. |
| 501 |
|
* |
| 502 |
|
* @param string the url to the favicon.ico file |
| 503 |
|
* @param string the type of the image. |
| 504 |
|
* NOTE: Default is image/x-ico |
| 505 |
|
*/ |
| 506 |
|
function set_favicon($path, $type="image/x-ico") { |
| 507 |
|
$this->_favicon["href"] = $path; |
| 508 |
|
$this->_favicon["type"] = $type; |
| 509 |
|
$this->set_favicon_flag( TRUE ); |
| 510 |
|
} |
| 511 |
|
|
| 512 |
//************************************************** |
//************************************************** |
| 513 |
//* BODY tag related functions |
//* BODY tag related functions |
| 514 |
//************************************************** |
//************************************************** |
| 531 |
$js = ""; |
$js = ""; |
| 532 |
$js = $arg->get_javascript(); |
$js = $arg->get_javascript(); |
| 533 |
$class_name = get_class($arg); |
$class_name = get_class($arg); |
| 534 |
if ($js != "" && !$this->_widget_js_auto[$class_name]) { |
if ($js != "" && !isset($this->_widget_js_auto[$class_name])) { |
| 535 |
$this->add_head_js( str_replace(chr(9),'', $js) ); |
$this->add_head_js( str_replace(chr(9),'', $js) ); |
| 536 |
$this->_widget_js_auto[$class_name] = TRUE; |
$this->_widget_js_auto[$class_name] = TRUE; |
| 537 |
} |
} |
| 581 |
function _create_body() { |
function _create_body() { |
| 582 |
if ($this->_body == NULL) { |
if ($this->_body == NULL) { |
| 583 |
$this->_body = new BODYtag; |
$this->_body = new BODYtag; |
| 584 |
$this->_body->add( "\n" ); |
//$this->_body->add( " " ); |
| 585 |
} |
} |
| 586 |
} |
} |
| 587 |
|
|
| 635 |
|
|
| 636 |
$this->_head->add( $this->_build_content_type_tag() ); |
$this->_head->add( $this->_build_content_type_tag() ); |
| 637 |
|
|
| 638 |
$this->_head->add( $this->_title ); |
if ($this->_title) { |
| 639 |
|
$this->_head->add( $this->_title ); |
| 640 |
|
} |
| 641 |
|
|
| 642 |
|
if ($this->_favicon["enabled"]) { |
| 643 |
|
$this->_head->add( html_link($this->_favicon["href"], |
| 644 |
|
"shortcut icon", |
| 645 |
|
$this->_favicon["type"])); |
| 646 |
|
} |
| 647 |
|
|
| 648 |
if ( $this->_head_style->count_content() ) { |
if ( $this->_head_style->count_content() ) { |
| 649 |
$this->_head->add( $this->_head_style ); |
$this->_head->add( $this->_head_style ); |
| 650 |
} |
} |
| 687 |
*/ |
*/ |
| 688 |
function render() { |
function render() { |
| 689 |
|
|
| 690 |
|
//make sure the render type is correctly |
| 691 |
|
//set |
| 692 |
|
$GLOBALS["HTML_RENDER_TYPE"] = $this->_html_render_type; |
| 693 |
|
|
| 694 |
//lets use ourself to render the debug page! |
//lets use ourself to render the debug page! |
| 695 |
if ($this->_text_debug) { |
if ($this->_text_debug) { |
| 696 |
$page = new HTMLPageClass; |
$page = new HTMLPageClass; |
| 697 |
$page->add_css_link("/phphtmllib/css/HTMLPageClass.css"); |
$page->add_css_link("/phphtmllib/css/HTMLPageClass.css"); |
| 698 |
} |
} |
| 699 |
|
|
| 700 |
$newline = "\n"; |
$newline = " "; |
| 701 |
$attributes = $this->get_html_attributes(); |
$attributes = $this->get_html_attributes(); |
| 702 |
$html = new HTMLtag( $attributes ); |
$html = new HTMLtag( $attributes ); |
| 703 |
$html->add( $newline ); |
$html->add( $newline ); |
| 716 |
$html->add( $this->_frameset_wrap_body() ); |
$html->add( $this->_frameset_wrap_body() ); |
| 717 |
} else { |
} else { |
| 718 |
$html->add( $newline ); |
$html->add( $newline ); |
| 719 |
$this->_body->add( $newline ); |
//$this->_body->add( $newline ); |
| 720 |
$html->add( $this->_body ); |
$html->add( $this->_body ); |
| 721 |
} |
} |
| 722 |
|
|
| 723 |
$html-> add( $newline ); |
$html-> add( $newline ); |
| 724 |
|
|
| 725 |
if ($this->_text_debug) { |
if ($this->_text_debug) { |
| 726 |
if (HTML_RENDER_TYPE == XHTML_STRICT) { |
if ($GLOBALS["HTML_RENDER_TYPE"] == XHTML_STRICT) { |
| 727 |
$xml = new XMLtag(array("version" => "1.0", |
$xml = new XMLtag(array("version" => "1.0", |
| 728 |
"encoding"=>"UTF-8")); |
"encoding"=>$this->_xml_encoding)); |
| 729 |
$page->add( $xml->render(0,1) ); |
$page->add( $xml->render(0,1) ); |
| 730 |
} |
} |
| 731 |
$page->add( $this->_doctype->render(0,1) ); |
$page->add( $this->_doctype->render(0,1) ); |
| 733 |
return $page->render(); |
return $page->render(); |
| 734 |
} else { |
} else { |
| 735 |
$output = ''; |
$output = ''; |
| 736 |
if (HTML_RENDER_TYPE == XHTML_STRICT) { |
if ($GLOBALS["HTML_RENDER_TYPE"] == XHTML_STRICT) { |
| 737 |
$xml = new XMLtag(array("version" => "1.0", |
$xml = new XMLtag(array("version" => "1.0", |
| 738 |
"encoding"=>"UTF-8")); |
"encoding"=>$this->_xml_encoding)); |
| 739 |
$output = $xml->render(0); |
$output = $xml->render(0); |
| 740 |
} |
} |
| 741 |
$output .= $this->_doctype->render(); |
$output .= $this->_doctype->render(); |