- NAME
- DESCRIPTION
- COPYRIGHT
- USAGE
- FUNCTIONS

# 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 read the source code for individual functions for more detail. There is a column on phpbuilder.com about this package ( http://www.phpbuilder.com/columns/zhang19990610.php3 )

NOTE: In this manpage, OBJECT sometimes is not the exact meaning of object. it refers to the name of the object.

# COPYRIGHT

Copyright 1999 ValueHunt Inc. All rights reserved. <P>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("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

All the helper functions in class.layout.

setdefault($o,$a)
  Set default attributes ($a, array) for an object ($o, objectname). This function saves you lot of typing.

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

newhtml(&$w [,$a])
  Start the HTML page `$w` with optional attributes ($a, array). This function is <B>required</B>.

          newhtml(&$w,array("bgcolor"=>"#FFFFFF",
                            "onload"=>"some javascript here"));

insert($p,$c)
  Insert a child object into a parent container. `$p` is the parent object. `$c` is the child object. This function is the <B>main construction function</B> in this library.

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

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

          printhtml($w);

table([$a])
  A table object. `$a` is an optional array of attributes for the table and will overwrite any default value declared by `setdefault()` function.

          setdefault("table",array("cellpadding"=>"0"));
          insert($w, $t = table(array("cellpadding"=>"3","cols"=>"3")));

  This function returns the reference to the object. Table can be nested in any legal containers like cell etc. There is no <TR> constructor function in this library. the ``cols''=>``3'' attribute for table will set columns to 3 for the table.

          insert($t, $c  = cell());
          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"=>"#FFFFFF")));

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, generic("hr",array("noshade"=>"undef","size"=>"1")));

  insert a break

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

container($t [,$a])
  This function is for generating a generic html container if it is not available in this library. `$t` is the tag name, `$a` is an optional array of attributes.

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

block($t)
  Insert raw HTML or text into the page.

          insert($c, block('<B>Text here</B>'));

span($t [,$a])
  Used mostly for style sheet. `$a` is an optional array.

          insert($c, span("text goes here",array("class"=>"BIGBLUE")));

form($a)
  Form with attributes array $a.

           insert($c, $f = form(array("method"=>"post","action"=>"/cgi/c.pl")));

alist($t,$c [,$a])
  Create a LIST. `$t` is a tag name, like ``UL'',``OL'' etc. `$c` is an array of texts or objects. `$a` is the attribute array for the list.

           insert($c, $l = alist("ul",array("item1","item2")));

comment($m)
  Insert a comment into HTML page.

           insert($w, comment("start the page"));

script($c [,$a])
  the script object.

           insert($h, script("
                     javascription goes here
                     define lots of function
                     but do NOT use double quotes
                     in here
                     ",array("language"=>"JavaScript")));

wheader($t)
  Define the title $t. Also it is the container for script,meta etc.

           insert($w, $h = wheader("This is the title"));
           insert($h, script("scription goes here",
                      array("language"=>"JavaScript")));

heading($l,$c [,$a])
  Create <Hn> tags. `$l` is int from 1 to 5. `$c` is the text.

           insert($w, heading(1,"HEAD 1"));

button($a)
  Button. Used with form.

           insert($c, button(array("name"=>"Aname","value"=>"a button")));

checkbox($a,$t [,$c])
  A Checkbox. Used with form

           insert($c, checkbox(array("name"=>"somevalue"),"A check box",
                      "checkecd"));

inputfile($a)
  Upload file.

hidden($a)
  Hidden for form.

imagebutton($s,$a)
  `$s` is the source for the image.

password($a)
  Password entry.

radio($a,$t [,$c])
  Radio button. same as checkbox.

submit($a)
  Submit button.

input_text($a)
  Input text.

Other functions
  - freset($a) Reset button
  - selectbox($o,$a [,$s]) Select
  - textarea($a [,$m]) Text area
  - imagemap($a) Image map
  - area($a) Area, use with imagemap
  - layer($a) Layer
  - nolayer($m) No layer
  - frameset($a) Frame set
  - frame($a) Frame
  - noframe($m) No frame
  - style($m,$a) Style sheet