root/trunk/patForms/Renderer/Array.php

Revision 362, 1.8 kB (checked in by schst, 2 years ago)

Removed trailing whitespace

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
Line 
1 <?php
2 /**
3  * patForms array renderer class.
4  *
5  * $Id$
6  *
7  * @access        protected
8  * @package        patForms
9  * @subpackage    Renderer
10  */
11
12 /**
13  * patForms array renderer -  gathers serialized data from all elements,
14  * and returns it along with all attributes in a handy array that can directly
15  * be added to a template to display the form.
16  *
17  * @access        protected
18  * @package        patForms
19  * @subpackage    Renderer
20  * @author        Sebastian Mordziol <argh@php-tools.net>
21  * @license        LGPL, see license.txt for details
22  * @link        http://www.php-tools.net
23  * @todo        add javascript support
24  */
25 class patForms_Renderer_Array extends patForms_Renderer
26 {
27    /**
28     * gathers serialized data from all elements, and returns it along with all
29     * attributes in a handy array that can directly be added to a template to
30     * display the form.
31     *
32     * @access    public
33     * @param    object    &$patForms            Reference to the patForms object
34     * @return    string    $serializedElements    The list with elements.
35     */
36     function render( &$patForms )
37     {
38         $serializedElements = array();
39         $elements =& $patForms->getElements();
40
41         $cnt = count( $elements );
42         for( $i=0; $i < $cnt; $i++ ) {           
43             // first, serialize the element as this also initializes the attribute collection.
44             // if an error occurrs here, we just ignore it - we don't want the whole serialization
45             // process to fail because of a warning, for ex.
46             $serialized    =    $elements[$i]->serialize();
47             if( patErrorManager::isError( $serialized ) ) {
48                 continue;
49             }
50
51             // now get the attributes
52             $meta = $elements[$i]->getAttributes();
53             $meta['element'] = $serialized;
54             $meta['elementName'] = $elements[$i]->getElementName();
55
56             // skip the datasource instance if present
57             if (isset($meta['datasource'])) {
58                 unset($meta['datasource']);
59             }
60
61             array_push( $serializedElements, $meta );
62         }
63
64         return $serializedElements;
65     }
66 }
67 ?>
Note: See TracBrowser for help on using the browser.