ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
ilMultiSelectInputGUI Class Reference

This class represents a multi selection list property in a property form. 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
 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 multi 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.ilMultiSelectInputGUI.php.

Constructor & Destructor Documentation

◆ __construct()

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

Reimplemented from ilFormPropertyGUI.

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

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

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 254 of file class.ilMultiSelectInputGUI.php.

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

◆ checkInput()

ilMultiSelectInputGUI::checkInput ( )

Check input, strip slashes etc.

set alert, if input is not ok.

Reimplemented from ilFormPropertyGUI.

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

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

References 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 114 of file class.ilMultiSelectInputGUI.php.

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

◆ enableSelectedFirst()

ilMultiSelectInputGUI::enableSelectedFirst ( bool  $a_value)

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

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

◆ getCustomAttributes()

ilMultiSelectInputGUI::getCustomAttributes ( )

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

243 : array
244 {
246 }

References $custom_attributes.

Referenced by render().

+ Here is the caller graph for this function:

◆ getHeight()

ilMultiSelectInputGUI::getHeight ( )

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

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

References $height.

Referenced by render().

+ Here is the caller graph for this function:

◆ getHeightUnit()

ilMultiSelectInputGUI::getHeightUnit ( )

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

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

References $heightUnit.

Referenced by render().

+ Here is the caller graph for this function:

◆ getInput()

ilMultiSelectInputGUI::getInput ( )

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

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

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 82 of file class.ilMultiSelectInputGUI.php.

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

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 237 of file class.ilMultiSelectInputGUI.php.

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

References render().

+ Here is the call graph for this function:

◆ getValue()

ilMultiSelectInputGUI::getValue ( )
Returns
string[]

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

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

Referenced by render().

+ Here is the caller graph for this function:

◆ getWidth()

ilMultiSelectInputGUI::getWidth ( )

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

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

References $width.

Referenced by render().

+ Here is the caller graph for this function:

◆ getWidthUnit()

ilMultiSelectInputGUI::getWidthUnit ( )

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

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

References $widthUnit.

Referenced by render().

+ Here is the caller graph for this function:

◆ insert()

ilMultiSelectInputGUI::insert ( ilTemplate  $a_tpl)

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

230 : void
231 {
232 $a_tpl->setCurrentBlock("prop_generic");
233 $a_tpl->setVariable("PROP_GENERIC", $this->render());
234 $a_tpl->parseCurrentBlock();
235 }
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()

ilMultiSelectInputGUI::render ( )

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

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

References ilFormPropertyGUI\$lng, $options, 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 248 of file class.ilMultiSelectInputGUI.php.

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

References $custom_attributes.

◆ setHeight()

ilMultiSelectInputGUI::setHeight ( int  $a_height)

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

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

◆ setHeightUnit()

ilMultiSelectInputGUI::setHeightUnit ( string  $heightUnit)

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

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

References $heightUnit.

◆ setOptions()

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

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

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

◆ setValue()

ilMultiSelectInputGUI::setValue (   $a_array)
Parameters
mixed

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

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

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 109 of file class.ilMultiSelectInputGUI.php.

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

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

+ Here is the call graph for this function:

◆ setWidth()

ilMultiSelectInputGUI::setWidth ( int  $a_width)

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

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

◆ setWidthUnit()

ilMultiSelectInputGUI::setWidthUnit ( string  $widthUnit)

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

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

References $widthUnit.

◆ unserializeData()

ilMultiSelectInputGUI::unserializeData ( string  $a_data)

Reimplemented from ilFormPropertyGUI.

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

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

References $data, and setValue().

+ Here is the call graph for this function:

Field Documentation

◆ $custom_attributes

array ilMultiSelectInputGUI::$custom_attributes = []
protected

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

Referenced by getCustomAttributes(), and setCustomAttributes().

◆ $height

int ilMultiSelectInputGUI::$height = 100
private

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

Referenced by getHeight().

◆ $heightUnit

string ilMultiSelectInputGUI::$heightUnit = 'px'
protected

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

Referenced by getHeightUnit(), and setHeightUnit().

◆ $options

array ilMultiSelectInputGUI::$options = []
protected

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

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

◆ $select_all

bool ilMultiSelectInputGUI::$select_all = false
protected

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

◆ $selected_first

bool ilMultiSelectInputGUI::$selected_first = false
protected

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

◆ $value

array ilMultiSelectInputGUI::$value = []
protected

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

◆ $width

int ilMultiSelectInputGUI::$width = 160
private

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

Referenced by getWidth().

◆ $widthUnit

string ilMultiSelectInputGUI::$widthUnit = 'px'
protected

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

Referenced by getWidthUnit(), and setWidthUnit().


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