phpWebSite developer documentation :
Automated HTML code generation routines

Content

  1. Background: itemfuncs, form_options() and html_header_location()
  2. Safe HTML redirection with html_header_location()
  3. Create menus and radio-boxes with form_options()
  4. Create clever items tables for Admin panels with itemfuncs

top of page

Background: itemfuncs, form_options() and html_header_location()

Since we started deal with both php 4.1.x and with increasing code complexity we felt in need to create smarter ways to accomplish repetitive tasks without replicating the same code more and more. Functions described in this document had been created to achieve those goals.
Both all three group of functionalities described in this document had been created by Alessandro Pisani.
If you need more info or you have suggestions about them, you can find his email address at the end of this document.


top of page

Safe HTML redirection with html_header_location()

The html_header_location() function is a wrap around the PHP function header() in its most common use: header("Location: url"); (where url is a destination URL). html_header_location() provides compatibility with the different behaviour of the PHP costruct in different browsers (like Microsoft InternetExplorer 5.5 and above, Mozilla 0.9.8 and above, ...) and different versions of PHP.

Function prototype: function html_header_location($url)
Required parameters:

Return: this function does not return
Location: htmlheader.php (phpWebSite 0.8.1-CVS feb 2002)

Example: redirect to index.php
	html_header_location("index.php");


top of page

Create menus and radio-boxes with form_options()

form_options() is an automated way to generate HTML input-radio and select-option selections in HTML forms. The function assumes the form is opened and closed respectively before and after it is called.

Function prototype: function form_options($useecho,$type,$name,$options_and_values,$selection)
Required parameters:

Return: with $useecho=1 this function does not return, otherwise it returns a string buffer containing resulting HTML code.
Location: mainfile.php (phpWebSite 0.8.1-CVS gen 2002)

Example: generation of a box with a Yes/No select-option form
	$title = "Test form";
        $content = "<form method=\"post\" action=\"admin.php\">\n";
        $content .= form_options(0,"option","test_yesno",array("1","TRANSLATE[[Yes]]","0","TRANSLATE[[No]]"), 1);
	$content .= "</form>";
	thememainbox($title,$content);


top of page

Create clever items tables for Admin panels with itemfuncs

itemfuncs is a way to generate items tables with built-in Add/Edit/Delete capabilities in Admin panels without having to write code for them: you only need a field in the db schema; itemfuncs will require you only ONE line of code.
The itemfuncs system only have one public function, all the work is done behind the scenes.

Function prototype: configuration_table_items($itemtype,$itemtype_mod,$location,$prefix,$backpoint)
Required parameters:

Return: this function does not return, it creates and display a thememainbox() containing resulting HTML code
Location: itemfuncs.php and admin.php (phpWebSite 0.8.1-CVS gen 2002)

Example: see admin/censorship_admin.php


Alessandro Pisani <alextxm@users.sourceforge.net>