--- nfo/php/libs/com.newsblob.phphtmllib/widgets/HTMLPageClass.inc 2003/01/30 03:29:44 1.1
+++ nfo/php/libs/com.newsblob.phphtmllib/widgets/HTMLPageClass.inc 2004/05/06 16:27:41 1.4
@@ -3,7 +3,7 @@
/**
* This contains the HTMLPageClass widget
*
- * $Id: HTMLPageClass.inc,v 1.1 2003/01/30 03:29:44 jonen Exp $
+ * $Id: HTMLPageClass.inc,v 1.4 2004/05/06 16:27:41 jonen Exp $
*
* @author Walter A. Boring IV
* @package phpHtmlLib
@@ -85,6 +85,13 @@
*/
var $_charset = "iso-8859-1";
+
+ /**
+ * The encoding of the XHTML
+ * XML tag
+ */
+ var $_xml_encoding = "UTF-8";
+
/**
* BODYtag object that holds all content
* for the body tag.
@@ -167,6 +174,22 @@
*/
var $_indent_style = 0;
+ /**
+ * keeps track of the html
+ * render type.
+ *
+ * @var string
+ */
+ var $_html_render_type = HTML;
+
+ /**
+ * The favicon params
+ * @var array
+ */
+ var $_favicon = array("href" => "/favicon.ico",
+ "type" => "images/x-ico",
+ "enabled" => FALSE);
+
/**
@@ -198,14 +221,15 @@
switch ($html_type) {
case HTML:
default:
- $this->build_doctype("-//W3C//DTD HTML 4.01 Transitional//EN");
- define("HTML_RENDER_TYPE", HTML);
+ $this->build_doctype("-//W3C//DTD HTML 4.01 Transitional//EN",
+ "http://www.w3.org/TR/html4/loose.dtd");
+ $this->_html_render_type = $GLOBALS["HTML_RENDER_TYPE"] = HTML;
break;
case XHTML_STRICT:
$this->build_doctype("-//W3C//DTD XHTML 1.0 Strict//EN",
- "DTD/xhtml1-strict.dtd");
- define("HTML_RENDER_TYPE", XHTML_STRICT);
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd");
+ $this->_html_render_type = $GLOBALS["HTML_RENDER_TYPE"] = XHTML_STRICT;
$this->set_html_attributes( array( "xmlns" => "http://www.w3.org/1999/xhtml",
"xml:lang" => "en",
"lang" => "en") );
@@ -214,8 +238,8 @@
case XHTML:
case XHTML_TRANSITIONAL:
$this->build_doctype("-//W3C//DTD XHTML 1.0 Transitional//EN",
- "DTD/xhtml1-transitional.dtd");
- define("HTML_RENDER_TYPE", XHTML);
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd");
+ $this->_html_render_type = $GLOBALS["HTML_RENDER_TYPE"] = XHTML;
$this->set_html_attributes( array( "xmlns" => "http://www.w3.org/1999/xhtml",
"xml:lang" => "en",
"lang" => "en") );
@@ -225,8 +249,8 @@
//XHTML frameset? TODO LIST for 1.1
case XHTML_FRAMESET:
$this->build_doctype("-//W3C//DTD XHTML 1.0 Frameset//EN",
- "DTD/xhtml1-frameset.dtd");
- define("HTML_RENDER_TYPE", XHTML_FRAMESET);
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd");
+ $this->_html_render_type = $GLOBALS["HTML_RENDER_TYPE"] = XHTML_FRAMESET;
break;
}
@@ -343,12 +367,12 @@
}
/**
- * pushes an link to an externally referenced javascript
- * file, which will get rendered in the head.
- * @param mixed $link - script tag object or $url of .js file.
+ * This adds a link to an external Javascript
+ * file, which will get rendered in the head.
*
+ * @param mixed $link - script tag object or $url of .js file.
*/
- function push_js_link( $link ) {
+ function add_js_link( $link ) {
if (is_object($link)) {
$js = $link;
} else {
@@ -358,6 +382,15 @@
}
/**
+ * same as add_js_link()
+ *
+ * @deprecated
+ */
+ function push_js_link( $link ) {
+ $this->add_js_link( $link );
+ }
+
+ /**
* Automatically set a page meta tag refresh
* @param int $time - time in seconds to refresh
* @param string $url - the url to go to.
@@ -379,6 +412,27 @@
}
/**
+ * This sets the encoding type for
+ * XHTML documents
+ *
+ * @param string - the encoding parameter
+ */
+ function set_encoding( $encoding ) {
+ $this->_xml_encoding = $encoding;
+ }
+
+ /**
+ * This method sets the lang, and xml:lang
+ * setting in the HTML tag.
+ *
+ * @param string - the language
+ */
+ function set_language( $language ) {
+ $this->_html_attributes["xml:lang"] = $language;
+ $this->_html_attributes["lang"] = $language;
+ }
+
+ /**
* This function is used to set the FRAMSETtag
* object for this page. This automatically
* sets the output for this page object to
@@ -416,7 +470,7 @@
*/
function set_html_attributes( $attributes ) {
$this->_html_attributes = $attributes;
- }
+ }
/**
@@ -428,6 +482,33 @@
return html_meta($content_type, "Content-Type");
}
+ /**
+ * This is used to enable the ability to add the
+ * favicon link in the head of the document.
+ * By default it is off.
+ *
+ * @param boolean TRUE = enable
+ */
+ function set_favicon_flag($flag=TRUE) {
+ $this->_favicon["enabled"] = $flag;
+ }
+
+ /**
+ * This allows you to change the default url/path
+ * for where the favicon.ico lives.
+ * NOTE: calling this method automatically enables the
+ * link in the head to be created.
+ *
+ * @param string the url to the favicon.ico file
+ * @param string the type of the image.
+ * NOTE: Default is image/x-ico
+ */
+ function set_favicon($path, $type="image/x-ico") {
+ $this->_favicon["href"] = $path;
+ $this->_favicon["type"] = $type;
+ $this->set_favicon_flag( TRUE );
+ }
+
//**************************************************
//* BODY tag related functions
//**************************************************
@@ -450,7 +531,7 @@
$js = "";
$js = $arg->get_javascript();
$class_name = get_class($arg);
- if ($js != "" && !$this->_widget_js_auto[$class_name]) {
+ if ($js != "" && !isset($this->_widget_js_auto[$class_name])) {
$this->add_head_js( str_replace(chr(9),'', $js) );
$this->_widget_js_auto[$class_name] = TRUE;
}
@@ -500,7 +581,7 @@
function _create_body() {
if ($this->_body == NULL) {
$this->_body = new BODYtag;
- $this->_body->add( "\n" );
+ //$this->_body->add( " " );
}
}
@@ -554,7 +635,16 @@
$this->_head->add( $this->_build_content_type_tag() );
- $this->_head->add( $this->_title );
+ if ($this->_title) {
+ $this->_head->add( $this->_title );
+ }
+
+ if ($this->_favicon["enabled"]) {
+ $this->_head->add( html_link($this->_favicon["href"],
+ "shortcut icon",
+ $this->_favicon["type"]));
+ }
+
if ( $this->_head_style->count_content() ) {
$this->_head->add( $this->_head_style );
}
@@ -597,13 +687,17 @@
*/
function render() {
+ //make sure the render type is correctly
+ //set
+ $GLOBALS["HTML_RENDER_TYPE"] = $this->_html_render_type;
+
//lets use ourself to render the debug page!
if ($this->_text_debug) {
$page = new HTMLPageClass;
$page->add_css_link("/phphtmllib/css/HTMLPageClass.css");
}
- $newline = "\n";
+ $newline = " ";
$attributes = $this->get_html_attributes();
$html = new HTMLtag( $attributes );
$html->add( $newline );
@@ -622,16 +716,16 @@
$html->add( $this->_frameset_wrap_body() );
} else {
$html->add( $newline );
- $this->_body->add( $newline );
+ //$this->_body->add( $newline );
$html->add( $this->_body );
}
$html-> add( $newline );
if ($this->_text_debug) {
- if (HTML_RENDER_TYPE == XHTML_STRICT) {
+ if ($GLOBALS["HTML_RENDER_TYPE"] == XHTML_STRICT) {
$xml = new XMLtag(array("version" => "1.0",
- "encoding"=>"UTF-8"));
+ "encoding"=>$this->_xml_encoding));
$page->add( $xml->render(0,1) );
}
$page->add( $this->_doctype->render(0,1) );
@@ -639,9 +733,9 @@
return $page->render();
} else {
$output = '';
- if (HTML_RENDER_TYPE == XHTML_STRICT) {
+ if ($GLOBALS["HTML_RENDER_TYPE"] == XHTML_STRICT) {
$xml = new XMLtag(array("version" => "1.0",
- "encoding"=>"UTF-8"));
+ "encoding"=>$this->_xml_encoding));
$output = $xml->render(0);
}
$output .= $this->_doctype->render();