NAME

PHP Layout Class - A PHP3 class for writing complex web pages.


DESCRIPTION

This document contain some examples that show typical usage of the class.layout. You should consult the source code for individual functions for more detail.


COPYRIGHT

Copyright 1999 ValueHunt Inc. All rights reserved. Permission is granted to anyone to use this software for any purpose on any computer system, and to alter it and redistribute it, subject to the following restrictions:

1. ValueHunt Inc. is not responsible for the consequences of use of this software, no matter how awful, even if they arise from flaws in it.

2. The origin of this software must not be misrepresented, either by explicit claim or by omission. Since few users ever read sources, credits must appear in the documentation. and also the URL http://www.vhconsultants.com

3. Altered versions must be plainly marked as such, and must not be misrepresented as being the original software. Since few users ever read sources, credits must appear in the documentation.

4. This notice may not be removed or altered.


USAGE

You must include the class in your script to use the layout functions.

    include("/path/to/the/class/class.layout");

Or, if you may configure a PHP3 module in Apache's httpd.conf

    php3_include_path /path/to/the/class
    php3_auto_prepend_file class.layout
    php3_magic_quotes_gpc on
    php3_track_vars on

A simple example

   <?php

    setdefault("window",array("bgcolor"=>"white"));
    setdefault("table",array("cellpadding"=>"0"));
    setdefault("text",array("size"=>"2"));
    newhtml(&$w);

    insert($w, wheader("A Test Page"))
    insert($w,$t = table(array("cols"=>"2","width"=>"650")));
    insert($t,$c = cell(array("colspan"=>"2")));
    insert($c,text("TEST ONLY"));

    printhtml($w); 

   ?>


Functions


setdefault($o,$a) Set default values for objects.

    setdefault("window",array("bgcolor"=>"white"));
    setdefault("table",array("cellpadding"=>"0"));


newhtml(&$w) Start the web page. This function is required.

    newhtml(&$w);


insert($p,$c) Insert a child object into a parent container. $p is the parent. $c is the child. You insert a cell into a table or a text line into a cell.

    insert($w, $t = table(array("width"=>"400","cols"=>"2")));
    insert($t, $c = cell(array("colspan"=>"2","bgcolor"=>"white")));
    insert($c, text("A TEXT CELL",array("color"=>"blue")));


printhtml($w) Print out the web page. This function is required.

    printhtml($w); 


table($a)

A table object. $a is an array of attributes for the table and will overwrite any default value declared in

    setdefault("table",array("cellpadding"=>"0"));

This function returns the reference to the object. Table can be nested in any legal containers like cell etc.

    insert($c, $t2 = table(array("width"=>"100%")));


cell($a)

A cell object. $a is an array of attributes. This function returns the reference to the cell object.

    insert($t, $c = cell(array("colspan"=>"2","bgcolor"=>"white")));


image($s,$a)

An image object. $s is the source (location) of the image file. $a is an array of attributes.

    insert($c, image("/title.gif",array("width"=>"10")));


anchor($h,$s,$a = "")

An anchor object. $h is the href, $s is the text or image object. $a is the optional array of attributes.

    insert($c,anchor("http://some.com";,"Click Here"));
    insert($c,anchor("http://some.com";,image("/some.gif",
                        array("width"=>"10"))));


text($t,$a = "")

The text object takes $t as the text and an optional array of attributes.

    insert($c,text("TEST",array("color"=>"red")));


generic($t,$a = "")

This function is for constructing generic html tags if it is not available in this class.layout. $t is the tag name, $a is an optional array of attributes.

to insert a horizontal ruler.

    insert($c, $g = generic("hr",array("noshade"=>"undef","size"=>"1")));

insert a break

    insert($c, $b = generic("br"));


container($t,$a = "")

This function is for generating a generic html container if it is not available in this class. $t is the tag name, $a is an optional array of attributes.

    insert($w, $con = container("div",array("align"=>"center")));


List of all the functions

        function insert($p,$c)
        function defsetting($a)
        function newhtml(&$w,$a = "")
        function printhtml($w)
        function table($a = "")
        function cell($a = "")
        function image($s,$a,$ni = "")
        function anchor($h,$s,$a = "")
        function block($t,$ni = "")
        function text($t,$a = "")
        function form($a = "")
        function alist($t,$c,$a = "")
        function comment($m)
        function generic($t,$a = "")
        function container($t,$a = "")
        function script($c,$a = "")
        function wheader($t)
        function heading($l,$c,$a = "" )
        function button($a)
        function checkbox($a,$t,$c = "")
        function inputfile($a)
        function hidden($a)
        function imagebutton($s,$a)
        function password($a)
        function radio($a,$t,$c = "")
        function freset($a)
        function submit($a)
        function input_text($a)
        function select($o,$a,$s = "")
        function textarea($a,$m = "")
        function imagemap($a)
        function area($a)
        function layer($a)
        function nolayer($m)
        function frameset($a)
        function frame($a)
        function noframe($m)
        function style($m,$a)
        function insert($c)