Base class for all CONTENIDO HTML classes

package Core
subpackage Frontend

 Methods

Constructor Function.

__construct(array $attributes) : void

Parameters

$attributes

array

Associative array of table tag attributes

Direct call of object as string will return it's generated markup.

__toString() : string

Returns

stringGenerated markup

Adds a required script to the current element.

addRequiredScript(string $script) : \cHTML

Anyway, scripts are not included twice.

Parameters

$script

string

the script to include

Returns

\cHTML$this

Advances to the next ID available in the system.

advanceID() : \cHTML

This function is useful if you need to use HTML elements in a loop, but don't want to re-create new objects each time.

Returns

\cHTML$this

Appends the given style definition to the HTML element.

appendStyleDefinition(string $property, string $value) : \cHTML

Example usage: $element->appendStyleDefinition('margin', '5px');

Parameters

$property

string

the property name, e.g. 'margin'

$value

string

the value of the property, e.g. '5px'

Returns

\cHTML$this

Appends the given style definitions to the HTML element.

appendStyleDefinitions(array $styles) : \cHTML

Example usage: $element->appendStyleDefinitions(array( 'margin' => '5px', 'padding' => '0' ));

Parameters

$styles

string

the styles to append

Returns

\cHTML$this

Attaches the code for an event

attachEventDefinition(string $name, string $event, string $code) : \cHTML

Example to attach an onClick handler: attachEventDefinition('foo', 'onClick', 'alert("foo");');

Parameters

$name

string

Defines the name of the event

$event

string

Defines the event (e.g. onClick)

$code

string

Defines the code

Returns

\cHTML$this

Attaches a style definition.

attachStyleDefinition(string $name, string $definition) : \cHTML

This function is not restricted to a single style, e.g. you can set multiple style definitions as-is to the handler.

$example->attachStyle('myIdentifier', 'border: 1px solid black; white-space: nowrap'); $example->attachStyle('myIdentifier2', 'padding: 0px');

Results in:

style="border: 1px solid black; white-space: nowrap; padding: 0px;"

deprecated [2012-07-23] Set the definition via appendStyleDefinition and do not use a name any more

Parameters

$name

string

Name for a style definition

$definition

string

Definition for the given entity

Returns

\cHTML$this

cHTML()

cHTML() 
deprecated [2012-01-19] use __construct instead

Outputs the generated markup

display() 

Fills the close skeleton

fillCloseSkeleton() : string

Returns

stringfilled SGML closer skeleton

Fills the open SGML tag skeleton

fillSkeleton(string $attributes) : string

fillSkeleton fills the SGML opener tag with the specified attributes. Attributes need to be passed in the stringyfied variant.

Parameters

$attributes

string

Attributes to set

Returns

stringfilled SGML opener skeleton

Returns the value of the given attribute.

getAttribute(string $attributeName) : string

Parameters

$attributeName

string

Attribute name

Returns

stringnull value or null if the attribute does not exist

Returns the assoc array(default) or string of attributes

getAttributes(bool $returnAsString) : array

Parameters

$returnAsString

bool

Whether to return the attributes as string

Returns

arraystring

Returns the current ID

getID() : string

Returns

stringcurrent ID

Removes an attribute

removeAttribute(string $attributeName) : \cHTML

Parameters

$attributeName

string

Attribute name

Returns

\cHTML$this

Alias for toHtml

render() : string

Returns

stringGenerated markup

Sets the alt and title attributes

setAlt(string $alt) : \cHTML

Sets the "alt" and "title" tags. Usually, "alt" is used for accessibility and "title" for mouse overs.

To set the text for all browsers for mouse over, set "alt" and "title". IE behaves incorrectly and shows "alt" on mouse over. Mozilla browsers only show "title" as mouse over.

Parameters

$alt

string

Text to set as the "alt" and "title" attribute

Returns

\cHTML$this

Sets a specific attribute

setAttribute(string $attributeName, string $value) : \cHTML

Parameters

$attributeName

string

Name of the attribute

$value

string

Value of the attribute

Returns

\cHTML$this

Sets the HTML attributes

setAttributes(array $attributes) : \cHTML

Parameters

$attributes

array

Associative array with attributes

Returns

\cHTML$this

Sets the CSS class

setClass(string $class) : \cHTML

Parameters

$class

string

Text to set as the "class" attribute

Returns

\cHTML$this

Contentless tag setter

setContentlessTag(bool $contentlessTag) : \cHTML
deprecated [2012-07-20] use $this->_contentLess directly or just use setContent() - this function sets the contentLess attribute to false

Parameters

$contentlessTag

bool

Returns

\cHTML$this

Adds an "on???" javascript event handler

setEvent(string $event, string $action) : \cHTML

example: $item->setEvent('change','document.forms[0].submit');

Parameters

$event

string

Type of the event, e. g. "change" for "onchange"

$action

string

Function or action to call (JavaScript Code)

Returns

\cHTML$this

Setter for static $_generateXHTML property

setGenerateXHTML(bool $value) 
Static

Parameters

$value

bool

Sets the ID class

setID(string $id) : \cHTML

Parameters

$id

string

Text to set as the "id"

Returns

\cHTML$this

Sets the CSS style

setStyle(string $style) : \cHTML

Parameters

$style

string

Text to set as the "style" attribute

Returns

\cHTML$this

setStyleDefinition()

setStyleDefinition(string $entity, string $definition) : \cHTML
deprecated [2012-07-23] name change, use appendStyleDefinition

Parameters

$entity

string

Entity to define

$definition

string

Definition for the given entity

Returns

\cHTML$this

Sets the HTML tag to $tag

setTag(string $tag) : \cHTML

Parameters

$tag

string

The new tag

Returns

\cHTML$this

Generates the markup of the element

toHTML() : string

Returns

stringGenerated markup

Removes an event handler

unsetEvent(string $event) : \cHTML

example: $item->unsetEvent('change');

Parameters

$event

string

Type of the event

Returns

\cHTML$this

Updates the passed attribute without changing the other existing attributes

updateAttribute(string $name, string $value) : \cHTML

Parameters

$name

string

the name of the attribute

$value

string

the value of the attribute with the given name

Returns

\cHTML$this

Updates the passed attributes without changing the other existing attributes

updateAttributes(array $attributes) : \cHTML

Parameters

$attributes

array

Associative array with attributes

Returns

\cHTML$this

Adds the given content to the already existing content of this object.

_appendContent(string | object | array $content) : \cHTML

Parameters

$content

stringobjectarray

String with the content or an object to render or an array of strings/objects.

Returns

\cHTML$this

Returns an HTML formatted attribute string

_getAttrString(array $attributes) : string

Parameters

$attributes

array

Associative array with attributes

Returns

stringAttribute string in HTML format

Returns a valid atrributes array.

_parseAttributes(array $attributes) : array

Parameters

$attributes

array

Associative array with attributes

Returns

arraythe parsed attributes

Sets the content of the object

_setContent(string | object | array $content) : \cHTML

Parameters

$content

stringobjectarray

String with the content or a cHTML object to render or an array of strings / objects.

Returns

\cHTML$this

 Properties

 

$_attributes : array
 

$_content : string
 

$_contentlessTag : bool
 

$_eventDefinitions : array
 

$_generateXHTML : bool
 

$_idCounter : int
 

$_requiredScripts : array
 

$_skeletonClose : string
 

$_skeletonOpen : string
 

$_skeletonSingle : string
 

$_styleDefinitions : array
 

$_styleDefs : array
 

$_tag : string