ILIAS  release_8 Revision v8.24
ilMultiSelectInputGUI Class Reference

This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V. More...

+ Inheritance diagram for ilMultiSelectInputGUI:
+ Collaboration diagram for ilMultiSelectInputGUI:

Public Member Functions

 __construct (string $a_title="", string $a_postvar="")
 
 setWidth (int $a_width)
 
 getWidth ()
 
 setHeight (int $a_height)
 
 getHeight ()
 
 setOptions (array $a_options)
 
 getOptions ()
 
 setValue ($a_array)
 
 getValue ()
 
 setValueByArray (array $a_values)
 
 enableSelectAll (bool $a_value)
 
 enableSelectedFirst (bool $a_value)
 
 checkInput ()
 Check input, strip slashes etc. More...
 
 getInput ()
 
 render ()
 
 insert (ilTemplate $a_tpl)
 
 getTableFilterHTML ()
 Get input item HTML to be inserted into table filters. More...
 
 getCustomAttributes ()
 
 setCustomAttributes (array $custom_attributes)
 
 addCustomAttribute (string $custom_attribute)
 
 getWidthUnit ()
 
 setWidthUnit (string $widthUnit)
 
 getHeightUnit ()
 
 setHeightUnit (string $heightUnit)
 
 unserializeData (string $a_data)
 
- 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...
 

Protected Attributes

array $options = []
 
array $value = []
 
bool $select_all = false
 
bool $selected_first = false
 
string $widthUnit = 'px'
 
string $heightUnit = 'px'
 
array $custom_attributes = []
 
- 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
 

Private Attributes

int $width = 160
 
int $height = 100
 

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
 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 file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V.

ILIAS is licensed with the GPL-3.0, see https://www.gnu.org/licenses/gpl-3.0.en.html You should have received a copy of said license along with the source code, too.

If this is not the case or you just want to try ILIAS, you'll find us at: https://www.ilias.de https://github.com/ILIAS-eLearning This class represents a multi selection list property in a property form.

Author
Alexander Killing killi.nosp@m.ng@l.nosp@m.eifos.nosp@m..de

Definition at line 26 of file class.ilMultiSelectInputGUI.php.

Constructor & Destructor Documentation

◆ __construct()

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

Reimplemented from ilFormPropertyGUI.

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

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

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

+ Here is the call graph for this function:

Member Function Documentation

◆ addCustomAttribute()

ilMultiSelectInputGUI::addCustomAttribute ( string  $custom_attribute)

Definition at line 253 of file class.ilMultiSelectInputGUI.php.

253 : void
254 {
255 $this->custom_attributes[] = $custom_attribute;
256 }

◆ checkInput()

ilMultiSelectInputGUI::checkInput ( )

Check input, strip slashes etc.

set alert, if input is not ok.

Reimplemented from ilFormPropertyGUI.

Definition at line 123 of file class.ilMultiSelectInputGUI.php.

123 : bool
124 {
126
127 $val = $this->getInput();
128 if ($this->getRequired() && count($val) == 0) {
129 $this->setAlert($lng->txt("msg_input_is_required"));
130 return false;
131 }
132 if (count($val) > 0) {
133 $options = array_map(function ($k) {
134 return (string) $k;
135 }, array_keys($this->getOptions()));
136 foreach ($val as $key => $val2) {
137 if ($key != 0 || $val2 != "") {
138 if (!in_array((string) $val2, $options)) {
139 $this->setAlert($lng->txt("msg_unknown_value"));
140 return false;
141 }
142 }
143 }
144 }
145 return true;
146 }
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...
string $key
Consumer key/client ID value.
Definition: System.php:193

References ILIAS\LTI\ToolProvider\$key, ilFormPropertyGUI\$lng, $options, getInput(), getOptions(), ilFormPropertyGUI\getRequired(), ilFormPropertyGUI\setAlert(), and ilLanguage\txt().

+ Here is the call graph for this function:

◆ enableSelectAll()

ilMultiSelectInputGUI::enableSelectAll ( bool  $a_value)

Definition at line 113 of file class.ilMultiSelectInputGUI.php.

113 : void
114 {
115 $this->select_all = $a_value;
116 }

◆ enableSelectedFirst()

ilMultiSelectInputGUI::enableSelectedFirst ( bool  $a_value)

Definition at line 118 of file class.ilMultiSelectInputGUI.php.

118 : void
119 {
120 $this->selected_first = $a_value;
121 }

◆ getCustomAttributes()

ilMultiSelectInputGUI::getCustomAttributes ( )

Definition at line 242 of file class.ilMultiSelectInputGUI.php.

242 : array
243 {
245 }

References $custom_attributes.

Referenced by render().

+ Here is the caller graph for this function:

◆ getHeight()

ilMultiSelectInputGUI::getHeight ( )

Definition at line 65 of file class.ilMultiSelectInputGUI.php.

65 : int
66 {
67 return $this->height;
68 }

References $height.

Referenced by render().

+ Here is the caller graph for this function:

◆ getHeightUnit()

ilMultiSelectInputGUI::getHeightUnit ( )

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

268 : string
269 {
270 return $this->heightUnit;
271 }

References $heightUnit.

Referenced by render().

+ Here is the caller graph for this function:

◆ getInput()

ilMultiSelectInputGUI::getInput ( )

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

148 : array
149 {
150 return $this->strArray($this->getPostVar());
151 }

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

Referenced by checkInput().

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

◆ getOptions()

ilMultiSelectInputGUI::getOptions ( )
Returns
array<string,string>

Definition at line 81 of file class.ilMultiSelectInputGUI.php.

81 : array
82 {
83 return $this->options;
84 }

References $options.

Referenced by checkInput(), and render().

+ Here is the caller graph for this function:

◆ getTableFilterHTML()

ilMultiSelectInputGUI::getTableFilterHTML ( )

Get input item HTML to be inserted into table filters.

Implements ilTableFilterItem.

Definition at line 236 of file class.ilMultiSelectInputGUI.php.

236 : string
237 {
238 $html = $this->render();
239 return $html;
240 }

References render().

+ Here is the call graph for this function:

◆ getValue()

ilMultiSelectInputGUI::getValue ( )
Returns
string[]

Definition at line 100 of file class.ilMultiSelectInputGUI.php.

100 : array
101 {
102 return is_array($this->value) ? $this->value : array();
103 }

Referenced by render().

+ Here is the caller graph for this function:

◆ getWidth()

ilMultiSelectInputGUI::getWidth ( )

Definition at line 55 of file class.ilMultiSelectInputGUI.php.

55 : int
56 {
57 return $this->width;
58 }

References $width.

Referenced by render().

+ Here is the caller graph for this function:

◆ getWidthUnit()

ilMultiSelectInputGUI::getWidthUnit ( )

Definition at line 258 of file class.ilMultiSelectInputGUI.php.

258 : string
259 {
260 return $this->widthUnit;
261 }

References $widthUnit.

Referenced by render().

+ Here is the caller graph for this function:

◆ insert()

ilMultiSelectInputGUI::insert ( ilTemplate  $a_tpl)

Definition at line 229 of file class.ilMultiSelectInputGUI.php.

229 : void
230 {
231 $a_tpl->setCurrentBlock("prop_generic");
232 $a_tpl->setVariable("PROP_GENERIC", $this->render());
233 $a_tpl->parseCurrentBlock();
234 }
setVariable($variable, $value='')
Sets a variable value.
Definition: IT.php:514
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()

ilMultiSelectInputGUI::render ( )

Definition at line 153 of file class.ilMultiSelectInputGUI.php.

153 : string
154 {
156
157 $tpl = new ilTemplate("tpl.prop_multi_select.html", true, true, "Services/Form");
158 $values = $this->getValue();
159
160 $options = $this->getOptions();
161 if ($options) {
162 if ($this->select_all) {
163 // enable select all toggle
164 $tpl->setCurrentBlock("item");
165 $tpl->setVariable("VAL", "");
166 $tpl->setVariable("ID_VAL", ilLegacyFormElementsUtil::prepareFormOutput("all__toggle"));
167 $tpl->setVariable("IID", $this->getFieldId());
168 $tpl->setVariable("TXT_OPTION", "<em>" . $lng->txt("select_all") . "</em>");
169 $tpl->setVariable("POST_VAR", $this->getPostVar());
170 $tpl->parseCurrentBlock();
171
172 $tpl->setVariable("TOGGLE_FIELD_ID", $this->getFieldId());
173 $tpl->setVariable("TOGGLE_ALL_ID", $this->getFieldId() . "_all__toggle");
174 $tpl->setVariable("TOGGLE_ALL_CBOX_ID", $this->getFieldId() . "_");
175 }
176
177 if ($this->selected_first) {
178 // move selected values to top
179 $tmp_checked = $tmp_unchecked = array();
180 foreach ($options as $option_value => $option_text) {
181 if (in_array($option_value, $values)) {
182 $tmp_checked[$option_value] = $option_text;
183 } else {
184 $tmp_unchecked[$option_value] = $option_text;
185 }
186 }
187 $options = $tmp_checked + $tmp_unchecked;
188 unset($tmp_checked);
189 unset($tmp_unchecked);
190 }
191
192 foreach ($options as $option_value => $option_text) {
193 $tpl->setCurrentBlock("item");
194 if ($this->getDisabled()) {
195 $tpl->setVariable(
196 "DISABLED",
197 " disabled=\"disabled\""
198 );
199 }
200 if (in_array($option_value, $values)) {
201 $tpl->setVariable(
202 "CHECKED",
203 " checked=\"checked\""
204 );
205 }
206
207 $tpl->setVariable("VAL", ilLegacyFormElementsUtil::prepareFormOutput($option_value));
208 $tpl->setVariable("ID_VAL", ilLegacyFormElementsUtil::prepareFormOutput($option_value));
209 $tpl->setVariable("IID", $this->getFieldId());
210 $tpl->setVariable("TXT_OPTION", $option_text);
211 $tpl->setVariable("POST_VAR", $this->getPostVar());
212 $tpl->parseCurrentBlock();
213 }
214 }
215
216 $tpl->setVariable("ID", $this->getFieldId());
217 $tpl->setVariable("CUSTOM_ATTRIBUTES", implode(' ', $this->getCustomAttributes()));
218
219 if ($this->getWidth()) {
220 $tpl->setVariable("WIDTH", $this->getWidth() . ($this->getWidthUnit() ?: ''));
221 }
222 if ($this->getHeight()) {
223 $tpl->setVariable("HEIGHT", $this->getHeight() . ($this->getHeightUnit() ?: ''));
224 }
225
226 return $tpl->get();
227 }
static prepareFormOutput($a_str, bool $a_strip=false)
special template class to simplify handling of ITX/PEAR
if($DIC->http() ->request() ->getMethod()=="GET" &&isset($DIC->http() ->request() ->getQueryParams()['tex'])) $tpl
Definition: latex.php:41

References ilFormPropertyGUI\$lng, $options, $tpl, getCustomAttributes(), ilFormPropertyGUI\getDisabled(), ilFormPropertyGUI\getFieldId(), getHeight(), getHeightUnit(), getOptions(), ilFormPropertyGUI\getPostVar(), getValue(), getWidth(), getWidthUnit(), ilLegacyFormElementsUtil\prepareFormOutput(), and ilLanguage\txt().

Referenced by getTableFilterHTML(), and insert().

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

◆ setCustomAttributes()

ilMultiSelectInputGUI::setCustomAttributes ( array  $custom_attributes)

Definition at line 247 of file class.ilMultiSelectInputGUI.php.

247 : void
248 {
249 $this->custom_attributes = $custom_attributes;
250 }

References $custom_attributes.

◆ setHeight()

ilMultiSelectInputGUI::setHeight ( int  $a_height)

Definition at line 60 of file class.ilMultiSelectInputGUI.php.

60 : void
61 {
62 $this->height = $a_height;
63 }

◆ setHeightUnit()

ilMultiSelectInputGUI::setHeightUnit ( string  $heightUnit)

Definition at line 273 of file class.ilMultiSelectInputGUI.php.

273 : void
274 {
275 $this->heightUnit = $heightUnit;
276 }

References $heightUnit.

◆ setOptions()

ilMultiSelectInputGUI::setOptions ( array  $a_options)
Parameters
array<string,string>$a_options Options. Array ("value" => "option_text")

Definition at line 73 of file class.ilMultiSelectInputGUI.php.

73 : void
74 {
75 $this->options = $a_options;
76 }

◆ setValue()

ilMultiSelectInputGUI::setValue (   $a_array)
Parameters
mixed

Definition at line 89 of file class.ilMultiSelectInputGUI.php.

89 : void
90 {
91 $this->value = [];
92 if (is_array($a_array)) {
93 $this->value = $a_array;
94 }
95 }

Referenced by __construct(), setValueByArray(), and unserializeData().

+ Here is the caller graph for this function:

◆ setValueByArray()

ilMultiSelectInputGUI::setValueByArray ( array  $a_values)
Parameters
string[]

Definition at line 108 of file class.ilMultiSelectInputGUI.php.

108 : void
109 {
110 $this->setValue($a_values[$this->getPostVar()] ?? []);
111 }

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

+ Here is the call graph for this function:

◆ setWidth()

ilMultiSelectInputGUI::setWidth ( int  $a_width)

Definition at line 50 of file class.ilMultiSelectInputGUI.php.

50 : void
51 {
52 $this->width = $a_width;
53 }

◆ setWidthUnit()

ilMultiSelectInputGUI::setWidthUnit ( string  $widthUnit)

Definition at line 263 of file class.ilMultiSelectInputGUI.php.

263 : void
264 {
265 $this->widthUnit = $widthUnit;
266 }

References $widthUnit.

◆ unserializeData()

ilMultiSelectInputGUI::unserializeData ( string  $a_data)

Reimplemented from ilFormPropertyGUI.

Definition at line 278 of file class.ilMultiSelectInputGUI.php.

278 : void
279 {
280 $data = unserialize($a_data);
281
282 if (is_array($data)) {
283 $this->setValue($data);
284 } else {
285 $this->setValue([]);
286 }
287 }

References $data, and setValue().

+ Here is the call graph for this function:

Field Documentation

◆ $custom_attributes

array ilMultiSelectInputGUI::$custom_attributes = []
protected

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

Referenced by getCustomAttributes(), and setCustomAttributes().

◆ $height

int ilMultiSelectInputGUI::$height = 100
private

Definition at line 33 of file class.ilMultiSelectInputGUI.php.

Referenced by getHeight().

◆ $heightUnit

string ilMultiSelectInputGUI::$heightUnit = 'px'
protected

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

Referenced by getHeightUnit(), and setHeightUnit().

◆ $options

array ilMultiSelectInputGUI::$options = []
protected

Definition at line 28 of file class.ilMultiSelectInputGUI.php.

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

◆ $select_all

bool ilMultiSelectInputGUI::$select_all = false
protected

Definition at line 30 of file class.ilMultiSelectInputGUI.php.

◆ $selected_first

bool ilMultiSelectInputGUI::$selected_first = false
protected

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

◆ $value

array ilMultiSelectInputGUI::$value = []
protected

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

◆ $width

int ilMultiSelectInputGUI::$width = 160
private

Definition at line 32 of file class.ilMultiSelectInputGUI.php.

Referenced by getWidth().

◆ $widthUnit

string ilMultiSelectInputGUI::$widthUnit = 'px'
protected

Definition at line 34 of file class.ilMultiSelectInputGUI.php.

Referenced by getWidthUnit(), and setWidthUnit().


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