ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
ilCheckboxGroupInputGUI Class Reference

This class represents a property in a property form. More...

+ Inheritance diagram for ilCheckboxGroupInputGUI:
+ Collaboration diagram for ilCheckboxGroupInputGUI:

Public Member Functions

 __construct ($a_title="", $a_postvar="")
 Constructor. More...
 
 setUseValuesAsKeys ($a_val)
 Set use values as keys. More...
 
 getUseValuesAsKeys ()
 Get use values as keys. More...
 
 addOption ($a_option)
 Add Option. More...
 
 setOptions ($a_options)
 Set Options. More...
 
 getOptions ()
 Get Options. More...
 
 setValue ($a_value)
 Set Value. More...
 
 getValue ()
 Get Value. More...
 
 setValueByArray ($a_values)
 Set value by array. More...
 
 checkInput ()
 Check input, strip slashes etc. More...
 
 insert ($a_tpl)
 Insert property html. More...
 
 getItemByPostVar ($a_post_var)
 Get item by post var. More...
 
 getTableFilterHTML ()
 Get input item HTML to be inserted into table filters. More...
 
 getToolbarHTML ()
 Get input item HTML to be inserted into ilToolbarGUI. More...
 
- Public Member Functions inherited from ilSubEnabledFormPropertyGUI
 addSubItem ($a_item)
 Add Subitem. More...
 
 getSubItems ()
 Get Subitems. More...
 
 getSubInputItemsRecursive ()
 returns a flat array of possibly existing subitems recursively More...
 
 checkSubItemsInput ()
 Check SubItems. More...
 
 getSubForm ()
 Get sub form html. More...
 
 getItemByPostVar ($a_post_var)
 Get item by post var. 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...
 
 stripSlashesAddSpaceFallback ($a_str)
 Strip slashes with add space fallback, see https://www.ilias.de/mantis/view.php?id=19727. More...
 

Protected Member Functions

 render ($a_mode='')
 
- Protected Member Functions inherited from ilFormPropertyGUI
 setType ($a_type)
 Set Type. More...
 
 getMultiIconsHTML ()
 Get HTML for multiple value icons. More...
 

Protected Attributes

 $options = array()
 
 $value
 
 $use_values_as_keys = false
 
- Protected Attributes inherited from ilSubEnabledFormPropertyGUI
 $sub_items = 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
 

Additional Inherited Members

- Static Public Member Functions inherited from ilFormPropertyGUI
static removeProhibitedCharacters ($a_text)
 Remove prohibited characters see #19159. More...
 

Detailed Description

This class represents a property in a property form.

Author
Helmut Schottmüller ilias.nosp@m.@aur.nosp@m.ealis.nosp@m..de
Version
$Id$

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

Constructor & Destructor Documentation

◆ __construct()

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

Constructor.

Parameters
string$a_titleTitle
string$a_postvarPost Variable

Definition at line 46 of file class.ilCheckboxGroupInputGUI.php.

References ilFormPropertyGUI\setType().

47  {
48  parent::__construct($a_title, $a_postvar);
49  $this->setType("checkboxgroup");
50  }
setType($a_type)
Set Type.
+ Here is the call graph for this function:

Member Function Documentation

◆ addOption()

ilCheckboxGroupInputGUI::addOption (   $a_option)

◆ checkInput()

ilCheckboxGroupInputGUI::checkInput ( )

Check input, strip slashes etc.

set alert, if input is not ok.

Returns
boolean Input ok, true/false

Definition at line 152 of file class.ilCheckboxGroupInputGUI.php.

References $_POST, $lng, $ok, getOptions(), ilFormPropertyGUI\getPostVar(), ilFormPropertyGUI\getRequired(), and ilFormPropertyGUI\setAlert().

153  {
154  global $lng;
155 
156  if ($this->getRequired() && count($_POST[$this->getPostVar()]) == 0)
157  {
158  $this->setAlert($lng->txt("msg_input_is_required"));
159 
160  return false;
161  }
162 
163  $ok = true;
164  foreach($this->getOptions() as $option)
165  {
166  foreach($option->getSubItems() as $item)
167  {
168  $item_ok = $item->checkInput();
169  if (!$item_ok && in_array($option->getValue(), $_POST[$this->getPostVar()]))
170  {
171  $ok = false;
172  }
173  }
174  }
175  return $ok;
176 
177  }
getPostVar()
Get Post Variable.
setAlert($a_alert)
Set Alert Text.
global $lng
Definition: privfeed.php:17
$_POST["username"]
+ Here is the call graph for this function:

◆ getItemByPostVar()

ilCheckboxGroupInputGUI::getItemByPostVar (   $a_post_var)

Get item by post var.

Returns
mixed false or item object

Definition at line 196 of file class.ilCheckboxGroupInputGUI.php.

References $ret, getOptions(), and ilFormPropertyGUI\getPostVar().

197  {
198  if ($this->getPostVar() == $a_post_var)
199  {
200  return $this;
201  }
202 
203  foreach($this->getOptions() as $option)
204  {
205  foreach($option->getSubItems() as $item)
206  {
207  if ($item->getType() != "section_header")
208  {
209  $ret = $item->getItemByPostVar($a_post_var);
210  if (is_object($ret))
211  {
212  return $ret;
213  }
214  }
215  }
216  }
217 
218  return false;
219  }
getPostVar()
Get Post Variable.
$ret
Definition: parser.php:6
+ Here is the call graph for this function:

◆ getOptions()

ilCheckboxGroupInputGUI::getOptions ( )

Get Options.

Returns
array Array of CheckboxOption objects

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

References $options.

Referenced by checkInput(), getItemByPostVar(), render(), and setValueByArray().

+ Here is the caller graph for this function:

◆ getTableFilterHTML()

ilCheckboxGroupInputGUI::getTableFilterHTML ( )

Get input item HTML to be inserted into table filters.

Returns
string

Implements ilTableFilterItem.

Definition at line 221 of file class.ilCheckboxGroupInputGUI.php.

References render().

222  {
223  return $this->render();
224  }
+ Here is the call graph for this function:

◆ getToolbarHTML()

ilCheckboxGroupInputGUI::getToolbarHTML ( )

Get input item HTML to be inserted into ilToolbarGUI.

public

Returns
string

Implements ilToolbarItem.

Definition at line 226 of file class.ilCheckboxGroupInputGUI.php.

References render().

227  {
228  return $this->render('toolbar');
229  }
+ Here is the call graph for this function:

◆ getUseValuesAsKeys()

ilCheckboxGroupInputGUI::getUseValuesAsKeys ( )

Get use values as keys.

Returns
bool use values as keys

Definition at line 67 of file class.ilCheckboxGroupInputGUI.php.

References $use_values_as_keys.

Referenced by render().

+ Here is the caller graph for this function:

◆ getValue()

ilCheckboxGroupInputGUI::getValue ( )

Get Value.

Returns
array Value

Definition at line 125 of file class.ilCheckboxGroupInputGUI.php.

References $value.

Referenced by render().

+ Here is the caller graph for this function:

◆ insert()

ilCheckboxGroupInputGUI::insert (   $a_tpl)

Insert property html.

Returns
int Size

Definition at line 184 of file class.ilCheckboxGroupInputGUI.php.

References render().

185  {
186  $a_tpl->setCurrentBlock("prop_generic");
187  $a_tpl->setVariable("PROP_GENERIC", $this->render());
188  $a_tpl->parseCurrentBlock();
189  }
+ Here is the call graph for this function:

◆ render()

ilCheckboxGroupInputGUI::render (   $a_mode = '')
protected

Definition at line 231 of file class.ilCheckboxGroupInputGUI.php.

References $tpl, ilFormPropertyGUI\getDisabled(), ilFormPropertyGUI\getFieldId(), getOptions(), ilFormPropertyGUI\getParentForm(), ilFormPropertyGUI\getPostVar(), ilSubEnabledFormPropertyGUI\getSubInputItemsRecursive(), getUseValuesAsKeys(), and getValue().

Referenced by getTableFilterHTML(), getToolbarHTML(), and insert().

232  {
233  $tpl = new ilTemplate("tpl.prop_checkbox_group.html", true, true, "Services/Form");
234 
235  foreach($this->getOptions() as $option)
236  {
237  // information text for option
238  if ($option->getInfo() != "")
239  {
240  $tpl->setCurrentBlock("checkbox_option_desc");
241  $tpl->setVariable("CHECKBOX_OPTION_DESC", $option->getInfo());
242  $tpl->parseCurrentBlock();
243  }
244 
245 
246  if (count($option->getSubItems()) > 0)
247  {
248  $tpl->setCurrentBlock("checkbox_option_subform");
249  $pf = new ilPropertyFormGUI();
250  $pf->setMode("subform");
251  $pf->setItems($option->getSubItems());
252  $tpl->setVariable("SUB_FORM", $pf->getContent());
253  $tpl->setVariable("SOP_ID", $this->getFieldId()."_".$option->getValue());
254  if ($pf->getMultipart())
255  {
256  $this->getParentForm()->setMultipart(true);
257  }
258  $tpl->parseCurrentBlock();
259  if ($pf->getMultipart())
260  {
261  $this->getParentForm()->setMultipart(true);
262  }
263  }
264 
265  $tpl->setCurrentBlock("prop_checkbox_option");
266 
267  if (!$this->getUseValuesAsKeys())
268  {
269  $tpl->setVariable("POST_VAR", $this->getPostVar() . '[]');
270  $tpl->setVariable("VAL_CHECKBOX_OPTION", $option->getValue());
271  }
272  else
273  {
274  $tpl->setVariable("POST_VAR", $this->getPostVar().'['.$option->getValue().']');
275  $tpl->setVariable("VAL_CHECKBOX_OPTION", "1");
276  }
277 
278  $tpl->setVariable("OP_ID", $this->getFieldId()."_".$option->getValue());
279  $tpl->setVariable("FID", $this->getFieldId());
280 
281  if($this->getDisabled() or $option->getDisabled())
282  {
283  $tpl->setVariable('DISABLED','disabled="disabled" ');
284  }
285 
286  if (is_array($this->getValue()))
287  {
288  if (!$this->getUseValuesAsKeys())
289  {
290  if (in_array($option->getValue(), $this->getValue()))
291  {
292  $tpl->setVariable("CHK_CHECKBOX_OPTION",
293  'checked="checked"');
294  }
295  }
296  else
297  {
298  $cval = $this->getValue();
299  if ($cval[$option->getValue()] == 1)
300  {
301  $tpl->setVariable("CHK_CHECKBOX_OPTION",
302  'checked="checked"');
303  }
304  }
305  }
306  $tpl->setVariable("TXT_CHECKBOX_OPTION", $option->getTitle());
307 
308 
309  $tpl->parseCurrentBlock();
310  }
311  $tpl->setVariable("ID", $this->getFieldId());
312 
313  return $tpl->get();
314  }
This class represents a property form user interface.
getPostVar()
Get Post Variable.
getParentForm()
Get Parent Form.
global $tpl
Definition: ilias.php:8
getFieldId()
Get Post Variable.
special template class to simplify handling of ITX/PEAR
getUseValuesAsKeys()
Get use values as keys.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setOptions()

ilCheckboxGroupInputGUI::setOptions (   $a_options)

Set Options.

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

Definition at line 87 of file class.ilCheckboxGroupInputGUI.php.

88  {
89  foreach($a_options as $key => $label) {
90  if (is_string($label)) {
91  $chb = new ilCheckboxInputGUI($label, $key);
92  $this->options[] = $chb;
93  }
94  else if ($label instanceof ilCheckboxInputGUI) {
95  $this->options[] = $label;
96  }
97  }
98  }
This class represents a checkbox property in a property form.

◆ setUseValuesAsKeys()

ilCheckboxGroupInputGUI::setUseValuesAsKeys (   $a_val)

Set use values as keys.

Parameters
bool$a_valuse values as keys

Definition at line 57 of file class.ilCheckboxGroupInputGUI.php.

58  {
59  $this->use_values_as_keys = $a_val;
60  }

◆ setValue()

ilCheckboxGroupInputGUI::setValue (   $a_value)

Set Value.

Parameters
array$a_valueValue

Definition at line 115 of file class.ilCheckboxGroupInputGUI.php.

Referenced by ilECSObjectSettings\addSettingsToForm(), ilPageLayoutGUI\initForm(), ilObjAssessmentFolderGUI\settingsObject(), setValueByArray(), and ilObjPrivacySecurityGUI\showPrivacy().

116  {
117  $this->value = $a_value;
118  }
+ Here is the caller graph for this function:

◆ setValueByArray()

ilCheckboxGroupInputGUI::setValueByArray (   $a_values)

Set value by array.

Parameters
array$a_valuesvalue array

Definition at line 135 of file class.ilCheckboxGroupInputGUI.php.

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

136  {
137  $this->setValue($a_values[$this->getPostVar()]);
138  foreach($this->getOptions() as $option)
139  {
140  foreach($option->getSubItems() as $item)
141  {
142  $item->setValueByArray($a_values);
143  }
144  }
145  }
getPostVar()
Get Post Variable.
+ Here is the call graph for this function:

Field Documentation

◆ $options

ilCheckboxGroupInputGUI::$options = array()
protected

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

Referenced by getOptions().

◆ $use_values_as_keys

ilCheckboxGroupInputGUI::$use_values_as_keys = false
protected

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

Referenced by getUseValuesAsKeys().

◆ $value

ilCheckboxGroupInputGUI::$value
protected

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

Referenced by getValue().


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