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

Static Public Member Functions

static tag ($tagname, $contents, array $attributes=null)
static start_tag ($tagname, array $attributes=null)
static end_tag ($tagname)
static empty_tag ($tagname, array $attributes=null)
static nonempty_tag ($tagname, $contents, array $attributes=null)
static attribute ($name, $value)
static attributes (array $attributes=null)
static random_id ($base='random')
static link ($url, $text, array $attributes=null)
static checkbox ($name, $value, $checked=true, $label= '', array $attributes=null)
static select_yes_no ($name, $selected=true, array $attributes=null)
static select (array $options, $name, $selected= '', $nothing=array(''=>'choosedots'), array $attributes=null)
static select_time ($type, $name, $currenttime=0, $step=5, array $attributes=null)
static alist (array $items, array $attributes=null, $tag= 'ul')
static input_hidden_params (moodle_url $url, array $exclude=null)
static script ($jscode, $url=null)
static table (html_table $table)
static label ($text, $for, $colonize=true, array $attributes=array())

Detailed Description

Simple html output class

Definition at line 913 of file outputcomponents.php.


Member Function Documentation

static alist ( array items,
array attributes = null,
tag = 'ul' 
) [static]

Shortcut for quick making of lists

Parameters:
array$items
string$tagul or ol
array$attributes
Returns:
string

Definition at line 1244 of file outputcomponents.php.

Here is the call graph for this function:

Here is the caller graph for this function:

static attribute ( name,
value 
) [static]

Outputs a HTML attribute and value

Parameters:
string$nameThe name of the attribute ('src', 'href', 'class' etc.)
string$valueThe value of the attribute. The value will be escaped with s()
Returns:
string HTML fragment

Definition at line 974 of file outputcomponents.php.

Here is the call graph for this function:

Here is the caller graph for this function:

static attributes ( array attributes = null) [static]

Outputs a list of HTML attributes and values

Parameters:
array$attributesThe tag attributes (array('src' => $url, 'class' => 'class1') etc.) The values will be escaped with s()
Returns:
string HTML fragment

Definition at line 997 of file outputcomponents.php.

Here is the call graph for this function:

Here is the caller graph for this function:

static checkbox ( name,
value,
checked = true,
label = '',
array attributes = null 
) [static]

generates a simple checkbox with optional label

Parameters:
string$name
string$value
bool$checked
string$label
array$attributes
Returns:
string html fragment

Definition at line 1045 of file outputcomponents.php.

Here is the call graph for this function:

Here is the caller graph for this function:

static empty_tag ( tagname,
array attributes = null 
) [static]

Outputs an empty tag with attributes

Parameters:
string$tagnameThe name of tag ('input', 'img', 'br' etc.)
array$attributesThe tag attributes (array('src' => $url, 'class' => 'class1') etc.)
Returns:
string HTML fragment

Definition at line 950 of file outputcomponents.php.

Here is the call graph for this function:

static end_tag ( tagname) [static]

Outputs a closing tag

Parameters:
string$tagnameThe name of tag ('a', 'img', 'span' etc.)
Returns:
string HTML fragment

Definition at line 940 of file outputcomponents.php.

static input_hidden_params ( moodle_url url,
array exclude = null 
) [static]

Returns hidden input fields created from url parameters.

Parameters:
moodle_url$url
array$excludelist of excluded parameters
Returns:
string HTML fragment

Definition at line 1264 of file outputcomponents.php.

Here is the call graph for this function:

Here is the caller graph for this function:

static label ( text,
for,
colonize = true,
array attributes = array() 
) [static]

Renders form element label

By default, the label is suffixed with a label separator defined in the current language pack (colon by default in the English lang pack). Adding the colon can be explicitly disabled if needed. Label separators are put outside the label tag itself so they are not read by screenreaders (accessibility).

Parameter $for explicitly associates the label with a form control. When set, the value of this attribute must be the same as the value of the id attribute of the form control in the same document. When null, the label being defined is associated with the control inside the label element.

Parameters:
string$textcontent of the label tag
string | null$forid of the element this label is associated with, null for no association
bool$colonizeadd label separator (colon) to the label text, if it is not there yet
array$attributesto be inserted in the tab, for example array('accesskey' => 'a')
Returns:
string HTML of the label element

Definition at line 1548 of file outputcomponents.php.

Here is the call graph for this function:

Here is the caller graph for this function:

static link ( url,
text,
array attributes = null 
) [static]

Generates a simple html link

Parameters:
string | moodle_url$url
string$textlink txt
array$attributesextra html attributes
Returns:
string HTML fragment

Definition at line 1030 of file outputcomponents.php.

Here is the call graph for this function:

static nonempty_tag ( tagname,
contents,
array attributes = null 
) [static]

Outputs a tag, but only if the contents are not empty

Parameters:
string$tagnameThe name of tag ('a', 'img', 'span' etc.)
string$contentsWhat goes between the opening and closing tags
array$attributesThe tag attributes (array('src' => $url, 'class' => 'class1') etc.)
Returns:
string HTML fragment

Definition at line 961 of file outputcomponents.php.

Here is the call graph for this function:

Here is the caller graph for this function:

static random_id ( base = 'random') [static]

Generates random html element id.

Parameters:
string$base
Returns:
string

Definition at line 1011 of file outputcomponents.php.

Here is the caller graph for this function:

static script ( jscode,
url = null 
) [static]

Generate a script tag containing the the specified code.

Parameters:
string$jsthe JavaScript code
moodle_url|stringoptional url of the external script, $code ignored if specified
Returns:
string HTML, the code wrapped in <script> tags.

Definition at line 1286 of file outputcomponents.php.

Here is the call graph for this function:

Here is the caller graph for this function:

static select ( array options,
name,
selected = '',
nothing = array(''=>'choosedots'),
array attributes = null 
) [static]

Generates a simple select form field

Parameters:
array$optionsassociative array value=>label ex.: array(1=>'One, 2=>Two) it is also possible to specify optgroup as complex label array ex.: array(array('Odd'=>array(1=>'One', 3=>'Three)), array('Even'=>array(2=>'Two'))) array(1=>'One', '--1uniquekey'=>array('More'=>array(2=>'Two', 3=>'Three')))
string$namename of select element
string | array$selectedvalue or array of values depending on multiple attribute
array | bool$nothing,addnothing selected option, or false of not added
array$attributes- html select element attributes
Returns:
string HTML fragment

Add 'select' selector always

Definition at line 1093 of file outputcomponents.php.

Here is the call graph for this function:

Here is the caller graph for this function:

static select_time ( type,
name,
currenttime = 0,
step = 5,
array attributes = null 
) [static]

This is a shortcut for making an hour selector menu.

Parameters:
string$typeThe type of selector (years, months, days, hours, minutes)
string$namefieldname
int$currenttimeA default timestamp in GMT
int$stepminute spacing
array$attributes- html select element attributes
Returns:
HTML fragment

Definition at line 1182 of file outputcomponents.php.

Here is the call graph for this function:

Here is the caller graph for this function:

static select_yes_no ( name,
selected = true,
array attributes = null 
) [static]

Generates a simple select yes/no form field

Parameters:
string$namename of select element
bool$selected
array$attributes- html select element attributes
Returns:
string HRML fragment

Definition at line 1075 of file outputcomponents.php.

Here is the call graph for this function:

Here is the caller graph for this function:

static start_tag ( tagname,
array attributes = null 
) [static]

Outputs an opening tag with attributes

Parameters:
string$tagnameThe name of tag ('a', 'img', 'span' etc.)
array$attributesThe tag attributes (array('src' => $url, 'class' => 'class1') etc.)
Returns:
string HTML fragment

Definition at line 931 of file outputcomponents.php.

Here is the call graph for this function:

static table ( html_table table) [static]

Renders HTML table

This method may modify the passed instance by adding some default properties if they are not set yet. If this is not what you want, you should make a full clone of your data before passing them to this method. In most cases this is not an issue at all so we do not clone by default for performance and memory consumption reasons.

Parameters:
html_table$tabledata to be rendered
Returns:
string HTML code

Definition at line 1311 of file outputcomponents.php.

Here is the call graph for this function:

Here is the caller graph for this function:

static tag ( tagname,
contents,
array attributes = null 
) [static]

Outputs a tag with attributes and contents

Parameters:
string$tagnameThe name of tag ('a', 'img', 'span' etc.)
string$contentsWhat goes between the opening and closing tags
array$attributesThe tag attributes (array('src' => $url, 'class' => 'class1') etc.)
Returns:
string HTML fragment

Definition at line 921 of file outputcomponents.php.

Here is the call graph for this function:


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