Cradle  0.3.3
Simple library for creating Web-based applications
Html Class Reference

Digger HTML Class. More...

Static Public Member Functions

static arrayToList ($array, $listType='ul', $arrayAttributes=null, $callback=null)
 
static getElement ($tag, $body='', $arrayAttributes=null, $callback=null)
 

Detailed Description

Digger HTML Class.

Class for HTML represents of data.

Version
3.0
Author
Digger mrdig.nosp@m.ger@.nosp@m.sad-s.nosp@m.yste.nosp@m.ms.ru

Member Function Documentation

static arrayToList (   $array,
  $listType = 'ul',
  $arrayAttributes = null,
  $callback = null 
)
static

To creates a simple HTML list from an input array.

Parameters
array$arrayInput array.
string$listType(Option) Type of main tag (UL | OL)
array$arrayAttributesArray of attributes of main tag: ['class' => '...', 'id' => ... ]
function$callbackCallback function (on befor create item)
See also
getElement
Returns
string HTML code.

Example:

echo Html::arrayToList(['a'=>['b'=>['c'=>'value']]], 'ul', ['id'=>'myID1', 'class'=>'myclass']);
//--- Output:
<ul id="myID1" class="myclass">
<li>a
<ul>
<li>b
<ul>
<li>value</li>
</ul>
</li>
</ul>
</li>
</ul>
static getElement (   $tag,
  $body = '',
  $arrayAttributes = null,
  $callback = null 
)
static

To create an html element

Parameters
string$tagHtml tag name (a, ul, li ...)
string$bodyIt is a text will be placed inside the tag.
array$arrayAttributesArray of tag attributes: ['class' => '...', 'id' => ... ]
function$callbackThis function will be called with given parameters: $tag, $body, $arrayAttributes that can be changed before creating the element.
Returns
string HTML code.

Example:

echo Html::getElement('a', 'my link', ['href' => 'http://somewere'], function(&$tag, &$body, &$attr){ $body .= '... some body ...'; $attr['class']='new class'; });
//--- Output:
<a href="http://somewere" class="new class">my link... some body ...</a>

The documentation for this class was generated from the following file: