ILIAS  release_4-4 Revision
All Data Structures Namespaces Files Functions Variables Modules Pages
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...
 
- 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...
 

Protected Attributes

 $options
 
 $value
 
 $select_all
 
 $selected_first
 
- 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

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

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

64  {
65  parent::__construct($a_title, $a_postvar);
66  $this->setType("multi_select");
67  $this->setValue(array());
68  }
setType($a_type)
Set Type.
+ Here is the call graph for this function:

Member Function Documentation

◆ checkInput()

ilMultiSelectInputGUI::checkInput ( )

Check input, strip slashes etc.

set alert, if input is not ok.

Returns
boolean Input ok, true/false

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

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

182  {
183  global $lng;
184 
185  if (is_array($_POST[$this->getPostVar()]))
186  {
187  foreach ($_POST[$this->getPostVar()] as $k => $v)
188  {
189  $_POST[$this->getPostVar()][$k] =
191  }
192  }
193  else
194  {
195  $_POST[$this->getPostVar()] = array();
196  }
197  if ($this->getRequired() && count($_POST[$this->getPostVar()]) == 0)
198  {
199  $this->setAlert($lng->txt("msg_input_is_required"));
200 
201  return false;
202  }
203  return true;
204  }
$_POST['username']
Definition: cron.php:12
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
global $lng
Definition: privfeed.php:40
+ Here is the call graph for this function:

◆ enableSelectAll()

ilMultiSelectInputGUI::enableSelectAll (   $a_value)

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

166  {
167  $this->select_all = (bool)$a_value;
168  }

◆ enableSelectedFirst()

ilMultiSelectInputGUI::enableSelectedFirst (   $a_value)

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

171  {
172  $this->selected_first = (bool)$a_value;
173  }

◆ getHeight()

ilMultiSelectInputGUI::getHeight ( )

Returns the height currently set for this field.

public

Returns
integer height

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

References $height.

Referenced by render().

110  {
111  return $this->height;
112  }
+ Here is the caller graph for this function:

◆ getOptions()

ilMultiSelectInputGUI::getOptions ( )

Get Options.

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

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

References $options.

Referenced by render().

130  {
131  return $this->options;
132  }
+ Here is the caller graph for this function:

◆ getTableFilterHTML()

ilMultiSelectInputGUI::getTableFilterHTML ( )

Get HTML for table filter.

Implements ilTableFilterItem.

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

References render().

302  {
303  $html = $this->render();
304  return $html;
305  }
+ Here is the call graph for this function:

◆ getValue()

ilMultiSelectInputGUI::getValue ( )

Get Value.

Returns
array array with all activated selections

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

Referenced by render().

150  {
151  return is_array($this->value) ? $this->value : array();
152  }
+ 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 87 of file class.ilMultiSelectInputGUI.php.

References $width.

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

References render().

292  {
293  $a_tpl->setCurrentBlock("prop_generic");
294  $a_tpl->setVariable("PROP_GENERIC", $this->render());
295  $a_tpl->parseCurrentBlock();
296  }
+ Here is the call graph for this function:

◆ render()

ilMultiSelectInputGUI::render ( )

Render item.

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

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

Referenced by getTableFilterHTML(), and insert().

210  {
211  global $lng;
212 
213  $tpl = new ilTemplate("tpl.prop_multi_select.html", true, true, "Services/Form");
214  $values = $this->getValue();
215 
216  $options = $this->getOptions();
217  if($options)
218  {
219  if($this->select_all)
220  {
221  // enable select all toggle
222  $tpl->setCurrentBlock("item");
223  $tpl->setVariable("VAL", "");
224  $tpl->setVariable("ID_VAL", ilUtil::prepareFormOutput("all__toggle"));
225  $tpl->setVariable("IID", $this->getFieldId());
226  $tpl->setVariable("TXT_OPTION" ,"<em>".$lng->txt("select_all")."</em>");
227  $tpl->setVariable("POST_VAR", $this->getPostVar());
228  $tpl->parseCurrentBlock();
229 
230  $tpl->setVariable("TOGGLE_FIELD_ID", $this->getFieldId());
231  $tpl->setVariable("TOGGLE_ALL_ID", $this->getFieldId()."_all__toggle");
232  $tpl->setVariable("TOGGLE_ALL_CBOX_ID", $this->getFieldId()."_");
233  }
234 
235  if($this->selected_first)
236  {
237  // move selected values to top
238  $tmp_checked = $tmp_unchecked = array();
239  foreach($options as $option_value => $option_text)
240  {
241  if (in_array($option_value, $values))
242  {
243  $tmp_checked[$option_value] = $option_text;
244  }
245  else
246  {
247  $tmp_unchecked[$option_value] = $option_text;
248  }
249  }
250  $options = $tmp_checked + $tmp_unchecked;
251  unset($tmp_checked);
252  unset($tmp_unchecked);
253  }
254 
255  foreach($options as $option_value => $option_text)
256  {
257  $tpl->setCurrentBlock("item");
258  if ($this->getDisabled())
259  {
260  $tpl->setVariable("DISABLED",
261  " disabled=\"disabled\"");
262  }
263  if (in_array($option_value, $values))
264  {
265  $tpl->setVariable("CHECKED",
266  " checked=\"checked\"");
267  }
268 
269  $tpl->setVariable("VAL", ilUtil::prepareFormOutput($option_value));
270  $tpl->setVariable("ID_VAL", ilUtil::prepareFormOutput($option_value));
271  $tpl->setVariable("IID", $this->getFieldId());
272  $tpl->setVariable("TXT_OPTION", $option_text);
273  $tpl->setVariable("POST_VAR", $this->getPostVar());
274  $tpl->parseCurrentBlock();
275  }
276  }
277 
278  $tpl->setVariable("ID", $this->getFieldId());
279 
280  $tpl->setVariable("WIDTH", $this->getWidth());
281  $tpl->setVariable("HEIGHT", $this->getHeight());
282 
283  return $tpl->get();
284  }
static prepareFormOutput($a_str, $a_strip=false)
prepares string output for html forms public
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
if(isset($_FILES['img_file']['size']) && $_FILES['img_file']['size'] > 0) $tpl
global $lng
Definition: privfeed.php:40
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setHeight()

ilMultiSelectInputGUI::setHeight (   $a_height)

Sets the height of this field.

public

Parameters
integer$a_height

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

Referenced by ilObjAdvancedEditingGUI\initTagsForm().

99  {
100  $this->height = (int)$a_height;
101  }
+ Here is the caller graph for this function:

◆ setOptions()

ilMultiSelectInputGUI::setOptions (   $a_options)

Set Options.

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

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

Referenced by assFormulaQuestionGUI\isSaveCommand().

120  {
121  $this->options = $a_options;
122  }
+ Here is the caller graph for this function:

◆ setValue()

ilMultiSelectInputGUI::setValue (   $a_array)

Set Value.

Parameters
arrayarray with all activated selections

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

Referenced by __construct(), and setValueByArray().

140  {
141  $this->value = $a_array;
142  }
+ 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 159 of file class.ilMultiSelectInputGUI.php.

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

160  {
161  $this->setValue($a_values[$this->getPostVar()]);
162  }
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 76 of file class.ilMultiSelectInputGUI.php.

77  {
78  $this->width = (int)$a_width;
79  }

Field Documentation

◆ $height

ilMultiSelectInputGUI::$height = 100
private

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

Referenced by getHeight().

◆ $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().


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