ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
ilSelectInputGUI Class Reference

This class represents a selection list property in a property form. More...

+ Inheritance diagram for ilSelectInputGUI:
+ Collaboration diagram for ilSelectInputGUI:

Public Member Functions

 __construct ($a_title="", $a_postvar="")
 Constructor. More...
 
 setOptions ($a_options)
 Set Options. More...
 
 getOptions ()
 Get Options. More...
 
 setValue ($a_value)
 Set Value. More...
 
 getValue ()
 Get Value. More...
 
 setValueByArray ($a_values)
 Set value by array. More...
 
 checkInput ()
 Check input, strip slashes etc. More...
 
 addCustomAttribute ($a_attr)
 
 getCustomAttributes ()
 
 render ($a_mode="")
 Render item. More...
 
 insert ($a_tpl)
 Insert property html. More...
 
 getTableFilterHTML ()
 Get HTML for table filter. More...
 
 getToolbarHTML ()
 Get HTML for toolbar. More...
 
 setHideSubForm ($a_value, $a_condition=null)
 Set initial sub form visibility, optionally add dynamic value-based condition. More...
 
 hideSubForm ()
 Sub form hidden on init? More...
 
- Public Member Functions inherited from ilSubEnabledFormPropertyGUI
 addSubItem ($a_item)
 Add Subitem. More...
 
 getSubItems ()
 Get Subitems. More...
 
 getSubInputItemsRecursive ()
 returns a flat array of possibly existing subitems recursively More...
 
 checkSubItemsInput ()
 Check SubItems. More...
 
 getSubForm ()
 Get sub form html. More...
 
 getItemByPostVar ($a_post_var)
 Get item by post var. More...
 
- Public Member Functions inherited from ilFormPropertyGUI
 __construct ($a_title="", $a_postvar="")
 Constructor. More...
 
 executeCommand ()
 Execute command. More...
 
 getType ()
 Get Type. More...
 
 setTitle ($a_title)
 Set Title. More...
 
 getTitle ()
 Get Title. More...
 
 setPostVar ($a_postvar)
 Set Post Variable. More...
 
 getPostVar ()
 Get Post Variable. More...
 
 getFieldId ()
 Get Post Variable. More...
 
 setInfo ($a_info)
 Set Information Text. More...
 
 getInfo ()
 Get Information Text. More...
 
 setAlert ($a_alert)
 Set Alert Text. More...
 
 getAlert ()
 Get Alert Text. More...
 
 setRequired ($a_required)
 Set Required. More...
 
 getRequired ()
 Get Required. More...
 
 setDisabled ($a_disabled)
 Set Disabled. More...
 
 getDisabled ()
 Get Disabled. More...
 
 checkInput ()
 Check input, strip slashes etc. More...
 
 setParentForm ($a_parentform)
 Set Parent Form. More...
 
 getParentForm ()
 Get Parent Form. More...
 
 setParent ($a_val)
 Set Parent GUI object. More...
 
 getParent ()
 Get Parent GUI object. More...
 
 getSubForm ()
 Get sub form html. More...
 
 hideSubForm ()
 Sub form hidden on init? More...
 
 setHiddenTitle ($a_val)
 Set hidden title (for screenreaders) More...
 
 getHiddenTitle ()
 Get hidden title. More...
 
 getItemByPostVar ($a_post_var)
 Get item by post var. More...
 
 serializeData ()
 serialize data More...
 
 unserializeData ($a_data)
 unserialize data More...
 
 writeToSession ()
 Write to session. More...
 
 clearFromSession ()
 Clear session value. More...
 
 readFromSession ()
 Read from session. More...
 
 getHiddenTag ($a_post_var, $a_value)
 Get hidden tag (used for disabled properties) More...
 
 setMulti ($a_multi, $a_sortable=false, $a_addremove=true)
 Set Multi. More...
 
 getMulti ()
 Get Multi. More...
 
 setMultiValues (array $a_values)
 Set multi values. More...
 
 getMultiValues ()
 Get multi values. More...
 
 getContentOutsideFormTag ()
 Get content that has to reside outside of the parent form tag, e.g. More...
 
 stripSlashesAddSpaceFallback ($a_str)
 Strip slashes with add space fallback, see https://www.ilias.de/mantis/view.php?id=19727. More...
 
 getTableFilterLabelFor ()
 Get label "for" attribute value for filter. More...
 
 getFormLabelFor ()
 Get label "for" attribute value for form. More...
 
- Public Member Functions inherited from ilTableFilterItem
 getTableFilterHTML ()
 Get input item HTML to be inserted into table filters. More...
 
 getTableFilterLabelFor ()
 Get label "for" attribute value. More...
 
 getToolbarHTML ()
 Get input item HTML to be inserted into ilToolbarGUI. More...
 

Protected Attributes

 $cust_attr = array()
 
 $options = array()
 
 $value
 
- Protected Attributes inherited from ilSubEnabledFormPropertyGUI
 $sub_items = array()
 
- Protected Attributes inherited from ilFormPropertyGUI
 $ctrl
 
 $lng
 
 $type
 
 $title
 
 $postvar
 
 $info
 
 $alert
 
 $required = false
 
 $parentgui
 
 $parentform
 
 $hidden_title = ""
 
 $multi = false
 
 $multi_sortable = false
 
 $multi_addremove = true
 
 $multi_values
 

Additional Inherited Members

- Static Public Member Functions inherited from ilFormPropertyGUI
static removeProhibitedCharacters ($a_text)
 Remove prohibited characters see #19159. More...
 
- Protected Member Functions inherited from ilFormPropertyGUI
 setType ($a_type)
 Set Type. More...
 
 getMultiIconsHTML ()
 Get HTML for multiple value icons. More...
 

Detailed Description

This class represents a selection list property in a property form.

Author
Alex Killing alex..nosp@m.kill.nosp@m.ing@g.nosp@m.mx.d.nosp@m.e
Version
$Id$

Definition at line 17 of file class.ilSelectInputGUI.php.

Constructor & Destructor Documentation

◆ __construct()

ilSelectInputGUI::__construct (   $a_title = "",
  $a_postvar = "" 
)

Constructor.

Parameters
string$a_titleTitle
string$a_postvarPost Variable

Reimplemented from ilFormPropertyGUI.

Reimplemented in ilCountrySelectInputGUI.

Definition at line 29 of file class.ilSelectInputGUI.php.

30 {
31 global $DIC;
32
33 $this->lng = $DIC->language();
34 parent::__construct($a_title, $a_postvar);
35 $this->setType("select");
36 }
setType($a_type)
Set Type.
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
$DIC
Definition: xapitoken.php:46

References $DIC, ILIAS\GlobalScreen\Provider\__construct(), and ilFormPropertyGUI\setType().

+ Here is the call graph for this function:

Member Function Documentation

◆ addCustomAttribute()

ilSelectInputGUI::addCustomAttribute (   $a_attr)

Definition at line 135 of file class.ilSelectInputGUI.php.

136 {
137 $this->cust_attr[] = $a_attr;
138 }

Referenced by setHideSubForm().

+ Here is the caller graph for this function:

◆ checkInput()

ilSelectInputGUI::checkInput ( )

Check input, strip slashes etc.

set alert, if input is not ok.

Returns
boolean Input ok, true/false

Reimplemented from ilFormPropertyGUI.

Definition at line 101 of file class.ilSelectInputGUI.php.

102 {
104
105 $valid = true;
106 if (!$this->getMulti()) {
108 if ($this->getRequired() && trim($_POST[$this->getPostVar()]) == "") {
109 $valid = false;
110 } elseif (!array_key_exists($_POST[$this->getPostVar()], (array) $this->getOptions())) {
111 $this->setAlert($lng->txt('msg_invalid_post_input'));
112 return false;
113 }
114 } else {
115 foreach ($_POST[$this->getPostVar()] as $idx => $value) {
116 $_POST[$this->getPostVar()][$idx] = ilUtil::stripSlashes($value);
117 if (!array_key_exists($value, (array) $this->getOptions())) {
118 $this->setAlert($lng->txt('msg_invalid_post_input'));
119 return false;
120 }
121 }
122 $_POST[$this->getPostVar()] = array_unique($_POST[$this->getPostVar()]);
123
124 if ($this->getRequired() && !trim(implode("", $_POST[$this->getPostVar()]))) {
125 $valid = false;
126 }
127 }
128 if (!$valid) {
129 $this->setAlert($lng->txt("msg_input_is_required"));
130 return false;
131 }
132 return $this->checkSubItemsInput();
133 }
$_POST["username"]
getPostVar()
Get Post Variable.
setAlert($a_alert)
Set Alert Text.
static stripSlashes($a_str, $a_strip_html=true, $a_allow="")
strip slashes if magic qoutes is enabled
$valid

References $_POST, ilFormPropertyGUI\$lng, $valid, $value, ilSubEnabledFormPropertyGUI\checkSubItemsInput(), ilFormPropertyGUI\getMulti(), getOptions(), ilFormPropertyGUI\getPostVar(), ilFormPropertyGUI\getRequired(), ilFormPropertyGUI\setAlert(), and ilUtil\stripSlashes().

+ Here is the call graph for this function:

◆ getCustomAttributes()

ilSelectInputGUI::getCustomAttributes ( )

Definition at line 140 of file class.ilSelectInputGUI.php.

141 {
142 return (array) $this->cust_attr;
143 }

References $cust_attr.

Referenced by render().

+ Here is the caller graph for this function:

◆ getOptions()

ilSelectInputGUI::getOptions ( )

Get Options.

Returns
array Options. Array ("value" => "option_text")

Reimplemented in ilCountrySelectInputGUI, and ilTaxAssignInputGUI.

Definition at line 53 of file class.ilSelectInputGUI.php.

54 {
55 return $this->options ? $this->options : array();
56 }

Referenced by checkInput(), and render().

+ Here is the caller graph for this function:

◆ getTableFilterHTML()

ilSelectInputGUI::getTableFilterHTML ( )

Get HTML for table filter.

Implements ilTableFilterItem.

Definition at line 235 of file class.ilSelectInputGUI.php.

236 {
237 $html = $this->render();
238 return $html;
239 }
render($a_mode="")
Render item.

References render().

+ Here is the call graph for this function:

◆ getToolbarHTML()

ilSelectInputGUI::getToolbarHTML ( )

Get HTML for toolbar.

Implements ilToolbarItem.

Definition at line 244 of file class.ilSelectInputGUI.php.

245 {
246 $html = $this->render("toolbar");
247 return $html;
248 }

References render().

+ Here is the call graph for this function:

◆ getValue()

ilSelectInputGUI::getValue ( )

Get Value.

Returns
string Value

Definition at line 77 of file class.ilSelectInputGUI.php.

78 {
79 return $this->value;
80 }

References $value.

Referenced by render().

+ Here is the caller graph for this function:

◆ hideSubForm()

ilSelectInputGUI::hideSubForm ( )

Sub form hidden on init?

Reimplemented from ilFormPropertyGUI.

Definition at line 268 of file class.ilSelectInputGUI.php.

269 {
270 return (bool) $this->hide_sub;
271 }

◆ insert()

ilSelectInputGUI::insert (   $a_tpl)

Insert property html.

Returns
int Size

Definition at line 225 of file class.ilSelectInputGUI.php.

226 {
227 $a_tpl->setCurrentBlock("prop_generic");
228 $a_tpl->setVariable("PROP_GENERIC", $this->render());
229 $a_tpl->parseCurrentBlock();
230 }

References render().

+ Here is the call graph for this function:

◆ render()

ilSelectInputGUI::render (   $a_mode = "")

Render item.

Reimplemented in ilMailTemplateSelectInputGUI.

Definition at line 148 of file class.ilSelectInputGUI.php.

149 {
150 $tpl = new ilTemplate("tpl.prop_select.html", true, true, "Services/Form");
151
152 foreach ($this->getCustomAttributes() as $attr) {
153 $tpl->setCurrentBlock('cust_attr');
154 $tpl->setVariable('CUSTOM_ATTR', $attr);
155 $tpl->parseCurrentBlock();
156 }
157
158 // determin value to select. Due to accessibility reasons we
159 // should always select a value (per default the first one)
160 $first = true;
161 foreach ($this->getOptions() as $option_value => $option_text) {
162 if ($first) {
163 $sel_value = $option_value;
164 }
165 $first = false;
166 if ((string) $option_value == (string) $this->getValue()) {
167 $sel_value = $option_value;
168 }
169 }
170 foreach ($this->getOptions() as $option_value => $option_text) {
171 $tpl->setCurrentBlock("prop_select_option");
172 $tpl->setVariable("VAL_SELECT_OPTION", ilUtil::prepareFormOutput($option_value));
173 if ((string) $sel_value == (string) $option_value) {
174 $tpl->setVariable(
175 "CHK_SEL_OPTION",
176 'selected="selected"'
177 );
178 }
179 $tpl->setVariable("TXT_SELECT_OPTION", $option_text);
180 $tpl->parseCurrentBlock();
181 }
182 $tpl->setVariable("ID", $this->getFieldId());
183
184 $postvar = $this->getPostVar();
185 if ($this->getMulti() && substr($postvar, -2) != "[]") {
186 $postvar .= "[]";
187 }
188
189 if ($this->getDisabled()) {
190 if ($this->getMulti()) {
191 $value = $this->getMultiValues();
192 $hidden = "";
193 if (is_array($value)) {
194 foreach ($value as $item) {
195 $hidden .= $this->getHiddenTag($postvar, $item);
196 }
197 }
198 } else {
199 $hidden = $this->getHiddenTag($postvar, $this->getValue());
200 }
201 if ($hidden) {
202 $tpl->setVariable("DISABLED", " disabled=\"disabled\"");
203 $tpl->setVariable("HIDDEN_INPUT", $hidden);
204 }
205 } else {
206 $tpl->setVariable("POST_VAR", $postvar);
207 }
208
209 // multi icons
210 if ($this->getMulti() && !$a_mode && !$this->getDisabled()) {
211 $tpl->touchBlock("inline_in_bl");
212 $tpl->setVariable("MULTI_ICONS", $this->getMultiIconsHTML());
213 }
214
215 $tpl->setVariable("ARIA_LABEL", ilUtil::prepareFormOutput($this->getTitle()));
216
217 return $tpl->get();
218 }
getMultiIconsHTML()
Get HTML for multiple value icons.
getHiddenTag($a_post_var, $a_value)
Get hidden tag (used for disabled properties)
getMultiValues()
Get multi values.
getFieldId()
Get Post Variable.
special template class to simplify handling of ITX/PEAR
static prepareFormOutput($a_str, $a_strip=false)
prepares string output for html forms @access public
if(isset($_FILES['img_file']['size']) && $_FILES['img_file']['size'] > 0) $tpl

References ilFormPropertyGUI\$postvar, $tpl, $value, getCustomAttributes(), ilFormPropertyGUI\getDisabled(), ilFormPropertyGUI\getFieldId(), ilFormPropertyGUI\getHiddenTag(), ilFormPropertyGUI\getMulti(), ilFormPropertyGUI\getMultiIconsHTML(), ilFormPropertyGUI\getMultiValues(), getOptions(), ilFormPropertyGUI\getPostVar(), ilFormPropertyGUI\getTitle(), getValue(), and ilUtil\prepareFormOutput().

Referenced by getTableFilterHTML(), getToolbarHTML(), and insert().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setHideSubForm()

ilSelectInputGUI::setHideSubForm (   $a_value,
  $a_condition = null 
)

Set initial sub form visibility, optionally add dynamic value-based condition.

See also
ilObjBookingPoolGUI
Parameters
bool$a_value
string$a_condition

Definition at line 257 of file class.ilSelectInputGUI.php.

258 {
259 $this->hide_sub = (bool) $a_value;
260
261 if ($a_condition) {
262 $this->addCustomAttribute('onchange="if(this.value ' . $a_condition . ')' .
263 ' { il.Form.showSubForm(\'subform_' . $this->getFieldId() . '\', \'il_prop_cont_' . $this->getFieldId() . '\'); }' .
264 ' else { il.Form.hideSubForm(\'subform_' . $this->getFieldId() . '\'); };"');
265 }
266 }

References addCustomAttribute(), and ilFormPropertyGUI\getFieldId().

+ Here is the call graph for this function:

◆ setOptions()

ilSelectInputGUI::setOptions (   $a_options)

Set Options.

Parameters
array$a_optionsOptions. Array ("value" => "option_text")

Reimplemented in ilTaxAssignInputGUI.

Definition at line 43 of file class.ilSelectInputGUI.php.

44 {
45 $this->options = $a_options;
46 }

◆ setValue()

ilSelectInputGUI::setValue (   $a_value)

Set Value.

Parameters
string$a_valueValue

Definition at line 63 of file class.ilSelectInputGUI.php.

64 {
65 if ($this->getMulti() && is_array($a_value)) {
66 $this->setMultiValues($a_value);
67 $a_value = array_shift($a_value);
68 }
69 $this->value = $a_value;
70 }
setMultiValues(array $a_values)
Set multi values.

References ilFormPropertyGUI\getMulti(), and ilFormPropertyGUI\setMultiValues().

Referenced by ilTaxAssignInputGUI\setCurrentValues(), and setValueByArray().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setValueByArray()

ilSelectInputGUI::setValueByArray (   $a_values)

Set value by array.

Parameters
array$a_valuesvalue array

Definition at line 88 of file class.ilSelectInputGUI.php.

89 {
90 $this->setValue($a_values[$this->getPostVar()]);
91 foreach ($this->getSubItems() as $item) {
92 $item->setValueByArray($a_values);
93 }
94 }
setValue($a_value)
Set Value.

References ilFormPropertyGUI\getPostVar(), ilSubEnabledFormPropertyGUI\getSubItems(), and setValue().

+ Here is the call graph for this function:

Field Documentation

◆ $cust_attr

ilSelectInputGUI::$cust_attr = array()
protected

Definition at line 19 of file class.ilSelectInputGUI.php.

Referenced by getCustomAttributes().

◆ $options

ilSelectInputGUI::$options = array()
protected

◆ $value

ilSelectInputGUI::$value
protected

Definition at line 21 of file class.ilSelectInputGUI.php.

Referenced by checkInput(), getValue(), and render().


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