ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
ilTaxAssignInputGUI Class Reference

This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V. More...

+ Inheritance diagram for ilTaxAssignInputGUI:
+ Collaboration diagram for ilTaxAssignInputGUI:

Public Member Functions

 __construct (int $a_taxonomy_id, bool $a_multi=true, string $a_title="", string $a_postvar="", bool $a_include_please_select=true)
 
 setTaxonomyId (int $a_val)
 Set taxonomy id. More...
 
 getTaxonomyId ()
 Get taxonomy id. More...
 
 setOptions ($a_options)
 Set Options. More...
 
 getOptions ()
 Get Options. More...
 
 saveInput (string $a_component_id, int $a_obj_id, string $a_item_type, int $a_item_id)
 Save input. More...
 
 setCurrentValues (string $a_component_id, int $a_obj_id, string $a_item_type, int $a_item_id)
 Set current values. More...
 
- Public Member Functions inherited from ilSelectInputGUI
 __construct (string $a_title="", string $a_postvar="")
 
 setOptions (array $a_options)
 
 getOptions ()
 
 setOptionsLangAttribute (\Closure $langresolve)
 
 getOptionsLangAttribute ($key)
 
 setValue ($a_value)
 Set Value. More...
 
 getValue ()
 Get Value. More...
 
 setValueByArray (array $a_values)
 
 checkInput ()
 Check input, strip slashes etc. More...
 
 getInput ()
 
 addCustomAttribute (string $a_attr)
 
 getCustomAttributes ()
 
 render ($a_mode="")
 
 insert (ilTemplate $a_tpl)
 
 getTableFilterHTML ()
 Get input item HTML to be inserted into table filters. More...
 
 getToolbarHTML ()
 Get input item HTML to be inserted into ilToolbarGUI. More...
 
 setHideSubForm (bool $a_value, ?string $a_condition=null)
 Set initial sub form visibility, optionally add dynamic value-based condition. More...
 
 hideSubForm ()
 
- 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)
 Get item by post var. More...
 
- 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
 getTableFilterHTML ()
 Get input item HTML to be inserted into table filters. More...
 
 getTableFilterLabelFor ()
 Get label "for" attribute value. More...
 
 getToolbarHTML ()
 Get input item HTML to be inserted into ilToolbarGUI. More...
 

Protected Attributes

bool $include_please_select
 
int $taxononmy_id
 
- Protected Attributes inherited from ilSelectInputGUI
array $cust_attr = array()
 
array $options = array()
 
Closure $langresolve = null
 
 $value
 
bool $hide_sub = 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...
 
- 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)
 

Detailed Description

This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V.

ILIAS is licensed with the GPL-3.0, see https://www.gnu.org/licenses/gpl-3.0.en.html You should have received a copy of said license along with the source code, too.

If this is not the case or you just want to try ILIAS, you'll find us at: https://www.ilias.de https://github.com/ILIAS-eLearning Input GUI class for taxonomy assignments

Author
Alexander Killing killi.nosp@m.ng@l.nosp@m.eifos.nosp@m..de

Definition at line 23 of file class.ilTaxAssignInputGUI.php.

Constructor & Destructor Documentation

◆ __construct()

ilTaxAssignInputGUI::__construct ( int  $a_taxonomy_id,
bool  $a_multi = true,
string  $a_title = "",
string  $a_postvar = "",
bool  $a_include_please_select = true 
)

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

34 {
35 global $DIC;
36
37 $this->lng = $DIC->language();
38 $lng = $DIC->language();
39
41 $this->setMulti($a_multi);
42 $this->include_please_select = $a_include_please_select;
43
44 if ($a_title == "") {
45 $a_title = $lng->txt("tax_taxonomy");
46 }
47
48 if ($a_postvar == "") {
49 $a_postvar = "tax_node_assign";
50 }
51
52 parent::__construct($a_title, $a_postvar);
53 $this->setType("tax_assign");
54
55 if ((int) $a_taxonomy_id == 0) {
56 throw new ilTaxonomyException("No taxonomy ID passed to ilTaxAssignInputGUI.");
57 }
58
59 $this->setTaxonomyId((int) $a_taxonomy_id);
60 }
setMulti(bool $a_multi, bool $a_sortable=false, bool $a_addremove=true)
loadLanguageModule(string $a_module)
Load language module.
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...
setTaxonomyId(int $a_val)
Set taxonomy id.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
global $DIC
Definition: shib_login.php:26

References $DIC, ilFormPropertyGUI\$lng, ILIAS\GlobalScreen\Provider\__construct(), ILIAS\Repository\lng(), ilLanguage\loadLanguageModule(), ilFormPropertyGUI\setMulti(), setTaxonomyId(), ilFormPropertyGUI\setType(), and ilLanguage\txt().

+ Here is the call graph for this function:

Member Function Documentation

◆ getOptions()

ilTaxAssignInputGUI::getOptions ( )

Get Options.

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

Reimplemented from ilSelectInputGUI.

Definition at line 93 of file class.ilTaxAssignInputGUI.php.

93 : array
94 {
96
97 $options = [];
98 if ($this->include_please_select) {
99 $options = array("" => $lng->txt("please_select"));
100 }
101
102 $tax_tree = new ilTaxonomyTree($this->getTaxonomyId());
103
104 $nodes = $tax_tree->getSubTree($tax_tree->getNodeData($tax_tree->readRootId()));
105 foreach ($nodes as $n) {
106 if ($n["type"] == "taxn") {
107 $options[$n["child"]] = str_repeat(" ", ($n["depth"] - 2) * 2) . $n["title"];
108 }
109 }
110
111 return $options;
112 }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...

References ilFormPropertyGUI\$lng, ilSelectInputGUI\$options, getTaxonomyId(), and ilLanguage\txt().

+ Here is the call graph for this function:

◆ getTaxonomyId()

ilTaxAssignInputGUI::getTaxonomyId ( )

Get taxonomy id.

Returns
int taxonomy id

Definition at line 75 of file class.ilTaxAssignInputGUI.php.

75 : int
76 {
78 }

References $taxononmy_id.

Referenced by getOptions().

+ Here is the caller graph for this function:

◆ saveInput()

ilTaxAssignInputGUI::saveInput ( string  $a_component_id,
int  $a_obj_id,
string  $a_item_type,
int  $a_item_id 
)

Save input.

Exceptions
ilTaxonomyException

Definition at line 118 of file class.ilTaxAssignInputGUI.php.

123 : void {
124 $tax_node_ass = new ilTaxNodeAssignment($a_component_id, $a_obj_id, $a_item_type, $this->getTaxonomyId());
125
126 $body = $this->request->getParsedBody();
127 $post = $body[$this->getPostVar()] ?? "";
128
129 if (!$this->getMulti()) {
130 $post = array($post);
131 } elseif (!is_array($post)) {
132 // BH: when multi values are ENABLED and $form->checkInput is NOT called
133 // there is no post parameter available WHEN the selection is left empty
134 // - fixed mantis #22186 - the followup issue
135 $post = array();
136 }
137
138 $current_ass = $tax_node_ass->getAssignmentsOfItem($a_item_id);
139 $exising = array();
140 foreach ($current_ass as $ca) {
141 if (!in_array($ca["node_id"], $post)) {
142 $tax_node_ass->deleteAssignment((int) $ca["node_id"], $a_item_id);
143 } else {
144 $exising[] = (int) $ca["node_id"];
145 }
146 }
147
148 foreach ($post as $p) {
149 if (!in_array((int) $p, $exising)) {
150 $tax_node_ass->addAssignment((int) $p, $a_item_id);
151 }
152 }
153 }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
$post
Definition: ltitoken.php:46

References $post.

◆ setCurrentValues()

ilTaxAssignInputGUI::setCurrentValues ( string  $a_component_id,
int  $a_obj_id,
string  $a_item_type,
int  $a_item_id 
)

Set current values.

Exceptions
ilTaxonomyException

Definition at line 159 of file class.ilTaxAssignInputGUI.php.

164 : void {
165 $tax_node_ass = new ilTaxNodeAssignment($a_component_id, $a_obj_id, $a_item_type, $this->getTaxonomyId());
166 $ass = $tax_node_ass->getAssignmentsOfItem($a_item_id);
167
168 $nodes = array();
169 foreach ($ass as $a) {
170 $nodes[] = $a["node_id"];
171 }
172 if ($this->getMulti()) {
173 $this->setValue($nodes);
174 } else {
175 $this->setValue($nodes[0]);
176 }
177 }
setValue($a_value)
Set Value.
$a
thx to https://mlocati.github.io/php-cs-fixer-configurator for the examples

◆ setOptions()

ilTaxAssignInputGUI::setOptions (   $a_options)

Set Options.

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

Definition at line 84 of file class.ilTaxAssignInputGUI.php.

84 : void
85 {
86 throw new ilTaxonomyException("setOptions: Not supported for ilTaxAssignInputGUI.");
87 }

◆ setTaxonomyId()

ilTaxAssignInputGUI::setTaxonomyId ( int  $a_val)

Set taxonomy id.

Parameters
int$a_valtaxonomy id

Definition at line 66 of file class.ilTaxAssignInputGUI.php.

66 : void
67 {
68 $this->taxononmy_id = $a_val;
69 }

Referenced by __construct().

+ Here is the caller graph for this function:

Field Documentation

◆ $include_please_select

bool ilTaxAssignInputGUI::$include_please_select
protected

Definition at line 25 of file class.ilTaxAssignInputGUI.php.

◆ $taxononmy_id

int ilTaxAssignInputGUI::$taxononmy_id
protected

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

Referenced by getTaxonomyId().


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