Subversion Repositories Applications.papyrus

Rev

Rev 320 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 320 Rev 443
Line 14... Line 14...
14
// | license@php.net so we can mail you a copy immediately.               |
14
// | license@php.net so we can mail you a copy immediately.               |
15
// +----------------------------------------------------------------------+
15
// +----------------------------------------------------------------------+
16
// | Author: Ron McClain <ron@humaniq.com>                                |
16
// | Author: Ron McClain <ron@humaniq.com>                                |
17
// +----------------------------------------------------------------------+
17
// +----------------------------------------------------------------------+
18
//
18
//
19
// $Id: ObjectFlexy.php,v 1.1 2005-03-30 08:50:33 jpm Exp $
19
// $Id: ObjectFlexy.php,v 1.2 2005-09-20 17:01:22 ddelon Exp $
Line 20... Line 20...
20
 
20
 
Line 21... Line 21...
21
require_once("HTML/QuickForm/Renderer/Object.php");
21
require_once("HTML/QuickForm/Renderer/Object.php");
22
 
22
 
-
 
23
/**
23
/**
24
 * QuickForm renderer for Flexy template engine, static version.
24
 * @abstract Long Description
25
 * 
25
 * A static renderer for HTML_Quickform.  Makes a QuickFormFlexyObject
26
 * A static renderer for HTML_Quickform.  Makes a QuickFormFlexyObject
26
 * from the form content suitable for use with a Flexy template
27
 * from the form content suitable for use with a Flexy template
27
 *
28
 *
Line 34... Line 35...
34
 * $form->accept($renderer);
35
 * $form->accept($renderer);
35
 * $view = new StdClass;
36
 * $view = new StdClass;
36
 * $view->form = $renderer->toObject();
37
 * $view->form = $renderer->toObject();
37
 * $template->compile("mytemplate.html");
38
 * $template->compile("mytemplate.html");
38
 *
39
 *
39
 * @see QuickFormFlexyObject
-
 
40
 *
-
 
41
 * Based on the code for HTML_QuickForm_Renderer_ArraySmarty
40
 * Based on the code for HTML_QuickForm_Renderer_ArraySmarty
42
 *
41
 *
-
 
42
 * @see QuickFormFlexyObject
43
 * @public
43
 * @access public
44
 */
44
 */
45
class HTML_QuickForm_Renderer_ObjectFlexy extends HTML_QuickForm_Renderer_Object {
45
class HTML_QuickForm_Renderer_ObjectFlexy extends HTML_QuickForm_Renderer_Object
-
 
46
{
46
    /**
47
    /**
47
     * HTML_Template_Flexy instance
48
     * HTML_Template_Flexy instance
48
     * @var object $_flexy
49
     * @var object $_flexy
49
     */
50
     */
50
    var $_flexy;
51
    var $_flexy;
Line 57... Line 58...
57
 
58
 
58
    /**
59
    /**
59
     * The current element index inside a group
60
     * The current element index inside a group
60
     * @var integer $_groupElementIdx
61
     * @var integer $_groupElementIdx
61
     */
62
     */
Line 62... Line 63...
62
     var $_groupElementIdx = 0;
63
    var $_groupElementIdx = 0;
63
 
64
 
64
    /**
65
    /**
65
     * Name of template file for form html
66
     * Name of template file for form html
Line 113... Line 114...
113
 
114
 
114
    /**
115
    /**
115
     * Creates an object representing an element containing
116
     * Creates an object representing an element containing
116
     * the key for storing this
117
     * the key for storing this
117
     *
118
     *
118
     * @private
119
     * @access private
119
     * @param element object     An HTML_QuickForm_element object
120
     * @param element object     An HTML_QuickForm_element object
120
     * @param required bool        Whether an element is required
121
     * @param required bool        Whether an element is required
121
     * @param error string    Error associated with the element
122
     * @param error string    Error associated with the element
122
     * @return object
123
     * @return object
123
     */
124
     */
124
     function _elementToObject(&$element, $required, $error)
125
    function _elementToObject(&$element, $required, $error)
125
     {
126
    {
126
        $ret = parent::_elementToObject($element, $required, $error);
127
        $ret = parent::_elementToObject($element, $required, $error);
127
        if($ret->type == 'group') {
128
        if($ret->type == 'group') {
128
            $ret->html = $element->toHtml();
129
            $ret->html = $element->toHtml();
129
            unset($ret->elements);
130
            unset($ret->elements);
Line 172... Line 173...
172
 
173
 
173
    /**
174
    /**
174
     * Stores an object representation of an element in the 
175
     * Stores an object representation of an element in the 
175
     * QuickformFormObject instance
176
     * QuickformFormObject instance
176
     *
177
     *
177
     * @private
178
     * @access private
178
     * @param elObj object  Object representation of an element
179
     * @param elObj object  Object representation of an element
179
     * @return void
180
     * @return void
180
     */
181
     */
181
    function _storeObject($elObj) 
182
    function _storeObject($elObj) 
Line 200... Line 201...
200
     * {if:error}
201
     * {if:error}
201
     *   <font color="red" size="1">{error:h}</font><br />
202
     *   <font color="red" size="1">{error:h}</font><br />
202
     * {end:}
203
     * {end:}
203
     * {html:h}
204
     * {html:h}
204
     *
205
     *
205
     * @public
206
     * @access public
206
     * @param template string   Filename of template
207
     * @param template string   Filename of template
207
     * @return void
208
     * @return void
208
     */
209
     */
209
    function setHtmlTemplate($template)
210
    function setHtmlTemplate($template)
210
    {
211
    {
Line 220... Line 221...
220
     * {if:required}
221
     * {if:required}
221
     * <font color="orange" size="1">*</font>
222
     * <font color="orange" size="1">*</font>
222
     * {end:}
223
     * {end:}
223
     * {label:h}
224
     * {label:h}
224
     *
225
     *
225
     * @public
226
     * @access public
226
     * @param template string   Filename of template
227
     * @param template string   Filename of template
227
     * @return void
228
     * @return void
228
     */
229
     */
229
    function setLabelTemplate($template) 
230
    function setLabelTemplate($template) 
230
    {
231
    {
Line 240... Line 241...
240
    function _renderHtml(&$ret)
241
    function _renderHtml(&$ret)
241
    {
242
    {
242
        $this->_flexy->compile($this->_html);
243
        $this->_flexy->compile($this->_html);
243
        $ret->html = $this->_flexy->bufferedOutputObject($ret);
244
        $ret->html = $this->_flexy->bufferedOutputObject($ret);
244
    }
245
    }
245
 
-
 
246
} // end class HTML_QuickForm_Renderer_ObjectFlexy
246
} // end class HTML_QuickForm_Renderer_ObjectFlexy
Line 247... Line 247...
247
 
247
 
248
/**
-
 
249
 * @abstract Long Description
248
/**
250
 * This class represents the object passed to outputObject()
-
 
251
 * 
-
 
252
 * Eg.  
-
 
253
 * {form.outputJavaScript():h}
-
 
254
 * {form.outputHeader():h}
-
 
255
 *   <table>
-
 
256
 *     <tr>
-
 
257
 *       <td>{form.name.label:h}</td><td>{form.name.html:h}</td>
-
 
258
 *     </tr>
-
 
259
 *   </table>
-
 
260
 * </form>
-
 
261
 * 
-
 
262
 * @public
249
 * Adds nothing to QuickformForm, left for backwards compatibility
263
 */
250
 */
264
class QuickformFlexyForm {
-
 
265
    /**
-
 
266
     * Whether the form has been frozen
-
 
267
     * @var boolean $frozen
-
 
268
     */
-
 
269
    var $frozen;        
-
 
270
    
-
 
271
    /**
-
 
272
     * Javascript for client-side validation
-
 
273
     * @var string $javascript
-
 
274
     */
-
 
275
     var $javascript;
-
 
276
 
-
 
277
     /**
-
 
278
      * Attributes for form tag
-
 
279
      * @var string $attributes
-
 
280
      */
-
 
281
     var $attributes;
-
 
282
 
-
 
283
     /**
-
 
284
      * Note about required elements
-
 
285
      * @var string $requirednote
-
 
286
      */
-
 
287
     var $requirednote;
-
 
288
 
-
 
289
     /**
-
 
290
      * Collected html of all hidden variables
-
 
291
      * @var string $hidden
-
 
292
      */
-
 
293
     var $hidden;
-
 
294
 
-
 
295
     /**
-
 
296
      * Set if there were validation errors.  
-
 
297
      * StdClass object with element names for keys and their
-
 
298
      * error messages as values
-
 
299
      * @var object $errors
-
 
300
      */
-
 
301
     var $errors;
-
 
302
 
-
 
303
     /**
-
 
304
      * Array of QuickformElementObject elements.  If there are headers in the form
-
 
305
      * this will be empty and the elements will be in the 
-
 
306
      * separate sections
-
 
307
      * @var array $elements
-
 
308
      */
-
 
309
     var $elements;
-
 
310
 
-
 
311
     /**
-
 
312
      * Array of sections contained in the document
-
 
313
      * @var array $sections
-
 
314
      */
-
 
315
     var $sections;
251
class QuickformFlexyForm extends QuickformForm
316
 
-
 
317
     /**
-
 
318
      * Output &lt;form&gt; header
-
 
319
      * {form.outputHeader():h} 
-
 
320
      * @return string    &lt;form attributes&gt;
-
 
321
      */
-
 
322
     function outputHeader()
-
 
323
     {
-
 
324
        $hdr = "<form " . $this->attributes . ">\n";
-
 
325
        return $hdr;
-
 
326
     }
252
{
327
 
-
 
328
     /**
-
 
329
      * Output form javascript
-
 
330
      * {form.outputJavaScript():h}
-
 
331
      * @return string    Javascript
-
 
332
      */
-
 
333
     function outputJavaScript()
-
 
334
     {
-
 
335
        return $this->javascript;
-
 
336
     }
-
 
Line 337... Line 253...
337
} // end class QuickformFlexyForm
253
}
338
 
-
 
339
/**
254
 
340
 * Convenience class describing a form element.
-
 
341
 * The properties defined here will be available from 
-
 
342
 * your flexy templates by referencing
255
/**
343
 * {form.zip.label:h}, {form.zip.html:h}, etc.
-
 
344
 */
-
 
345
class QuickformFlexyElement {
-
 
346
    
-
 
347
    /**
-
 
348
     * Element name
-
 
349
     * @var string $name
-
 
350
     */
-
 
351
    var $name;
-
 
352
 
-
 
353
    /**
-
 
354
     * Element value
-
 
355
     * @var mixed $value
-
 
356
     */
-
 
357
    var $value;
-
 
358
 
-
 
359
    /**
-
 
360
     * Type of element
-
 
361
     * @var string $type
-
 
362
     */
-
 
363
    var $type;
-
 
364
 
-
 
365
    /**
-
 
366
     * Whether the element is frozen
-
 
367
     * @var boolean $frozen
-
 
368
     */
-
 
369
    var $frozen;
-
 
370
 
-
 
371
    /**
-
 
372
     * Label for the element
-
 
373
     * @var string $label
-
 
374
     */
-
 
375
    var $label;
-
 
376
 
-
 
377
    /**
-
 
378
     * Whether element is required
-
 
379
     * @var boolean $required
-
 
380
     */
-
 
381
    var $required;
-
 
382
 
-
 
383
    /**
-
 
384
     * Error associated with the element
-
 
385
     * @var string $error
-
 
386
     */
-
 
387
    var $error;
-
 
388
 
-
 
389
    /**
-
 
390
     * Some information about element style
-
 
391
     * @var string $style
-
 
392
     */
-
 
393
    var $style;
-
 
394
 
-
 
395
    /**
-
 
396
     * HTML for the element
-
 
397
     * @var string $html
-
 
398
     */
-
 
399
    var $html;
-
 
400
 
-
 
401
    /**
-
 
402
     * If element is a group, the group separator
-
 
403
     * @var mixed $separator
-
 
404
     */
-
 
405
    var $separator;
-
 
406
 
-
 
407
    /**
-
 
408
     * If element is a group, an array of subelements
-
 
409
     * @var array $elements
-
 
410
     */
-
 
411
    var $elements;
-
 
412
} // end class QuickformFlexyElement
256
 * Adds nothing to QuickformElement, left for backwards compatibility
-
 
257
 */
-
 
258
class QuickformFlexyElement extends QuickformElement
-
 
259
{
-
 
260
}