View Source

<ac:macro ac:name="unmigrated-inline-wiki-markup"><ac:plain-text-body><![CDATA[{zone-template-instance:ZFDEV:Zend Proposal Zone Template}

{zone-data:component-name}
Zend_Html
{zone-data}

{zone-data:proposer-list}
[Felix|mailto:zf@felixdd.de]
{zone-data}

{zone-data:revision}
1.2 - 22 June 2006: forgot to change section 5 ...
1.1 - 21 June 2006: added link to code package
1.0 - 21 June 2006: Initialisation
{zone-data}

{zone-data:overview}
Zend_Html is a base component handling HTML elements. Already included: some derived classes (like Zend_Html_A, Zend_Html_Img, etc.), and a document, form and table generator.
{zone-data}

{zone-data:references}
* [PEAR::HTML_Common2|http://pear.php.net/package/HTML_Common2]
* [PEAR::XML_FastCreate|http://pear.php.net/package/XML_FastCreate]
* [PEAR::HTML_Page2|http://pear.php.net/package/HTML_Page2]
* [PEAR::HTML_QuickForm|http://pear.php.net/package/HTML_QuickForm]
* [PEAR::HTML_Table|http://pear.php.net/package/HTML_Table]
{zone-data}

{zone-data:requirements}
* Generates structured HTML code (HTML 4.01 or XHTML 1.0)
* Automatic content and attribute values escaping
* Handles forms, including filtering and validation against rules
* Building tables
{zone-data}

{zone-data:dependencies}
* Standard PHP Library (SPL) Functions (access to table rows and cell like an array)
* Zend (loadClass feature)
{zone-data}

{zone-data:operation}
It works already in my laboratory, but it's not completly tested.
{zone-data}

{zone-data:class-list}
* Zend_Html
* some like Zend_Html_A, Zend_Html_Img, ...
* Zend_Html_Document
* Zend_Html_Form
* Zend_Html_Input
* Zend_Html_Input_Text, Zend_Html_Input_Submit, ...
* Zend_Html_Form_Group (grouping elements)
* Zend_Html_Form_Rule_...
* Zend_Html_Form_Filter_...
* Zend_Html_Form_Builder_...
* Zend_Html_Table
* Zend_Html_Tbody, Zend_Html_Tr, Zend_Html_Td, ...
* some more
{zone-data}

{zone-data:use-cases}
||UC-01||
* two simple elements
{code}
// create first (container) element
$div = Zend_Html::factory('div');
// or: (if a div class exists. it is not necessary for the syntax above or the magic method call used below)
$div = new Zend_Html_Div();
// for the next elements call a magic method named like element
// this generates an anker element <a href="uri">content</a>
$a = $div->a('uri', 'content');
//
$div->add($a); // <div><a href ... </div>
{code}

* document with a form
{code}
$document = new Zend_Html_Document('title content'); // complete html document skeleton

$form = new Zend_Html_Form('form_name', 'get/post', 'action');
$form->addElement(
$form->input_text('name', 'a Label') // magic method, generates an <input type=text> element
->addRule(new Zend_Html_Form_Rule_Required('required field')) // add a rule and a filter
->addFilter('trim'));
$form->addElement($form->input_submit(null, 'Send')); // submit button

if ($form->validate()) {
print_r($form->exportValues());
$form->freeze();
}
$form->build(); // a builder generates html nodes structure. i.e. inserts elements into a layout table

$document->body->add($form);
echo $document; // or $documentHtml = $document->__toString();
//you can also use <?php echo $form; ?> in a template
{code}

* a simple table
{code}
$table = new Zend_Html_Table(array('border' => 1)); // creates a table with a border attribute
// you can also set attributes like: $table->border = 1;

$table // adding some elements after the last cell (currently there are no cells, we just created an empty table)
->addHeaderCell('bla') // this results into (output is formatted more beautifully than this example):
->addCell('fasel') // <table>
->addRow() // <tr><th>bla</th><td>fasel</td></tr>
->addHeaderCell('foo') // <tr><th>foo</th><td>bar</td></tr>
->addCell('bar'); // </table>
echo $table;

// direct cell access
echo $table[1][1]; // bar
// creates a new cell using direct cell access (gaps will be filled with empty cells)
$table[2][1] = $table->span(array('style' => 'color:red'), 'new content');
echo $table;
{code}
{zone-data}

{zone-data:skeletons}
Most parts already exists in my laboratory. See [my small website|http://felixdd.de]. Package is currently named [Fx_Html|http://felixdd.de/Fx_Html.zip]. A documentation is not yet available (except for the phpdoc comments).
{zone-data}

{zone-template-instance}]]></ac:plain-text-body></ac:macro>