Class: pnHTML

Source Location: /pnHTML.php

Class Overview


                  
HTML creation and display functions


Author(s):

Methods


Inherited Variables

Inherited Methods


Class Details

[line 123]
HTML creation and display functions

This class is designed to make generating HTML output in MDPro very simple and also allow for much greater control of output by the site administrator.

Example

 // Information array
 $colors = array(array('id' => 1,
                         'name' => 'Red',
                         'encoding' => 'ff0000'),
                   array('id' => 2,
                         'name' => 'Blue',
                         'encoding' => '00ff00'),
                   array('id' => 3,
                         'name' => 'Green',
                         'encoding' => '0000ff'));

 // Create the HTML object and start it
 $myhtml = new pnHTML();
 $myhtml->Start();

 // Add table showing encoding information
 $myhtml->TableStart('Colors and Their Encodings', array('Color', 'Encoding'));
 foreach ($colors as $color) {
       $info = array($color['name'], $color['encoding']);
       $myhtml->TableAddRow($info);
 }
 $myhtml->TableEnd();

 // Add form to select a color
 $myhtml->Text('<P><P>');
 $myhtml->FormStart('colorchosen.php');
 $myhtml->Text('Select a color: ');
 $myhtml->FormList('chosen', $colorinfo);
 $myhtml->FormSubmit('That\'s the color I want');
 $myhtml->FormEnd();


 // End the HTML object and print it
 $myhtml->End();
 $myhtml->PrintPage();
 



[ Top ]


Class Methods


constructor pnHTML [line 191]

boolean pnHTML( )

Constructor



Tags:

return:   Always returns true
access:   public


[ Top ]

method BoldText [line 616]

string BoldText( string $text)

add bold text to the object's buffer



Tags:

return:   An HTML string if

1 ReturnHTML()
has been called, otherwise null
access:   public


Parameters:

string   $text   the text string to add

[ Top ]

method ConfirmAction [line 531]

void ConfirmAction( string $confirm_text, string $confirm_url, string $cancel_text, string $cancel_url, [array $arg = array ()])

composite function for generic confirmation of action



Tags:

access:   public


Parameters:

string   $confirm_text   Confirmation message to display
string   $confirm_url   URL to go to if confirm button is clicked
string   $cancel_text   Link text cor the cancel message
string   $cancel_url   URL to go to is action is canceled
array   $arg   An array of args to create hidden fields for

[ Top ]

method EndPage [line 383]

string EndPage( )

Put the appropriate HTML tags in place to create a valid end to HTML output.



Tags:

return:   An HTML string if

1 ReturnHTML()
has been called, otherwise null
see:   pnHTML::StartPage()
access:   public


[ Top ]

method FormCheckbox [line 1141]

string FormCheckbox( string $fieldname, [boolean $checked = false], [string $value = '1'], [string $type = 'checkbox'], [string $accesskey = ''])

Add HTML tags for a checkbox or radio button field as part of a form.



Tags:

return:   An HTML string if

1 ReturnHTML()
has been called, otherwise null
since:   1.13 - 2002/01/23
access:   public


Parameters:

string   $fieldname   the name of the checkbox field
string   $value   (optional) the value of the checkbox field
boolean   $checked   (optional) the field is checked
string   $type   (optional) the type of field this is, either

1 'checkbox'
or

1 'radio'
string   $accesskey   (optional) accesskey to active this item

[ Top ]

method FormEnd [line 930]

string FormEnd( )

Add HTML tags to end a form.



Tags:

return:   An HTML string if

1 ReturnHTML()
has been called, otherwise null
access:   public


[ Top ]

method FormFile [line 1168]

string FormFile( string $fieldname, [integer $size = 32], [integer $maxsize = 1000000], [string $accesskey = ''])

Add HTML tags for a file upload field as part of a form.



Tags:

return:   An HTML string if

1 ReturnHTML()
has been called, otherwise null
since:   1.13 - 2002/01/23
access:   public


Parameters:

string   $fieldname   the name of the field
integer   $size   (optional) the size of the field on the page in number of characters
integer   $maxsize   (optional) the maximum file size allowed (in bytes)
string   $accesskey   (optional) accesskey to active this item

[ Top ]

method FormHidden [line 1029]

string FormHidden( mixed $fieldname, [string $value = ''])

Add HTML tags for a hidden field as part of a form.



Tags:

return:   An HTML string if

1 ReturnHTML()
has been called, otherwise null
access:   public


Parameters:

mixed   $fieldname   the name of the hidden field. can also be an array.
string   $value   the value of the hidden field

[ Top ]

method FormSelectMultiple [line 1072]

string FormSelectMultiple( string $fieldname, array $data, integer $multiple, [integer $size = 1], [string $selected = ''], [string $accesskey = ''], [mixed $events = ''], string $events:)

Add HTML tags for a select field as part of a form.



Tags:

return:   An HTML string if

1 ReturnHTML()
has been called, otherwise null
since:   1.13 - 2002/01/23
access:   public


Parameters:

string   $fieldname   the name of the select field
array   $data   an array containing the data for the list. Each array entry is itself an array, containing the values for

1 'id'
(the value returned if the entry is selected),

1 'name'
(the string displayed for this entry) and

1 'selected'
(optional,

1 1
if this option is selected)
integer   $multiple   (optional)

1 1
if the user is allowed to make multiple selections
integer   $size   (optional) the number of entries that are visible in the select at any one time. Note that if the number of actual items is less than this value then the select box will shrink automatically to the correct size
string   $selected   (optional) selected value of

1 id
string   $accesskey   (optional) accesskey to active this item
string   $events:   javascript events

[ Top ]

method FormStart [line 903]

string FormStart( string $action, [mixed $name = ''])

Add HTML tags to start a form.



Tags:

return:   An HTML string if

1 ReturnHTML()
has been called, otherwise null
access:   public


Parameters:

string   $action   the URL that this form should go to on submission

[ Top ]

method FormSubmit [line 951]

string FormSubmit( [string $label = 'Submit'], [string $accesskey = ''])

Add HTML tags for a submission button as part of a form.



Tags:

return:   An HTML string if

1 ReturnHTML()
has been called, otherwise null
access:   public


Parameters:

string   $label   (optional) the name of the submission button. This defaults to

1 'Submit'
string   $accesskey   (optional) accesskey to active this button

[ Top ]

method FormText [line 977]

string FormText( string $fieldname, [string $contents = ''], [integer $size = 16], [integer $maxlength = 64], [boolean $password = false], [string $accesskey = ''])

Add HTML tags for a text field as part of a form.



Tags:

return:   An HTML string if

1 ReturnHTML()
has been called, otherwise null
access:   public


Parameters:

string   $fieldname   the name of the text field
string   $contents   (optional) the inital value of the text field
integer   $size   (optional) the size of the text field on the page in number of characters
integer   $maxlength   (optional) the maximum number of characters the text field can hold
boolean   $password   (optional) field acts as a password field
string   $accesskey   (optional) accesskey to active this item

[ Top ]

method FormTextArea [line 1006]

string FormTextArea( string $fieldname, [string $contents = ''], [integer $rows = 6], [integer $cols = 40], [string $wrap = 'soft'], [string $accesskey = ''])

Add HTML tags for a text area as part of a form



Tags:

return:   An HTML string if

1 ReturnHTML()
has been called, otherwise null
access:   public


Parameters:

string   $fieldname   the name of the text area filed
string   $contents   the initial value of the text area field
integer   $rows   the number of rows that the text area | should cover
integer   $cols   the number of columns that the text area | should cover
string   $wrap   (optional) wordwrap mode to use, either

1 'soft'
or

1 'hard'
string   $accesskey   (optional) accesskey to active this item

[ Top ]

method GetInputMode [line 252]

integer GetInputMode( )

Retrive the current input state



Tags:

return:   Current input state
see:   pnHTML::SetInputMode()
since:   1.13 - 2002/01/23
access:   public


[ Top ]

method GetOutput [line 315]

string GetOutput( )

Return the HTML output from the buffer.

Note that this function does not clear out the object's buffer.




Tags:

return:   An HTML string
since:   1.15 - 2002/01/30
access:   public


[ Top ]

method GetOutputMode [line 210]

integer GetOutputMode( )

Return the current state of the output stream



Tags:

return:   Current output state
see:   pnHTML::SetOutputMode()
since:   1.13 - 2002/01/23
access:   public


[ Top ]

method Linebreak [line 633]

string Linebreak( [integer $numbreaks = 1])

Add line break



Tags:

return:   An HTML string if

1 ReturnHTML()
has been called, otherwise null
access:   public


Parameters:

integer   $numbreaks   number of linebreaks to add

[ Top ]

method Pager [line 419]

void Pager( integer $startnum, integer $total, string $urltemplate, [integer $perpage = 10])



Tags:

since:   1.13 - 2002/01/23
author:   Greg 'Adam Baum'
access:   public


Parameters:

integer   $startnum   start item
integer   $total   total number of items present
string   $urltemplate   template for url, will replace '%%' with item number
integer   $perpage   number of links to display (default=10)

[ Top ]

method PrintPage [line 327]

void PrintPage( )

Print the HTML currently held in the object.

Note that this function does not clear out the object's buffer.




Tags:

access:   public


[ Top ]

method Redirect [line 490]

string Redirect( string $url, [integer $waittime = 3])

Redirect the user to another page

This function is broken, do not use it!




Tags:

return:   An HTML string if

1 ReturnHTML()
has been called, otherwise null
todo:   This function is broken, do not use it!
access:   public


Parameters:

string   $url   URL to redirect to
integer   $waittime   Seconds to wait before redirecting

[ Top ]

method SetInputMode [line 267]

integer SetInputMode( int $st)

Set state of the input stream



Tags:

return:   Previous state
see:   pnHTML::GetInputMode()
since:   1.14 - 2002/01/29
access:   public


Parameters:

int   $st   Input state to set to

[ Top ]

method SetOutputMode [line 225]

integer SetOutputMode( int $st)

Set state of the output stream



Tags:

return:   Previous state
see:   pnHTML::GetOutputMode()
since:   1.14 - 2002/01/29
access:   public


Parameters:

int   $st   Output state to set to

[ Top ]

method StartPage [line 354]

string StartPage( )

Put the appropriate HTML tags in place to create a valid start to HTML output.



Tags:

return:   An HTML string if

1 ReturnHTML()
has been called, otherwise null
see:   pnHTML::EndPage()
access:   public


[ Top ]

method TableAddRow [line 834]

string TableAddRow( array $row, [string $align = 'center'], [mixed $valign = 'middle'])

Add HTML tags for a row of a table.



Tags:

return:   An HTML string if

1 ReturnHTML()
has been called, otherwise null
access:   public


Parameters:

array   $row   an array of row entries
string   $align   (optional) the alignment of the row, which can be one of

1 'left'
,

1 'center'
or

1 'right'

[ Top ]

method TableColEnd [line 780]

string TableColEnd( )

Add HTML tags for the end of a table column.



Tags:

return:   An HTML string if

1 ReturnHTML()
has been called, otherwise null
access:   public


[ Top ]

method TableColStart [line 763]

string TableColStart( [integer $colspan = 1], [string $align = 'center'], [string $valign = 'middle'], [integer $rowspan = 1])

Add HTML tags for the start of a table column.



Tags:

return:   An HTML string if

1 ReturnHTML()
has been called, otherwise null
access:   public


Parameters:

integer   $colspan   number of columns that this column spans
string   $align   Horizantal alignment of the column
string   $valign   Vertical alignment of this column
integer   $rowspan   Total rows this column uses

[ Top ]

method TableEnd [line 814]

string TableEnd( )

Add HTML tags for the end of a table.



Tags:

return:   An HTML string if

1 ReturnHTML()
has been called, otherwise null
access:   public


[ Top ]

method TableRowEnd [line 797]

string TableRowEnd( )

Add HTML tags for the end of a table row.



Tags:

return:   An HTML string if

1 ReturnHTML()
has been called, otherwise null
access:   public


[ Top ]

method TableRowStart [line 742]

string TableRowStart( [string $align = 'center'], [string $valign = 'middle'])

Add HTML tags for the start of a table row.



Tags:

return:   An HTML string if

1 ReturnHTML()
has been called, otherwise null
access:   public


Parameters:

string   $align   Default horizantal alignment for all columns on this row
string   $valign   Default vertical alignment for all columns on this row

[ Top ]

method TableStart [line 696]

string TableStart( [string $title = ''], [array $headers = array()], integer $border, [string $width = '100%'], mixed $cellpadding, mixed $cellspacing)

Add HTML tags for the start of a table.



Tags:

return:   An HTML string if

1 ReturnHTML()
has been called, otherwise null
access:   public


Parameters:

string   $title   the title of the table
array   $headers   an array of column headings
integer   $border   size of table borders
string   $width   the width of the table. can be null if no width needs to be specified

[ Top ]

method Text [line 569]

string Text( string $text)

Add free-form text to the object's buffer



Tags:

return:   An HTML string if

1 ReturnHTML()
has been called, otherwise null
access:   public


Parameters:

string   $text   The text string to add

[ Top ]

method Title [line 590]

string Title( string $text)

Add free-form text to the object's buffer as a title



Tags:

return:   An HTML string if

1 ReturnHTML()
has been called, otherwise null
access:   public


Parameters:

string   $text   the text string to add

[ Top ]

method UploadMode [line 294]

boolean UploadMode( )

Set the form to allow file uploads to take place



Tags:

return:   Always returns true
see:   pnHTML::FormStart(), pnHTML::FormFile()
since:   1.13 - 2002/01/23
access:   public


[ Top ]

method URL [line 656]

string URL( string $url, string $text)

Add HTML tags for a hotlink.



Tags:

return:   An HTML string if

1 ReturnHTML()
has been called, otherwise null
since:   1.13 - 2002/01/23
access:   public


Parameters:

string   $url   the URL of the link
string   $text   the text that the URL is anchored to

[ Top ]