PHP Classes
elePHPant
Icontem

File: Another_example

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of Niels Nielsen  >  HTMList  >  Another_example  >  Download  
File: Another_example
Role: Example script
Content type: text/plain
Description: Shows how a HTML class can be set up
Class: HTMList
Create and manipulate HTML output programaticallly
Author: By
Last change: Translated some Danish strings
Date: 5 years ago
Size: 2,480 bytes
 

Contents

Class file image Download
<?php
   
   
   
require_once("htmlist.php");
   
    class
HTML {
       
        private
$title, $description, $keywords, $author;
       
        function
__construct($params=array()) {
           
           
$this -> title = (isset($params["title"])) ? $params["title"] : "MYSITE -- My site description";
           
$this -> description = (isset($params["description"])) ? $params["description"] : "Full length description";
           
$this -> keywords = (isset($params["keywords"])) ? $params["keywords"] : "keywords, listed, by, commas";
           
           
$this -> author = "Me";
           
        }
       
        function
build_HTML() {
           
            global
$r00t;
           
           
$begin_html = array(
               
"doctype1" => "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML Basic 1.1//EN\"",
               
"doctype2" => "\"http://www.w3.org/TR/xhtml-basic/xhtml-basic11.dtd\">",
               
"html_in" => "<html xmlns=\"http://www.w3.org/1999/xhtml\">"
           
);
           
$begin_head = array(
               
"head_in" => "<head>",
               
"",
               
"meta_charset" => "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=iso-8859-1\">",
               
"meta_description" => "<meta name=\"description\" content=\"".$this -> description."\">",
               
"meta_keywords" => "<meta name=\"keywords\" content=\"".$this -> keywords."\">",
               
"",
               
"head_title" => "<title>".$this -> title."</title>",
               
"",
               
"meta_revisit" => "<meta name=\"Revisit-after\" content=\"20\">",
               
"meta_robots" => "<meta name=\"robots\" content=\"all\">",
               
"meta_author" => "<meta name=\"author\" content=\"".$this -> author."\">",
               
"",
               
"favicon" => "<link rel=\"shortcut icon\" href=\"_ico/icon.ico\">",
               
"css_main" => "<link rel=\"stylesheet\" type=\"text/css\" href=\"_css/main.css\">",
               
"stylesheet" => "",
               
"js_fun" => "<script type=\"text/javascript\" src=\"_js/functions.js\"></script>",
               
"javascript" => "",
               
""
           
);
           
$begin_body = array(
               
"head_out" => "</head>",
               
"body_in" => "<body>",
               
"",
               
"start_the_content" => ""
           
);
           
$end_of_file = array(
               
"",
               
"body_out" => "</body>",
               
"html_out" => "</html>"
           
);
           
           
$r00t -> add_before($begin_html, "r00t", "begin_html");
           
$r00t -> add_before($begin_head, "r00t", "begin_head");
           
$r00t -> add_before($begin_body, "r00t", "begin_body");
           
$r00t -> add_before($end_of_file, "r00t", "eof");
           
        }
       
    }
   
   
$r00t = new HTMList(array("r00t" => ""));
   
   
$o_html = new HTML(array("title"=>"MySite -- Smart description"));
   
$o_html -> build_HTML();
   
   
$r00t -> str(true);
   
   
?>