View Source

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



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

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.

* [PEAR::HTML_Common2|]
* [PEAR::XML_FastCreate|]
* [PEAR::HTML_Page2|]
* [PEAR::HTML_QuickForm|]
* [PEAR::HTML_Table|]

* 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

* Standard PHP Library (SPL) Functions (access to table rows and cell like an array)
* Zend (loadClass feature)

It works already in my laboratory, but it's not completly tested.

* 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

* two simple elements
// 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>

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

$form = new Zend_Html_Form('form_name', 'get/post', 'action');
$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
$form->addElement($form->input_submit(null, 'Send')); // submit button

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

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

* a simple table
$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;

Most parts already exists in my laboratory. See [my small website|]. Package is currently named [Fx_Html|]. A documentation is not yet available (except for the phpdoc comments).