--- nfo/php/libs/com.newsblob.phphtmllib/widgets/HTMLPageClass.inc 2003/11/14 21:31:40 1.3 +++ 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.3 2003/11/14 21:31:40 jonen Exp $ + * $Id: HTMLPageClass.inc,v 1.4 2004/05/06 16:27:41 jonen Exp $ * * @author Walter A. Boring IV * @package phpHtmlLib @@ -174,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); + /** @@ -205,14 +221,15 @@ switch ($html_type) { case HTML: default: - $this->build_doctype("-//W3C//DTD HTML 4.01 Transitional//EN"); - $GLOBALS["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", "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"); - $GLOBALS["HTML_RENDER_TYPE"] = XHTML_STRICT; + $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") ); @@ -222,7 +239,7 @@ case XHTML_TRANSITIONAL: $this->build_doctype("-//W3C//DTD XHTML 1.0 Transitional//EN", "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"); - $GLOBALS["HTML_RENDER_TYPE"] = XHTML; + $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") ); @@ -233,7 +250,7 @@ case XHTML_FRAMESET: $this->build_doctype("-//W3C//DTD XHTML 1.0 Frameset//EN", "http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd"); - $GLOBALS["HTML_RENDER_TYPE"] = XHTML_FRAMESET; + $this->_html_render_type = $GLOBALS["HTML_RENDER_TYPE"] = XHTML_FRAMESET; break; } @@ -465,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 //************************************************** @@ -487,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; } @@ -594,6 +638,12 @@ 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 ); @@ -637,6 +687,10 @@ */ 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;