Base class for all Contenido HTML classes

author Timo A. Hummel

 Methods

Constructor Function Initializes the SGML open/close tags

__construct() : void

_setContent: Sets the content of the object

_setContent(\$content $content) 

Parameters

$content

\$content

string/object String with the content or an object to render.

addRequiredScript()

addRequiredScript($script) 

Parameters

$script

advances to the next ID available in the system.

advanceID() 

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.

attachEventDefinition: Attaches the code for an event

attachEventDefinition(\$sName $sName, \$sEvent $sEvent, \$sCode $sCode) 

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

Parameters

$sName

\$sName

string defines the name of the event

$sEvent

\$sEvent

string defines the event (e.g. onClick)

$sCode

\$sCode

string defines the code

attachStyleDefinition: Attaches a style definition.

attachStyleDefinition(\$sName $sName, \$sDefinition $sDefinition) : string

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;"

Parameters

$sName

\$sName

string Name for a style definition

$sDefinition

\$sDefinition

string Definition for the given entity

Returns

stringfilled SGML closing skeleton

old Constructor

cHTML() 

deprecated since CONTENIDO 4.8.16

fillCloseSkeleton: Fills the close skeleton

fillCloseSkeleton() : string

Returns

stringfilled SGML closer skeleton

fillSkeleton: Fills the open SGML tag skeleton

fillSkeleton(\$attributes $attributes) : string

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

Parameters

$attributes

\$attributes

string Attributes to set

Returns

stringfilled SGML opener skeleton

getID: returns the current ID

getID() : string

Returns

stringcurrent ID

render(): Alias for toHtml

render() : string

Returns

stringRendered HTML

setAlt: sets the alt and title attributes

setAlt(\$alt $alt) 

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

\$alt

string Text to set as the "alt" attribute

setAttribte: Sets a specific attribute

setAttribute(\$sAttributeName $sAttributeName, \$sValue $sValue) 

Parameters

$sAttributeName

\$sAttributeName

string Name of the attribute

$sValue

\$sValue

string Value of the attribute

sets the CSS class

setClass(\$class $class) 

Parameters

$class

\$class

string Text to set as the "alt" attribute

setContentlessTag()

setContentlessTag(\type $contentlessTag) 

Parameters

$contentlessTag

\type

adds an "onXXX" javascript event handler

setEvent(\$event $event, \$action $action) 

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

Parameters

$event

\$event

string Type of the event

$action

\$action

string Function or action to call (JavaScript Code)

sets the ID class

setID(\$class $id) 

Parameters

$id

\$class

string Text to set as the "id"

sets the CSS style

setStyle(\$class $style) 

Parameters

$style

\$class

string Text to set as the "alt" attribute

addStyleDefinition

setStyleDefinition(\$entity $entity, \$definition $definition) : string

deprecated name change, use attachStyleDefinition

Parameters

$entity

\$entity

string Entity to define

$definition

\$definition

string Definition for the given entity

Returns

stringfilled SGML closing skeleton

Renders the output If the tag

toHTML() 

removes an event handler

unsetEvent(\$event $event) 

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

Parameters

$event

\$event

string Type of the event

 Properties

 

Defines which JS events contain which scripts

$_aEventDefinitions 

 

Style definitions

$_aStyleDefinitions 

 

The content itself

$_content 

 

Defines if the current tag is a contentless tag

$_contentlessTag : boolean

access private
 

Defines all scripts which are required by the current element

$_requiredScripts : array

access private
 

Storage of the close SGML tag

$_skeleton_close : string

access private
 

Storage of the open SGML tag template

$_skeleton_open : string

access private
 

Storage of a single SGML tag template

$_skeleton_single : string

access private
 

Defines the style definitions

$_styledefs : string

access private
 

Defines which tag to use

$_tag : string

access private