/ecdForms.inc.php

Description

XHTML-compliant html generating functions

in general, the api here is simple. each function returns a XHTML-valid string (given that its input is XHTML valid). Generally, each function can be fed a $attributes array which is the last argument of the function.

  • see: xml_attributes() $Id: ecdForms.inc.php, v 1.3 2005/01/07 01:32:17 anarcat Exp $
Functions
a (line 108)

generate a hyperlink

void a (string $content, string $href, [array $attributes = null])
  • array $attributes: the attributes of the tag.
  • string $content: the content of the hyperlink
  • string $href: the destination of the hyperlink
add_get (line 682)
void add_get (mixed $url, mixed $key, [mixed $val = null])
add_get_array (line 675)
void add_get_array (mixed $url, mixed $array)
add_or_replace_get (line 691)
void add_or_replace_get (mixed $url, mixed $key, [mixed $val = null])
form (line 121)

generate a simple form tag

just a handy shortcut to xml_element

void form (string $action, string $content, [array $attributes = null])
  • array $attributes: the attributes of the tag.
  • string $action: set as an attribute to the form tag
  • string $content: the content of the XML tag
form_checkbox (line 272)
void form_checkbox (mixed $name, mixed $value, [mixed $label = ""], [mixed $values = null], [array $attributes = null])
  • array $attributes: the attributes of the tag.
form_checkboxes (line 341)

return checkboxes

void form_checkboxes (mixed $name, mixed $values, mixed $labels, [mixed $is_list = false], [array $attributes = null])
  • array $attributes: the attributes of the tag.
form_hidden (line 176)

a hidden form item

void form_hidden (mixed $name, mixed $value, [array $attributes = null])
  • array $attributes: the attributes of the tag.
form_image (line 190)

a submit button

void form_image (mixed $image, [mixed $name = 'submit'], [mixed $value = 'Submit'], [array $attributes = null])
  • array $attributes: the attributes of the tag.
form_input (line 153)

alias for form_item

void form_input (mixed $type, mixed $name, [mixed $value = null], [array $attributes = null])
  • array $attributes: the attributes of the tag.
form_item (line 131)

generate a form item

just a handy shortcut to xml_element

void form_item (mixed $type, mixed $name, [mixed $value = null], [array $attributes = null])
  • array $attributes: the attributes of the tag.
form_items (line 166)

generate many similar form items

returns an array of form_items based on the $values array

useful to pass _GET values in hidden fields, e.g.:

print form_items('hidden', $_GET);

void form_items (mixed $type, mixed $values, [array $attributes = null])
  • array $attributes: the attributes of the tag.
form_item_choice (line 244)

common generator for radios, checkboxes and options

this is an internal function and shouldn't be used outside this class, normally.

generates a single one of:

<option [value="$value"] [$check_attr]>$label</option> ($name applies to the select so we ignore it)

or

[<label>]<input type="checkbox" name="$name" [value="$value"] [$check_attr]>[$label</label>]

or

[<label>]<input type="radio" name="$name" [value="$value"] [$check_attr]>[$label</label>]

where $type is of course "radio", "checkbox" or "option"

void form_item_choice (mixed $type, mixed $name, mixed $value, mixed $label, mixed $values, mixed $check_attr, [array $attributes = null])
  • array $attributes: the attributes of the tag.
form_option (line 288)
void form_option (mixed $name, mixed $value, mixed $label, mixed $values, [array $attributes = null])
  • array $attributes: the attributes of the tag.
form_radio (line 280)
void form_radio (mixed $name, mixed $value, mixed $label, mixed $values, [array $attributes = null])
  • array $attributes: the attributes of the tag.
form_radios (line 326)

form_radios() and form_checkboxes() both return a group of checkboxes or radios and work about the same

$name is the name of the group

$values is the current value, either a string or an array where the key corresponds the the $name. If the key's value fits with one of the values of the radios, that radio is checked

Eg. form_radios('lang', 'fr', array('fr' => 'Franšais', 'en' => 'English')); or $_GET['lang'] = 'fr'; form_radios('lang', $_GET, array('fr' => 'Franšais', 'en' => 'English'));

output the same: <input checked type="radio" name="lang" value="fr" /> <input type="radio" name="lang" value="en" />

This also works with checkboxes: if $_GET is multi-dimensional, it is looked-up deeper for values.

void form_radios (mixed $name, mixed $values, mixed $labels, [mixed $is_list = false], [array $attributes = null])
  • array $attributes: the attributes of the tag.
form_select (line 361)

this is not very different from form_radios/checkboxes, except that the name applies to the select itself

void form_select (mixed $name, mixed $values, mixed $labels, [mixed $is_list = false], [mixed $multiple = false], [array $attributes = null])
  • array $attributes: the attributes of the tag.
form_select_country (line 384)

returns a country select (CA/US)

void form_select_country (mixed $name, mixed $value, [mixed $attributes = null])
form_select_state (line 410)

create a state selection form

  • return: a state/province select that depends on which country is set right now
  • see: form_select()
string form_select_state ([mixed $name = 'state'], [mixed $value = null], [mixed $country = null], [mixed $attributes = null])
form_submit (line 183)

a submit button

void form_submit ([mixed $name = 'submit'], [mixed $value = 'Submit'], [array $attributes = null])
  • array $attributes: the attributes of the tag.
form_submitted (line 580)

test if a form was submitted by pressing a named button

this is done by examining if the $name variable is set in the $request array. The $name is looked for:

  • in lowercase
  • with a .x and .y appended, for standard image submits
  • with a _x and _y appended, for IE broken image submits
If any of those match, the form is considered submitted.

boolean form_submitted (string $request, [string $name = 'Submit'])
  • string $request: the array to check (usually $_GET or $_POST)
  • string $name: the name of the button. Defaults to 'Submit'.
form_text (line 198)

simple textfield

void form_text (mixed $name, mixed $value, [array $attributes = null])
  • array $attributes: the attributes of the tag.
form_textarea (line 205)

simple textarea

void form_textarea (mixed $name, mixed $value, [mixed $rows = 5], [mixed $cols = 20], [array $attributes = null])
  • array $attributes: the attributes of the tag.
insert_args_ifset (line 664)
  • todo: document this.
void insert_args_ifset (mixed $hidden_array, mixed $vars)
insert_hidden_ifset (line 650)
  • todo: document this.
void insert_hidden_ifset (mixed $hidden_array, mixed $vars)
redirect (line 612)

create a META redirection

the created HTML would look something like this:

  1. <meta http-equiv="refresh" content="$delay; URL=$url" />

string redirect ([string $url = null], [int $delay = 0])
  • string $url: the URL to redirect to. Defaults to $PHP_SELF
  • int $delay: the delay in seconds to wait. Defaults to 0 seconds.
redirect_page (line 632)

create a complete redirection page

Creates a complete page (with HTML, HEAD and BODY tags) with an informational message for the user.

string redirect_page ([string $url = null], [int $delay = 0], [string $title = 'Redirecting...'], [string $pre_msg = ''])
  • string $url: the URL to redirect to. Defaults to $PHP_SELF
  • int $delay: the delay in seconds to wait. Defaults to 0 seconds.
  • string $title: the title of the page
  • string $pre_msg: text to put before the redirect message
remove_get (line 714)
void remove_get (mixed $url, mixed $key)
xml_attributes (line 52)

generate a serie of html attributes

  • return:

    a serie of XHTML attributes made up from the $attributes parameter:

    1. $key="$val" ...

    or just $key is $val is null

string xml_attributes ([array $attributes = null])
  • array $attributes: the attributes of the tag.
xml_element (line 83)

generic html generation function

an xml_element (mixed $name, [mixed $content = null], [mixed $attributes = null])

Documentation generated on Tue, 11 Jan 2005 01:38:21 -0500 by phpDocumentor 1.3.0RC3