ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
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 (string $a_title="", string $a_postvar="")
 
 setOptions (array $a_options)
 
 getOptions ()
 
 setOptionsLangAttribute (\Closure $langresolve)
 
 getOptionsLangAttribute ($key)
 
 setValue ($a_value)
 Set Value. More...
 
 getValue ()
 Get Value. More...
 
 setValueByArray (array $a_values)
 
 checkInput ()
 Check input, strip slashes etc. More...
 
 getInput ()
 
 addCustomAttribute (string $a_attr)
 
 getCustomAttributes ()
 
 render ($a_mode="")
 
 insert (ilTemplate $a_tpl)
 
 getTableFilterHTML ()
 Get input item HTML to be inserted into table filters. More...
 
 getToolbarHTML ()
 Get input item HTML to be inserted into ilToolbarGUI. More...
 
 setHideSubForm (bool $a_value, ?string $a_condition=null)
 Set initial sub form visibility, optionally add dynamic value-based condition. More...
 
 hideSubForm ()
 
- Public Member Functions inherited from ilSubEnabledFormPropertyGUI
 addSubItem (ilFormPropertyGUI $a_item)
 
 getSubItems ()
 
 getSubInputItemsRecursive ()
 returns a flat array of possibly existing subitems recursively More...
 
 checkSubItemsInput ()
 Check SubItems. More...
 
 getSubForm ()
 
 getItemByPostVar (string $a_post_var)
 Get item by post var. More...
 
- Public Member Functions inherited from ilFormPropertyGUI
 __construct (string $a_title="", string $a_postvar="")
 
 executeCommand ()
 
 getType ()
 
 setTitle (string $a_title)
 
 getTitle ()
 
 setPostVar (string $a_postvar)
 
 getPostVar ()
 
 getFieldId ()
 
 setInfo (string $a_info)
 
 getInfo ()
 
 setAlert (string $a_alert)
 
 getAlert ()
 
 setRequired (bool $a_required)
 
 getRequired ()
 
 setDisabled (bool $a_disabled)
 
 getDisabled ()
 
 checkInput ()
 Check input, strip slashes etc. More...
 
 setParentForm (ilPropertyFormGUI $a_parentform)
 
 getParentForm ()
 
 setParent (ilFormPropertyGUI $a_val)
 
 getParent ()
 
 getSubForm ()
 
 hideSubForm ()
 
 setHiddenTitle (string $a_val)
 
 getHiddenTitle ()
 
 getItemByPostVar (string $a_post_var)
 Get item by post var. More...
 
 serializeData ()
 
 unserializeData (string $a_data)
 
 setParentTable ($a_val)
 Set parent table. More...
 
 getParentTable ()
 Get parent table. More...
 
 writeToSession ()
 
 clearFromSession ()
 
 readFromSession ()
 
 getHiddenTag (string $a_post_var, string $a_value)
 
 setMulti (bool $a_multi, bool $a_sortable=false, bool $a_addremove=true)
 
 getMulti ()
 
 setMultiValues (array $a_values)
 
 getMultiValues ()
 
 getContentOutsideFormTag ()
 Get content that has to reside outside of the parent form tag, e.g. More...
 
 stripSlashesAddSpaceFallback (string $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...
 
 setRequestParam (string $key, $val)
 This writes the request (aka post) values. 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

array $cust_attr = array()
 
array $options = array()
 
Closure $langresolve = null
 
 $value
 
bool $hide_sub = false
 
- Protected Attributes inherited from ilSubEnabledFormPropertyGUI
array $sub_items = array()
 
- Protected Attributes inherited from ilFormPropertyGUI
array $set_params = []
 
ilTable2GUI $parent_table = null
 
ilFormPropertyGUI $parent_gui = null
 
ilCtrl $ctrl
 
ilLanguage $lng
 
string $type = ""
 
string $title = ""
 
string $postvar = ""
 
string $info = ""
 
string $alert = ""
 
bool $required = false
 
ilPropertyFormGUI $parentform = null
 
string $hidden_title = ""
 
bool $multi = false
 
bool $multi_sortable = false
 
bool $multi_addremove = true
 
array $multi_values = []
 
RequestInterface $request
 
HTTP Services $http
 
Refinery Factory $refinery = null
 
bool $disabled = false
 
ilGlobalTemplateInterface $global_tpl = null
 

Additional Inherited Members

- Static Public Member Functions inherited from ilFormPropertyGUI
static removeProhibitedCharacters (string $a_text)
 Remove prohibited characters see #19159. More...
 
- Protected Member Functions inherited from ilFormPropertyGUI
 symbol ()
 
 setType (string $a_type)
 
 checkParentFormTable ()
 
 getSessionKey ()
 
 getMultiIconsHTML ()
 
 int ($key)
 
 intArray ($key)
 
 str ($key)
 
 raw ($key)
 
 strArray ($key)
 
 arrayArray ($key)
 
 isRequestParamArray (string $key)
 
 getRequestParam (string $key, Refinery\Transformation $t)
 

Detailed Description

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

Author
Alexander Killing killi.nosp@m.ng@l.nosp@m.eifos.nosp@m..de
Deprecated:
12 This component will be removed with ILIAS 12

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

Constructor & Destructor Documentation

◆ __construct()

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

Reimplemented from ilFormPropertyGUI.

Reimplemented in ilCountrySelectInputGUI.

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

41 {
42 global $DIC;
43
44 $this->lng = $DIC->language();
45 parent::__construct($a_title, $a_postvar);
46 $this->setType("select");
47 }
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
global $DIC
Definition: shib_login.php:26

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

+ Here is the call graph for this function:

Member Function Documentation

◆ addCustomAttribute()

ilSelectInputGUI::addCustomAttribute ( string  $a_attr)

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

144 : void
145 {
146 $this->cust_attr[] = $a_attr;
147 }

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.

Reimplemented from ilFormPropertyGUI.

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

102 : bool
103 {
105
106 $valid = true;
107 if (!$this->getMulti()) {
108 if ($this->getRequired() && trim($this->str($this->getPostVar())) == "") {
109 $valid = false;
110 } elseif (!array_key_exists($this->str($this->getPostVar()), $this->getOptions())) {
111 $this->setAlert($lng->txt('msg_invalid_post_input'));
112 return false;
113 }
114 } else {
115 $values = $this->strArray($this->getPostVar());
116 foreach ($values as $value) {
117 if (!array_key_exists($value, $this->getOptions())) {
118 $this->setAlert($lng->txt('msg_invalid_post_input'));
119 return false;
120 }
121 }
122 if ($this->getRequired() && !trim(implode("", $values))) {
123 $valid = false;
124 }
125 }
126 if (!$valid) {
127 $this->setAlert($lng->txt("msg_input_is_required"));
128 return false;
129 }
130 return $this->checkSubItemsInput();
131 }
txt(string $a_topic, string $a_default_lang_fallback_mod="")
gets the text for a given topic if the topic is not in the list, the topic itself with "-" will be re...
$valid

References ilFormPropertyGUI\$lng, $valid, $value, ilSubEnabledFormPropertyGUI\checkSubItemsInput(), ilFormPropertyGUI\getMulti(), getOptions(), ilFormPropertyGUI\getPostVar(), ilFormPropertyGUI\getRequired(), ilFormPropertyGUI\setAlert(), ilFormPropertyGUI\str(), ilFormPropertyGUI\strArray(), and ilLanguage\txt().

+ Here is the call graph for this function:

◆ getCustomAttributes()

ilSelectInputGUI::getCustomAttributes ( )

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

149 : array
150 {
151 return $this->cust_attr;
152 }

References $cust_attr.

Referenced by render().

+ Here is the caller graph for this function:

◆ getInput()

ilSelectInputGUI::getInput ( )
Returns
string|string[]

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

137 {
138 if (!$this->getMulti()) {
139 return $this->str($this->getPostVar());
140 }
141 return $this->strArray($this->getPostVar());
142 }

References ilFormPropertyGUI\getMulti(), ilFormPropertyGUI\getPostVar(), ilFormPropertyGUI\str(), and ilFormPropertyGUI\strArray().

+ Here is the call graph for this function:

◆ getOptions()

ilSelectInputGUI::getOptions ( )

Reimplemented in ilCountrySelectInputGUI, and ilTaxAssignInputGUI.

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

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

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

+ Here is the caller graph for this function:

◆ getOptionsLangAttribute()

ilSelectInputGUI::getOptionsLangAttribute (   $key)

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

64 : string
65 {
66 return $this->langresolve($this->getOptions(), $key);
67 }

References getOptions().

+ Here is the call graph for this function:

◆ getTableFilterHTML()

ilSelectInputGUI::getTableFilterHTML ( )

Get input item HTML to be inserted into table filters.

Implements ilTableFilterItem.

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

246 : string
247 {
248 $html = $this->render();
249 return $html;
250 }

References render().

+ Here is the call graph for this function:

◆ getToolbarHTML()

ilSelectInputGUI::getToolbarHTML ( )

Get input item HTML to be inserted into ilToolbarGUI.

Implements ilToolbarItem.

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

252 : string
253 {
254 $html = $this->render("toolbar");
255 return $html;
256 }

References render().

+ Here is the call graph for this function:

◆ getValue()

ilSelectInputGUI::getValue ( )

Get Value.

Returns
string|array Value

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

89 {
90 return $this->value;
91 }

References $value.

Referenced by render().

+ Here is the caller graph for this function:

◆ hideSubForm()

ilSelectInputGUI::hideSubForm ( )

Reimplemented from ilFormPropertyGUI.

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

274 : bool
275 {
276 return $this->hide_sub;
277 }

◆ insert()

ilSelectInputGUI::insert ( ilTemplate  $a_tpl)

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

239 : void
240 {
241 $a_tpl->setCurrentBlock("prop_generic");
242 $a_tpl->setVariable("PROP_GENERIC", $this->render());
243 $a_tpl->parseCurrentBlock();
244 }
setVariable($variable, $value='')
Sets a variable value.
Definition: IT.php:544
setCurrentBlock(string $part=ilGlobalTemplateInterface::DEFAULT_BLOCK)
parseCurrentBlock(string $part=ilGlobalTemplateInterface::DEFAULT_BLOCK)

References ilTemplate\parseCurrentBlock(), render(), ilTemplate\setCurrentBlock(), and HTML_Template_IT\setVariable().

+ Here is the call graph for this function:

◆ render()

ilSelectInputGUI::render (   $a_mode = "")

Reimplemented in ilMailTemplateSelectInputGUI.

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

154 : string
155 {
156 $sel_value = "";
157 $tpl = new ilTemplate("tpl.prop_select.html", true, true, "components/ILIAS/Form");
158
159 foreach ($this->getCustomAttributes() as $attr) {
160 $tpl->setCurrentBlock('cust_attr');
161 $tpl->setVariable('CUSTOM_ATTR', $attr);
162 $tpl->parseCurrentBlock();
163 }
164
165 if ($this->getRequired()) {
166 $tpl->setCurrentBlock('required_attribute');
167 $tpl->setVariable('REQUIRED', 'required');
168 $tpl->parseCurrentBlock();
169 }
170
171 // determine value to select. Due to accessibility reasons we
172 // should always select a value (per default the first one)
173 $first = true;
174 foreach ($this->getOptions() as $option_value => $option_text) {
175 if ($first) {
176 $sel_value = $option_value;
177 }
178 $first = false;
179 if ((string) $option_value == (string) $this->getValue()) {
180 $sel_value = $option_value;
181 }
182 }
183 foreach ($this->getOptions() as $option_value => $option_text) {
184 $tpl->setCurrentBlock("prop_select_option");
185 $tpl->setVariable("VAL_SELECT_OPTION", ilLegacyFormElementsUtil::prepareFormOutput((string) $option_value));
186 if ((string) $sel_value == (string) $option_value) {
187 $tpl->setVariable(
188 "CHK_SEL_OPTION",
189 ' selected="selected"'
190 );
191 }
192 $tpl->setVariable("TXT_SELECT_OPTION", $option_text);
193
194 if ($this->langresolve) {
196 $lang = $f($this->getOptions(), $option_value);
197 $tpl->setVariable("OPTION_LANG", ' lang="' . $lang . '"');
198 }
199
200 $tpl->parseCurrentBlock();
201 }
202 $tpl->setVariable("ID", $this->getFieldId());
203
204 $postvar = $this->getPostVar();
205 if ($this->getMulti() && substr($postvar, -2) != "[]") {
206 $postvar .= "[]";
207 }
208
209 $tpl->setVariable("POST_VAR", $postvar);
210 if ($this->getDisabled()) {
211 if ($this->getMulti()) {
212 $value = $this->getMultiValues();
213 $hidden = "";
214 if (is_array($value)) {
215 foreach ($value as $item) {
216 $hidden .= $this->getHiddenTag($postvar, $item);
217 }
218 }
219 } else {
220 $hidden = $this->getHiddenTag($postvar, (string) $this->getValue());
221 }
222 if ($hidden) {
223 $tpl->setVariable("DISABLED", " disabled=\"disabled\"");
224 $tpl->setVariable("HIDDEN_INPUT", $hidden);
225 }
226 }
227
228 // multi icons
229 if ($this->getMulti() && !$a_mode && !$this->getDisabled()) {
230 $tpl->touchBlock("inline_in_bl");
231 $tpl->setVariable("MULTI_ICONS", $this->getMultiIconsHTML());
232 }
233
234 $tpl->setVariable("ARIA_LABEL", ilLegacyFormElementsUtil::prepareFormOutput($this->getTitle()));
235
236 return $tpl->get();
237 }
getHiddenTag(string $a_post_var, string $a_value)
static prepareFormOutput($a_str, bool $a_strip=false)
special template class to simplify handling of ITX/PEAR
$lang
Definition: xapiexit.php:25

References Vendor\Package\$f, $lang, $langresolve, ilFormPropertyGUI\$postvar, $value, getCustomAttributes(), ilFormPropertyGUI\getDisabled(), ilFormPropertyGUI\getFieldId(), ilFormPropertyGUI\getHiddenTag(), ilFormPropertyGUI\getMulti(), ilFormPropertyGUI\getMultiIconsHTML(), ilFormPropertyGUI\getMultiValues(), getOptions(), ilFormPropertyGUI\getPostVar(), ilFormPropertyGUI\getRequired(), ilFormPropertyGUI\getTitle(), getValue(), and ilLegacyFormElementsUtil\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 ( bool  $a_value,
?string  $a_condition = null 
)

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

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

264 : void {
265 $this->hide_sub = $a_value;
266
267 if ($a_condition) {
268 $this->addCustomAttribute('onchange="if(this.value ' . $a_condition . ')' .
269 ' { il.Form.showSubForm(\'subform_' . $this->getFieldId() . '\', \'il_prop_cont_' . $this->getFieldId() . '\'); }' .
270 ' else { il.Form.hideSubForm(\'subform_' . $this->getFieldId() . '\'); };"');
271 }
272 }
addCustomAttribute(string $a_attr)

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

+ Here is the call graph for this function:

◆ setOptions()

ilSelectInputGUI::setOptions ( array  $a_options)

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

49 : void
50 {
51 $this->options = $a_options;
52 }

◆ setOptionsLangAttribute()

ilSelectInputGUI::setOptionsLangAttribute ( \Closure  $langresolve)

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

59 : void
60 {
61 $this->langresolve = $langresolve;
62 }

References $langresolve.

◆ setValue()

ilSelectInputGUI::setValue (   $a_value)

Set Value.

Parameters
string | array$a_valueValue

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

74 : void
75 {
76 if ($this->getMulti() && is_array($a_value)) {
77 $this->setMultiValues($a_value);
78 $a_value = array_shift($a_value);
79 }
80 $this->value = $a_value;
81 }
setMultiValues(array $a_values)

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

Referenced by setValueByArray().

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

◆ setValueByArray()

ilSelectInputGUI::setValueByArray ( array  $a_values)

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

94 : void
95 {
96 $this->setValue($a_values[$this->getPostVar()] ?? "");
97 foreach ($this->getSubItems() as $item) {
98 $item->setValueByArray($a_values);
99 }
100 }
setValue($a_value)
Set Value.

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

+ Here is the call graph for this function:

Field Documentation

◆ $cust_attr

array ilSelectInputGUI::$cust_attr = array()
protected

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

Referenced by getCustomAttributes().

◆ $hide_sub

bool ilSelectInputGUI::$hide_sub = false
protected

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

◆ $langresolve

Closure ilSelectInputGUI::$langresolve = null
protected

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

Referenced by render(), and setOptionsLangAttribute().

◆ $options

array ilSelectInputGUI::$options = array()
protected

◆ $value

ilSelectInputGUI::$value
protected

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

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


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