ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
ilTaxMDGUI Class Reference

Taxonomies selection for metadata helper GUI. More...

+ Collaboration diagram for ilTaxMDGUI:

Public Member Functions

 __construct ($a_md_rbac_id, $a_md_obj_id, $a_md_obj_type, $a_ref_id)
 Constructor. More...
 
 executeCommand ()
 Execute command. More...
 
 show ()
 Show. More...
 
 save ()
 Save form. More...
 
 initForm ()
 Init taxonomy form. More...
 
 getSelectableTaxonomies ()
 Get selectable taxonomies for current object. More...
 
 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 ($a_tax_id)
 Init tax node assignment. More...
 

Protected Attributes

 $obj_definition
 
 $tree
 
 $md_rbac_id
 
 $md_obj_id
 
 $md_obj_type
 

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 ilTaxMDGUI: ilFormPropertyDispatchGUI

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

Constructor & Destructor Documentation

◆ __construct()

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

Constructor.

Parameters
int$a_md_rbac_id
int$a_md_obj_id
int$a_md_obj_type
Returns
self

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

References $DIC.

37  {
38  global $DIC;
39 
40  $this->obj_definition = $DIC["objDefinition"];
41  $this->tree = $DIC->repositoryTree();
42 
43 
44  $this->tabs = $DIC->tabs();
45  $this->ctrl = $DIC->ctrl();
46  $this->lng = $DIC->language();
47  $this->tpl = $DIC["tpl"];
48 
49  $this->md_rbac_id = $a_md_rbac_id;
50  $this->md_obj_id = $a_md_obj_id;
51  $this->md_obj_type = $a_md_obj_type;
52  $this->ref_id = $a_ref_id;
53  }
global $DIC
Definition: saml.php:7

Member Function Documentation

◆ addSubTab()

ilTaxMDGUI::addSubTab ( )

addSubTab

Parameters

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

References $lng, $tabs, and getSelectableTaxonomies().

244  {
245  $tabs = $this->tabs;
246  $ctrl = $this->ctrl;
247  $lng = $this->lng;
248 
249  $tax_ids = $this->getSelectableTaxonomies();
250  if (is_array($tax_ids)) {
251  $tabs->addSubTab(
252  "tax_assignment",
253  $lng->txt("tax_tax_assignment"),
254  $ctrl->getLinkTarget($this, "")
255  );
256  }
257  }
getSelectableTaxonomies()
Get selectable taxonomies for current object.
if(!empty($this->data['faventry'])) $tabs
Definition: disco.tpl.php:124
global $lng
Definition: privfeed.php:17
+ Here is the call graph for this function:

◆ addToMDForm()

ilTaxMDGUI::addToMDForm ( ilPropertyFormGUI  $a_form)

Add taxonomy selector to MD (quick edit) form.

Parameters
ilPropertyFormGUI$a_form

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

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

Referenced by initForm().

193  {
194  $tax_ids = $this->getSelectableTaxonomies();
195  if (is_array($tax_ids)) {
196  include_once "Services/Taxonomy/classes/class.ilTaxSelectInputGUI.php";
197  foreach ($tax_ids as $tax_id) {
198  // get existing assignments
199  $node_ids = array();
200  $ta = $this->initTaxNodeAssignment($tax_id);
201  foreach ($ta->getAssignmentsOfItem($this->md_obj_id) as $ass) {
202  $node_ids[] = $ass["node_id"];
203  }
204 
205  $tax_sel = new ilTaxSelectInputGUI($tax_id, "md_tax_" . $tax_id, true);
206  $tax_sel->setValue($node_ids);
207  $a_form->addItem($tax_sel);
208  }
209  }
210  }
Select taxonomy nodes input GUI.
addItem($a_item)
Add Item (Property, SectionHeader).
getSelectableTaxonomies()
Get selectable taxonomies for current object.
initTaxNodeAssignment($a_tax_id)
Init tax node assignment.
Create styles array
The data for the language used.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ executeCommand()

ilTaxMDGUI::executeCommand ( )

Execute command.

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

References $_GET, $form, array, and initForm().

59  {
60  $next_class = $this->ctrl->getNextClass($this);
61  $cmd = $this->ctrl->getCmd("show");
62 
63  switch ($next_class) {
64  case 'ilformpropertydispatchgui':
65  $form = $this->initForm();
66  include_once './Services/Form/classes/class.ilFormPropertyDispatchGUI.php';
67  $form_prop_dispatch = new ilFormPropertyDispatchGUI();
68  $item = $form->getItemByPostVar($_GET["postvar"]);
69  $form_prop_dispatch->setItem($item);
70  return $this->ctrl->forwardCommand($form_prop_dispatch);
71 
72  default:
73  if (in_array($cmd, array("show", "save"))) {
74  $this->$cmd();
75  }
76  }
77  }
$_GET["client_id"]
initForm()
Init taxonomy form.
if(isset($_POST['submit'])) $form
Create styles array
The data for the language used.
+ Here is the call graph for this function:

◆ getSelectableTaxonomies()

ilTaxMDGUI::getSelectableTaxonomies ( )

Get selectable taxonomies for current object.

Returns
array

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

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

Referenced by ilObjectMetaDataGUI\__construct(), addSubTab(), addToMDForm(), and updateFromMDForm().

137  {
138  $objDefinition = $this->obj_definition;
139  $tree = $this->tree;
140 
141  if ($this->ref_id > 0 && $objDefinition->isRBACObject($this->md_obj_type)) {
142  $res = array();
143 
144  // see ilTaxonomyBlockGUI::getActiveTaxonomies()
145 
146  // get all active taxonomies of parent objects
147  foreach ($tree->getPathFull((int) $this->ref_id) as $node) {
148  if ($node["ref_id"] != (int) $this->ref_id) {
149  // currently only active for categories
150  if ($node["type"] == "cat") {
151  include_once "Services/Object/classes/class.ilObjectServiceSettingsGUI.php";
152  include_once "Services/Container/classes/class.ilContainer.php";
154  $node["obj_id"],
156  false
157  )
158  ) {
159  include_once "Services/Taxonomy/classes/class.ilObjTaxonomy.php";
160  $tax_ids = ilObjTaxonomy::getUsageOfObject($node["obj_id"]);
161  if (sizeof($tax_ids)) {
162  $res = array_merge($res, $tax_ids);
163  }
164  }
165  }
166  }
167  }
168 
169  if (sizeof($res)) {
170  return $res;
171  }
172  }
173  }
static getUsageOfObject($a_obj_id, $a_include_titles=false)
Get usage of object.
foreach($_POST as $key=> $value) $res
Create styles array
The data for the language used.
static _lookupContainerSetting($a_id, $a_keyword, $a_default_value=null)
Lookup a container setting.
+ 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 115 of file class.ilTaxMDGUI.php.

References $form, and addToMDForm().

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

116  {
117  include_once("Services/Form/classes/class.ilPropertyFormGUI.php");
118  $form = new ilPropertyFormGUI();
119 
120  $this->addToMDForm($form);
121 
122  $form->addCommandButton("save", $this->lng->txt("save"));
123 
124 
125  $form->setTitle($this->lng->txt("tax_tax_assignment"));
126  $form->setFormAction($this->ctrl->getFormAction($this));
127 
128  return $form;
129  }
This class represents a property form user interface.
if(isset($_POST['submit'])) $form
addToMDForm(ilPropertyFormGUI $a_form)
Add taxonomy selector to MD (quick edit) form.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ initTaxNodeAssignment()

ilTaxMDGUI::initTaxNodeAssignment (   $a_tax_id)
protected

Init tax node assignment.

Parameters
int$a_tax_id
Returns
ilTaxNodeAssignment

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

Referenced by addToMDForm(), and updateFromMDForm().

182  {
183  include_once("./Services/Taxonomy/classes/class.ilTaxNodeAssignment.php");
184  return new ilTaxNodeAssignment($this->md_obj_type, $this->md_obj_id, "obj", $a_tax_id);
185  }
Taxonomy node <-> item assignment.
+ Here is the caller graph for this function:

◆ save()

ilTaxMDGUI::save ( )

Save form.

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

References $form, $tpl, initForm(), ilUtil\sendSuccess(), and updateFromMDForm().

97  {
98  $tpl = $this->tpl;
99  $ctrl = $this->ctrl;
100 
101  $form = $this->initForm();
102  if ($form->checkInput()) {
103  $this->updateFromMDForm();
104  ilUtil::sendSuccess($this->lng->txt("msg_obj_modified"), true);
105  $ctrl->redirect($this, "show");
106  } else {
107  $form->setValuesByPost();
108  $tpl->setContent($form->getHtml());
109  }
110  }
static sendSuccess($a_info="", $a_keep=false)
Send Success Message to Screen.
$tpl
Definition: ilias.php:10
initForm()
Init taxonomy form.
if(isset($_POST['submit'])) $form
updateFromMDForm()
Import settings from MD (quick edit) form.
+ Here is the call graph for this function:

◆ show()

ilTaxMDGUI::show ( )

Show.

Parameters

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

References $form, $tpl, and initForm().

86  {
87  $tpl = $this->tpl;
88 
89  $form = $this->initForm();
90  $tpl->setContent($form->getHTML());
91  }
$tpl
Definition: ilias.php:10
initForm()
Init taxonomy form.
if(isset($_POST['submit'])) $form
+ Here is the call graph for this function:

◆ updateFromMDForm()

ilTaxMDGUI::updateFromMDForm ( )

Import settings from MD (quick edit) form.

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

References $_POST, getSelectableTaxonomies(), and initTaxNodeAssignment().

Referenced by save().

216  {
217  $tax_ids = $this->getSelectableTaxonomies();
218  if (is_array($tax_ids)) {
219  include_once("./Services/Taxonomy/classes/class.ilTaxNodeAssignment.php");
220 
221  foreach ($tax_ids as $tax_id) {
222  $ta = $this->initTaxNodeAssignment($tax_id);
223 
224  // delete existing assignments
225  $ta->deleteAssignmentsOfItem($this->md_obj_id);
226 
227  // set current assignment
228  if (is_array($_POST["md_tax_" . $tax_id])) {
229  foreach ($_POST["md_tax_" . $tax_id] as $node_id) {
230  $ta->addAssignment($node_id, $this->md_obj_id);
231  }
232  }
233  }
234  }
235  }
getSelectableTaxonomies()
Get selectable taxonomies for current object.
initTaxNodeAssignment($a_tax_id)
Init tax node assignment.
$_POST["username"]
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Field Documentation

◆ $md_obj_id

ilTaxMDGUI::$md_obj_id
protected

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

◆ $md_obj_type

ilTaxMDGUI::$md_obj_type
protected

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

◆ $md_rbac_id

ilTaxMDGUI::$md_rbac_id
protected

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

◆ $obj_definition

ilTaxMDGUI::$obj_definition
protected

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

Referenced by getSelectableTaxonomies().

◆ $tree

ilTaxMDGUI::$tree
protected

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

Referenced by getSelectableTaxonomies().


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