CONTENIDO HTML generation
cHTML
The central element is the cHTML class with the elementary features to generate valid html tags including content, attributes.
Complete class diagramm:
The cHtml class provides to set ids automatically. The Ids will be in the format 'm1', the number will be incremented for every new instance. If you don´t want to use this feature it is possible to set the id manually with the public method setID(id).
Code examples:
Code Block | ||
---|---|---|
| ||
$cHtml = new cHTML(); // cHTML object has the id 'm1'; $cHtml->setId('testId'); // cHTML object has the id 'testId'; |
Method | Description | ||
---|---|---|---|
addRequiredScript($script) | Adds a required script to the current element.Scripts are not included twice. | ||
advanceID() | generate a unique id. | ||
appendStyleDefinition($property, $value) | Appends the given style definition to the HTML element. | ||
appendStyleDefinitions(array $styles) | Appends the given style definitions to the HTML element. | ||
attachEventDefinition($name, $event, $code) | Attaches the code for an event. | ||
display() | Outputs the generated markup. | ||
getAttribute($attributeName) | Returns the value of the given attribute. | ||
getAttributes($returnAsString = false) | Returns the assoc array(default) or string of attributes | ||
getID() | Returns the current ID. | ||
removeAttribute($attributeName) | Removes an attribute. | ||
render() | Alias for toHtml. | ||
setAlt($alt, $setTitle = true) | Sets the alt and title attributes. | ||
setAttribute($attributeName, $value = NULL) | Sets a specific attribute. | ||
setAttributes(array $attributes) | Sets the HTML attributes. | ||
setClass($class) | Sets the CSS class. | ||
setEvent($event, $action) | Adds an "on???" javascript event handler. | ||
setGenerateXHTML($value) | Setter for static $_generateXHTML property. | ||
setID($id) | Sets the ID class. | ||
setStyle($style) | Sets the CSS style. | ||
setTag($tag) | Sets the HTML tag. | ||
toHTML() | Generates the markup of the element. | ||
unsetEvent($event) | Removes an event handler. | ||
updateAttribute($name, $value) | Updates the passed attribute without changing the other existing attributes. | ||
updateAttributes(array $attributes) | Updates the passed attributes without changing the other existing attributes. |
At the first inheritance level are the classes cHTMLFormElement, cHTMLContentElement, cHTMLIframe and cHTMLImage.
cHTMLFormElement
cHTMLContentElement
cHTMLIFrame
cHTMLImage