ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
class.ilTaxMDGUI.php
Go to the documentation of this file.
1<?php
2/* Copyright (c) 1998-2012 ILIAS open source, Extended GPL, see docs/LICENSE */
3
13{
14 protected $md_rbac_id; // [int]
15 protected $md_obj_id; // [int]
16 protected $md_obj_type; // [string]
17
26 public function __construct($a_md_rbac_id, $a_md_obj_id, $a_md_obj_type)
27 {
28 $this->md_rbac_id = $a_md_rbac_id;
29 $this->md_obj_id = $a_md_obj_id;
30 $this->md_obj_type = $a_md_obj_type;
31 }
32
38 protected function getSelectableTaxonomies()
39 {
40 global $objDefinition, $tree;
41
42 if($objDefinition->isRBACObject($this->md_obj_type))
43 {
44 $res = array();
45
46 // see ilTaxonomyBlockGUI::getActiveTaxonomies()
47
48 // get all active taxonomies of parent objects
49 foreach($tree->getPathFull((int)$_REQUEST["ref_id"]) as $node)
50 {
51 // currently only active for categories
52 if($node["type"] == "cat")
53 {
54 include_once "Services/Object/classes/class.ilObjectServiceSettingsGUI.php";
55 include_once "Services/Container/classes/class.ilContainer.php";
57 $node["obj_id"],
59 false
60 ))
61 {
62 include_once "Services/Taxonomy/classes/class.ilObjTaxonomy.php";
63 $tax_ids = ilObjTaxonomy::getUsageOfObject($node["obj_id"]);
64 if(sizeof($tax_ids))
65 {
66 $res = array_merge($res, $tax_ids);
67 }
68 }
69 }
70 }
71
72 if(sizeof($res))
73 {
74 return $res;
75 }
76 }
77 }
78
85 protected function initTaxNodeAssignment($a_tax_id)
86 {
87 include_once("./Services/Taxonomy/classes/class.ilTaxNodeAssignment.php");
88 return new ilTaxNodeAssignment($this->md_obj_type, $this->md_obj_id, "obj", $a_tax_id);
89 }
90
96 public function addToMDForm(ilPropertyFormGUI $a_form)
97 {
98 $tax_ids = $this->getSelectableTaxonomies();
99 if(is_array($tax_ids))
100 {
101 include_once "Services/Taxonomy/classes/class.ilTaxSelectInputGUI.php";
102 foreach($tax_ids as $tax_id)
103 {
104 // get existing assignments
105 $node_ids = array();
106 $ta = $this->initTaxNodeAssignment($tax_id);
107 foreach($ta->getAssignmentsOfItem($this->md_obj_id) as $ass)
108 {
109 $node_ids[] = $ass["node_id"];
110 }
111
112 $tax_sel = new ilTaxSelectInputGUI($tax_id, "md_tax_".$tax_id, true);
113 $tax_sel->setValue($node_ids);
114 $a_form->addItem($tax_sel);
115 }
116 }
117 }
118
122 public function updateFromMDForm()
123 {
124 $tax_ids = $this->getSelectableTaxonomies();
125 if(is_array($tax_ids))
126 {
127 include_once("./Services/Taxonomy/classes/class.ilTaxNodeAssignment.php");
128
129 foreach($tax_ids as $tax_id)
130 {
131 $ta = $this->initTaxNodeAssignment($tax_id);
132
133 // delete existing assignments
134 $ta->deleteAssignmentsOfItem($this->md_obj_id);
135
136 // set current assignment
137 if(is_array($_POST["md_tax_".$tax_id]))
138 {
139 foreach($_POST["md_tax_".$tax_id] as $node_id)
140 {
141 $ta->addAssignment($node_id, $this->md_obj_id);
142 }
143 }
144 }
145 }
146 }
147}
_lookupContainerSetting($a_id, $a_keyword, $a_default_value=NULL)
Lookup a container setting.
static getUsageOfObject($a_obj_id, $a_include_titles=false)
Get usage of object.
This class represents a property form user interface.
addItem($a_item)
Add Item (Property, SectionHeader).
getSelectableTaxonomies()
Get selectable taxonomies for current object.
initTaxNodeAssignment($a_tax_id)
Init tax node assignment.
addToMDForm(ilPropertyFormGUI $a_form)
Add taxonomy selector to MD (quick edit) form.
updateFromMDForm()
Import settings from MD (quick edit) form.
__construct($a_md_rbac_id, $a_md_obj_id, $a_md_obj_type)
Constructor.
Taxonomy node <-> item assignment.
Select taxonomy nodes input GUI.
$_POST['username']
Definition: cron.php:12
if($_REQUEST['ilias_path']) define('ILIAS_HTTP_PATH' $_REQUEST['ilias_path']
Definition: index.php:7