xplo.re Medusa Core Framework 3.2
  • Namespace
  • Class
  • Tree
  • Deprecated
  • Event
  • Todo
  • Download

Namespaces

  • Core
    • Authentication
      • Auto
        • Driver
      • Driver
    • Cache
      • Driver
    • Charset
      • Driver
    • Configuration
      • Driver
    • Controller
    • Converter
      • Driver
    • Decoder
      • Driver
    • Encoder
      • Driver
    • Env
      • Authentication
      • Locale
      • Proxy
      • Server
        • HTTP
        • Redirect
        • X
    • Exception
    • Exchange
      • Driver
    • Fault
      • Formatter
        • Driver
      • Incident
        • Exception
      • Reporter
        • Driver
    • Field
    • Filter
      • Driver
    • Formatter
      • Driver
        • coreuimarkup
          • Token
    • Hash
    • Loader
    • Locale
    • Log
      • Driver
    • Module
      • Dependency
        • Requirement
          • Core
          • PHP
      • Linkage
        • Driver
    • PDF
    • Plugin
    • Query
      • Driver
    • Server
      • Driver
    • Session
      • Driver
    • Set
    • Storage
      • Driver
      • Field
        • Element
    • Stream
      • Driver
    • String
    • Translation
      • Driver
      • Language
        • Driver
    • Type
    • URI
      • Driver
    • Version
    • View
      • Driver
        • coreui
          • Control
            • Button
            • Table
          • Element
        • htmlbuilder
          • Tags
        • yui
          • Modules
  • None
  • PHP

Classes

  • Control
  • Element

Interfaces

  • Dynamo

Class Element

HTML element node.

An element can have an arbitrary number of child nodes. Child nodes are either other elements, controls, plain text or values that are converted to strings when the element is rendered as HTML.

Core\Object implements Core\Chainable
Extended by Core\Set implements Core\Accessor
Extended by Core\View\Driver\coreui\Element implements ArrayAccess, Countable

Direct known subclasses

Core\View\Driver\coreui\Element\A, Core\View\Driver\coreui\Element\COL, Core\View\Driver\coreui\Element\LEGEND, Core\View\Driver\coreui\Element\LI, Core\View\Driver\coreui\Element\LINK, Core\View\Driver\coreui\Element\META, Core\View\Driver\coreui\Element\OBJECT, Core\View\Driver\coreui\Element\OL, Core\View\Driver\coreui\Element\OPTGROUP, Core\View\Driver\coreui\Element\P, Core\View\Driver\coreui\Element\PARAM, Core\View\Driver\coreui\Element\SCRIPT, Core\View\Driver\coreui\Element\COLGROUP, Core\View\Driver\coreui\Element\SELECT, Core\View\Driver\coreui\Element\SOURCE, Core\View\Driver\coreui\Element\TABLE, Core\View\Driver\coreui\Element\TD, Core\View\Driver\coreui\Element\TEXTAREA, Core\View\Driver\coreui\Element\TH, Core\View\Driver\coreui\Element\TR, Core\View\Driver\coreui\Element\UL, Core\View\Driver\coreui\Element\VIDEO, Core\View\Driver\coreui\Element\DIV, Core\View\Driver\coreui\Element\FIELDSET, Core\View\Driver\coreui\Element\FORM, Core\View\Driver\coreui\Element\IFRAME, Core\View\Driver\coreui\Element\IMG, Core\View\Driver\coreui\Element\INPUT, Core\View\Driver\coreui\Element\LABEL

Indirect known subclasses

Core\View\Driver\coreui\Element\BUTTON, Core\View\Driver\coreui\Element\TBODY, Core\View\Driver\coreui\Element\TFOOT, Core\View\Driver\coreui\Element\THEAD

Namespace: Core\View\Driver\coreui
Package: CoreUI\Element
Since: 3.1
Requires: PHP 5.3
Version: 1.0
Located at View/Driver/coreui/Element.inc.php

Methods summary

public
# __clone( )

Creates deep clones of properties and resets the ID attribute.

Creates deep clones of properties and resets the ID attribute.

Since

3.1
protected
# __construct( Core\View\Driver\coreui $proxy, string $type, string $subType, array $extraArguments = null )

Element constructor.

Element constructor.

Parameters

$proxy
CoreUI proxy instance that created this element instance.
$type
HTML tag name of element.
$subType
Specification of HTML tag, i.e. the type of an input.
$extraArguments
Array of additional arguments passed on from the factory method.

Since

3.1
public string
# __toString( )

Renders the HTML code for the element.

Renders the HTML code for the element.

Returns

string
Generated HTML code for the element.

Since

3.1

Overrides

Core\Object::__toString
public
# addClass( string $class )

Adds a CSS class.

Adds a CSS class.

Parameters

$class
CSS class name to add to element.

Returns


$this

Since

3.1
public
# addClasses( array $classes = null )

Adds an array of CSS classes.

Adds an array of CSS classes.

Parameters

$classes
Array of css class names to add to element.

Returns


$this

Since

3.1
public Core\View\Driver\coreui\Element|Core\View\Driver\coreui\Control
# append( Core\View\Driver\coreui\Element|Core\View\Driver\coreui\Control|string $element )

Appends a new element or control to the list of child nodes.

Appends a new element or control to the list of child nodes.

Parameters

$element

Element or control instance to add. If a string is given, a new instance is created by delegating the call to the proxy view by calling the Core\View\Driver\coreui\coreui::spawn() method.

Returns

Core\View\Driver\coreui\Element|Core\View\Driver\coreui\Control
The element that was added to the list of children.

Since

3.1
public
# cdata( string $string )

Adds a new CDATA node to the list of child nodes.

Adds a new CDATA node to the list of child nodes.

Parameters

$string
Text to add wrapped in a CDATA node.

Returns


$this

Since

3.1
public
# clear( )

Removes all child nodes from the element.

Removes all child nodes from the element.

Returns


$this

Since

3.1
public integer
# count( )

Returns the number of child nodes.

Returns the number of child nodes.

Returns

integer
Number of child nodes.

Since

3.1

Implementation of

Countable::count()
public static Core\View\Driver\coreui\Element
# derive( Core\View\Driver\coreui $proxy, string $description )

Element factory.

Element factory.

Parameters

$proxy
CoreUI proxy instance that creates the new element.
$description

Description string for the new element. Contains the tag name plus an optional sub-type separated by a plus sign and followed by a whitespace or comma-separated list of class names and finally an arbitrary number of attributes separated by a slash in the form "key=value". Example:

Element::derive($proxy, 'input+text/left highlight/minlength=2/maxlength=10', 'username', 'Ardy');

In the example an input text box of type "text" is created with the CSS classes "left" and "highlight" and the attributes "minlength" set to 2 and "maxlength" set to 10.

Additionally, depending on the element being created, further arguments are passed verbatim to the element constructor. In the given example, input elements accept two additional arguments: a name and a value. These are automatically set by the constructor to "username" and "Ardy", respectively, using the corresponding setters.

Returns

Core\View\Driver\coreui\Element

Since

3.1
public
# extend( Core\View\Driver\coreui\Element|Core\View\Driver\coreui\Control|string $element )

Appends a new child node but returns an instance to this element instead.

Appends a new child node but returns an instance to this element instead.

Parameters

$element
See Core\View\Driver\coreui\Element::append().

Returns


$this

Since

3.1
public string
# id( )

Returns an automatically assigned ID for the element. The ID is generated on first request and buffered by the element. An ID is unique per instance and automatically reset if an element is cloned.

Returns an automatically assigned ID for the element. The ID is generated on first request and buffered by the element. An ID is unique per instance and automatically reset if an element is cloned.

If the ID of an element is required but accessed for the first time after the element was rendered, the rendered element does not have an ID set. In that case call this method before rendering the element.

Returns

string
ID of element. Currently equals a random v4 UUID.

Since

3.1
public Core\View\Driver\coreui\Element|Core\View\Driver\coreui\Control
# insertAt( integer $index, Core\View\Driver\coreui\Element|Core\View\Driver\coreui\Control|string $element )

Inserts a new child node at a specified position. The node previously occupying the specified position will be moved to the next position.

Inserts a new child node at a specified position. The node previously occupying the specified position will be moved to the next position.

Parameters

$index

Offset to insert new element at. If negative, the offset is calculated from the end of the list of child nodes.

$element
See Core\View\Driver\coreui\Element::append().

Returns

Core\View\Driver\coreui\Element|Core\View\Driver\coreui\Control
The element that was added to the list of child nodes.

Since

3.1
public boolean
# issetStyle( string $styleName )

Tests, whether a specified style attribute is set.

Tests, whether a specified style attribute is set.

Parameters

$styleName
Name of style attribute to test for.

Returns

boolean

true, if a value is set for the specified style attribute, otherwise false.

Since

3.1
public boolean
# hasAttribute( string $attributeName )

Tests, whether a specified attribute is set.

Tests, whether a specified attribute is set.

Parameters

$attributeName
Name of attribute to test for.

Returns

boolean
true, if the specified attribute is set, otherwise false.

Since

3.1
public boolean
# hasClass( string $class )

Tests, whether the specified CSS class is set.

Tests, whether the specified CSS class is set.

Parameters

$class
Name of CSS class to test for.

Returns

boolean
true, if the specified class is set for the element, otherwise false.

Since

3.1
public
# hide( )

Hides the element from view by setting the display style attribute to "none".

Hides the element from view by setting the display style attribute to "none".

Returns


$this

Since

3.1
public boolean
# offsetExists( mixed $offset )

Tests, whether a given offset is valid for the list of child nodes.

Tests, whether a given offset is valid for the list of child nodes.

Parameters

$offset
Offset to check for.

Returns

boolean

true, if the offset is valid for the list of child nodes, otherwise false.

Since

3.1

Implementation of

ArrayAccess::offsetExists()
public Core\View\Driver\coreui\Element|Core\View\Driver\coreui\Control
# offsetGet( mixed $offset )

Retrieves a child node based on a given offset.

Retrieves a child node based on a given offset.

Parameters

$offset
Child node offset to retrieve.

Returns

Core\View\Driver\coreui\Element|Core\View\Driver\coreui\Control
Child node at given offset.

Since

3.1

Implementation of

ArrayAccess::offsetGet()
public
# offsetSet( mixed $offset, mixed $value )

Overwrites, sets or appends a child node.

Overwrites, sets or appends a child node.

Used to provide array-style append syntax for new child node:

$childNode = ...;

// Append new child node to element.
$element [] = $childNode;

Parameters

$offset

Offset of child node to overwrite or set. If null, the child node is appended to the end.

$value
Child node to set.

Since

3.1

Implementation of

ArrayAccess::offsetSet()
public
# offsetUnset( mixed $offset )

Removes a child node at a given offset.

Removes a child node at a given offset.

Parameters

$offset
Offset to remove child node at.

Since

3.1

Implementation of

ArrayAccess::offsetUnset()
public
# on( string $event, string $action )

Attaches an event handler to the element.

Attaches an event handler to the element.

Parameters

$event
Name of event to attach event handler to (without "on" prefix).
$action

JavaScript code block to handle event. The code will be put inside a function with a single argument e that represents the event.

Returns


$this

Since

3.1
public mixed
# pop( )

Removes the last child node and returns it.

Removes the last child node and returns it.

Returns

mixed

Child node removed from list of child nodes or null if the list of child nodes is empty.

Since

3.1
public
# push( mixed $value )

Appends an existing child node to the list of child nodes.

Appends an existing child node to the list of child nodes.

Parameters

$value
Child node to add to end of list of child nodes.

Returns


$this

Since

3.1
public
# removeClass( string $class )

Removes a CSS class.

Removes a CSS class.

Parameters

$class
Name of CSS class to remove.

Returns


$this

Since

3.1
public
# setAttribute( string $key, string $value )

Sets a HTML attribute.

Sets a HTML attribute.

Parameters

$key
Name of HTML key to set.
$value
Attribute value to set.

Returns


$this

Since

3.1
public
# setAttributes( array $attributes = null )

Sets an array of HTML attributes.

Sets an array of HTML attributes.

Parameters

$attributes
Associative array of attributes and their values to set.

Returns


$this

Since

3.1
public
# setStyle( string|array $style )

Sets style attributes.

Sets style attributes.

Does not overwrite all style attributes but merges the existing set of style attributes with the new style attributes and values.

Parameters

$style

Either associative array of style attributes with their values, or a string of CSS style definitions that is automatically parsed by this method.

Returns


$this

Since

3.1
public
# setTitle( string $title )

Sets the HTML title attribute.

Sets the HTML title attribute.

Parameters

$title
Title to set or null to remove the attribute.

Returns


$this

Since

3.1
public mixed
# shift( )

Removes a child node from the beginning of the list of child nodes and returns it.

Removes a child node from the beginning of the list of child nodes and returns it.

Returns

mixed
Child node removed from beginning of the list of child nodes.

Since

3.1
public
# text( string $text )

Appends a new text node to the list of child nodes.

Appends a new text node to the list of child nodes.

Parameters

$text

Text to append to list of child nodes. The text is automatically encoded using the currently set $encoder.

Returns


$this

Since

3.1
public
# unShift( mixed $value )

Prepends an existing child node to the list of child nodes.

Prepends an existing child node to the list of child nodes.

Parameters

$value
Child node to prepend to the list of child nodes.

Returns


$this

Since

3.1
public
# verbatim( mixed $value )

Appends a given arbitrary value verbatim to the list of child nodes.

Appends a given arbitrary value verbatim to the list of child nodes.

Parameters

$value
Value to append to the list of child nodes.

Returns


$this

Since

3.1

Methods inherited from Core\Set

__get(), __isset()

Methods inherited from Core\Object

__autocreateFactory(), __call(), __processParameters(), attachMethod(), chain(), getValueForKey(), getValueForKeyPath(), getValueForUndefinedKey(), hash(), issetValueForKey(), setValueForKey(), setValueForKeyPath(), setValueForUndefinedKey(), uuid()

Constants summary

boolean AllowsInnerNL

If set, the rendering of the HTML tag represented by the element is not affected by newlines inside the tag.

If set, the rendering of the HTML tag represented by the element is not affected by newlines inside the tag.

Since

3.1
# false
boolean AllowsOuterNL

If set, the rendering of the HTML tag represented by the element is not affected by newlines outside the tag.

If set, the rendering of the HTML tag represented by the element is not affected by newlines outside the tag.

Since

3.1
# false
boolean AllowsShortTag

If set, the HTML tag represented by the element allows short tag notion.

If set, the HTML tag represented by the element allows short tag notion.

Since

3.1
# true

Constants inherited from Core\Object

AnyParameterType, AutochainParameterType, AutocreateParameterType, BooleanParameterType, CharParameterType, EnumParameterType, IntegerParameterType, RealParameterType, StringParameterType, UserParameterType

Properties summary

protected Core\Hash $_v_attributes

Hash of element attributes.

Hash of element attributes.

Since

3.1
#
protected mixed[] $_v_children

Array of child nodes.

Array of child nodes.

Since

3.1
#
protected Core\Hash $_v_classes

Hash of assigned CSS classes.

Hash of assigned CSS classes.

Since

3.1
#
protected Core\View\Driver\coreui $_v_proxy

CoreUI proxy driver instance.

CoreUI proxy driver instance.

Since

3.1
#
protected Core\Hash $_v_styles

Hash of inline styles.

Hash of inline styles.

Since

3.1
#
protected string $_v_type

HTML tag name.

HTML tag name.

Since

3.1
#
protected string $_id

Buffered ID of element, automatically generated by the Core\View\Driver\coreui\Element::id() method. Set on first request.

Buffered ID of element, automatically generated by the Core\View\Driver\coreui\Element::id() method. Set on first request.

Since

3.1
#

Magic properties

public read-only Core\Hash $attributes

Associative array of HTML element attributes.

public read-only Core\Hash $classes

Hash of assigned CSS classes.

public read-only integer $count

Number of child nodes.

public read-only string $id

Unique ID of element instance. Automatically generated for each instance, cloned elements will also receive a new ID.

public read-only Core\View\Driver\coreui $proxy

CoreUI proxy driver instance.

public read-only Core\Hash $styles

Hash of inline styles.

public read-only string $type

HTML tag name.

Magic properties inherited from Core\Object

$hash, $uuid

xplo.re Medusa Core Framework 3.2 API documentation generated by ApiGen