LSB
[ class tree: LSB ] [ index: LSB ] [ all elements ]

Class: sc_form_elements

Source Location: /PhpDoc/lsb/sc_classes.php

Class Overview


Helper class for rendering html elements.


Author(s):

  • Panos Kyriakakis (http://www.salix.gr)

Copyright:

  • Copyright (c) 2006,7 Panos Kyriakakis

Variables

Methods



Class Details

[line 49]
Helper class for rendering html elements.

Renders select box, radio button and checkbox groups. For radio and checkbox the problem is that we usualy read from database some choices and have to show a number of radios or checkboxes, this class takes care of that giving options to format how they are shown for example in columns, placed in tables. For example if we want our checkboxes shown in a table in 3 columns we set $o->group_wrap_every=3; in order to have 3 elements per row
$o->group_pre_group = "<tr>"; before each group of 3 start a new table row
$o->group_post_group ="</tr>"; after each group of 3 end table row
$o->group_pre_input = "<td>"; start a td before input element
$o->group_post_input = "</td>"; close tag after element




Tags:

author:  Panos Kyriakakis (http://www.salix.gr)
copyright:  Copyright (c) 2006,7 Panos Kyriakakis
license:  GNU Public License


[ Top ]


Class Variables

$group_post_group =  ''

[line 74]

html tag placed at the end of elements group


Type:   string


[ Top ]

$group_post_input =  '<br />'

[line 84]

html tag placed after input element


Type:   string


[ Top ]

$group_post_wrap =  '<br />'

[line 99]

html tag placed after input element warp in group.


Type:   string


[ Top ]

$group_pre_group =  ''

[line 69]

html tag placed at the begining of elements group


Type:   string


[ Top ]

$group_pre_input =  ''

[line 79]

html tag placed before input element


Type:   string


[ Top ]

$group_pre_wrap =  ''

[line 94]

html tag placed before input element warp in group. Defaul is ''.


Type:   string


[ Top ]

$group_wrap_every =  0

[line 89]

Wrap elements in group every N elements. 0 means no wrap (default).


Type:   int


[ Top ]

$select_add_prompt_row =  TRUE

[line 64]

show pease "Please select" option in select box or not


Type:   bool


[ Top ]

$select_prompt_key =  0

[line 54]

the value of "Please select" option in select boxes


Type:   int


[ Top ]

$select_prompt_text =  'Please Select'

[line 59]

the text of "Please select" option in select boxes


Type:   string


[ Top ]



Class Methods


method add_checkbox_group [line 349]

void add_checkbox_group( array $list, string $selected, string $name, [bool $add_id = FALSE], [string $extra = ""])

Renders a group of checkbox elements.



Tags:

see:  sc_form_elements::_add_input_group()
access:  public


Parameters:

array   $list   An associative array with value-description pairs to be used for inputs. Array's key is Value and array's value is description :) eg for 12-Item 12 it is $list[12]='Item 12'.
string   $selected   A comma separated string with the keys of the selected items of the list. eg 12,41
string   $name   Html name property for the group.
bool   $add_id   If TRUE an id property is added to the elements
string   $extra   Any extra html properties we might like to add to the elements, useful for styles.

[ Top ]

method add_radio_group [line 334]

void add_radio_group( array $list, string $selected, string $name, [bool $add_id = FALSE], [string $extra = ""])

Renders a group of radio button elements.



Tags:

see:  sc_form_elements::_add_input_group()
access:  public


Parameters:

array   $list   An associative array with value-description pairs to be used for inputs. Array's key is Value and array's value is description :) eg for 12-Item 12 it is $list[12]='Item 12'.
string   $selected   A comma separated string with the keys of the selected items of the list. eg 12,41
string   $name   Html name property for the group.
bool   $add_id   If TRUE an id property is added to the elements
string   $extra   Any extra html properties we might like to add to the elements, useful for styles.

[ Top ]

method add_select_box [line 291]

void add_select_box( array $list, string $selected, string $name, string $id, [string $extra = ""], [bool $multiple = FALSE], [int $size = 1])

Renders a select box element. Select box prompt text is defined in class property

$select_prompt_text and the value of that option in $select_prompt_key




Tags:



Parameters:

array   $list   An associative array with value-description pairs to be used for inputs. Array's key is Value and array's value is description :) eg for 12-Item 12 it is $list[12]='Item 12'.
string   $selected   A comma separated string with the keys of the selected items of the list. eg 12,41
string   $name   Html name property for the group.
string   $id   HTML id parameter's value.
string   $extra   Any extra html properties we might like to add to the elements, useful for styles.
bool   $multiple   Controls select box's multiselect capability. If true multi select enabled.
int   $size   Size of select box as defined in html. If size=1 works as combo box, if higher as list box.

[ Top ]

method get_list_from_db [line 262]

array get_list_from_db( string $table, string $key_fld, string $text_fld, [string $order_fld = ''])

Loads the list of items from database table.



Tags:

return:  Returns an associative array, keys are the $key_fld values and values the $text_fld values.
access:  public


Parameters:

string   $table   is the database table where select box options are stored.
string   $key_fld   is the field which holds key values for select box options.
string   $text_fld   is the field which holds description text for select box options.
string   $order_fld   is the field you want to be used to order option list. If table is already indexed or you want options shown in the same order that are stored in db set order_field_name value to "".

[ Top ]

method _add_input_group [line 211]

void _add_input_group( string $type, array $list, string $selected, string $name, [bool $add_id = FALSE], [string $extra = ""])

This is core function that drives input elements group rendering.

It is called from wrapper functions add_radio_group and add_checkbox_group. Tagging and wraping is controled by classes global settings.




Tags:

access:  private


Parameters:

string   $type   Input element's type. Possible values are 'checkbox' and 'radio'
array   $list   An associative array with value-description pairs to be used for inputs. Array's key is Value and array's value is description :) eg for 12-Item 12 it is $list[12]='Item 12'.
string   $selected   A comma separated string with the keys of the selected items of the list. eg 12,41
string   $name   Html name property for the group.
bool   $add_id   If TRUE an id property is added to the elements
string   $extra   Any extra html properties we might like to add to the elements, useful for styles.

[ Top ]

method _getRecords [line 108]

array _getRecords( string $query)

Wrapper function fetching mysql records



Tags:

return:  Returns an array with records.
access:  private


Parameters:

string   $query   The Select sql query

[ Top ]

method _is_key_selected [line 190]

bool _is_key_selected( string $key, string $selected)

Helper function, used by _make_checkbox_input, _make_radio_input.

Checks if $key exists in a comma separated list ($selected).




Tags:

return:  True if selected, False if not.
access:  private


Parameters:

string   $key  
string   $selected  

[ Top ]

method _make_checkbox_input [line 163]

string _make_checkbox_input( string $name, bool $add_id, string $key, string $text, bool $selected, [$extra $extra = ""])

Builds checkbox input html code.



Tags:

return:  checkbox input html code
access:  private


Parameters:

string   $name  
bool   $add_id  
string   $key  
string   $text  
bool   $selected  
$extra   $extra  

[ Top ]

method _make_radio_input [line 133]

string _make_radio_input( string $name, bool $add_id, string $key, string $text, bool $selected, [string $extra = ""])

Builds radio button html code



Tags:

return:  radio button html code
access:  private


Parameters:

string   $name  
bool   $add_id  
string   $key  
string   $text  
bool   $selected  
string   $extra  

[ Top ]


Documentation generated on Sun, 04 Nov 2007 22:12:31 +0200 by phpDocumentor 1.4.0a2