Html
in package
Helper functions for outputting HTML elements.
Table of Contents
Properties
- $windowed_urls : mixed
Methods
- anchor() : string
- Create HTML link anchors.
- attributes() : string
- Compiles an array of HTML attributes into an attribute string.
- className() : string
- Convert a PHP class name to something that can be used in URLs or HTML id/class.
- email() : string
- Generates an obfuscated version of an email address.
- image() : string
- Creates a image link.
- link() : string
- Creates a link tag.
- mailto() : string
- Creates an email anchor.
- namespace() : string
- Wrap all element 'names' in a namespace.
- namespaceName() : string
- Wrap a field name in a extra name.
- script() : string
- Creates a script link.
Properties
$windowed_urls
public
static mixed
$windowed_urls
= FALSE
Methods
anchor()
Create HTML link anchors.
public
static anchor(string $uri[, string|null $title = null ][, array<string|int, mixed> $attributes = [] ][, string|null $protocol = null ][, bool $escape_title = true ]) : string
Parameters
- $uri : string
-
URL or URI string
- $title : string|null = null
-
Link text
- $attributes : array<string|int, mixed> = []
-
HTML anchor attributes
- $protocol : string|null = null
-
Non-default protocol, eg: https
- $escape_title : bool = true
-
Option to escape the title that is output
Return values
stringattributes()
Compiles an array of HTML attributes into an attribute string.
public
static attributes(string|array<string|int, mixed> $attrs) : string
Parameters
- $attrs : string|array<string|int, mixed>
-
Array of attributes
Return values
stringclassName()
Convert a PHP class name to something that can be used in URLs or HTML id/class.
public
static className(string|object $class) : string
Example: SproutModules\Controllers\BlogPostController --> 'blog-post-controller'
Parameters
- $class : string|object
Return values
stringemail()
Generates an obfuscated version of an email address.
public
static email(string $email) : string
Parameters
- $email : string
-
Email address
Return values
stringimage()
Creates a image link.
public
static image([string|array<string|int, mixed>|null $src = null ][, string|array<string|int, mixed>|null $alt = null ][, bool $index = false ]) : string
Parameters
- $src : string|array<string|int, mixed>|null = null
-
Image source, or an array of attributes
- $alt : string|array<string|int, mixed>|null = null
-
Image alt attribute, or an array of attributes
- $index : bool = false
-
Include the index_page in the link
Return values
stringlink()
Creates a link tag.
public
static link(string|array<string|int, mixed> $href, string|array<string|int, mixed> $rel, string|array<string|int, mixed> $type[, string|false $suffix = false ][, string|array<string|int, mixed>|false $media = false ][, bool $index = false ]) : string
Parameters
- $href : string|array<string|int, mixed>
-
Filename
- $rel : string|array<string|int, mixed>
-
Relationship
- $type : string|array<string|int, mixed>
-
Mimetype
- $suffix : string|false = false
-
Specifies suffix of the file
- $media : string|array<string|int, mixed>|false = false
-
Specifies on what device the document will be displayed
- $index : bool = false
-
Include the index_page in the link
Return values
stringmailto()
Creates an email anchor.
public
static mailto(string $email[, string|null $title = null ][, array<string|int, mixed>|null $attributes = null ]) : string
Parameters
- $email : string
-
Email address to send to
- $title : string|null = null
-
Link text
- $attributes : array<string|int, mixed>|null = null
-
HTML anchor attributes
Return values
stringnamespace()
Wrap all element 'names' in a namespace.
public
static namespace(string $namespace, string $html[, bool $merge = false ]) : string
Anything that matches <tag name=''>.
Parameters
- $namespace : string
- $html : string
- $merge : bool = false
-
Merge the namespace with existing names
- true: don't insert where the the name exists
- false: always insert the namespace (default)
Return values
stringnamespaceName()
Wrap a field name in a extra name.
public
static namespaceName(string $namespace, string $name[, bool $merge = true ]) : string
Basic (non-merge) examples:
ns + name => ns[name]ns + name[nest] => ns[name][nest]ns[foo] + name[nest] => ns[foo][name][nest]ns + ns => ns[ns]ns + ns[name] => ns[ns][name]
Merging examples:
ns + ns[name] => ns[name](prefix merge)ns[name] + ns[name] => ns[name](duplicate merge)ns[name] + ns[name][nest] => ns[name][nest](nested merge)ns[name] + foo[nest] => foo[name][nest](complex merge)
Parameters
- $namespace : string
- $name : string
- $merge : bool = true
-
Merge the namespace with existing names
- true: don't insert where the the name exists
- false: always insert the namespace
Return values
stringscript()
Creates a script link.
public
static script(string|array<string|int, mixed> $script[, bool $index = false ]) : string
Parameters
- $script : string|array<string|int, mixed>
-
Filename
- $index : bool = false
-
Include the index_page in the link