\Horde_View_Helper_Tag

Use these methods to generate HTML tags programmatically.

By default, they output HTML 4.01 Strict compliant tags.

Summary

Methods
Properties
Constants
__construct()
__get()
__set()
__call()
tag()
contentTag()
cdataSection()
escape()
escapeOnce()
tagOptions()
No public properties found
No constants found
No protected methods found
$_view
N/A
_fixDoubleEscape()
$_booleanAttributes
N/A

Properties

$_view

$_view : \Horde_View

The parent view invoking the helper.

Type

\Horde_View

$_booleanAttributes

$_booleanAttributes : array

Boolean HTML attributes.

Type

array

Methods

__construct()

__construct(\Horde_View  $view) 

Creates a helper for $view.

Parameters

\Horde_View $view

The view to help.

__get()

__get(  $name) 

Proxy on undefined property access (get).

Parameters

$name

__set()

__set(  $name,   $value) 

Proxy on undefined property access (set).

Parameters

$name
$value

__call()

__call(string  $method, array  $args) : mixed

Call chaining so members of the view can be called (including other helpers).

Parameters

string $method

The method.

array $args

The parameters for the method.

Returns

mixed —

The result of the method.

tag()

tag(string  $name, string  $options = null) : string

Returns an empty HTML tag of type $name.

Add HTML attributes by passing an attributes hash to $options. For attributes with no value (like disabled and readonly), give it a value of TRUE in the $options array.

$this->tag('br') // =>
$this->tag('input', array('type' => 'text', 'disabled' => true)) // =>

Parameters

string $name

Tag name.

string $options

Tag attributes.

Returns

string —

Generated HTML tag.

contentTag()

contentTag(string  $name, string  $content, array  $options = null) : string

Returns an HTML block tag of type $name surrounding the $content.

Add HTML attributes by passing an attributes hash to $options. For attributes with no value (like disabled and readonly), give it a value of TRUE in the $options array.

$this->contentTag('p', 'Hello world!') // =>

Hello world!

$this->contentTag('div', $this->contentTag('p', 'Hello world!'), array('class' => 'strong')) // =>

Hello world!

$this->contentTag('select', $options, array('multiple' => true)) // =>

Parameters

string $name

Tag name.

string $content

Content to place between the tags.

array $options

Tag attributes.

Returns

string —

Generated HTML tags with content between.

cdataSection()

cdataSection(string  $content) : string

Returns a CDATA section with the given $content.

CDATA sections are used to escape blocks of text containing characters which would otherwise be recognized as markup. CDATA sections begin with the string "<![CDATA[" and end with (and may not contain) the string "]]>".

$this->cdataSection(''); // => <![CDATA[]]>

Parameters

string $content

Content for inside CDATA section.

Returns

string —

CDATA section with content.

escape()

escape(string  $var) : string

Escapes a value for output in a view template.

escape($this->templateVar) ?>

Parameters

string $var

The output to escape.

Returns

string —

The escaped value.

escapeOnce()

escapeOnce(string  $html) : string

Returns the escaped $html without affecting existing escaped entities.

$this->escapeOnce('1 > 2 & 3') // => '1 < 2 & 3'

Parameters

string $html

HTML to be escaped.

Returns

string —

Escaped HTML without affecting existing escaped entities.

tagOptions()

tagOptions(array  $options) : string

Converts an associative array of $options into a string of HTML attributes.

Parameters

array $options

Key/value pairs.

Returns

string —

'key1="value1" key2="value2"'

_fixDoubleEscape()

_fixDoubleEscape(string  $escaped) : string

Fix double-escaped entities, such as &amp;amp;, &amp;#123;, etc.

Parameters

string $escaped

Double-escaped entities.

Returns

string —

Entities fixed.