ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
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...
 
 getTableFilterLabelFor ()
 Get label "for" attribute value for filter. More...
 
 getFormLabelFor ()
 Get label "for" attribute value for form. More...
 
- Public Member Functions inherited from ilTableFilterItem
 getTableFilterLabelFor ()
 Get label "for" attribute value. 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

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

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 51 of file class.ilCheckboxGroupInputGUI.php.

References $DIC, and ilFormPropertyGUI\setType().

52  {
53  global $DIC;
54 
55  $this->lng = $DIC->language();
56  parent::__construct($a_title, $a_postvar);
57  $this->setType("checkboxgroup");
58  }
global $DIC
Definition: saml.php:7
setType($a_type)
Set Type.
+ Here is the call graph for this function:

Member Function Documentation

◆ addOption()

ilCheckboxGroupInputGUI::addOption (   $a_option)

Add Option.

Parameters
object$a_optionCheckboxOption object

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

Referenced by ilObjTestSettingsScoringResultsGUI\addMiscSettingsFormSection(), ilObjTestSettingsGeneralGUI\addTestRunProperties(), ilMemberExportGUI\initSettingsForm(), ilObjUserTrackingGUI\initSettingsForm(), and ilSettingsTemplateGUI\initSettingsTemplateForm().

86  {
87  $this->options[] = $a_option;
88  }
+ Here is the caller graph for this function:

◆ checkInput()

ilCheckboxGroupInputGUI::checkInput ( )

Check input, strip slashes etc.

set alert, if input is not ok.

Returns
boolean Input ok, true/false

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

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

158  {
159  $lng = $this->lng;
160 
161  if ($this->getRequired() && (!is_array($_POST[$this->getPostVar()]) || count($_POST[$this->getPostVar()]) === 0)) {
162  $this->setAlert($lng->txt('msg_input_is_required'));
163  return false;
164  }
165 
166  $ok = true;
167  foreach ($this->getOptions() as $option) {
168  foreach ($option->getSubItems() as $item) {
169  $item_ok = $item->checkInput();
170  if (!$item_ok && in_array($option->getValue(), $_POST[$this->getPostVar()])) {
171  $ok = false;
172  }
173  }
174  }
175  return $ok;
176  }
getPostVar()
Get Post Variable.
setAlert($a_alert)
Set Alert Text.
$_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 195 of file class.ilCheckboxGroupInputGUI.php.

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

196  {
197  if ($this->getPostVar() == $a_post_var) {
198  return $this;
199  }
200 
201  foreach ($this->getOptions() as $option) {
202  foreach ($option->getSubItems() as $item) {
203  if ($item->getType() != "section_header") {
204  $ret = $item->getItemByPostVar($a_post_var);
205  if (is_object($ret)) {
206  return $ret;
207  }
208  }
209  }
210  }
211 
212  return false;
213  }
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 112 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 215 of file class.ilCheckboxGroupInputGUI.php.

References render().

216  {
217  return $this->render();
218  }
+ 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 220 of file class.ilCheckboxGroupInputGUI.php.

References render().

221  {
222  return $this->render('toolbar');
223  }
+ 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 75 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 132 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 183 of file class.ilCheckboxGroupInputGUI.php.

References render().

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

◆ render()

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

Definition at line 225 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().

226  {
227  $tpl = new ilTemplate("tpl.prop_checkbox_group.html", true, true, "Services/Form");
228 
229  foreach ($this->getOptions() as $option) {
230  // information text for option
231  if ($option->getInfo() != "") {
232  $tpl->setCurrentBlock("checkbox_option_desc");
233  $tpl->setVariable("CHECKBOX_OPTION_DESC", $option->getInfo());
234  $tpl->parseCurrentBlock();
235  }
236 
237 
238  if (count($option->getSubItems()) > 0) {
239  $tpl->setCurrentBlock("checkbox_option_subform");
240  $pf = new ilPropertyFormGUI();
241  $pf->setMode("subform");
242  $pf->setItems($option->getSubItems());
243  $tpl->setVariable("SUB_FORM", $pf->getContent());
244  $tpl->setVariable("SOP_ID", $this->getFieldId() . "_" . $option->getValue());
245  if ($pf->getMultipart()) {
246  $this->getParentForm()->setMultipart(true);
247  }
248  $tpl->parseCurrentBlock();
249  if ($pf->getMultipart()) {
250  $this->getParentForm()->setMultipart(true);
251  }
252  }
253 
254  $tpl->setCurrentBlock("prop_checkbox_option");
255 
256  if (!$this->getUseValuesAsKeys()) {
257  $tpl->setVariable("POST_VAR", $this->getPostVar() . '[]');
258  $tpl->setVariable("VAL_CHECKBOX_OPTION", $option->getValue());
259  } else {
260  $tpl->setVariable("POST_VAR", $this->getPostVar() . '[' . $option->getValue() . ']');
261  $tpl->setVariable("VAL_CHECKBOX_OPTION", "1");
262  }
263 
264  $tpl->setVariable("OP_ID", $this->getFieldId() . "_" . $option->getValue());
265  $tpl->setVariable("FID", $this->getFieldId());
266 
267  if ($this->getDisabled() or $option->getDisabled()) {
268  $tpl->setVariable('DISABLED', 'disabled="disabled" ');
269  }
270 
271  if (is_array($this->getValue())) {
272  if (!$this->getUseValuesAsKeys()) {
273  if (in_array($option->getValue(), $this->getValue())) {
274  $tpl->setVariable(
275  "CHK_CHECKBOX_OPTION",
276  'checked="checked"'
277  );
278  }
279  } else {
280  $cval = $this->getValue();
281  if ($cval[$option->getValue()] == 1) {
282  $tpl->setVariable(
283  "CHK_CHECKBOX_OPTION",
284  'checked="checked"'
285  );
286  }
287  }
288  }
289  $tpl->setVariable("TXT_CHECKBOX_OPTION", $option->getTitle());
290 
291 
292  $tpl->parseCurrentBlock();
293  }
294  $tpl->setVariable("ID", $this->getFieldId());
295 
296  return $tpl->get();
297  }
This class represents a property form user interface.
$tpl
Definition: ilias.php:10
getPostVar()
Get Post Variable.
getParentForm()
Get Parent Form.
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 95 of file class.ilCheckboxGroupInputGUI.php.

References $key.

96  {
97  foreach ($a_options as $key => $label) {
98  if (is_string($label)) {
99  $chb = new ilCheckboxInputGUI($label, $key);
100  $this->options[] = $chb;
101  } elseif ($label instanceof ilCheckboxInputGUI) {
102  $this->options[] = $label;
103  }
104  }
105  }
This class represents a checkbox property in a property form.
$key
Definition: croninfo.php:18

◆ setUseValuesAsKeys()

ilCheckboxGroupInputGUI::setUseValuesAsKeys (   $a_val)

Set use values as keys.

Parameters
bool$a_valuse values as keys

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

66  {
67  $this->use_values_as_keys = $a_val;
68  }

◆ setValue()

ilCheckboxGroupInputGUI::setValue (   $a_value)

Set Value.

Parameters
array$a_valueValue

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

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

123  {
124  $this->value = $a_value;
125  }
+ 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 142 of file class.ilCheckboxGroupInputGUI.php.

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

143  {
144  $this->setValue($a_values[$this->getPostVar()]);
145  foreach ($this->getOptions() as $option) {
146  foreach ($option->getSubItems() as $item) {
147  $item->setValueByArray($a_values);
148  }
149  }
150  }
getPostVar()
Get Post Variable.
+ Here is the call graph for this function:

Field Documentation

◆ $lng

ilCheckboxGroupInputGUI::$lng
protected

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

Referenced by checkInput().

◆ $options

ilCheckboxGroupInputGUI::$options = array()
protected

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

Referenced by getOptions().

◆ $use_values_as_keys

ilCheckboxGroupInputGUI::$use_values_as_keys = false
protected

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

Referenced by getUseValuesAsKeys().

◆ $value

ilCheckboxGroupInputGUI::$value
protected

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

Referenced by getValue().


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