src/System/Helpershtml_helper.php

CodeIgniter

An open source application development framework for PHP

This content is released under the MIT License (MIT)

Copyright (c) 2014-2019 British Columbia Institute of Technology Copyright (c) 2019 CodeIgniter Foundation

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Functions

ul()

ul(array  $list, string  $attributes = '') : string

Unordered List

Generates an HTML unordered list from an single or multi-dimensional array.

Parameters

array $list
string $attributes

HTML attributes

Returns

string

ol()

ol(array  $list, string  $attributes = '') : string

Ordered List

Generates an HTML ordered list from an single or multi-dimensional array.

Parameters

array $list
string $attributes

HTML attributes

Returns

string

_list()

_list(string  $type = 'ul', mixed  $list = array(), string  $attributes = '', integer  $depth) : string

Generates the list

Generates an HTML ordered list from an single or multi-dimensional array.

Parameters

string $type
mixed $list
string $attributes
integer $depth

Returns

string

img()

img(mixed  $src = '', boolean  $indexPage = false, mixed  $attributes = '') : string

Image

Generates an image element

Parameters

mixed $src
boolean $indexPage
mixed $attributes

Returns

string

doctype()

doctype(string  $type = 'html5') : string

Doctype

Generates a page document type declaration

Examples of valid options: html5, xhtml-11, xhtml-strict, xhtml-trans, xhtml-frame, html4-strict, html4-trans, and html4-frame. All values are saved in the doctypes config file.

Parameters

string $type

The doctype to be generated

Returns

string

script_tag()

script_tag(mixed  $src = '', boolean  $indexPage = false) : string

Script

Generates link to a JS file

Parameters

mixed $src

Script source or an array

boolean $indexPage

Should indexPage be added to the JS path

Returns

string

link_tag()

link_tag(mixed  $href = '', string  $rel = 'stylesheet', string  $type = 'text/css', string  $title = '', string  $media = '', boolean  $indexPage = false) : string

Link

Generates link to a CSS file

Parameters

mixed $href

Stylesheet href or an array

string $rel
string $type
string $title
string $media
boolean $indexPage

should indexPage be added to the CSS path.

Returns

string

video()

video(mixed  $src, string  $unsupportedMessage = '', string  $attributes = '', array  $tracks = array(), boolean  $indexPage = false) : string

Video

Generates a video element to embed videos. The video element can contain one or more video sources

Parameters

mixed $src

Either a source string or an array of sources

string $unsupportedMessage

The message to display if the media tag is not supported by the browser

string $attributes

HTML attributes

array $tracks
boolean $indexPage

Returns

string

audio()

audio(mixed  $src, string  $unsupportedMessage = '', string  $attributes = '', array  $tracks = array(), boolean  $indexPage = false) : string

Audio

Generates an audio element to embed sounds

Parameters

mixed $src

Either a source string or an array of sources

string $unsupportedMessage

The message to display if the media tag is not supported by the browser.

string $attributes

HTML attributes

array $tracks
boolean $indexPage

Returns

string

_media()

_media(string  $name, array  $types = array(), string  $unsupportedMessage = '', string  $attributes = '', array  $tracks = array()) : string

Generate media based tag

Parameters

string $name
array $types
string $unsupportedMessage

The message to display if the media tag is not supported by the browser.

string $attributes
array $tracks

Returns

string

source()

source(string  $src, string  $type = 'unknown', string  $attributes = '', boolean  $indexPage = false) : string

Source

Generates a source element that specifies multiple media resources for either audio or video element

Parameters

string $src

The path of the media resource

string $type

The MIME-type of the resource with optional codecs parameters

string $attributes

HTML attributes

boolean $indexPage

Returns

string

track()

track(string  $src, string  $kind, string  $srcLanguage, string  $label) : string

Track

Generates a track element to specify timed tracks. The tracks are formatted in WebVTT format.

Parameters

string $src

The path of the .VTT file

string $kind
string $srcLanguage
string $label

Returns

string

object()

object(string  $data, string  $type = 'unknown', string  $attributes = '', array  $params = array(), boolean  $indexPage = false) : string

Object

Generates an object element that represents the media as either image or a resource plugin such as audio, video, Java applets, ActiveX, PDF and Flash

Parameters

string $data

A resource URL

string $type

Content-type of the resource

string $attributes

HTML attributes

array $params
boolean $indexPage

Returns

string

param()

param(string  $name, string  $value, string  $type = 'ref', string  $attributes = '') : string

Param

Generates a param element that defines parameters for the object element.

Parameters

string $name

The name of the parameter

string $value

The value of the parameter

string $type

The MIME-type

string $attributes

HTML attributes

Returns

string

embed()

embed(string  $src, string  $type = 'unknown', string  $attributes = '', boolean  $indexPage = false) : string

Embed

Generates an embed element

Parameters

string $src

The path of the resource to embed

string $type

MIME-type

string $attributes

HTML attributes

boolean $indexPage

Returns

string

_has_protocol()

_has_protocol(string  $url) : false|integer

Test the protocol of a URI.

Parameters

string $url

Returns

false|integer

_space_indent()

_space_indent(integer  $depth = 2) : string

Provide space indenting.

Parameters

integer $depth

Returns

string