Versions Compared

Key

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

CONTENIDO HTML generation

CONTENIDO provides the feature to build html code in your php script with the use of objects. So it is possible to generate valid markup without writing the code by yourself.

The big advantage of such a central functionality is that the changes at one place effect all other usages, for example to set a default attribut in the whole CONTENIDO markup. Because of these potential it is highly recommended to use the cHTML classes to build your html code.

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

At the first inheritance level are the classes cHTMLFormElement, cHTMLContentElement, cHTMLIframe and cHTMLImage.

Complete class diagramm:

diagram_white.svg

 Methods:

 
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. All the inheritanced classes are logically grouped by the form context.

Specified elements:

cHTMLSelectElement select element
Class

Description

HTML element

cHTMLButton

The cHTMLButton class represents a button.
<button></button>
cHTMLSelectElement
cHTMLCheckboxcHTMLCheckbox class represents a checkbox.
<input type="checkbox" />
cHTMLHiddenFieldcHTMLHiddenField class represents a hidden form field.<select></select>
<input type="hidden" />
cHTMLOptionElementcHTMLOptionElement class represents a select option element.
<option></option>
cHTMLPasswordboxcHTMLPasswordbox class represents a password form field.
<input type="password" />
cHTMLHiddenFieldcHTMLRadiobuttoncHTMLHiddenField cHTMLRadiobutton class represents a hidden form fieldradio button.
<input type="
hidden
radio" />
cHTMLUploadcHTMLSelectElementcHTMLUpload cHTMLSelectElement class represents a file upload select element.<input type="file" />
<select></select>
cHTMLTextareacHTMLTextarea class represents a textarea.
<textarea></textarea>
cHTMLRadiobuttoncHTMLTextboxcHTMLRadiobutton cHTMLTextbox class represents a radio buttontextbox.
<input type="
radio
text" />
cHTMLCheckboxcHTMLUploadcHTMLCheckbox cHTMLUpload class represents a checkboxfile upload element.
<input type="
checkbox
file" />
cHTMLTextbox
cHTMLTextbox class represents a textbox.<input type="text" />

 

 

 

cHTMLContentElement

The cHTMLContentElement class represents a content element.

ClassDescriptioncHTMLOptgroup optgrops.cHTMLFieldsetcHTMLTableHead table head
cHTMLCanvas cHTMLOptgroupcHTMLCanvas class can be used for creating graphics.
<canvas></canvas>
cHTMLDiv cHTMLDiv class represents a div element.
<div></div>
cHTMLFieldset cHTMLFieldset class represents a fieldset element.cHTMLTableHeader
<fieldset></fieldset>
cHTMLFooter HTMLFooter class represents a footer.cHTMLSectioncHTMLSection
<footer></footer>
cHTMLForm cHTMLForm class represents a section within an articleform.cHTMLListItemcHTMLListItem
<form></form>
cHTMLHeader cHTMLHeader class represents a list item.cHTMLTableBodycHTMLTableBody header.
<header></header>
cHTMLHgroup cHTMLHgroup class represents a table body.cHTMLTimecHTMLTime set of related headlines.
<hgroup></hgroup>
cHTMLLabel cHTMLLabel class represents a date/time.cHTMLNavcHTMLNav form label.
<label></label>
cHTMLLegend cHTMLLegend class represents a navigation.cHTMLFormcHTMLForm legend element.
<legend></legend>
cHTMLLink cHTMLLink class represents a formlink.
cHTMLCanvascHTMLCanvas class can be used for creating graphics.
cHTMLList
<a></a>
cHTMLList cHTMLList class represents a list.cHTMLTableDatacHTMLTableData
<ul></ul>, <ol></ol>
cHTMLListItem cHTMLListItem class represents a table datelist item.
cHTMLArticlecHTMLArticle class represents an HTML5 article element.
cHTMLSpancHTMLSpan
<li></li>
cHTMLNav cHTMLNav class represents a span elementnavigation.
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"
<nav></nav>
cHTMLOptgroup cHTMLOptgroup class can be used for creating optgrops.
<optgroup></optgroup>
cHTMLParagraph cHTMLParagraph class represents a paragraph.
<p></p>
cHTMLScript cHTMLScript class represents a script.
<script></script>
cHTMLSection cHTMLSection class represents a section within an article.
<section></section>
cHTMLSpan cHTMLSpan class represents a span element.
<span></span>
cHTMLTable cHTMLTable class represents a table.
<table></table>
cHTMLTableBody cHTMLTableBody class represents a table body.
<tbody></tbody>
cHTMLTableData cHTMLTableData class represents a table date.
<td></td>
cHTMLTableHeader cHTMLTableHead class represents a table head.
<th></th>
cHTMLTime cHTMLTime class represents a date/time.
<time></time>
cHTMLVideo cHTMLVideo class represents a video.
<video></video>

 

cHTMLIFrame

The cHTMLIFrame class represents an iframe.

 

MethodDescription
setSrc(string $src)This method sets the source of the iframe.
setWidth(string $width)This method sets the width of the iframe.
setHeight(string $height)This method sets the height of the iframe.
setBorder(string $border)This method sets the border of the iframe.

cHTMLImage

The cHTMLImage class represents an image.

MethodDescription
setSrc(string $src)This method sets the source of the image.
setWidth(string $width)This method sets the width of the image.
setHeight(string $height)This method sets the height of the image.
setBorder(string $border)This method sets the border of the image.