.

InputWidgetMultiselectBase Class Reference
[View]

A multiselect input. More...

Inheritance diagram for InputWidgetMultiselectBase:
InputWidgetBase InputWidgetBaseBase IWidget IRenderer InputWidgetMultiselect

List of all members.

Protected Member Functions

  build_multiselect_checkbox ($name, $key, $display, $values, $attrs, $lbl_class)
  Build a single mutiselect checkbox.
  build_multiselect_checkboxes ($name, $options, $value, $attrs, $lbl_class)
  Build a mutiselect as a set of checkboxes.
  build_multiselect_select ($name, $options, $value, $attrs)
  Build a mutiselect out of a SELECT box.
  build_mutiselect_checkbox_group ($name, $title, $options, $value, $attrs, $lbl_class)
  Build a mutiselct checbox group (heading + checkboxes).
  render_input ($attrs, $params, $name, $title, $value, $policy)
  Render the actual widget.
  render_label ($widget, $html_attrs, $params, $name, $title, $value, $policy)
  Render a label around widget.
  render_postprocess ($output, $policy)
  Last steps.

Protected Attributes

  $use_checkboxes = false

Detailed Description

A multiselect input.

Renders either as a set of checkboxes or a multiselect select box

Author:
Gerd Riesselmann

Definition at line 10 of file multiselect.input.widget.php.


Member Function Documentation

InputWidgetMultiselectBase::build_multiselect_checkbox ( name,
key,
display,
values,
attrs,
lbl_class  
) [protected]

Build a single mutiselect checkbox.

Definition at line 103 of file multiselect.input.widget.php.

00103                                                                                                           {
00104                 $ret = '';
00105                 $attrs['value'] = $key;
00106                 if (in_array($key, $values)) {
00107                         $attrs['checked'] = 'checked';
00108                 }
00109                 unset($attrs['id']);
00110                 $checkbox_html = html::input('checkbox', $name, $attrs);
00111                 $checkbox_html .= ' ' . $display;
00112                 $ret .= html::label($checkbox_html, '', 'spanning ' . $lbl_class);
00113                 return $ret;
00114         }
InputWidgetMultiselectBase::build_multiselect_checkboxes ( name,
options,
value,
attrs,
lbl_class  
) [protected]

Build a mutiselect as a set of checkboxes.

Definition at line 75 of file multiselect.input.widget.php.

00075                                                                                                      {
00076                 $ret = '';
00077                 foreach($options as $key => $display) {
00078                         if (is_array($display)) {
00079                                 $ret .= $this->build_mutiselect_checkbox_group($name, $key, $display, $value, $attrs, $lbl_class);
00080                         }
00081                         else {
00082                                 $ret .= $this->build_multiselect_checkbox($name, $key, $display, $value, $attrs, $lbl_class);
00083                         }
00084                 }
00085                 return $ret;
00086         }
InputWidgetMultiselectBase::build_multiselect_select ( name,
options,
value,
attrs  
) [protected]

Build a mutiselect out of a SELECT box.

Definition at line 65 of file multiselect.input.widget.php.

00065                                                                                      {
00066                 $c = count($options);
00067                 $attrs['size'] = Arr::get_item($attrs, 'size', $c > APP_MULTISELECT_THRESHOLD ? APP_MULTISELECT_THRESHOLD : $c);
00068                 $attrs['multiple'] = 'multiple';
00069                 return html::select($name, $options, $value, $attrs);
00070         }
InputWidgetMultiselectBase::build_mutiselect_checkbox_group ( name,
title,
options,
value,
attrs,
lbl_class  
) [protected]

Build a mutiselct checbox group (heading + checkboxes).

Definition at line 91 of file multiselect.input.widget.php.

00091                                                                                                                 {
00092                 $ret = '';
00093                 $ret .= '<div class="multiselect-group">';
00094                 $ret .= html::div($title,  'label multiselect-group-title ' . $lbl_class);
00095                 $ret .= $this->build_multiselect_checkboxes($name, $options, $value, $attrs, $lbl_class);
00096                 $ret .= '</div>';
00097                 return $ret;
00098         }
InputWidgetMultiselectBase::render_input ( attrs,
params,
name,
title,
value,
policy  
) [protected]

Render the actual widget.

Reimplemented from InputWidgetBaseBase.

Definition at line 16 of file multiselect.input.widget.php.

00016                                                                                          {
00017                 $ret = '';
00018                 $options = Arr::get_item($attrs, 'options', array());
00019                 $c = count($options);
00020                 unset($attrs['options']);
00021 
00022                 $ret .= html::input('hidden', $name, '');
00023                 
00024                 $name .= '[]';
00025                 $value = Arr::force($value, false);
00026                 
00027                 $this->use_checkboxes = ( 
00028                         ($c <= APP_MULTISELECT_THRESHOLD && !Common::flag_is_set($policy, WidgetInput::FORCE_SELECT_BOX)) 
00029                         || 
00030                         (Common::flag_is_set($policy, WidgetInput::FORCE_CHECKBOXES))
00031                 );
00032 
00033                 if ($this->use_checkboxes) {
00034                         $ret .= $this->build_multiselect_checkboxes($name, $options, $value, $attrs, Arr::get_item($params, 'label:class', ''));
00035                 }
00036                 else {
00037                         $ret .= $this->build_multiselect_select($name, $options, $value, $attrs);
00038                 }
00039                 return $ret;
00040         }       
InputWidgetMultiselectBase::render_label ( widget,
html_attrs,
params,
name,
title,
value,
policy  
) [protected]

Render a label around widget.

Reimplemented from InputWidgetBaseBase.

Definition at line 45 of file multiselect.input.widget.php.

00045                                                                                                        {
00046                 if ($this->use_checkboxes) {
00047                         $policy |= WidgetInput::NO_LABEL;
00048                 }
00049                 return parent::render_label($widget, $html_attrs, $params, $name, $title, $value, $policy);
00050         }       
InputWidgetMultiselectBase::render_postprocess ( output,
policy  
) [protected]

Last steps.

Reimplemented from InputWidgetBaseBase.

Definition at line 55 of file multiselect.input.widget.php.

00055                                                                 {
00056                 if ($this->use_checkboxes) {
00057                         $output .= '<div class="multiselect-end"></div>';
00058                 }
00059                 return parent::render_postprocess($output, $policy); 
00060         }

Member Data Documentation

InputWidgetMultiselectBase::$use_checkboxes = false [protected]

Definition at line 11 of file multiselect.input.widget.php.


The documentation for this class was generated from the following file: