[ Index ]
 

Code source de b2evolution 2.1.0-beta

Accédez au Source d'autres logiciels libres

Classes | Fonctions | Variables | Constantes | Tables

title

Body

[fermer]

/blogs/inc/_core/ui/forms/ -> _form.class.php (sommaire)

This file implements the Fast Form handling class. This file is part of the evoCore framework - {@link http://evocore.net/} See also {@link http://sourceforge.net/projects/evocms/}.

Author: blueyed: Daniel HAHLER
Author: fplanque: Francois PLANQUE.
Author: fsaya: Fabrice SAYA-GASNIER / PROGIDISTRI
Author: mbruneau: Marc BRUNEAU / PROGIDISTRI
Copyright: (c)2003-2007 by Francois PLANQUE - {@link http://fplanque.net/}
Version: $Id: _form.class.php,v 1.16 2007/11/02 02:39:57 fplanque Exp $
Poids: 3002 lignes (95 kb)
Inclus ou requis:0 fois
Référencé: 0 fois
Nécessite: 0 fichiers

Définit 1 class

Form:: (58 méthodes):
  Form()
  switch_layout()
  begin_field()
  end_field()
  begin_fieldset()
  end_fieldset()
  text_input()
  text()
  password_input()
  password()
  date_input()
  date()
  time_input()
  time()
  time_select()
  _number_select()
  duration_input()
  duration()
  dayOfWeek_input()
  dayOfWeek()
  checkbox_input()
  checkbox_basic_input()
  checkbox()
  check_all()
  begin_form()
  end_form()
  checklist()
  select_input()
  select()
  select_input_object()
  select_object()
  select_input_options()
  select_options()
  select_input_array()
  combo_box()
  textarea_input()
  textarea()
  info_field()
  info()
  buttons_input()
  buttons()
  button_input()
  button()
  convert_button_to_field_params()
  hidden()
  hidden_ctrl()
  hiddens()
  hiddens_by_key()
  submit_input()
  submit()
  radio_input()
  radio()
  input_field()
  get_input_element()
  get_valid_id()
  get_label()
  handle_common_params()
  display_or_return()


Classe: Form  - X-Ref

Form class

Form( $form_action = NULL, $form_name = '', $form_method = 'post', $layout = NULL, $enctype = '' )   X-Ref
Constructor

param: string the action destination of the form (NULL for pagenow)
param: string the name of the form (will be used as an ID)
param: string the action to execute when the form is submitted
param: string the method used to send data
param: string the form layout : 'fieldset', 'table' or '' (NULL means: if there is an {@link $AdminUI} object get it from there, otherwise use 'fieldset')

switch_layout( $layout )   X-Ref

param: string|NULL the form layout : 'fieldset', 'table' or ''; NULL to restore previsouly saved layout

begin_field( $field_name = NULL, $field_label = NULL, $reset_common_params = false )   X-Ref
Start an input field.

A field is a fielset containing a label div and an input div.

param: string The name of the field
param: string The field label
param: boolean Reset {@link $_common_params}? This should be used if you build a field by yourself.
return: The generated HTML

end_field( $field_note = NULL, $field_note_format = NULL )   X-Ref
End an input field.

A field is a fielset containing a label div and an input div.

param: string Field's note to display. (deprecated)
param: string Format of the field's note (%s gets replaced with the note). (deprecated)
return: The generated HTML

begin_fieldset( $title = '', $field_params = array()   X-Ref
Builds a fieldset tag. This is a fieldset element by default, but a th element
for table layout.

param: string the title of the fieldset
param: string the field params to the fieldset
return: true|string true (if output) or the generated HTML if not outputting

end_fieldset()   X-Ref
Ends a fieldset.

return: true|string true (if output) or the generated HTML if not outputting

text_input( $field_name, $field_value, $field_size, $field_label, $field_note = '', $field_params = array()   X-Ref
Builds a text (or password) input field.

Note: please use {@link Form::password_input()} for password fields.

param: string The name of the input field. This gets used for id also, if no id given in $field_params.
param: string Initial value
param: integer Size of the input field
param: string Label displayed with the field
param: string "help" note (Should provide something useful, otherwise leave it empty)
param: array Extended attributes/params.
return: true|string true (if output) or the generated HTML if not outputting

text( $field_name, $field_value, $field_size, $field_label, $field_note = '', $field_maxlength = 0, $field_class = '', $inputtype = 'text', $force_to = '' )   X-Ref
Builds a text (or password) input field.

Note: please use {@link Form::password()} for password fields

param: string the name of the input field
param: string initial value
param: integer size of the input field
param: string label displayed in front of the field
param: string note displayed with field
param: integer max length of the value (if 0 field_size will be used!)
param: string the CSS class to use
param: string input type (only 'text' or 'password' makes sense)
return: mixed true (if output) or the generated HTML if not outputting

password_input( $field_name, $field_value, $field_size, $field_label, $field_params = array()   X-Ref
Builds a password input field.

Calls the text_input() method with type == 'password'.

param: string The name of the input field. This gets used for id also, if no id given in $field_params.
param: string Initial value
param: integer Size of the input field
param: string Label displayed in front of the field
param: string Note displayed with field
param: integer Max length of the value (if 0 field_size will be used!)
param: string Extended attributes, see {@link text_input()}.
return: mixed true (if output) or the generated HTML if not outputting

password( $field_name, $field_value, $field_size, $field_label, $field_note = '', $field_maxlength = 0 , $field_class = '' )   X-Ref
Builds a password input field.

Calls the text() method with a 'password' parameter.

param: string the name of the input field
param: string initial value
param: integer size of the input field
param: string label displayed in front of the field
param: string note displayed with field
param: integer max length of the value (if 0 field_size will be used!)
param: string the CSS class to use
return: mixed true (if output) or the generated HTML if not outputting

date_input( $field_name, $field_value, $field_label, $field_params = array()   X-Ref
Builds a date input field.

param: string the name of the input field
param: string initial value (ISO datetime (YYYY-MM-DD HH:MM:SS)
param: string label displayed in front of the field
param: array Optional params. Additionally to {@link $_common_params} you can use:
return: mixed true (if output) or the generated HTML if not outputting

date( $field_name, $field_value, $field_label, $date_format = NULL )   X-Ref
Builds a date input field.

param: string the name of the input field
param: string initial value (ISO datetime)
param: string label displayed in front of the field
param: string date format (php format)
return: mixed true (if output) or the generated HTML if not outputting

time_input( $field_name, $field_value, $field_label, $field_params = array()   X-Ref
Builds a time input field.

param: string The name of the input field
param: string Initial value (ISO datetime)
param: string Label displayed in front of the field
param: array Optional params. Additionally to {@link $_common_params} you can use:
return: mixed true (if output) or the generated HTML if not outputting

time( $field_name, $field_value, $field_label, $field_format = 'hh:mm:ss' )   X-Ref
Builds a time input field.

param: string the name of the input field
param: string initial value (ISO datetime)
param: string label displayed in front of the field
return: mixed true (if output) or the generated HTML if not outputting

time_select( $field_name, $field_value = NULL, $precision = '5mn', $field_label, $field_note = NULL, $field_class = NULL, $field_onchange = NULL )   X-Ref
Builds a time select input field

param: string field name
param: string initial value (ISO datetime or time only)
param: string precison xmn or xsec (x:integer) for the options minutes or secondes
param: string field label to be display before the field
param: string note to be displayed after the field
param: string CSS class for select
param: string Javascript to add for onchange event (trailing ";").

_number_select( $field_value, $max, $precision = 1, $field_params )   X-Ref
Buil a select input field number

param: string     field value of selected
param: integer maximum value for the input select
param: integer increment for the loop (precision)
param: array params

duration_input( $field_prefix, $duration, $field_label, $field_params = array()   X-Ref
Builds a duration input field.

param: string the name of the input field
param: string initial value (seconds)
param: string label displayed in front of the field
param: array Optional params. Additionally to {@link $_common_params} you can use:
return: mixed true (if output) or the generated HTML if not outputting

duration( $field_prefix, $duration, $field_label )   X-Ref
Builds a duration input field.

param: string the name of the input field
param: string initial value (seconds)
param: string label displayed in front of the field
return: mixed true (if output) or the generated HTML if not outputting

dayOfWeek_input( $field_name, $field_value, $field_label, $field_params = array()   X-Ref
Build a select to choose a weekday.

return: true|string

dayOfWeek( $field_name, $field_value, $field_label, $field_note = NULL, $field_class = NULL )   X-Ref
Build a select to choose a weekday.

return: true|string

checkbox_input( $field_name, $field_checked, $field_label, $field_params = array()   X-Ref
Builds a checkbox field

param: string the name of the checkbox
param: boolean indicating if the checkbox must be checked by default
param: string label
param: array Optional params. Additionally to {@link $_common_params} you can use:
return: mixed true (if output) or the generated HTML if not outputting

checkbox_basic_input( $field_name, $field_checked, $field_label, $field_params = array()   X-Ref
Pas de description

checkbox( $field_name, $field_checked, $field_label, $field_note = '', $field_class = '', $field_value = 1, $field_disabled = false )   X-Ref
Builds a checkbox field

param: string the name of the checkbox
param: boolean indicating if the checkbox must be checked
param: string label
param: string note
param: string CSS class
param: string value to use
param: boolean an optional indicating whether the box is disabled or not
return: mixed true (if output) or the generated HTML if not outputting

check_all()   X-Ref
Return links to check and uncheck all check boxes of the form


begin_form( $form_class = NULL, $form_title = '', $form_params = array()   X-Ref
Builds the form field

param: string the class to use for the form tag
param: string title to display on top of the form
param: array Additional params to the form element. See {@link $_common_params}.
return: mixed true (if output) or the generated HTML if not outputting

end_form( $buttons = array()   X-Ref
Ends the form, optionally displays buttons and closes all open fieldsets.

param: array Optional array to display the buttons before the end of the form, see {@link buttons_input()}
return: true|string true (if output) or the generated HTML if not outputting.

checklist( $options, $field_name, $field_label, $required = false, $add_highlight_spans = false )   X-Ref
Builds a checkbox list

the two-dimension array must indicate, for each checkbox:
- the name,
- the value,
- the comment to put between <input> and <br />
- a boolean indicating whether the box must be checked or not
- an optional boolean indicating whether the box is disabled or not
- an optional note
- 'required': is the box required to be checked (boolean; default: false)

param: array a two-dimensional array containing the parameters of the input tag
param: string name
param: string label
param: boolean true to surround checkboxes if they are required
param: boolean true add a surround_check span, used by check_all mouseover
return: mixed true (if output) or the generated HTML if not outputting

select_input( $field_name, $field_value, $field_list_callback, $field_label, $field_params = array()   X-Ref
Display a select field and populate it with a callback function.

param: string field name
param: string default field value
param: callback callback function
param: string field label to be display before the field
param: array Optional params. Additionally to {@link $_common_params} you can use:
return: mixed true (if output) or the generated HTML if not outputting

select( $field_name, $field_value, $field_list_callback, $field_label, $field_note = '', $field_class = '', $field_onchange = NULL )   X-Ref
Display a select field and populate it with a callback function.

param: string field name
param: string default field value
param: callback callback function
param: string field label to be display before the field
param: string note to be displayed after the field
param: string CSS class for select
param: string Javascript to add for onchange event (trailing ";").
return: mixed true (if output) or the generated HTML if not outputting

select_input_object( $field_name, $field_value, & $field_object, $field_label, $field_params = array()   X-Ref
Display a select field and populate it with a cache object by using a callback
method.

param: string Field name
param: string Default field value
param: DataObjectCache Cache containing values for list
param: string Field label to be display with the field
param: array Optional params. Additionally to {@link $_common_params} you can use:
return: mixed true (if output) or the generated HTML if not outputting

select_object( $field_name, $field_value, & $field_object, $field_label, $field_note = '', $allow_none = false, $field_class = '', $field_object_callback = 'get_option_list', $field_onchange = NULL )   X-Ref
Display a select field and populate it with a cache object.

param: string field name
param: string default field value
param: DataObjectCache Cache containing values for list
param: string field label to be display before the field
param: string note to be displayed after the field
param: boolean allow to select [none] in list
param: string CSS class for select
param: string Object's callback method name.
param: string Javascript to add for onchange event (trailing ";").
return: mixed true (if output) or the generated HTML if not outputting

select_input_options( $field_name, $field_options, $field_label, $field_note = '', $field_params = array()   X-Ref
Display a select field and populate it with a cache object.

param: string field name
param: string string containing options '<option>...</option>'
param: string field label to be display before the field
param: string "help" note (Should provide something useful, otherwise leave it empty)
param: array Optional params. Additionally to {@link $_common_params} you can use:
return: mixed true (if output) or the generated HTML if not outputting

select_options( $field_name, $field_options, $field_label, $field_note = NULL, $field_class = NULL, $field_onchange = NULL )   X-Ref
Display a select field and populate it with a cache object.

param: string field name
param: string string containing options
param: string field label to be display before the field
param: string note to be displayed after the field
param: string CSS class for select
param: string Javascript to add for onchange event (trailing ";").
return: mixed true (if output) or the generated HTML if not outputting

select_input_array( $field_name, $field_value, $field_options, $field_label, $field_note = NULL, $field_params = array()   X-Ref
This is a stub for {@link select_input_options()} which builds the required list
of <option> elements from a given list of options ($field_options) and
the selected value ($field_value).

param: string field name
param: mixed Initial value
param: array Options. If an associative key (string) is used, this gets the value attribute.
param: string Field label to be display before the field
param: string Note
param: array Optional params. Additionally to {@link $_common_params} you can use:
return: mixed true (if output) or the generated HTML if not outputting

combo_box( $field_name, $field_value, $field_options, $field_label, $field_params = array()   X-Ref
Combo box
Display a select options list with an option 'new',
and when this one is seleted, display a combo input text to add a new value

param: string field name
param: string field value
param: string containing options
param: string field label
param: array Optional params
return: mixed true (if output) or the generated HTML if not outputting

textarea_input( $field_name, $field_value, $field_rows, $field_label, $field_params = array()   X-Ref
Build a text area.

param: string Name of the field
param: string Value of the field
param: integer Number of rows
param: string Label for the field
param: array Optional params. Additionally to {@link $_common_params} you can use:

textarea( $field_name, $field_value, $field_rows, $field_label, $field_note = '', $field_cols = 50 , $field_class = '' )   X-Ref
Build a text area.

param: string
param: string
param: integer
param: string
param: string
param: integer
param: string

info_field( $field_label, $field_info, $field_params = array()   X-Ref
Builds an info field.
An info field is a fieldset containing a label div and an info div.

{@internal
NOTE: we don't use {@link begin_field()} here, because the label is meant
to be always on the left and this avoids fiddling with the <label> tag.
}}

param: string the field label
param: string the field info
param: array Optional params. Additionally to {@link $_common_params} you can use:
return: mixed true (if output) or the generated HTML if not outputting

info( $field_label, $field_info, $field_note = NULL, $format = 'htmlbody' )   X-Ref
Builds an info field.
An info field is a fieldset containing a label div and an info div.

param: string the field label
param: string the field info
param: string see {@link format_to_output()}
return: mixed true (if output) or the generated HTML if not outputting

buttons_input( $buttons = array()   X-Ref
Builds a button list.

The array contains an associative array for each button (params to {@link button_input()}.

param: array a two-dimension array containing the elements of the input tags
return: mixed true (if output) or the generated HTML if not outputting

buttons( $buttons = array()   X-Ref
Builds a button list.

Array entries with numeric (deprecated) keys are converted to their equivalent string indexes.

the two-dimension array must contain :
- the button type
- the name (optional)
- the value (optional)
- the class (optional)
- the onclick attribute (optional)
- the style (optional)

param: array a two-dimension array containing the elements of the input tags
param: boolean to select or not the default display
return: mixed true (if output) or the generated HTML if not outputting

button_input( $field_params = array()   X-Ref
Builds a button.

Array entries with numeric (deprecated) keys are converted to their equivalent string indexes.

param: array Optional params. Additionally to {@link $_common_params} you can use:
return: mixed true (if output) or the generated HTML if not outputting

button( $options )   X-Ref
Builds a button

the array must contain :
- the button type
- the name (optional)
- the value (optional)
- the class (optional)
- the onclick attribute (optional)
- the style (optional)

param: array a two-dimension array containing the elements of the input tags
return: mixed true (if output) or the generated HTML if not outputting

convert_button_to_field_params( $options )   X-Ref
Convert a deprecated, numeric button array to a field_params array.

param: array A button array like button() and buttons() are getting.
return: array The button array converted to a string indexed button array (field_params).

hidden( $field_name, $field_value, $field_params = array()   X-Ref
Builds an hidden input tag, overwriting any previous hidden values (except for "foo[]").

param: string Field name
param: string Field value
param: array Optional params. This is e.g. useful for "id".

hidden_ctrl()   X-Ref
Add the "ctrl" param, used in the backoffice, as a hidden field.


hiddens( $hiddens )   X-Ref
Builds a list of hidden inputs.

param: array Array of parameters to {@link hidden()}:
return: mixed true (if output) or the generated HTML if not outputting

hiddens_by_key( $hiddens, $exclude = NULL )   X-Ref
Builds a list of hidden inputs from an array where the keys are the field names.

It supports array values (one-dimensional) and generates appropriate key-value pairs.

param: array associative array ( name => value ) of hidden fields.
param: array|NULL A list of keys to ignore.

submit_input( $field_params = array()   X-Ref
Builds a submit input tag

the array must contain :
- the name (optional)
- the value (optional)
- the class (optional)
- the onclick attribute (optional)
- the style (optional)

param: array Optional params. Additionally to {@link $_common_params} you can use:
return: mixed true (if output) or the generated HTML if not outputting

submit( $options )   X-Ref
Builds a submit input tag

the array must contain :
- the name (optional)
- the value (optional)
- the class (optional)
- the onclick attribute (optional)
- the style (optional)

param: array an array containing the elements of the input tags
return: mixed true (if output) or the generated HTML if not outputting

radio_input( $field_name, $field_value, $field_options, $field_label, $field_params = array()   X-Ref
Generate set of radio options.

param: string The name of the radio options
param: string The checked option's value
param: array of arrays The radio options
param: string Label
param: array Optional params. Additionally to {@link $_common_params} you can use:
return: mixed true (if output) or the generated HTML if not outputting

radio( $field_name, $field_value, $field_options, $field_label, $field_lines = false, $field_note = '' )   X-Ref
Generate set of radio options.

param: string the name of the radio options
param: string the checked option
param: array of arrays the radio options (0: value, 1: label, 2: notes, 3: additional HTML [input field, ..], 4: attribs for <input tag> )
param: string label
param: boolean options on seperate lines (DIVs)
param: string notes
return: mixed true (if output) or the generated HTML if not outputting

input_field( $field_params = array()   X-Ref
Generate a general input field.

This is the base function for text_input(), checkbox_input(), ..

param: array Optional params. Additionally to {@link $_common_params} you can use:
return: true|string true (if output) or the generated HTML if not outputting

get_input_element( $field_params = array()   X-Ref
Generate a general input element.

param: array Optional params.
return: string The <input /> element.

get_valid_id( $id )   X-Ref
Convert a given string (e.g. fieldname) to a valid HTML id.

return: string

get_label()   X-Ref
Get the label of a field. This is used by {@link begin_field()} or {@link end_field()},

return: string

handle_common_params( & $field_params, $field_name = NULL, $field_label = NULL )   X-Ref
Extract common params out of $field_params into {@link $_common_params} and unsets them in $field_params.

Also handles adding errors to the note.

param: array An array passed to a field generating function like {@link text_input()}. By reference!
param: string|NULL The name of the field. If not empty it gets used to build the id attribute.

display_or_return( $r )   X-Ref
Display or return, according to {@link $output}.

return: true|string True, if we want to display, the string if not.



Généré le : Thu Nov 29 23:58:50 2007 par Balluche grâce à PHPXref 0.7
  Clicky Web Analytics