ILIAS  trunk Revision v11.0_alpha-1713-gd8962da2f67
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
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 (string $a_title="", string $a_postvar="")
 
 setUseValuesAsKeys (bool $a_val)
 Set use values as keys. More...
 
 getUseValuesAsKeys ()
 
 addOption ($a_option)
 
 setOptions (array $a_options)
 Set Options. More...
 
 getOptions ()
 
 setValue (?array $a_value)
 
 getValue ()
 
 setValueByArray (array $a_values)
 
 checkInput ()
 
 getInput ()
 
 insert (ilTemplate $a_tpl)
 
 getItemByPostVar (string $a_post_var)
 
 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 (ilFormPropertyGUI $a_item)
 
 getSubItems ()
 
 getSubInputItemsRecursive ()
 returns a flat array of possibly existing subitems recursively More...
 
 checkSubItemsInput ()
 Check SubItems. More...
 
 getSubForm ()
 
 getItemByPostVar (string $a_post_var)
 
- Public Member Functions inherited from ilFormPropertyGUI
 __construct (string $a_title="", string $a_postvar="")
 
 executeCommand ()
 
 getType ()
 
 setTitle (string $a_title)
 
 getTitle ()
 
 setPostVar (string $a_postvar)
 
 getPostVar ()
 
 getFieldId ()
 
 setInfo (string $a_info)
 
 getInfo ()
 
 setAlert (string $a_alert)
 
 getAlert ()
 
 setRequired (bool $a_required)
 
 getRequired ()
 
 setDisabled (bool $a_disabled)
 
 getDisabled ()
 
 checkInput ()
 Check input, strip slashes etc. More...
 
 setParentForm (ilPropertyFormGUI $a_parentform)
 
 getParentForm ()
 
 setParent (ilFormPropertyGUI $a_val)
 
 getParent ()
 
 getSubForm ()
 
 hideSubForm ()
 
 setHiddenTitle (string $a_val)
 
 getHiddenTitle ()
 
 getItemByPostVar (string $a_post_var)
 Get item by post var. More...
 
 serializeData ()
 
 unserializeData (string $a_data)
 
 setParentTable ($a_val)
 Set parent table. More...
 
 getParentTable ()
 Get parent table. More...
 
 writeToSession ()
 
 clearFromSession ()
 
 readFromSession ()
 
 getHiddenTag (string $a_post_var, string $a_value)
 
 setMulti (bool $a_multi, bool $a_sortable=false, bool $a_addremove=true)
 
 getMulti ()
 
 setMultiValues (array $a_values)
 
 getMultiValues ()
 
 getContentOutsideFormTag ()
 Get content that has to reside outside of the parent form tag, e.g. More...
 
 stripSlashesAddSpaceFallback (string $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...
 
 setRequestParam (string $key, $val)
 This writes the request (aka post) values. 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
 symbol ()
 
 setType (string $a_type)
 
 checkParentFormTable ()
 
 getSessionKey ()
 
 getMultiIconsHTML ()
 
 int ($key)
 
 intArray ($key)
 
 str ($key)
 
 raw ($key)
 
 strArray ($key)
 
 arrayArray ($key)
 
 isRequestParamArray (string $key)
 
 getRequestParam (string $key, Refinery\Transformation $t)
 

Protected Attributes

array $options = array()
 
array $value = null
 
bool $use_values_as_keys = false
 
- Protected Attributes inherited from ilSubEnabledFormPropertyGUI
array $sub_items = array()
 
- Protected Attributes inherited from ilFormPropertyGUI
array $set_params = []
 
ilTable2GUI $parent_table = null
 
ilFormPropertyGUI $parent_gui = null
 
ilCtrl $ctrl
 
ilLanguage $lng
 
string $type = ""
 
string $title = ""
 
string $postvar = ""
 
string $info = ""
 
string $alert = ""
 
bool $required = false
 
ilPropertyFormGUI $parentform = null
 
string $hidden_title = ""
 
bool $multi = false
 
bool $multi_sortable = false
 
bool $multi_addremove = true
 
array $multi_values = []
 
RequestInterface $request
 
HTTP Services $http
 
Refinery Factory $refinery = null
 
bool $disabled = false
 
ilGlobalTemplateInterface $global_tpl = null
 

Additional Inherited Members

- Static Public Member Functions inherited from ilFormPropertyGUI
static removeProhibitedCharacters (string $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

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

Constructor & Destructor Documentation

◆ __construct()

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

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

References $DIC, ILIAS\GlobalScreen\Provider\__construct(), ILIAS\Repository\lng(), and ilFormPropertyGUI\setType().

35  {
36  global $DIC;
37 
38  $this->lng = $DIC->language();
39  parent::__construct($a_title, $a_postvar);
40  $this->setType("checkboxgroup");
41  }
global $DIC
Definition: shib_login.php:22
__construct(Container $dic, ilPlugin $plugin)
+ Here is the call graph for this function:

Member Function Documentation

◆ addOption()

ilCheckboxGroupInputGUI::addOption (   $a_option)

◆ checkInput()

ilCheckboxGroupInputGUI::checkInput ( )

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

References ilFormPropertyGUI\$lng, getOptions(), ilFormPropertyGUI\getPostVar(), ilFormPropertyGUI\getRequired(), ilFormPropertyGUI\setAlert(), ilFormPropertyGUI\strArray(), and ilLanguage\txt().

106  : bool
107  {
108  $lng = $this->lng;
109 
110  $values = $this->strArray($this->getPostVar());
111  if ($this->getRequired() && count($values) === 0) {
112  $this->setAlert($lng->txt('msg_input_is_required'));
113  return false;
114  }
115 
116  $ok = true;
117  foreach ($this->getOptions() as $option) {
118  foreach ($option->getSubItems() as $item) {
119  $item_ok = $item->checkInput();
120  if (!$item_ok && in_array($option->getValue(), $values)) {
121  $ok = false;
122  }
123  }
124  }
125  return $ok;
126  }
txt(string $a_topic, string $a_default_lang_fallback_mod="")
gets the text for a given topic if the topic is not in the list, the topic itself with "-" will be re...
+ Here is the call graph for this function:

◆ getInput()

ilCheckboxGroupInputGUI::getInput ( )

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

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

128  : array
129  {
130  return $this->strArray($this->getPostVar());
131  }
+ Here is the call graph for this function:

◆ getItemByPostVar()

ilCheckboxGroupInputGUI::getItemByPostVar ( string  $a_post_var)

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

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

141  {
142  if ($this->getPostVar() == $a_post_var) {
143  return $this;
144  }
145 
146  foreach ($this->getOptions() as $option) {
147  foreach ($option->getSubItems() as $item) {
148  if ($item->getType() != "section_header") {
149  $ret = $item->getItemByPostVar($a_post_var);
150  if (is_object($ret)) {
151  return $ret;
152  }
153  }
154  }
155  }
156 
157  return null;
158  }
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
+ Here is the call graph for this function:

◆ getOptions()

ilCheckboxGroupInputGUI::getOptions ( )

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

References $options.

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

81  : array
82  {
83  return $this->options;
84  }
+ Here is the caller graph for this function:

◆ getTableFilterHTML()

ilCheckboxGroupInputGUI::getTableFilterHTML ( )

Get input item HTML to be inserted into table filters.

Implements ilTableFilterItem.

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

References render().

160  : string
161  {
162  return $this->render();
163  }
+ Here is the call graph for this function:

◆ getToolbarHTML()

ilCheckboxGroupInputGUI::getToolbarHTML ( )

Get input item HTML to be inserted into ilToolbarGUI.

Implements ilToolbarItem.

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

References render().

165  : string
166  {
167  return $this->render('toolbar');
168  }
+ Here is the call graph for this function:

◆ getUseValuesAsKeys()

ilCheckboxGroupInputGUI::getUseValuesAsKeys ( )

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

References $use_values_as_keys.

Referenced by render().

51  : bool
52  {
54  }
+ Here is the caller graph for this function:

◆ getValue()

ilCheckboxGroupInputGUI::getValue ( )

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

References $value.

Referenced by render().

91  : ?array
92  {
93  return $this->value;
94  }
+ Here is the caller graph for this function:

◆ insert()

ilCheckboxGroupInputGUI::insert ( ilTemplate  $a_tpl)

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

References ilTemplate\parseCurrentBlock(), render(), ilTemplate\setCurrentBlock(), and HTML_Template_IT\setVariable().

133  : void
134  {
135  $a_tpl->setCurrentBlock("prop_generic");
136  $a_tpl->setVariable("PROP_GENERIC", $this->render());
137  $a_tpl->parseCurrentBlock();
138  }
parseCurrentBlock(string $part=ilGlobalTemplateInterface::DEFAULT_BLOCK)
setVariable($variable, $value='')
Sets a variable value.
Definition: IT.php:544
setCurrentBlock(string $part=ilGlobalTemplateInterface::DEFAULT_BLOCK)
+ Here is the call graph for this function:

◆ render()

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

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

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

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

170  : string
171  {
172  $tpl = new ilTemplate("tpl.prop_checkbox_group.html", true, true, "components/ILIAS/Form");
173 
174  foreach ($this->getOptions() as $option) {
175  // information text for option
176  if ($option->getInfo() != "") {
177  $tpl->setCurrentBlock("checkbox_option_desc");
178  $tpl->setVariable("CHECKBOX_OPTION_DESC", $option->getInfo());
179  $tpl->parseCurrentBlock();
180  }
181 
182 
183  if (count($option->getSubItems()) > 0) {
184  $tpl->setCurrentBlock("checkbox_option_subform");
185  $pf = new ilPropertyFormGUI();
186  $pf->setMode("subform");
187  $pf->setItems($option->getSubItems());
188  $tpl->setVariable("SUB_FORM", $pf->getContent());
189  $tpl->setVariable("SOP_ID", $this->getFieldId() . "_" . $option->getValue());
190  if ($pf->getMultipart()) {
191  $this->getParentForm()->setMultipart(true);
192  }
193  $tpl->parseCurrentBlock();
194  if ($pf->getMultipart()) {
195  $this->getParentForm()->setMultipart(true);
196  }
197  }
198 
199  $tpl->setCurrentBlock("prop_checkbox_option");
200 
201  if (!$this->getUseValuesAsKeys()) {
202  $tpl->setVariable("POST_VAR", $this->getPostVar() . '[]');
203  $tpl->setVariable("VAL_CHECKBOX_OPTION", $option->getValue());
204  } else {
205  $tpl->setVariable("POST_VAR", $this->getPostVar() . '[' . $option->getValue() . ']');
206  $tpl->setVariable("VAL_CHECKBOX_OPTION", "1");
207  }
208 
209  $tpl->setVariable("OP_ID", $this->getFieldId() . "_" . $option->getValue());
210  $tpl->setVariable("FID", $this->getFieldId());
211 
212  if ($this->getDisabled() or $option->getDisabled()) {
213  $tpl->setVariable('DISABLED', 'disabled="disabled" ');
214  }
215 
216  if (is_array($this->getValue())) {
217  if (!$this->getUseValuesAsKeys()) {
218  if (in_array($option->getValue(), $this->getValue())) {
219  $tpl->setVariable(
220  "CHK_CHECKBOX_OPTION",
221  'checked="checked"'
222  );
223  }
224  } else {
225  $cval = $this->getValue();
226  if (isset($cval[$option->getValue()]) && $cval[$option->getValue()] == 1) {
227  $tpl->setVariable(
228  "CHK_CHECKBOX_OPTION",
229  'checked="checked"'
230  );
231  }
232  }
233  }
234  $tpl->setVariable("TXT_CHECKBOX_OPTION", $option->getTitle());
235 
236 
237  $tpl->parseCurrentBlock();
238  }
239  $tpl->setVariable("ID", $this->getFieldId());
240 
241  return $tpl->get();
242  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setOptions()

ilCheckboxGroupInputGUI::setOptions ( array  $a_options)

Set Options.

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

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

69  : void
70  {
71  foreach ($a_options as $key => $label) {
72  if (is_string($label)) {
73  $chb = new ilCheckboxInputGUI($label, $key);
74  $this->options[] = $chb;
75  } elseif ($label instanceof ilCheckboxInputGUI) {
76  $this->options[] = $label;
77  }
78  }
79  }

◆ setUseValuesAsKeys()

ilCheckboxGroupInputGUI::setUseValuesAsKeys ( bool  $a_val)

Set use values as keys.

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

46  : void
47  {
48  $this->use_values_as_keys = $a_val;
49  }

◆ setValue()

ilCheckboxGroupInputGUI::setValue ( ?array  $a_value)

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

Referenced by ilECSObjectSettings\addSettingsToForm(), ilPageLayoutGUI\initForm(), ilECSParticipantSettingsGUI\initFormSettings(), ilObjPrivacySecurityGUI\initPrivacyForm(), and setValueByArray().

86  : void
87  {
88  $this->value = $a_value;
89  }
+ Here is the caller graph for this function:

◆ setValueByArray()

ilCheckboxGroupInputGUI::setValueByArray ( array  $a_values)

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

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

96  : void
97  {
98  $this->setValue($a_values[$this->getPostVar()] ?? null);
99  foreach ($this->getOptions() as $option) {
100  foreach ($option->getSubItems() as $item) {
101  $item->setValueByArray($a_values);
102  }
103  }
104  }
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
+ Here is the call graph for this function:

Field Documentation

◆ $options

array ilCheckboxGroupInputGUI::$options = array()
protected

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

Referenced by getOptions().

◆ $use_values_as_keys

bool ilCheckboxGroupInputGUI::$use_values_as_keys = false
protected

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

Referenced by getUseValuesAsKeys().

◆ $value

array ilCheckboxGroupInputGUI::$value = null
protected

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

Referenced by getValue().


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