Moodle  2.2.1
http://www.collinsharper.com
xhtml_container_stack Class Reference

Public Member Functions

 __construct ()
 push ($type, $closehtml)
 pop ($type)
 pop_all_but_last ($shouldbenone=false)
 discard ()

Protected Member Functions

 log ($action, $type)
 output_log ()

Protected Attributes

 $opencontainers = array()
 $log = array()
 $isdebugging

Detailed Description

This class keeps track of which HTML tags are currently open.

This makes it much easier to always generate well formed XHTML output, even if execution terminates abruptly. Any time you output some opening HTML without the matching closing HTML, you should push the necessary close tags onto the stack.

Since:
Moodle 2.0

Definition at line 1206 of file outputlib.php.


Constructor & Destructor Documentation

Definition at line 1221 of file outputlib.php.

Here is the call graph for this function:


Member Function Documentation

discard ( )

You can call this function if you want to throw away an instance of this class without properly emptying the stack (for example, in a unit test). Calling this method stops the destruct method from outputting a developer debug warning. After calling this method, the instance can no longer be used.

Returns:
void

Definition at line 1297 of file outputlib.php.

log ( action,
type 
) [protected]

Adds an entry to the log.

Parameters:
string$actionThe name of the action
string$typeThe type of action
Returns:
void

Definition at line 1307 of file outputlib.php.

Here is the call graph for this function:

Here is the caller graph for this function:

output_log ( ) [protected]

Outputs the log's contents as a HTML list.

Returns:
string HTML list of the log

Definition at line 1316 of file outputlib.php.

Here is the call graph for this function:

Here is the caller graph for this function:

pop ( type)

Pop the HTML for the next closing container from the stack. The $type must match the type passed when the container was opened, otherwise a warning will be output.

Parameters:
string$typeThe type of container.
Returns:
string the HTML required to close the container.

Definition at line 1249 of file outputlib.php.

Here is the call graph for this function:

pop_all_but_last ( shouldbenone = false)

Close all but the last open container. This is useful in places like error handling, where you want to close all the open containers (apart from <body>) before outputting the error message.

Parameters:
bool$shouldbenoneassert that the stack should be empty now - causes a developer debug warning if it isn't.
Returns:
string the HTML required to close any open containers inside <body>.

Definition at line 1277 of file outputlib.php.

Here is the call graph for this function:

push ( type,
closehtml 
)

Push the close HTML for a recently opened container onto the stack.

Parameters:
string$typeThe type of container. This is checked when pop() is called and must match, otherwise a developer debug warning is output.
string$closehtmlThe HTML required to close the container.
Returns:
void

Definition at line 1232 of file outputlib.php.

Here is the call graph for this function:


Field Documentation

$isdebugging [protected]

Definition at line 1219 of file outputlib.php.

$log = array() [protected]

Definition at line 1213 of file outputlib.php.

$opencontainers = array() [protected]

Definition at line 1208 of file outputlib.php.


The documentation for this class was generated from the following file:
 All Data Structures Namespaces Files Functions Variables Enumerations