InputWidgetBaseBase Class Reference
[View]
Basic input widget. More...
Public Member Functions |
|
__construct ($name, $label, $value, $params) | |
Constructor. |
|
render ($policy=self::NONE) | |
Render the widget. |
|
Protected Member Functions |
|
create_default_attributes ($params, $name, $policy) | |
Create default attribute array. |
|
extend_attributes (&$attrs, $params, $name, $title, $value, $policy) | |
Add new attributes or process old ones.
|
|
get_input_type () | |
Returns type of this input widget, like
'textarea' or 'select', or 'multiselect'. |
|
input_build_noedit ($params, $name, $title, $value, $policy) | |
Builds a widget that cannot be editetd.
|
|
input_build_widget ($params, $name, $title, $value, $policy) | |
Build an edit widget. |
|
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 |
|
$label | |
$name | |
$params | |
$value |
Detailed Description
Basic input widget.
Definition at line 8 of file base.input.widget.php.
Constructor & Destructor Documentation
InputWidgetBaseBase::__construct | ( | $ | name, | |
$ | label, | |||
$ | value, | |||
$ | params | |||
) |
Constructor.
Definition at line 17 of file base.input.widget.php.
00017 { 00018 $this->name = $name; 00019 $this->label = $label; 00020 $this->value = $value; 00021 $this->params = Arr::force($params, false); 00022 }
Member Function Documentation
InputWidgetBaseBase::create_default_attributes | ( | $ | params, | |
$ | name, | |||
$ | policy | |||
) | [protected] |
Create default attribute array.
Definition at line 77 of file base.input.widget.php.
00077 { 00078 $id = strtr(arr::get_item($params, 'id', $name), '[]', '__'); 00079 $attrs = array( 00080 'id' => $id 00081 ); 00082 00083 $attrs = array_merge($attrs, $params); 00084 00085 unset($attrs['label:class']); 00086 unset($attrs['notes']); 00087 unset($attrs['item']); 00088 return $attrs; 00089 }
InputWidgetBaseBase::extend_attributes | ( | &$ | attrs, | |
$ | params, | |||
$ | name, | |||
$ | title, | |||
$ | value, | |||
$ | policy | |||
) | [protected] |
Add new attributes or process old ones.
Reimplemented in InputWidgetCheckboxBase, InputWidgetDateBase, InputWidgetHiddenBase, InputWidgetPasswordBase, InputWidgetSubmitBase, InputWidgetTextBase, and InputWidgetTextareaBase.
Definition at line 94 of file base.input.widget.php.
InputWidgetBaseBase::get_input_type | ( | ) | [protected] |
Returns type of this input widget, like 'textarea' or 'select', or 'multiselect'.
- Returns:
- string Always lower case
Definition at line 29 of file base.input.widget.php.
InputWidgetBaseBase::input_build_noedit | ( | $ | params, | |
$ | name, | |||
$ | title, | |||
$ | value, | |||
$ | policy | |||
) | [protected] |
Builds a widget that cannot be editetd.
- Parameters:
-
array $params string $name
- Returns:
- string
Definition at line 153 of file base.input.widget.php.
00153 { 00154 $ret = ''; 00155 $ret .= html::span($title, 'label') . ' '; 00156 $ret .= html::span($value, 'value'); 00157 $ret = html::p($ret, 'noedit'); 00158 return $ret; 00159 }
InputWidgetBaseBase::input_build_widget | ( | $ | params, | |
$ | name, | |||
$ | title, | |||
$ | value, | |||
$ | policy | |||
) | [protected] |
Build an edit widget.
- Parameters:
-
Array of params $params string $name
- Returns:
- string
Definition at line 61 of file base.input.widget.php.
00061 { 00062 $ret = ''; 00063 00064 $html_attrs = $this->create_default_attributes($params, $name, $policy); 00065 $this->extend_attributes($html_attrs, $params, $name, $title, $value, $policy); 00066 00067 $widget = $this->render_input($html_attrs, $params, $name, $title, $value, $policy); 00068 $widget = $this->render_label($widget, $html_attrs, $params, $name, $title, $value, $policy); 00069 $ret = $this->render_postprocess($widget, $policy); 00070 00071 return $ret; 00072 }
InputWidgetBaseBase::render | ( | $ | policy =
self::NONE |
) |
Render the widget.
Implements IRenderer.
Definition at line 39 of file base.input.widget.php.
00039 { 00040 $ret = ''; 00041 $item = Arr::get_item($this->params, 'item', false); 00042 $name = array_pop(Arr::extract_array_keys($this->name)); 00043 $can_edit = ($item) ? AccessControl::is_allowed('edit', $item, $name) : true; 00044 if ($can_edit) { 00045 $ret = $this->input_build_widget($this->params, $this->name, $this->label, $this->value, $policy); 00046 } 00047 else { 00048 $ret = $this->input_build_noedit($this->params, $this->name, $this->label, $this->value, $policy); 00049 } 00050 return $ret; 00051 }
InputWidgetBaseBase::render_input | ( | $ | attrs, | |
$ | params, | |||
$ | name, | |||
$ | title, | |||
$ | value, | |||
$ | policy | |||
) | [protected] |
Render the actual widget.
Reimplemented in InputWidgetCheckboxBase, InputWidgetDateBase, InputWidgetFileBase, InputWidgetHiddenBase, InputWidgetMultiselectBase, InputWidgetPasswordBase, InputWidgetRadioBase, InputWidgetSelectBase, InputWidgetSubmitBase, InputWidgetTextBase, and InputWidgetTextareaBase.
Definition at line 100 of file base.input.widget.php.
InputWidgetBaseBase::render_label | ( | $ | widget, | |
$ | html_attrs, | |||
$ | params, | |||
$ | name, | |||
$ | title, | |||
$ | value, | |||
$ | policy | |||
) | [protected] |
Render a label around widget.
Reimplemented in InputWidgetCheckboxBase, InputWidgetMultiselectBase, and InputWidgetRadioBase.
Definition at line 106 of file base.input.widget.php.
00106 { 00107 $ret = ''; 00108 $id = Arr::get_item($html_attrs, 'id', ''); 00109 $lbl_class = Arr::get_item($params, 'label:class', ''); 00110 $label = ''; 00111 if ($title) { 00112 $notes = Cast::int(arr::get_item($params, 'notes', 0)); 00113 if ($notes > 0) { 00114 $title .= ' '. html::span(str_repeat('*', $notes), 'notes'); 00115 } 00116 if (Common::flag_is_set($policy, WidgetInput::NO_LABEL)) { 00117 // Div before input 00118 $ret = html::div($title, 'label ' . $lbl_class) . $widget; 00119 } 00120 else if (Common::flag_is_set($policy, WidgetInput::WRAP_LABEL)) { 00121 // Wrap label around input: <label><input /> title</label> 00122 $ret = html::label($widget. ' ' . $title, $id, 'spanning ' . $lbl_class); 00123 } 00124 else { 00125 // label before input <label>title</label><input /> 00126 $ret = html::label($title, $id, 'outside ' . $lbl_class) . $widget; 00127 } 00128 } 00129 else { 00130 $ret = $widget; 00131 } 00132 return $ret; 00133 }
InputWidgetBaseBase::render_postprocess | ( | $ | output, | |
$ | policy | |||
) | [protected] |
Last steps.
Reimplemented in InputWidgetHiddenBase, and InputWidgetMultiselectBase.
Definition at line 138 of file base.input.widget.php.
00138 { 00139 $ret = $output; 00140 if (!Common::flag_is_set($policy, WidgetInput::NO_BREAK)) { 00141 $ret .= html::br(); 00142 } 00143 return $ret; 00144 }
Member Data Documentation
InputWidgetBaseBase::$label
[protected] |
Definition at line 10 of file base.input.widget.php.
InputWidgetBaseBase::$name
[protected] |
Definition at line 9 of file base.input.widget.php.
InputWidgetBaseBase::$params
[protected] |
Definition at line 12 of file base.input.widget.php.
InputWidgetBaseBase::$value
[protected] |
Definition at line 11 of file base.input.widget.php.
The documentation for this class was generated from the following file:
- gyro/core/view/widgets/input/base/base.input.widget.php