HTML
|
|
|
|
<?php class HTML_code {
// background image
var $bgimage = "";
// background color
var $bgcolor = "";
// text color
var $text = "";
// link color
var $link = "";
// unvisited link color
var $alink = "";
// visited link color
var $vlink = "";
// cascading style sheet file name
var $stylesheet = "";
// CSS class on body tag
var $bodyclass = "";
// script
var $script = "";
// onLoad javascript function
var $onload = "";
// title
var $title = "";
// content of the head tag
var $head = "";
// content of the body
var $body="";
// style in the body tag
var $body_style = "";
// constructor
function HTML_code() {
}
// sets the background image in the body tag
function setBackgroundImage($image) {
$this->bgimage = $image;
}
// sets the background color in the body tag
function setBackgroundColor($color) {
$this->bgcolor = $color;
}
// set the text color
function setTextColor($color) {
$this->text = $color;
}
// sets the link color
function setLink($link) {
$this->link = $link;
}
// sets the link color
function setAlink($link) {
$this->alink = $link;
}
// sets the visited link color
function setVlink($link) {
$this->vlink = $link;
}
// sets the stylesheet filename
function setStyleSheet($sheet) {
$this->stylesheet = $sheet;
}
// set the CSS class for the body tag
function setBodyClass($class) {
$this->bodyclass = $class;
}
// set the CSS style for the body tag
function setBodyStyle($style) {
$this->body_style = $style;
}
// set the onLoad Javascript functions
function setOnLoad($function) {
$this->onload = $function;
}
// set title
function setTitle($title) {
$this->title = $title;
}
// adds content to the body tag
function addToBody($string) {
$this->body .= $string;
}
// adds an image tag to the body
function addImageToBody($image) {
$this->body .= "<img src="".$image."" width="100%"></img>";
}
// adds content to the head tag
function addToHead($string) {
$this->head .= $string;
}
function addScriptToHead($string) {
$this->script .= $string;
}
// generates a string with the HTML code for the HEAD tag
function returnHead() {
$output = "";
$output .= "<HEAD>n";
$output .= '<meta http-equiv="Content-Type" content="text/html; charset=utf-8">'."n";
if ($this->stylesheet <> "") {
$output .= $this->returnCSS();
}
if ($this->script <> "") {
$output .= $this->returnScript();
}
$output .="<TITLE></TITLE>";
$output .="</HEAD>n";
return $output;
}
// generates a string with the <LINK> tag
function returnCSS() {
$output = "";
$output .= '<LINK rel="stylesheet" type="text/css" href="'.$this->stylesheet."">n";
// $output .= "</LINK>n";
return $output;
}
// generates a string with the <SCRIPT> tag
function returnScript() {
$output = "";
$output .= "<SCRIPT TYPE="text/javascript">n";
$output .= $this->script;
$output .= "</SCRIPT>n";
return $output;
}
// generates a string with the opening <BODY> tag
function returnBodyOpenTag() {
$output = "";
$output .= "<BODY";
if ($this->bgimage <> "") {
$output .= " background="".$this->bgimage."" ";
}
if ($this->bgcolor <> "") {
$output .= " bgcolor="".$this->bgcolor."" ";
}
if ($this->link <> "") {
$output .= " LINK="".$this->link."" ";
}
if ($this->alink <> "") {
$output .= " ALINK="".$this->alink."" ";
}
if ($this->vlink <> "") {
$output .= " VLINK="".$this->vlink.""";
}
if ($this->text <> "") {
$output .= " TEXT="".$this->vlink.""";
}
if ($this->bodyclass <> "") {
$output .= " class="".$this->bodyclass.""";
}
if ($this->onload <> "") {
$output .= " onLoad="".$this->onload."" ";
}
if ($this->body_style <> "") {
$output .= " style="".$this->body_style."" ";
}
$output .= ">n";
return $output;
}
// generates a string with the HTML code for the BODY
function returnBody() {
$output = "";
$output .= $this->returnBodyOpenTag();
$output .= $this->body;
$output .= "</BODY>n";
return $output;
}
// generates a string with the HTML code for the whole page
function returnHTML() {
$output = "";
$output .= '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">'."n";
$output .= "<HTML>n";
$output .= $this->returnHead();
$output .= $this->returnBody();
$output .= "</HTML>n";
return $output;
}
} // end of the HTML_code class
/* $Fields contains the names of the header of the table,
$Width the values of the width of the columns
$Data is bidimensional array that contains tha data
the function will return a string $t that contain the
HTML code to display the resulting table
string drawTable(array Field[], array Width[], array Data[][])
*/
?>
|
|
|
Usage Example
|
|
|
Rate This Script
|
|
|
|