[ Index ]
 

Code source de phpMyVisites 2.3

Accédez au Source d'autres logiciels libres

Classes | Fonctions | Variables | Constantes | Tables

title

Body

[fermer]

/libs/Html/QuickForm/Renderer/ -> ArraySmarty.php (sommaire)

(pas de description)

Poids: 376 lignes (14 kb)
Inclus ou requis: 1 fois
Référencé: 0 fois
Nécessite: 0 fichiers

Définit 1 class

HTML_QuickForm_Renderer_ArraySmarty:: (10 méthodes):
  HTML_QuickForm_Renderer_ArraySmarty()
  renderHeader()
  startGroup()
  _elementToArray()
  _storeArray()
  _renderRequired()
  _renderError()
  _tplFetch()
  setRequiredTemplate()
  setErrorTemplate()


Classe: HTML_QuickForm_Renderer_ArraySmarty  - X-Ref

A static renderer for HTML_QuickForm, makes an array of form content
useful for an Smarty template

Based on old toArray() code and ITStatic renderer.

The form array structure is the following:
Array (
[frozen]       => whether the complete form is frozen'
[javascript]   => javascript for client-side validation
[attributes]   => attributes for <form> tag
[hidden]       => html of all hidden elements
[requirednote] => note about the required elements
[errors] => Array
(
[1st_element_name] => Error for the 1st element
...
[nth_element_name] => Error for the nth element
)

[header] => Array
(
[1st_header_name] => Header text for the 1st header
...
[nth_header_name] => Header text for the nth header
)

[1st_element_name] => Array for the 1st element
...
[nth_element_name] => Array for the nth element

// where an element array has the form:
(
[name]      => element name
[value]     => element value,
[type]      => type of the element
[frozen]    => whether element is frozen
[label]     => label for the element
[required]  => whether element is required
// if element is not a group:
[html]      => HTML for the element
// if element is a group:
[separator] => separator for group elements
[1st_gitem_name] => Array for the 1st element in group
...
[nth_gitem_name] => Array for the nth element in group
)
)

HTML_QuickForm_Renderer_ArraySmarty(&$tpl, $staticLabels = false)   X-Ref
Constructor

param: object  reference to the Smarty template engine instance
param: bool    true: render an array of labels to many labels, $key 0 to 'label' and the oterh to "label_$key"

renderHeader(&$header)   X-Ref
Called when visiting a header element

param: object     An HTML_QuickForm_header element being visited
return: void

startGroup(&$group, $required, $error)   X-Ref
Called when visiting a group, before processing any group elements

param: object     An HTML_QuickForm_group object being visited
param: bool       Whether a group is required
param: string     An error message associated with a group
return: void

_elementToArray(&$element, $required, $error)   X-Ref
Creates an array representing an element containing
the key for storing this

param: object    An HTML_QuickForm_element object
param: bool      Whether an element is required
param: string    Error associated with the element
return: array

_storeArray($elAry)   X-Ref
Stores an array representation of an element in the form array

param: array  Array representation of an element
return: void

_renderRequired(&$label, &$html, &$required, &$error)   X-Ref
Called when an element is required

This method will add the required tag to the element label and/or the element html
such as defined with the method setRequiredTemplate.

param: string      The element label
param: string      The element html rendering
param: boolean     The element required
param: string      The element error
return: void

_renderError(&$label, &$html, &$error)   X-Ref
Called when an element has a validation error

This method will add the error message to the element label or the element html
such as defined with the method setErrorTemplate. If the error placeholder is not found
in the template, the error will be displayed in the form error block.

param: string      The element label
param: string      The element html rendering
param: string      The element error
return: void

_tplFetch($tplSource)   X-Ref
Process an template sourced in a string with Smarty

Smarty has no core function to render    a template given as a string.
So we use the smarty eval plugin function    to do this.

param: string      The template source
return: void

setRequiredTemplate($template)   X-Ref
Sets the way required elements are rendered

You can use {$label} or {$html} placeholders to let the renderer know where
where the element label or the element html are positionned according to the
required tag. They will be replaced accordingly with the right value.    You
can use the full smarty syntax here, especially a custom modifier for I18N.
For example:
{if $required}<span style="color: red;">*</span>{/if}{$label|translate}
will put a red star in front of the label if the element is required and
translate the label.


param: string      The required element template
return: void

setErrorTemplate($template)   X-Ref
Sets the way elements with validation errors are rendered

You can use {$label} or {$html} placeholders to let the renderer know where
where the element label or the element html are positionned according to the
error message. They will be replaced accordingly with the right value.
The error message will replace the {$error} placeholder.
For example:
{if $error}<span style="color: red;">{$error}</span>{/if}<br />{$html}
will put the error message in red on top of the element html.

If you want all error messages to be output in the main error block, use
the {$form.errors} part of the rendered array that collects all raw error
messages.

If you want to place all error messages manually, do not specify {$html}
nor {$label}.

Groups can have special layouts. With this kind of groups, you have to
place the formated error message manually. In this case, use {$form.group.error}
where you want the formated error message to appear in the form.

param: string      The element error template
return: void



Généré le : Mon Nov 26 14:10:01 2007 par Balluche grâce à PHPXref 0.7
  Clicky Web Analytics