Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

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:

diagram_white.svg

 

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
languagephp
$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

The cHTMLFormElement class represents a form element.

Specified elements:

Class

Description

HTML element

cHTMLButton

The cHTMLButton class represents a button.
<button></button>
cHTMLSelectElementcHTMLSelectElement class represents a select element.<select></select>
cHTMLOptionElementcHTMLOptionElement class represents a select option element.<option></option>
cHTMLPasswordboxcHTMLPasswordbox class represents a password form field.<input type="password" />
cHTMLHiddenFieldcHTMLHiddenField class represents a hidden form field.<input type="hidden" />
cHTMLUploadcHTMLUpload class represents a file upload element.
<input type="file" />
cHTMLTextareacHTMLTextarea class represents a textarea.<textarea></textarea>
cHTMLRadiobuttoncHTMLRadiobutton class represents a radio button.<input type="radio" />
cHTMLCheckboxcHTMLCheckbox class represents a checkbox.<input type="checkbox" />
cHTMLTextboxcHTMLTextbox class represents a textbox.<input type="text" />

 

 

 

cHTMLContentElement

The cHTMLContentElement class represents a content element.

ClassDescription
cHTMLOptgroupcHTMLOptgroup class can be used for creating optgrops.
cHTMLFieldsetcHTMLFieldset class represents a fieldset element.
cHTMLTableHeadercHTMLTableHead class represents a table head.
cHTMLSectioncHTMLSection class represents a section within an article.
cHTMLListItemcHTMLListItem class represents a list item.
cHTMLTableBodycHTMLTableBody class represents a table body.
cHTMLTimecHTMLTime class represents a date/time.
cHTMLNavcHTMLNav class represents a navigation.
cHTMLFormcHTMLForm class represents a form.
cHTMLCanvascHTMLCanvas class can be used for creating graphics.
cHTMLListcHTMLList class represents a list.
cHTMLTableDatacHTMLTableData class represents a table date.
cHTMLArticlecHTMLArticle class represents an HTML5 article element.
cHTMLSpancHTMLSpan class represents a span element.
cHTMLAside

cHTMLAside class represents content which is related to the surrounding content.

  
cHTMLLabelcHTMLLabel class represents a form label.
cHTMLLink  cHTMLLink class represents a link.cHTMLLabelcHTMLLabel class represents a form label.
  
cHTMLLegendcHTMLLegend class represents a legend element.
cHTMLScriptcHTMLScript class represents a script.
  
cHTMLParagraphcHTMLParagraph class represents a paragraph.
cHTMLHeadercHTMLHeader class represents a header.
cHTMLFooterHTMLFooter class represents a footer.
cHTMLHgroupcHTMLHgroup class represents a set of related headlines.
cHTMLDivcHTMLDiv class represents a div element.
cHTMLTableRowcHTMLTableRow class represents a table row.
cHTMLVideocHTMLVideo class represents a video.
cHTMLAudiocHTMLAudio class specifies sound content.
cHTMLTablecHTMLTable class represents a table.

 

 

 

cHTMLIFrame

 

 

cHTMLImage

 

<input type="password"