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

Taxonomies selection for metadata helper GUI. More...

+ Collaboration diagram for ilTaxMDGUI:

Public Member Functions

 __construct (int $a_md_rbac_id, int $a_md_obj_id, string $a_md_obj_type, int $a_ref_id)
 Constructor. More...
 
 executeCommand ()
 Execute command. More...
 
 show ()
 
 save ()
 
 initForm ()
 Init taxonomy form. More...
 
 getSelectableTaxonomies ()
 
 addToMDForm (ilPropertyFormGUI $a_form)
 Add taxonomy selector to MD (quick edit) form. More...
 
 updateFromMDForm ()
 Import settings from MD (quick edit) form. More...
 
 addSubTab ()
 addSubTab More...
 

Protected Member Functions

 initTaxNodeAssignment (int $a_tax_id)
 

Protected Attributes

ilObjectDefinition $obj_definition
 
ilTree $tree
 
int $md_rbac_id
 
int $md_obj_id
 
string $md_obj_type
 
string $requested_post_var
 
RequestInterface $request
 
ilCtrl $ctrl
 
ilGlobalTemplateInterface $tpl
 
ilLanguage $lng
 
ilTabsGUI $tabs
 
int $ref_id
 

Detailed Description

Taxonomies selection for metadata helper GUI.

Author
Jörg Lützenkirchen luetz.nosp@m.enki.nosp@m.rchen.nosp@m.@lei.nosp@m.fos.c.nosp@m.om @ilCtrl_Calls ilTaxMDGUI: ilFormPropertyDispatchGUI

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

Constructor & Destructor Documentation

◆ __construct()

ilTaxMDGUI::__construct ( int  $a_md_rbac_id,
int  $a_md_obj_id,
string  $a_md_obj_type,
int  $a_ref_id 
)

Constructor.

Definition at line 45 of file class.ilTaxMDGUI.php.

50 {
51 global $DIC;
52
53 $this->obj_definition = $DIC["objDefinition"];
54 $this->tree = $DIC->repositoryTree();
55
56
57 $this->tabs = $DIC->tabs();
58 $this->ctrl = $DIC->ctrl();
59 $this->lng = $DIC->language();
60 $this->tpl = $DIC->ui()->mainTemplate();
61
62 // @todo introduce request wrapper
63 $this->request = $DIC->http()->request();
64
65 $this->md_rbac_id = $a_md_rbac_id;
66 $this->md_obj_id = $a_md_obj_id;
67 $this->md_obj_type = $a_md_obj_type;
68 $this->ref_id = $a_ref_id;
69
70 $params = $this->request->getQueryParams();
71 $this->requested_post_var = $params["postvar"] ?? "";
72 }
if(! $DIC->user() ->getId()||!ilLTIConsumerAccess::hasCustomProviderCreationAccess()) $params
Definition: ltiregstart.php:31
global $DIC
Definition: shib_login.php:26

References $DIC, $params, ILIAS\Repository\ctrl(), ILIAS\Repository\lng(), and ILIAS\Repository\tabs().

+ Here is the call graph for this function:

Member Function Documentation

◆ addSubTab()

ilTaxMDGUI::addSubTab ( )

addSubTab

Definition at line 220 of file class.ilTaxMDGUI.php.

220 : void
221 {
225
226 $tax_ids = $this->getSelectableTaxonomies();
227 if (is_array($tax_ids)) {
229 "tax_assignment",
230 $lng->txt("tax_tax_assignment"),
231 $ctrl->getLinkTarget($this, "")
232 );
233 }
234 }
getLinkTarget(object $a_gui_obj, ?string $a_cmd=null, ?string $a_anchor=null, bool $is_async=false, bool $has_xml_style=false)
@inheritDoc
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...
addSubTab(string $a_id, string $a_text, string $a_link, string $a_frame="")
ilLanguage $lng
ilTabsGUI $tabs

References $ctrl, $lng, $tabs, ilTabsGUI\addSubTab(), ilCtrl\getLinkTarget(), getSelectableTaxonomies(), and ilLanguage\txt().

+ Here is the call graph for this function:

◆ addToMDForm()

ilTaxMDGUI::addToMDForm ( ilPropertyFormGUI  $a_form)

Add taxonomy selector to MD (quick edit) form.

Definition at line 174 of file class.ilTaxMDGUI.php.

174 : void
175 {
176 $tax_ids = $this->getSelectableTaxonomies();
177 if (is_array($tax_ids)) {
178 foreach ($tax_ids as $tax_id) {
179 // get existing assignments
180 $node_ids = array();
181 $ta = $this->initTaxNodeAssignment((int) $tax_id);
182 foreach ($ta->getAssignmentsOfItem($this->md_obj_id) as $ass) {
183 $node_ids[] = $ass["node_id"];
184 }
185
186 $tax_sel = new ilTaxSelectInputGUI($tax_id, "md_tax_" . $tax_id, true);
187 $tax_sel->setValue($node_ids);
188 $a_form->addItem($tax_sel);
189 }
190 }
191 }
initTaxNodeAssignment(int $a_tax_id)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...

References ilPropertyFormGUI\addItem(), getSelectableTaxonomies(), and initTaxNodeAssignment().

Referenced by initForm().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ executeCommand()

ilTaxMDGUI::executeCommand ( )

Execute command.

Returns
mixed|string
Exceptions
ilCtrlException

Definition at line 79 of file class.ilTaxMDGUI.php.

80 {
81 $next_class = $this->ctrl->getNextClass($this);
82 $cmd = $this->ctrl->getCmd("show");
83
84 if ($next_class == 'ilformpropertydispatchgui') {
85 $form = $this->initForm();
86 $form_prop_dispatch = new ilFormPropertyDispatchGUI();
87 $item = $form->getItemByPostVar($this->requested_post_var);
88 $form_prop_dispatch->setItem($item);
89 return $this->ctrl->forwardCommand($form_prop_dispatch);
90 } elseif (in_array($cmd, array("show", "save"))) {
91 $this->$cmd();
92 }
93 return "";
94 }
initForm()
Init taxonomy form.

References ILIAS\Repository\ctrl(), and initForm().

+ Here is the call graph for this function:

◆ getSelectableTaxonomies()

ilTaxMDGUI::getSelectableTaxonomies ( )

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

135 : array
136 {
137 $objDefinition = $this->obj_definition;
139
140 $res = [];
141 if ($this->ref_id > 0 && $objDefinition->isRBACObject($this->md_obj_type)) {
142 // get all active taxonomies of parent objects
143 foreach ($tree->getPathFull($this->ref_id) as $node) {
144 // currently only active for categories
145 if ((int) $node["ref_id"] != $this->ref_id && $node["type"] == "cat") {
147 (int) $node["obj_id"],
149 false
150 ) !== ''
151 ) {
152 $tax_ids = ilObjTaxonomy::getUsageOfObject((int) $node["obj_id"]);
153 if (count($tax_ids) !== 0) {
154 $res = array_merge($res, $tax_ids);
155 }
156 }
157 }
158 }
159 }
160 return $res;
161 }
static _lookupContainerSetting(int $a_id, string $a_keyword, ?string $a_default_value=null)
static getUsageOfObject(int $a_obj_id, bool $a_include_titles=false)
ilObjectDefinition $obj_definition
getPathFull(int $a_endnode_id, int $a_startnode_id=0)
get path from a given startnode to a given endnode if startnode is not given the rootnode is startnod...
$res
Definition: ltiservices.php:69

References $obj_definition, $res, $tree, ilContainer\_lookupContainerSetting(), ilTree\getPathFull(), ilObjTaxonomy\getUsageOfObject(), and ilObjectServiceSettingsGUI\TAXONOMIES.

Referenced by addSubTab(), addToMDForm(), and updateFromMDForm().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ initForm()

ilTaxMDGUI::initForm ( )

Init taxonomy form.

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

123 {
124 $form = new ilPropertyFormGUI();
125
126 $this->addToMDForm($form);
127 $form->addCommandButton("save", $this->lng->txt("save"));
128 $form->setTitle($this->lng->txt("tax_tax_assignment"));
129 $form->setFormAction($this->ctrl->getFormAction($this));
130
131 return $form;
132 }
This class represents a property form user interface.
addToMDForm(ilPropertyFormGUI $a_form)
Add taxonomy selector to MD (quick edit) form.

References addToMDForm(), ILIAS\Repository\ctrl(), and ILIAS\Repository\lng().

Referenced by executeCommand(), save(), and show().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ initTaxNodeAssignment()

ilTaxMDGUI::initTaxNodeAssignment ( int  $a_tax_id)
protected
Exceptions
ilTaxonomyException

Definition at line 166 of file class.ilTaxMDGUI.php.

167 {
168 return new ilTaxNodeAssignment($this->md_obj_type, $this->md_obj_id, "obj", $a_tax_id);
169 }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...

Referenced by addToMDForm(), and updateFromMDForm().

+ Here is the caller graph for this function:

◆ save()

ilTaxMDGUI::save ( )

Definition at line 103 of file class.ilTaxMDGUI.php.

103 : void
104 {
107
108 $form = $this->initForm();
109 if ($form->checkInput()) {
110 $this->updateFromMDForm();
111 $this->tpl->setOnScreenMessage('success', $this->lng->txt("msg_obj_modified"), true);
112 $ctrl->redirect($this, "show");
113 } else {
114 $form->setValuesByPost();
115 $tpl->setContent($form->getHTML());
116 }
117 }
redirect(object $a_gui_obj, ?string $a_cmd=null, ?string $a_anchor=null, bool $is_async=false)
@inheritDoc
ilGlobalTemplateInterface $tpl
updateFromMDForm()
Import settings from MD (quick edit) form.
setContent(string $a_html)
Sets content for standard template.

References $ctrl, $tpl, initForm(), ILIAS\Repository\lng(), ilCtrl\redirect(), ILIAS\UICore\GlobalTemplate\setContent(), and updateFromMDForm().

+ Here is the call graph for this function:

◆ show()

ilTaxMDGUI::show ( )

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

96 : void
97 {
99 $form = $this->initForm();
100 $tpl->setContent($form->getHTML());
101 }

References $tpl, initForm(), and ILIAS\UICore\GlobalTemplate\setContent().

+ Here is the call graph for this function:

◆ updateFromMDForm()

ilTaxMDGUI::updateFromMDForm ( )

Import settings from MD (quick edit) form.

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

196 : void
197 {
198 $body = $this->request->getParsedBody();
199 $tax_ids = $this->getSelectableTaxonomies();
200 if (is_array($tax_ids)) {
201 foreach ($tax_ids as $tax_id) {
202 $ta = $this->initTaxNodeAssignment($tax_id);
203
204 // delete existing assignments
205 $ta->deleteAssignmentsOfItem($this->md_obj_id);
206
207 // set current assignment
208 if (isset($body["md_tax_" . $tax_id])) {
209 foreach ($body["md_tax_" . $tax_id] as $node_id) {
210 $ta->addAssignment($node_id, $this->md_obj_id);
211 }
212 }
213 }
214 }
215 }

References getSelectableTaxonomies(), and initTaxNodeAssignment().

Referenced by save().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Field Documentation

◆ $ctrl

ilCtrl ilTaxMDGUI::$ctrl
protected

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

Referenced by addSubTab(), and save().

◆ $lng

ilLanguage ilTaxMDGUI::$lng
protected

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

Referenced by addSubTab().

◆ $md_obj_id

int ilTaxMDGUI::$md_obj_id
protected

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

◆ $md_obj_type

string ilTaxMDGUI::$md_obj_type
protected

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

◆ $md_rbac_id

int ilTaxMDGUI::$md_rbac_id
protected

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

◆ $obj_definition

ilObjectDefinition ilTaxMDGUI::$obj_definition
protected

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

Referenced by getSelectableTaxonomies().

◆ $ref_id

int ilTaxMDGUI::$ref_id
protected

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

◆ $request

RequestInterface ilTaxMDGUI::$request
protected

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

◆ $requested_post_var

string ilTaxMDGUI::$requested_post_var
protected

Definition at line 34 of file class.ilTaxMDGUI.php.

◆ $tabs

ilTabsGUI ilTaxMDGUI::$tabs
protected

Definition at line 39 of file class.ilTaxMDGUI.php.

Referenced by addSubTab().

◆ $tpl

ilGlobalTemplateInterface ilTaxMDGUI::$tpl
protected

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

Referenced by save(), and show().

◆ $tree

ilTree ilTaxMDGUI::$tree
protected

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

Referenced by getSelectableTaxonomies().


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