ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
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...
 
 removeProhibitedCharacters ($a_text)
 Remove prohibited characters see #19159. More...
 
 stripSlashesAddSpaceFallback ($a_str)
 Strip slashes with add space fallback, see https://www.ilias.de/mantis/view.php?id=19727. More...
 
 getTableFilterHTML ()
 Get input item HTML to be inserted into table filters. More...
 

Protected Attributes

 $options
 
 $value
 
 $select_all
 
 $selected_first
 
 $widthUnit = 'px'
 
 $heightUnit = 'px'
 
 $custom_attributes = array()
 
- Protected Attributes inherited from ilFormPropertyGUI
 $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

- 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

Reimplemented from ilFormPropertyGUI.

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

79 {
80 parent::__construct($a_title, $a_postvar);
81 $this->setType("multi_select");
82 $this->setValue(array());
83 }
setType($a_type)
Set Type.

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

+ Here is the call graph for this function:

Member Function Documentation

◆ addCustomAttribute()

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

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

349 {
350 $this->custom_attributes[] = $custom_attribute;
351 }

◆ checkInput()

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

197 {
198 global $lng;
199
200 if (is_array($_POST[$this->getPostVar()]))
201 {
202 foreach ($_POST[$this->getPostVar()] as $k => $v)
203 {
204 $_POST[$this->getPostVar()][$k] =
206 }
207 }
208 else
209 {
210 $_POST[$this->getPostVar()] = array();
211 }
212 if ($this->getRequired() && count($_POST[$this->getPostVar()]) == 0)
213 {
214 $this->setAlert($lng->txt("msg_input_is_required"));
215
216 return false;
217 }
218 return true;
219 }
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
$_POST['username']
Definition: cron.php:12
global $lng
Definition: privfeed.php:40

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

+ Here is the call graph for this function:

◆ enableSelectAll()

ilMultiSelectInputGUI::enableSelectAll (   $a_value)

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

181 {
182 $this->select_all = (bool)$a_value;
183 }

◆ enableSelectedFirst()

ilMultiSelectInputGUI::enableSelectedFirst (   $a_value)

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

186 {
187 $this->selected_first = (bool)$a_value;
188 }

◆ getCustomAttributes()

ilMultiSelectInputGUI::getCustomAttributes ( )
Returns
array

Definition at line 333 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.

@access public

Returns
integer height

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

References $height.

Referenced by render().

+ Here is the caller graph for this function:

◆ getHeightUnit()

ilMultiSelectInputGUI::getHeightUnit ( )
Returns
string

Definition at line 370 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 144 of file class.ilMultiSelectInputGUI.php.

References $options.

Referenced by render().

+ Here is the caller graph for this function:

◆ getTableFilterHTML()

ilMultiSelectInputGUI::getTableFilterHTML ( )

Get HTML for table filter.

Implements ilTableFilterItem.

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

324 {
325 $html = $this->render();
326 return $html;
327 }
$html
Definition: example_001.php:87

References $html, and render().

+ Here is the call graph for this function:

◆ getValue()

ilMultiSelectInputGUI::getValue ( )

Get Value.

Returns
array array with all activated selections

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

165 {
166 return is_array($this->value) ? $this->value : array();
167 }

Referenced by render().

+ Here is the caller graph for this function:

◆ getWidth()

ilMultiSelectInputGUI::getWidth ( )

Returns the width currently set for this field.

@access public

Returns
integer width

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

References $width.

Referenced by render().

+ Here is the caller graph for this function:

◆ getWidthUnit()

ilMultiSelectInputGUI::getWidthUnit ( )
Returns
string

Definition at line 356 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 313 of file class.ilMultiSelectInputGUI.php.

314 {
315 $a_tpl->setCurrentBlock("prop_generic");
316 $a_tpl->setVariable("PROP_GENERIC", $this->render());
317 $a_tpl->parseCurrentBlock();
318 }

References render().

+ Here is the call graph for this function:

◆ render()

ilMultiSelectInputGUI::render ( )

Render item.

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

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

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

Referenced by getTableFilterHTML(), and insert().

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

341 {
342 $this->custom_attributes = $custom_attributes;
343 }

References $custom_attributes.

◆ setHeight()

ilMultiSelectInputGUI::setHeight (   $a_height)

Sets the height of this field.

@access public

Parameters
integer$a_height

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

114 {
115 $this->height = (int)$a_height;
116 }

◆ setHeightUnit()

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

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

377 {
378 $this->heightUnit = $heightUnit;
379 }

References $heightUnit.

◆ setOptions()

ilMultiSelectInputGUI::setOptions (   $a_options)

Set Options.

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

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

135 {
136 $this->options = $a_options;
137 }

◆ setValue()

ilMultiSelectInputGUI::setValue (   $a_array)

Set Value.

Parameters
arrayarray with all activated selections

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

155 {
156 $this->value = $a_array;
157 }

Referenced by __construct(), and setValueByArray().

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

175 {
176 $this->setValue($a_values[$this->getPostVar()]);
177 }

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

+ Here is the call graph for this function:

◆ setWidth()

ilMultiSelectInputGUI::setWidth (   $a_width)

Sets the width of this field.

@access public

Parameters
integer$a_width

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

92 {
93 $this->width = (int)$a_width;
94 }

◆ setWidthUnit()

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

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

363 {
364 $this->widthUnit = $widthUnit;
365 }

References $widthUnit.

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 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: