ILIAS  trunk Revision v11.0_alpha-2638-g80c1d007f79
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
Deprecated:
12 This component will be removed with ILIAS 12

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

Constructor & Destructor Documentation

◆ __construct()

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

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

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

36  {
37  global $DIC;
38 
39  $this->lng = $DIC->language();
40  parent::__construct($a_title, $a_postvar);
41  $this->setType("checkboxgroup");
42  }
global $DIC
Definition: shib_login.php:26
__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 107 of file class.ilCheckboxGroupInputGUI.php.

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

107  : bool
108  {
109  $lng = $this->lng;
110 
111  $values = $this->strArray($this->getPostVar());
112  if ($this->getRequired() && count($values) === 0) {
113  $this->setAlert($lng->txt('msg_input_is_required'));
114  return false;
115  }
116 
117  $ok = true;
118  foreach ($this->getOptions() as $option) {
119  foreach ($option->getSubItems() as $item) {
120  $item_ok = $item->checkInput();
121  if (!$item_ok && in_array($option->getValue(), $values)) {
122  $ok = false;
123  }
124  }
125  }
126  return $ok;
127  }
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 129 of file class.ilCheckboxGroupInputGUI.php.

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

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

◆ getItemByPostVar()

ilCheckboxGroupInputGUI::getItemByPostVar ( string  $a_post_var)

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

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

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

◆ getOptions()

ilCheckboxGroupInputGUI::getOptions ( )

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

References $options.

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

82  : array
83  {
84  return $this->options;
85  }
+ 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 161 of file class.ilCheckboxGroupInputGUI.php.

References render().

161  : string
162  {
163  return $this->render();
164  }
+ 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 166 of file class.ilCheckboxGroupInputGUI.php.

References render().

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

◆ getUseValuesAsKeys()

ilCheckboxGroupInputGUI::getUseValuesAsKeys ( )

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

References $use_values_as_keys.

Referenced by render().

52  : bool
53  {
55  }
+ Here is the caller graph for this function:

◆ getValue()

ilCheckboxGroupInputGUI::getValue ( )

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

References $value.

Referenced by render().

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

◆ insert()

ilCheckboxGroupInputGUI::insert ( ilTemplate  $a_tpl)

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

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

134  : void
135  {
136  $a_tpl->setCurrentBlock("prop_generic");
137  $a_tpl->setVariable("PROP_GENERIC", $this->render());
138  $a_tpl->parseCurrentBlock();
139  }
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 171 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().

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

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

◆ setUseValuesAsKeys()

ilCheckboxGroupInputGUI::setUseValuesAsKeys ( bool  $a_val)

Set use values as keys.

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

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

◆ setValue()

ilCheckboxGroupInputGUI::setValue ( ?array  $a_value)

◆ setValueByArray()

ilCheckboxGroupInputGUI::setValueByArray ( array  $a_values)

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

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

97  : void
98  {
99  $this->setValue($a_values[$this->getPostVar()] ?? null);
100  foreach ($this->getOptions() as $option) {
101  foreach ($option->getSubItems() as $item) {
102  $item->setValueByArray($a_values);
103  }
104  }
105  }
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 29 of file class.ilCheckboxGroupInputGUI.php.

Referenced by getOptions().

◆ $use_values_as_keys

bool ilCheckboxGroupInputGUI::$use_values_as_keys = false
protected

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

Referenced by getUseValuesAsKeys().

◆ $value

array ilCheckboxGroupInputGUI::$value = null
protected

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

Referenced by getValue().


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