/[cvs]/nfo/php/libs/com.newsblob.phphtmllib/widgets/HTMLPageClass.inc
ViewVC logotype

Diff of /nfo/php/libs/com.newsblob.phphtmllib/widgets/HTMLPageClass.inc

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.1 by jonen, Thu Jan 30 03:29:44 2003 UTC revision 1.4 by jonen, Thu May 6 16:27:41 2004 UTC
# Line 85  class HTMLPageClass { Line 85  class HTMLPageClass {
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.
# Line 167  class HTMLPageClass { Line 174  class HTMLPageClass {
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      /**      /**
# Line 198  class HTMLPageClass { Line 221  class HTMLPageClass {
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") );
# Line 214  class HTMLPageClass { Line 238  class HTMLPageClass {
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") );
# Line 225  class HTMLPageClass { Line 249  class HTMLPageClass {
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    
# Line 343  class HTMLPageClass { Line 367  class HTMLPageClass {
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 {
# Line 358  class HTMLPageClass { Line 382  class HTMLPageClass {
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.
# Line 379  class HTMLPageClass { Line 412  class HTMLPageClass {
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
# Line 416  class HTMLPageClass { Line 470  class HTMLPageClass {
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      /**      /**
# Line 428  class HTMLPageClass { Line 482  class HTMLPageClass {
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      //**************************************************      //**************************************************
# Line 450  class HTMLPageClass { Line 531  class HTMLPageClass {
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                                  }                                  }
# Line 500  class HTMLPageClass { Line 581  class HTMLPageClass {
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    
# Line 554  class HTMLPageClass { Line 635  class HTMLPageClass {
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          }          }
# Line 597  class HTMLPageClass { Line 687  class HTMLPageClass {
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 );
# Line 622  class HTMLPageClass { Line 716  class HTMLPageClass {
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) );
# Line 639  class HTMLPageClass { Line 733  class HTMLPageClass {
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();                      

Legend:
Removed from v.1.1  
changed lines
  Added in v.1.4

MailToCvsAdmin">MailToCvsAdmin
ViewVC Help
Powered by ViewVC 1.1.26 RSS 2.0 feed