ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
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 ($a_title="", $a_postvar="")
 Constructor. More...
 
 setWidth ($a_width)
 Sets the width of this field. More...
 
 getWidth ()
 Returns the width currently set for this field. More...
 
 setHeight ($a_height)
 Sets the height of this field. More...
 
 getHeight ()
 Returns the height currently set for this field. More...
 
 setOptions ($a_options)
 Set Options. More...
 
 getOptions ()
 Get Options. More...
 
 setValue ($a_array)
 Set Value. More...
 
 getValue ()
 Get Value. More...
 
 setValueByArray ($a_values)
 Set value by array. More...
 
 enableSelectAll ($a_value)
 
 enableSelectedFirst ($a_value)
 
 checkInput ()
 Check input, strip slashes etc. More...
 
 render ()
 Render item. More...
 
 insert ($a_tpl)
 Insert property html. More...
 
 getTableFilterHTML ()
 Get HTML for table filter. More...
 
 getCustomAttributes ()
 
 setCustomAttributes ($custom_attributes)
 
 addCustomAttribute ($custom_attribute)
 
 getWidthUnit ()
 
 setWidthUnit ($widthUnit)
 
 getHeightUnit ()
 
 setHeightUnit ($heightUnit)
 
- 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...
 

Protected Attributes

 $options
 
 $value
 
 $select_all
 
 $selected_first
 
 $widthUnit = 'px'
 
 $heightUnit = 'px'
 
 $custom_attributes = 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
 

Private Attributes

 $width = 160
 
 $height = 100
 

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

Constructor & Destructor Documentation

◆ __construct()

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

Constructor.

Parameters
string$a_titleTitle
string$a_postvarPost Variable

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

References $DIC, array, ilFormPropertyGUI\setType(), and setValue().

79  {
80  global $DIC;
81 
82  $this->lng = $DIC->language();
83  parent::__construct($a_title, $a_postvar);
84  $this->setType("multi_select");
85  $this->setValue(array());
86  }
global $DIC
Definition: saml.php:7
setType($a_type)
Set Type.
Create styles array
The data for the language used.
+ Here is the call graph for this function:

Member Function Documentation

◆ addCustomAttribute()

ilMultiSelectInputGUI::addCustomAttribute (   $custom_attribute)
Parameters
array$custom_attribute

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

356  {
357  $this->custom_attributes[] = $custom_attribute;
358  }

◆ checkInput()

ilMultiSelectInputGUI::checkInput ( )

Check input, strip slashes etc.

set alert, if input is not ok.

Returns
boolean Input ok, true/false

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

References $_POST, $key, ilFormPropertyGUI\$lng, $options, array, getOptions(), ilFormPropertyGUI\getPostVar(), ilFormPropertyGUI\getRequired(), ilFormPropertyGUI\setAlert(), and ilUtil\stripSlashes().

200  {
201  $lng = $this->lng;
202 
203  if (is_array($_POST[$this->getPostVar()])) {
204  foreach ($_POST[$this->getPostVar()] as $k => $v) {
205  $_POST[$this->getPostVar()][$k] =
207  }
208  } else {
209  $_POST[$this->getPostVar()] = array();
210  }
211  if ($this->getRequired() && count($_POST[$this->getPostVar()]) == 0) {
212  $this->setAlert($lng->txt("msg_input_is_required"));
213 
214  return false;
215  }
216  if (count($_POST[$this->getPostVar()]) > 0) {
217  $options = array_map(function ($k) {
218  return (string) $k;
219  }, array_keys($this->getOptions()));
220  foreach ($_POST[$this->getPostVar()] as $key => $val) {
221  if ($key != 0 || $val != "") {
222  if (!in_array((string) $val, $options)) {
223  $this->setAlert($lng->txt("msg_unknown_value"));
224  return false;
225  }
226  }
227  }
228  }
229 
230  return true;
231  }
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
Create styles array
The data for the language used.
$key
Definition: croninfo.php:18
$_POST["username"]
+ Here is the call graph for this function:

◆ enableSelectAll()

ilMultiSelectInputGUI::enableSelectAll (   $a_value)

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

184  {
185  $this->select_all = (bool) $a_value;
186  }

◆ enableSelectedFirst()

ilMultiSelectInputGUI::enableSelectedFirst (   $a_value)

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

189  {
190  $this->selected_first = (bool) $a_value;
191  }

◆ getCustomAttributes()

ilMultiSelectInputGUI::getCustomAttributes ( )
Returns
array

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

References $custom_attributes.

Referenced by render().

+ Here is the caller graph for this function:

◆ getHeight()

ilMultiSelectInputGUI::getHeight ( )

Returns the height currently set for this field.

public

Returns
integer height

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

References $height.

Referenced by render().

128  {
129  return $this->height;
130  }
+ Here is the caller graph for this function:

◆ getHeightUnit()

ilMultiSelectInputGUI::getHeightUnit ( )
Returns
string

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

References $heightUnit.

Referenced by render().

+ Here is the caller graph for this function:

◆ getOptions()

ilMultiSelectInputGUI::getOptions ( )

Get Options.

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

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

References $options.

Referenced by checkInput(), and render().

148  {
149  return $this->options;
150  }
+ Here is the caller graph for this function:

◆ getTableFilterHTML()

ilMultiSelectInputGUI::getTableFilterHTML ( )

Get HTML for table filter.

Implements ilTableFilterItem.

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

References $html, and render().

328  {
329  $html = $this->render();
330  return $html;
331  }
$html
Definition: example_001.php:87
+ Here is the call graph for this function:

◆ getValue()

ilMultiSelectInputGUI::getValue ( )

Get Value.

Returns
array array with all activated selections

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

References array.

Referenced by render().

168  {
169  return is_array($this->value) ? $this->value : array();
170  }
Create styles array
The data for the language used.
+ Here is the caller graph for this function:

◆ getWidth()

ilMultiSelectInputGUI::getWidth ( )

Returns the width currently set for this field.

public

Returns
integer width

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

References $width.

Referenced by render().

106  {
107  return $this->width;
108  }
+ Here is the caller graph for this function:

◆ getWidthUnit()

ilMultiSelectInputGUI::getWidthUnit ( )
Returns
string

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

References $widthUnit.

Referenced by render().

+ Here is the caller graph for this function:

◆ insert()

ilMultiSelectInputGUI::insert (   $a_tpl)

Insert property html.

Returns
int Size

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

References render().

318  {
319  $a_tpl->setCurrentBlock("prop_generic");
320  $a_tpl->setVariable("PROP_GENERIC", $this->render());
321  $a_tpl->parseCurrentBlock();
322  }
+ Here is the call graph for this function:

◆ render()

ilMultiSelectInputGUI::render ( )

Render item.

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

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

Referenced by getTableFilterHTML(), and insert().

237  {
238  $lng = $this->lng;
239 
240  $tpl = new ilTemplate("tpl.prop_multi_select.html", true, true, "Services/Form");
241  $values = $this->getValue();
242 
243  $options = $this->getOptions();
244  if ($options) {
245  if ($this->select_all) {
246  // enable select all toggle
247  $tpl->setCurrentBlock("item");
248  $tpl->setVariable("VAL", "");
249  $tpl->setVariable("ID_VAL", ilUtil::prepareFormOutput("all__toggle"));
250  $tpl->setVariable("IID", $this->getFieldId());
251  $tpl->setVariable("TXT_OPTION", "<em>" . $lng->txt("select_all") . "</em>");
252  $tpl->setVariable("POST_VAR", $this->getPostVar());
253  $tpl->parseCurrentBlock();
254 
255  $tpl->setVariable("TOGGLE_FIELD_ID", $this->getFieldId());
256  $tpl->setVariable("TOGGLE_ALL_ID", $this->getFieldId() . "_all__toggle");
257  $tpl->setVariable("TOGGLE_ALL_CBOX_ID", $this->getFieldId() . "_");
258  }
259 
260  if ($this->selected_first) {
261  // move selected values to top
262  $tmp_checked = $tmp_unchecked = array();
263  foreach ($options as $option_value => $option_text) {
264  if (in_array($option_value, $values)) {
265  $tmp_checked[$option_value] = $option_text;
266  } else {
267  $tmp_unchecked[$option_value] = $option_text;
268  }
269  }
270  $options = $tmp_checked + $tmp_unchecked;
271  unset($tmp_checked);
272  unset($tmp_unchecked);
273  }
274 
275  foreach ($options as $option_value => $option_text) {
276  $tpl->setCurrentBlock("item");
277  if ($this->getDisabled()) {
278  $tpl->setVariable(
279  "DISABLED",
280  " disabled=\"disabled\""
281  );
282  }
283  if (in_array($option_value, $values)) {
284  $tpl->setVariable(
285  "CHECKED",
286  " checked=\"checked\""
287  );
288  }
289 
290  $tpl->setVariable("VAL", ilUtil::prepareFormOutput($option_value));
291  $tpl->setVariable("ID_VAL", ilUtil::prepareFormOutput($option_value));
292  $tpl->setVariable("IID", $this->getFieldId());
293  $tpl->setVariable("TXT_OPTION", $option_text);
294  $tpl->setVariable("POST_VAR", $this->getPostVar());
295  $tpl->parseCurrentBlock();
296  }
297  }
298 
299  $tpl->setVariable("ID", $this->getFieldId());
300  $tpl->setVariable("CUSTOM_ATTRIBUTES", implode(' ', $this->getCustomAttributes()));
301 
302  if ($this->getWidth()) {
303  $tpl->setVariable("WIDTH", $this->getWidth() . ($this->getWidthUnit()?$this->getWidthUnit():''));
304  }
305  if ($this->getHeight()) {
306  $tpl->setVariable("HEIGHT", $this->getHeight() . ($this->getHeightUnit()?$this->getHeightUnit():''));
307  }
308 
309  return $tpl->get();
310  }
static prepareFormOutput($a_str, $a_strip=false)
prepares string output for html forms public
$tpl
Definition: ilias.php:10
getPostVar()
Get Post Variable.
getHeight()
Returns the height currently set for this field.
getWidth()
Returns the width currently set for this field.
getFieldId()
Get Post Variable.
special template class to simplify handling of ITX/PEAR
Create styles array
The data for the language used.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setCustomAttributes()

ilMultiSelectInputGUI::setCustomAttributes (   $custom_attributes)
Parameters
array$custom_attributes

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

References $custom_attributes.

347  {
348  $this->custom_attributes = $custom_attributes;
349  }

◆ setHeight()

ilMultiSelectInputGUI::setHeight (   $a_height)

Sets the height of this field.

public

Parameters
integer$a_height

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

117  {
118  $this->height = (int) $a_height;
119  }

◆ setHeightUnit()

ilMultiSelectInputGUI::setHeightUnit (   $heightUnit)
Parameters
string$heightUnit

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

References $heightUnit.

388  {
389  $this->heightUnit = $heightUnit;
390  }

◆ setOptions()

ilMultiSelectInputGUI::setOptions (   $a_options)

Set Options.

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

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

Referenced by assFormulaQuestionGUI\isSaveCommand(), ilOrgUnitTypeAdvancedMetaDataFormGUI\saveObject(), and ilStudyProgrammeTypeAdvancedMetaDataFormGUI\saveObject().

138  {
139  $this->options = $a_options;
140  }
+ Here is the caller graph for this function:

◆ setValue()

ilMultiSelectInputGUI::setValue (   $a_array)

Set Value.

Parameters
arrayarray with all activated selections

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

Referenced by __construct(), and setValueByArray().

158  {
159  $this->value = $a_array;
160  }
+ Here is the caller graph for this function:

◆ setValueByArray()

ilMultiSelectInputGUI::setValueByArray (   $a_values)

Set value by array.

Parameters
array$a_valuesvalue array

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

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

178  {
179  $this->setValue($a_values[$this->getPostVar()]);
180  }
getPostVar()
Get Post Variable.
+ Here is the call graph for this function:

◆ setWidth()

ilMultiSelectInputGUI::setWidth (   $a_width)

Sets the width of this field.

public

Parameters
integer$a_width

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

95  {
96  $this->width = (int) $a_width;
97  }

◆ setWidthUnit()

ilMultiSelectInputGUI::setWidthUnit (   $widthUnit)
Parameters
string$widthUnit

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

References $widthUnit.

372  {
373  $this->widthUnit = $widthUnit;
374  }

Field Documentation

◆ $custom_attributes

ilMultiSelectInputGUI::$custom_attributes = array()
protected

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

Referenced by getCustomAttributes(), and setCustomAttributes().

◆ $height

ilMultiSelectInputGUI::$height = 100
private

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

Referenced by getHeight().

◆ $heightUnit

ilMultiSelectInputGUI::$heightUnit = 'px'
protected

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

Referenced by getHeightUnit(), and setHeightUnit().

◆ $options

ilMultiSelectInputGUI::$options
protected

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

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

◆ $select_all

ilMultiSelectInputGUI::$select_all
protected

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

◆ $selected_first

ilMultiSelectInputGUI::$selected_first
protected

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

◆ $value

ilMultiSelectInputGUI::$value
protected

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

◆ $width

ilMultiSelectInputGUI::$width = 160
private

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

Referenced by getWidth().

◆ $widthUnit

ilMultiSelectInputGUI::$widthUnit = 'px'
protected

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

Referenced by getWidthUnit(), and setWidthUnit().


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