Moodle PHP Documentation 4.5
Moodle 4.5dev (Build: 20240606) (d3ae1391abe)
|
Simple html output class. More...
Static Public Member Functions | |
static | alist (array $items, array $attributes=null, $tag='ul') |
Shortcut for quick making of lists. | |
static | attribute ($name, $value) |
Outputs a HTML attribute and value. | |
static | attributes (array $attributes=null) |
Outputs a list of HTML attributes and values. | |
static | checkbox ($name, $value, $checked=true, $label='', array $attributes=null, array $labelattributes=null) |
Generates a simple checkbox with optional label. | |
static | div ($content, $class='', array $attributes=null) |
Creates a. | |
static | empty_tag ($tagname, array $attributes=null) |
Outputs an empty tag with attributes. | |
static | end_div () |
Ends a. | |
static | end_span () |
Ends a tag. | |
static | end_tag ($tagname) |
Outputs a closing tag. | |
static | img ($src, $alt, array $attributes=null) |
Generates a simple image tag with attributes. | |
static | input_hidden_params (moodle_url $url, array $exclude=null) |
Returns hidden input fields created from url parameters. | |
static | label ($text, $for, $colonize=true, array $attributes=array()) |
Renders form element label. | |
static | link ($url, $text, array $attributes=null) |
Generates a simple html link. | |
static | nonempty_tag ($tagname, $contents, array $attributes=null) |
Outputs a tag, but only if the contents are not empty. | |
static | random_id ($base='random') |
Generates random html element id. | |
static | script ($jscode, $url=null) |
Generate a script tag containing the the specified code. | |
static | select (array $options, $name, $selected='', $nothing=array(''=> 'choosedots'), array $attributes=null) |
Generates a simple select form field. | |
static | select_time ($type, $name, $currenttime=0, $step=5, array $attributes=null, $timezone=99) |
This is a shortcut for making an hour selector menu. | |
static | select_yes_no ($name, $selected=true, array $attributes=null) |
Generates a simple select yes/no form field. | |
static | span ($content, $class='', array $attributes=null) |
Creates a tag. | |
static | start_div ($class='', array $attributes=null) |
Starts a. | |
static | start_span ($class='', array $attributes=null) |
Starts a tag. | |
static | start_tag ($tagname, array $attributes=null) |
Outputs an opening tag with attributes. | |
static | table (html_table $table) |
Renders HTML table. | |
static | tag ($tagname, $contents, array $attributes=null) |
Outputs a tag with attributes and contents. | |
Simple html output class.
|
static |
Shortcut for quick making of lists.
Note: 'list' is a reserved keyword ;-)
array | $items | |
array | $attributes | |
string | $tag | ul or ol |
string |
|
static |
Outputs a HTML attribute and value.
string | $name | The name of the attribute ('src', 'href', 'class' etc.) |
string | $value | The value of the attribute. The value will be escaped with s() |
string | HTML fragment |
|
static |
Outputs a list of HTML attributes and values.
array | $attributes | The tag attributes (array('src' => $url, 'class' => 'class1') etc.) The values will be escaped with s() |
string | HTML fragment |
|
static |
Generates a simple checkbox with optional label.
string | $name | The name of the checkbox |
string | $value | The value of the checkbox |
bool | $checked | Whether the checkbox is checked |
string | $label | The label for the checkbox |
array | $attributes | Any attributes to apply to the checkbox |
array | $labelattributes | Any attributes to apply to the label, if present |
string | html fragment |
|
static |
Creates a.
string | $content | HTML content of tag |
string | $class | Optional CSS class (or classes as space-separated list) |
array | $attributes | Optional other attributes as array |
string | HTML code for div |
|
static |
Outputs an empty tag with attributes.
string | $tagname | The name of tag ('input', 'img', 'br' etc.) |
array | $attributes | The tag attributes (array('src' => $url, 'class' => 'class1') etc.) |
string | HTML fragment |
|
static |
Ends a.
string | HTML code for close div tag |
|
static |
Ends a tag.
(Shortcut function.)
string | HTML code for close span tag |
|
static |
Outputs a closing tag.
string | $tagname | The name of tag ('a', 'img', 'span' etc.) |
string | HTML fragment |
|
static |
Generates a simple image tag with attributes.
string | $src | The source of image |
string | $alt | The alternate text for image |
array | $attributes | The tag attributes (array('height' => $max_height, 'class' => 'class1') etc.) |
string | HTML fragment |
|
static |
Returns hidden input fields created from url parameters.
moodle_url | $url | |
array | $exclude | list of excluded parameters |
string | HTML fragment |
|
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.
string | $text | content of the label tag |
string | null | $for | id of the element this label is associated with, null for no association |
bool | $colonize | add label separator (colon) to the label text, if it is not there yet |
array | $attributes | to be inserted in the tab, for example array('accesskey' => 'a') |
string | HTML of the label element |
|
static |
Generates a simple html link.
string | moodle_url | $url | The URL |
string | $text | The text |
array | $attributes | HTML attributes |
string | HTML fragment |
|
static |
Outputs a tag, but only if the contents are not empty.
string | $tagname | The name of tag ('a', 'img', 'span' etc.) |
string | $contents | What goes between the opening and closing tags |
array | $attributes | The tag attributes (array('src' => $url, 'class' => 'class1') etc.) |
string | HTML fragment |
|
static |
Generates random html element id.
@staticvar int $counter @staticvar string $uniq
string | $base | A string fragment that will be included in the random ID. |
string | A unique ID |
|
static |
Generate a script tag containing the the specified code.
string | $jscode | the JavaScript code |
moodle_url | string | $url | optional url of the external script, $code ignored if specified |
string | HTML, the code wrapped in <script> tags. |
|
static |
Generates a simple select form field.
Note this function does HTML escaping on the optgroup labels, but not on the choice labels.
array | $options | associative 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 | $name | name of select element |
string | array | $selected | value or array of values depending on multiple attribute |
array | bool | null | $nothing | add nothing selected option, or false of not added |
array | $attributes | html select element attributes |
string | HTML fragment |
|
static |
This is a shortcut for making an hour selector menu.
string | HTML fragment |
|
static |
Generates a simple select yes/no form field.
string | $name | name of select element |
bool | $selected | |
array | $attributes | - html select element attributes |
string | HTML fragment |
|
static |
Creates a tag.
(Shortcut function.)
string | $content | HTML content of tag |
string | $class | Optional CSS class (or classes as space-separated list) |
array | $attributes | Optional other attributes as array |
string | HTML code for span |
|
static |
Starts a.
string | $class | Optional CSS class (or classes as space-separated list) |
array | $attributes | Optional other attributes as array |
string | HTML code for open div tag |
|
static |
Starts a tag.
(Shortcut function.)
string | $class | Optional CSS class (or classes as space-separated list) |
array | $attributes | Optional other attributes as array |
string | HTML code for open span tag |
|
static |
Outputs an opening tag with attributes.
string | $tagname | The name of tag ('a', 'img', 'span' etc.) |
array | $attributes | The tag attributes (array('src' => $url, 'class' => 'class1') etc.) |
string | HTML fragment |
|
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.
html_table | $table | data to be rendered |
string | HTML code |
|
static |
Outputs a tag with attributes and contents.
string | $tagname | The name of tag ('a', 'img', 'span' etc.) |
string | $contents | What goes between the opening and closing tags |
array | $attributes | The tag attributes (array('src' => $url, 'class' => 'class1') etc.) |
string | HTML fragment |