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
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
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
()
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
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
()
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
()
Add a line break
void
br
()
Center the View::$data
void
center
()
Clear the View::$properties member
void
clear_properties
()
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
()
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:
void
div
(string $name)
-
string
$name: Name of the div
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:
void
font
()
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
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)
Return the value of $data
mixed
get_data
()
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.
string
get_unique_blank_key
(array $data)
-
array
$data: An associative array for which a unique blank key is needed
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:
void
h1
()
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:
void
h2
()
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:
void
h3
()
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
()
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
()
Add a horizontal line
void
hr
()
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
()
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:
void
i
()
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
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
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
()
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
()
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
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
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
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
()
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
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
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 specified array with View::$properties array
void
merge_properties
( &$data, array $data)
-
array
$data: The array to merge View::$properties into
-
&$data
Add a new line
to View::$data
void
nl
()
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)
Enclosure View::$data in a paragraph
void
p
()
Pop the last pushed data in View::$saved to View::$data
void
pop
()
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 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 the contents of View::$data to View::$saved
Function resets the value of $data to ''.
void
push
()
Print the $data HTML result
void
render
()
Reset the value of $data to 0.
void
reset_data
()
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)
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 the value of $data to a new value
void
set_data
(mixed $data)
-
mixed
$data: The data to be operated on
Set the value of $properties to a new value
void
set_properties
(array $properties)
-
array
$properties: The properties to set
Add a space to View::$data
void
sp
()
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)
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)
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)
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:
void
text_area
(string $name)
-
string
$name: Name of the text area
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:
void
u
()