Class View

Description

The View class generates HTML output

The class methods operates on the $data member.

Located in /phpfw.php (line 1454)


	
			
Variable Summary
mixed $data
array $properties
array $saved
array $template
Method Summary
View View ([mixed $data = ''], [ $properties = array()])
void a (string $link)
void add_element ()
void auto_reset_properties ([bool $reset = true])
void b ()
void body ()
void br ()
void center ()
void div (string $name)
void font ()
void form (string $name)
void generate_tag (string $tag, [string $newline = true])
mixed get_data ()
string get_unique_blank_key (array $data)
void h1 ()
void h2 ()
void h3 ()
void head ()
void header ()
void hr ()
void html ()
void i ()
void img (string $src)
void input ( &$input_data, array $input_data)
void input_button ()
void input_cancel ()
void input_file (string $name)
void input_hidden (string $name, string $value)
void input_password (string $name)
void input_submit ()
void input_text (string $name)
void label (string $id)
void link (string $file, [string $rel = "stylesheet"], [string $type = "text/css"])
void merge_properties ( &$data, array $data)
void nl ()
void options ([string $selected = null])
void p ()
void pop ()
void pop_append ([bool $all = false])
void pop_prepend ([bool $all = false])
void push ()
void render ()
void reset_data ()
void script (string $file, [string $type = "text/javascript"], [string $language = "javascript"])
void select (string $name)
void set_data (mixed $data)
void set_properties (array $properties)
void sp ()
void table ([bool $header = false], [array $align = 0], [array $width = 0], [string $tableclass = 0], [string $trclass = 0], [string $tdclass = 0])
void table_two_column_associative ([string $tableclass = 0], [string $trclass = 0], [string $tdclass = 0], [bool $header = false])
void tag (string $name, [mixed $data = 0], [bool $newline = true])
void text_area (string $name)
void u ()
Variables
mixed $data (line 1461)
  • var:

    Contains the view data to be processed.

    • Usually a string for methods like u(), a(), etc.
    • Needs to be an array for methods like table(), table_two_column_associative(), etc.

array $properties (line 1470)
  • var:

    Contains the HTML properties for the tag

    Expected format:

    • $properties['property_name1'] = 'property_value1';
    • $properties['property_name2'] = 'property_value2';

bool $reset_properties (line 1477)
  • var:

    Auto clear View::$properties after being consumed (default: true)

    Set value using View::auto_reset_properties()

array $saved (line 1485)
  • var:

    Contains saved HTML code.

    Array can be saved to using View::push() and recovered using View::pop(). The push and pop functions save View::$data to this array for later retrieval.

array $special_tags (line 1498)
  • var: List of special tags that need a /> at the end instead of a </tag>
array $template (line 1493)
  • var:

    Array containing multiple tag calls to process.

    • This member is appended to using View::add_template()
    • Template is processed using View::compile_template()

Methods
Constructor View (line 1507)

Constructor for the View class

Initializes the members based on the input

View View ([mixed $data = ''], [ $properties = array()])
  • mixed $data: The data to be operated on
  • $properties
a (line 2396)

Generate a URL link

This function uses View::$data as the default data to display within the URL link. Expects a string.

This function uses View::$properties for the properties of the URL link element. Expects following format:

  • $properties['property_name1'] = 'property_value1';
  • $properties['property_name2'] = 'property_value2';
Common properties:
  • target : string
  • onclick : string
  • class : string
  • style : string

void a (string $link)
  • string $link: Link to point to
add_element (line 1646)

Function to add an element to process to the View::$template member

The syntax is as follows:-

  • First parameter is the method to call - e.g. a, font, h2, table, etc. - string
  • Second parameter is the value to set in View::$data - array or string or 0
  • Third parameter is the value to set in View::$properties - array (see View::$properties format) or 0
  • Fourth parameter is what to append to the string once done - usually "nl" for newline or "sp" for a space or 0
  • Remaining parameters are the parameters sent to the above method call - mixed

void add_element ()
auto_reset_properties (line 1565)

Set the View::$reset_properties variable

The View::$properties variable is reset after it is consumed by default. Call this function with "false" if this is not desired.

void auto_reset_properties ([bool $reset = true])
  • bool $reset: Set to true or false as needed
b (line 2478)

Bold the View::$data

This function uses View::$properties for the properties of the b element. Expects following format:

  • $properties['property_name1'] = 'property_value1';
  • $properties['property_name2'] = 'property_value2';
Common properties:
  • class : int
  • style : string

void b ()
body (line 2337)

Generate a body tag

This function uses View::$data as the default data to display within the div. Expects a string.

This function uses View::$properties for the properties of the div element. Expects following format:

  • $properties['property_name1'] = 'property_value1';
  • $properties['property_name2'] = 'property_value2';
Common properties:
  • onload : string
  • background : string

void body ()
br (line 2450)

Add a line break

void br ()
center (line 2436)

Center the View::$data

void center ()
clear_properties (line 1553)

Clear the View::$properties member

void clear_properties ()
compile_template (line 1684)

Compile the template using the commands in View::$template

This function creates each element in the View::$template array and appends all the results together.

void compile_template ()
div (line 2368)

Generate a div

This function uses View::$data as the default data to display within the div. Expects a string.

This function uses View::$properties for the properties of the div element. Expects following format:

  • $properties['property_name1'] = 'property_value1';
  • $properties['property_name2'] = 'property_value2';
Common properties:
  • style : string

void div (string $name)
  • string $name: Name of the div
font (line 2523)

Enclosure View::$data in a font tag

This function uses View::$properties for the properties of the font element. Expects following format:

  • $properties['property_name1'] = 'property_value1';
  • $properties['property_name2'] = 'property_value2';
Common properties:
  • size : int
  • color : string

void font ()
form (line 2213)

Generate a form element

This function uses View::$data as the default data to display within the form. Expects a string.

This function uses View::$properties for the properties of the form element. Expects following format:

  • $properties['property_name1'] = 'property_value1';
  • $properties['property_name2'] = 'property_value2';
Common properties:
  • action : string
  • method : string
  • onsubmit : string
  • enctype : string
  • target : string

void form (string $name)
  • string $name: Name of the form
generate_tag (line 1884)

Format the View::$data - called by b(), u(), etc. Can be called directly with the tag name. A wrapper for the tag() function.

This function uses View::$data as the default data to display within the tag. Expects a string.

This function uses View::$properties for the properties of the tag element. Expects following format:

  • $properties['property_name1'] = 'property_value1';
  • $properties['property_name2'] = 'property_value2';
Common properties:
  • class : string
  • style : string

void generate_tag (string $tag, [string $newline = true])
  • string $tag: The name of the tag - b, i, u, font, etc.
  • string $newline: Print a new line if true (default: true)
get_data (line 1521)

Return the value of $data

  • return: The value of $data for this View
mixed get_data ()
get_unique_blank_key (line 1746)

Generate a unique blank string key for the $data array

The input array is an associative array. This function is useful to generate blank lines in the data array which will be operated on by the table_two_column_associative() function.

  • return: The blank key value
string get_unique_blank_key (array $data)
  • array $data: An associative array for which a unique blank key is needed
h1 (line 2537)

Enclose View::$data in a header 1

This function uses View::$properties for the properties of the h1 element. Expects following format:

  • $properties['property_name1'] = 'property_value1';
  • $properties['property_name2'] = 'property_value2';
Common properties:
  • color : string

void h1 ()
h2 (line 2551)

Enclose View::$data in a header 2

This function uses View::$properties for the properties of the h2 element. Expects following format:

  • $properties['property_name1'] = 'property_value1';
  • $properties['property_name2'] = 'property_value2';
Common properties:
  • color : string

void h2 ()
h3 (line 2565)

Enclose View::$data in a header 3

This function uses View::$properties for the properties of the h3 element. Expects following format:

  • $properties['property_name1'] = 'property_value1';
  • $properties['property_name2'] = 'property_value2';
Common properties:
  • color : string

void h3 ()
head (line 2350)

Generate a head tag

This function uses View::$data as the default data to display within the div. Expects a string.

This function uses View::$properties for the properties of the div element. Expects following format:

  • $properties['property_name1'] = 'property_value1';
  • $properties['property_name2'] = 'property_value2';

void head ()
header (line 1769)

Generate the header HTML around the main code

This function uses View::$data as the default data to display within the body. Expects a string.

This function uses View::$properties for the properties of the body element. Expects following format:

  • $properties['property_name1'] = 'property_value1';
  • $properties['property_name2'] = 'property_value2';

void header ()
hr (line 2457)

Add a horizontal line

void hr ()
html (line 2320)

Generate a html tag

This function uses View::$data as the default data to display within the div. Expects a string.

This function uses View::$properties for the properties of the div element. Expects following format:

  • $properties['property_name1'] = 'property_value1';
  • $properties['property_name2'] = 'property_value2';

void html ()
i (line 2493)

Italicize the View::$data

This function uses View::$properties for the properties of the i element. Expects following format:

  • $properties['property_name1'] = 'property_value1';
  • $properties['property_name2'] = 'property_value2';
Common properties:
  • size : int
  • color : string

void i ()
img (line 2422)

Generate an image tag

This function uses View::$properties for the properties of the image. Expects following format:

  • $properties['property_name1'] = 'property_value1';
  • $properties['property_name2'] = 'property_value2';
Common properties:
  • border : string
  • onclick : string
  • class : string
  • style : string

void img (string $src)
  • string $src: Link to the image
input (line 2023)

Generic input element function - called internally

This function is used by the other input() functions to add View::$properties to the properties array and generate the tag.

void input ( &$input_data, array $input_data)
  • array $input_data: Reference to the properties array for the input element
  • &$input_data
input_button (line 2114)

Generate a generic button

This function uses View::$properties for the properties of the button. Expects following format:

  • $properties['property_name1'] = 'property_value1';
  • $properties['property_name2'] = 'property_value2';
E.g. $properties = array('value' = 'display', 'onclick' = "javascript:open('url');");

Common properties

  • value : string
  • class : string
  • onclick : string

void input_button ()
input_cancel (line 2092)

Generate a cancel button which goes back to the previous page using history.back()

This function uses View::$properties for the properties of the cancel button. Expects following format:

  • $properties['property_name1'] = 'property_value1';
  • $properties['property_name2'] = 'property_value2';
E.g. $properties = array('value' = 'cancel');

Common properties

  • value : string
  • class : string

void input_cancel ()
input_file (line 2158)

Generate a file input element

This function uses View::$properties for the properties of the file input element. Expects following format:

  • $properties['property_name1'] = 'property_value1';
  • $properties['property_name2'] = 'property_value2';

void input_file (string $name)
  • string $name: Name of the file input element
input_hidden (line 2128)

Create a hidden input element

void input_hidden (string $name, string $value)
  • string $name: Name of the hidden input element
  • string $value: Value of the hidden input element
input_password (line 2141)

Generate a password input text box

This function uses View::$properties for the properties of the password input text box. Expects following format:

  • $properties['property_name1'] = 'property_value1';
  • $properties['property_name2'] = 'property_value2';

void input_password (string $name)
  • string $name: Name of the password input text box
input_submit (line 2071)

Generate a submit button

This function uses View::$properties for the properties of the submit button. Expects following format:

  • $properties['property_name1'] = 'property_value1';
  • $properties['property_name2'] = 'property_value2';
E.g. $properties = array('value' = 'submit');

Common properties

  • value : string
  • class : string

void input_submit ()
input_text (line 2050)

Generate an input text box

This function uses View::$properties for the properties of the input text box. Expects following format:

  • $properties['property_name1'] = 'property_value1';
  • $properties['property_name2'] = 'property_value2';
E.g. $properties = array('size' = 20, 'class' = 'inpBlue', 'value' = $inp_value);

Common properties

  • size : int
  • maxlength : int
  • value : string
  • class : string
  • onfocus : string
  • onblur : string

void input_text (string $name)
  • string $name: Name of the input text box
label (line 2012)

Create a label for an input element

Expects View::$data to contain the string to display as the label.

void label (string $id)
  • string $id: ID of the input element
link (line 2290)

Generate a link to stylesheet

void link (string $file, [string $rel = "stylesheet"], [string $type = "text/css"])
  • string $file: Name of the css file including web path
  • string $rel: Default: "stylesheet"
  • string $type: Mime type of file (default: text/css)
merge_properties (line 1574)

Merge specified array with View::$properties array

void merge_properties ( &$data, array $data)
  • array $data: The array to merge View::$properties into
  • &$data
nl (line 1724)

Add a new line
to View::$data

void nl ()
options (line 2234)

Generate an options list for <select>

This function uses View::$data for the options. Expects following format:

  • $data['name1] = 'value1';
  • $data['name2'] = 'value2';
  • ...

void options ([string $selected = null])
  • string $selected: Value to default select in the drop down (default selects name = " " if available)
p (line 2443)

Enclosure View::$data in a paragraph

void p ()
pop (line 1597)

Pop the last pushed data in View::$saved to View::$data

void pop ()
pop_append (line 1625)

Pop the last pushed data in View::$saved and append to View::$data

void pop_append ([bool $all = false])
  • bool $all: Set to true to pop_prepend() all the saved values. (default: false)
pop_prepend (line 1609)

Pop the last pushed data in View::$saved and prepend to View::$data

void pop_prepend ([bool $all = false])
  • bool $all: Set to true to pop_prepend() all the saved values. (default: false)
push (line 1589)

Push the contents of View::$data to View::$saved

Function resets the value of $data to ''.

void push ()
render (line 1755)

Print the $data HTML result

void render ()
reset_data (line 1537)

Reset the value of $data to 0.

void reset_data ()
script (line 2301)

Generate a script file header

void script (string $file, [string $type = "text/javascript"], [string $language = "javascript"])
  • string $file: Name of the script file including web path
  • string $type: Mime type of file (default: text/javascript)
  • string $language: Language of the script file (default: javascript)
select (line 2266)

Generate a select element

This function uses View::$data as the default data to display within the select. Expects a string.

This function uses View::$properties for the properties of the select element. Expects following format:

  • $properties['property_name1'] = 'property_value1';
  • $properties['property_name2'] = 'property_value2';

void select (string $name)
  • string $name: Name of the select
set_data (line 1530)

Set the value of $data to a new value

void set_data (mixed $data)
  • mixed $data: The data to be operated on
set_properties (line 1546)

Set the value of $properties to a new value

void set_properties (array $properties)
  • array $properties: The properties to set
sp (line 1731)

Add a space to View::$data

void sp ()
table (line 1916)

Display a table with multiple rows and columns

This function operates on View::$data. Expects following format for the table rows/columns:

  • $data[0] = array(row1col1, row1col2, row1col3, row1col4);
  • $data[1] = array(row2col1, row2col2, row2col3, row2col4);
  • $data[2] = ...

void table ([bool $header = false], [array $align = 0], [array $width = 0], [string $tableclass = 0], [string $trclass = 0], [string $tdclass = 0])
  • bool $header: Treats the first row in the input array as the header row <th> (default: false)
  • array $align: Array of align values for each column e.g. array(L, R, L) (default: 0)
  • array $width: Array of width values for each column e.g. array("100", "20") (default: 0)
  • string $tableclass: CSS table class to use (default: 0)
  • string $trclass: CSS tr class to use (default: 0)
  • string $tdclass: CSS td class to use (default: 0)
table_two_column_associative (line 1968)

Displays table of following format:

  • | r1col1 | r1col2 |
  • | r2col1 | r2col2 |
  • | r3col1 | r3col2 |
  • | r4col1 | r4col2 |
Expects View::$data in the following format:
  • $data["r1col1"] = "r1col2";
  • $data["r2col1"] = "r2col2";
  • ...

void table_two_column_associative ([string $tableclass = 0], [string $trclass = 0], [string $tdclass = 0], [bool $header = false])
  • string $tableclass: CSS table class to use (default: 0)
  • string $trclass: CSS tr class to use (default: 0)
  • string $tdclass: CSS td class to use (default: 0)
  • bool $header: Set the first row as a header row (default: false)
tag (line 1828)

Print an HTML tag with the supplied properties and inner HTML

This function does not operate on View::$data but its own local copy.

E.g.

  • $data['#'] = string in between tag : string
  • $data['property1'] = 'value1';
  • $data['property2'] = 'value2';
E.g. Properties for table
  • class : string
  • border : int
  • cellpadding : int
  • cellspacing : int
  • valign : string

void tag (string $name, [mixed $data = 0], [bool $newline = true])
  • string $name: The name of the tag. E.g. table, tr, a, div
  • mixed $data: Associative array specifying contents and properties of tag (default: 0)
  • bool $newline: Print a new line if true (default: true)
text_area (line 2181)

Generate a text area element

This function uses View::$data as the default data to display within the text area. Expects a string. Ignored if View::$data = int(0)

This function uses View::$properties for the properties of the text area element. Expects following format:

  • $properties['property_name1'] = 'property_value1';
  • $properties['property_name2'] = 'property_value2';
Common properties:
  • cols : int
  • rows : int

void text_area (string $name)
  • string $name: Name of the text area
u (line 2508)

Underline the View::$data

This function uses View::$properties for the properties of the u element. Expects following format:

  • $properties['property_name1'] = 'property_value1';
  • $properties['property_name2'] = 'property_value2';
Common properties:
  • size : int
  • color : string

void u ()

Documentation generated on Sat, 23 Jun 2007 21:28:27 -0500 by phpDocumentor 1.3.2