ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
ilTaxonomyClassificationProvider 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 ilTaxonomyClassificationProvider:
+ Collaboration diagram for ilTaxonomyClassificationProvider:

Public Member Functions

 render (array &$a_html, object $a_parent_gui)
 Render HTML chunks. More...
 
 importPostData (?array $a_saved=null)
 Import post data. More...
 
 setSelection (array $a_value)
 @inheritDoc More...
 
 getFilteredObjects ()
 Get filtered object ref ids. More...
 
- Public Member Functions inherited from ilClassificationProvider
 __construct (int $a_parent_ref_id, int $a_parent_obj_id, string $a_parent_obj_type)
 
 render (array &$a_html, object $a_parent_gui)
 Render HTML chunks. More...
 
 importPostData (?array $a_saved=null)
 Import post data. More...
 
 setSelection (array $a_value)
 Set selection. More...
 
 getFilteredObjects ()
 Get filtered object ref ids. More...
 
 initListGUI (ilObjectListGUI $a_list_gui)
 Init list gui properties. More...
 

Static Public Member Functions

static isActive (int $a_parent_ref_id, int $a_parent_obj_id, string $a_parent_obj_type)
 Is provider currently active? More...
 
- Static Public Member Functions inherited from ilClassificationProvider
static getValidProviders (int $a_parent_ref_id, int $a_parent_obj_id, string $a_parent_obj_type)
 Get all valid providers (for parent container) More...
 
static isActive (int $a_parent_ref_id, int $a_parent_obj_id, string $a_parent_obj_type)
 Is provider currently active? More...
 

Protected Member Functions

 init ()
 
 init ()
 

Static Protected Member Functions

static getActiveTaxonomiesForParentRefId (int $a_parent_ref_id)
 

Protected Attributes

array $selection = []
 
int $incoming_id = 0
 
- Protected Attributes inherited from ilClassificationProvider
int $parent_ref_id
 
int $parent_obj_id
 
string $parent_type
 
RequestInterface $request
 

Static Protected Attributes

static array $valid_tax_map = []
 

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 Taxonomy classification provider

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

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

Member Function Documentation

◆ getActiveTaxonomiesForParentRefId()

static ilTaxonomyClassificationProvider::getActiveTaxonomiesForParentRefId ( int  $a_parent_ref_id)
staticprotected

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

92 : int
93 {
94 global $DIC;
95
96 $tree = $DIC->repositoryTree();
97
98 if (!isset(self::$valid_tax_map[$a_parent_ref_id])) {
100
101 $all_valid = array();
102 foreach ($tree->getPathFull($a_parent_ref_id) as $node) {
103 if ($node["type"] == "cat") {
104 $node_valid = array();
105
107 (int) $node["obj_id"],
109 false
110 ) !== '') {
111 $all_valid = array_merge(
112 $all_valid,
113 ilObjTaxonomy::getUsageOfObject((int) $node["obj_id"])
114 );
115
116 $active = array();
117 foreach (ilContainer::_getContainerSettings((int) $node["obj_id"]) as $keyword => $value) {
118 if (substr($keyword, 0, strlen($prefix)) == $prefix && (bool) $value) {
119 $active[] = substr($keyword, strlen($prefix));
120 }
121 }
122
123 $node_valid = array_intersect($all_valid, $active);
124 }
125
126 if (count($node_valid) !== 0) {
127 foreach ($node_valid as $idx => $node_id) {
128 // #15268 - deleted taxonomy?
129 if (ilObject::_lookupType((int) $node_id) != "tax") {
130 unset($node_valid[$idx]);
131 }
132 }
133 }
134
135 $id_and_title = array_map(static function (int $id) {
136 return [
137 "id" => $id,
138 "title" => ilObject::_lookupTitle($id)
139 ];
140 }, $node_valid);
141 $id_and_title = ilArrayUtil::sortArray($id_and_title, "title");
142 $sorted_ids = array_map(static function (array $id_and_title) {
143 return (int) $id_and_title["id"];
144 }, $id_and_title);
145 self::$valid_tax_map[$node["ref_id"]] = $sorted_ids;
146 }
147 }
148 }
149
150 if (isset(self::$valid_tax_map[$a_parent_ref_id]) && is_array(self::$valid_tax_map[$a_parent_ref_id])) {
151 return count(self::$valid_tax_map[$a_parent_ref_id]);
152 }
153
154 return 0;
155 }
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
static sortArray(array $array, string $a_array_sortby_key, string $a_array_sortorder="asc", bool $a_numeric=false, bool $a_keep_keys=false)
static _getContainerSettings(int $a_id)
static _lookupContainerSetting(int $a_id, string $a_keyword, ?string $a_default_value=null)
static getUsageOfObject(int $a_obj_id, bool $a_include_titles=false)
static _lookupType(int $id, bool $reference=false)
static _lookupTitle(int $obj_id)
global $DIC
Definition: shib_login.php:26

References $DIC, $id, ilContainer\_getContainerSettings(), ilContainer\_lookupContainerSetting(), ilObject\_lookupTitle(), ilObject\_lookupType(), ilObjCategoryGUI\CONTAINER_SETTING_TAXBLOCK, ilObjTaxonomy\getUsageOfObject(), ilArrayUtil\sortArray(), and ilObjectServiceSettingsGUI\TAXONOMIES.

Referenced by isActive().

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

◆ getFilteredObjects()

ilTaxonomyClassificationProvider::getFilteredObjects ( )

Get filtered object ref ids.

Reimplemented from ilClassificationProvider.

Definition at line 157 of file class.ilTaxonomyClassificationProvider.php.

157 : array
158 {
159 $tax_obj_ids = array();
160 $tax_map = array();
161
162 // :TODO: this could be smarter
163 foreach ($this->selection as $node_id) {
164 $node = new ilTaxonomyNode((int) $node_id);
165 $tax_map[$node->getTaxonomyId()][] = (int) $node_id;
166 }
167
168 foreach ($tax_map as $tax_id => $node_ids) {
169 $tax_tree = new ilTaxonomyTree((int) $tax_id);
170
171 // combine taxonomy nodes AND
172 foreach ($node_ids as $node_id) {
173 $tax_nodes = array();
174 $tax_nodes = array_merge($tax_nodes, $tax_tree->getSubTreeIds((int) $node_id));
175 $tax_nodes[] = (int) $node_id;
176 if (!isset($tax_obj_ids[$tax_id])) {
177 $tax_obj_ids[$tax_id] = ilTaxNodeAssignment::findObjectsByNode((int) $tax_id, $tax_nodes, "obj");
178 } else {
179 $tax_obj_ids[$tax_id] = array_intersect(
180 $tax_obj_ids[$tax_id],
181 ilTaxNodeAssignment::findObjectsByNode((int) $tax_id, $tax_nodes, "obj")
182 );
183 }
184 }
185 }
186
187 // combine taxonomies AND
188 $obj_ids = null;
189 foreach ($tax_obj_ids as $tax_objs) {
190 $obj_ids = $obj_ids === null ? $tax_objs : array_intersect($obj_ids, $tax_objs);
191 }
192
193 return (array) $obj_ids;
194 }
static findObjectsByNode(int $a_tax_id, array $a_node_ids, string $a_item_type)
Find object which have assigned nodes.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...

References ilTaxNodeAssignment\findObjectsByNode(), and ILIAS\Repository\int().

+ Here is the call graph for this function:

◆ importPostData()

ilTaxonomyClassificationProvider::importPostData ( ?array  $a_saved = null)

Import post data.

Parameters
array | null$a_saved

Reimplemented from ilClassificationProvider.

Definition at line 64 of file class.ilTaxonomyClassificationProvider.php.

64 : array
65 {
67 if ($incoming_id !== 0) {
68 if (is_array($a_saved)) {
69 foreach ($a_saved as $idx => $node_id) {
70 if ($node_id == $incoming_id) {
71 unset($a_saved[$idx]);
72 return $a_saved;
73 }
74 }
75 $a_saved[] = $incoming_id;
76 return $a_saved;
77 } else {
78 return array($incoming_id);
79 }
80 }
81 return [];
82 }

References $incoming_id.

◆ init()

ilTaxonomyClassificationProvider::init ( )
protected

Reimplemented from ilClassificationProvider.

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

34 : void
35 {
36 $params = $this->request->getQueryParams();
37 $body = $this->request->getParsedBody();
38 $this->incoming_id = (int) ($body["taxNode"] ?? ($params["taxNode"] ?? null));
39 }
if(! $DIC->user() ->getId()||!ilLTIConsumerAccess::hasCustomProviderCreationAccess()) $params
Definition: ltiregstart.php:31

References $params, and ILIAS\Repository\int().

+ Here is the call graph for this function:

◆ isActive()

static ilTaxonomyClassificationProvider::isActive ( int  $a_parent_ref_id,
int  $a_parent_obj_id,
string  $a_parent_obj_type 
)
static

Is provider currently active?

Reimplemented from ilClassificationProvider.

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

29 : bool
30 {
31 return (bool) self::getActiveTaxonomiesForParentRefId($a_parent_ref_id);
32 }
static getActiveTaxonomiesForParentRefId(int $a_parent_ref_id)

References getActiveTaxonomiesForParentRefId().

+ Here is the call graph for this function:

◆ render()

ilTaxonomyClassificationProvider::render ( array &  $a_html,
object  $a_parent_gui 
)

Render HTML chunks.

Reimplemented from ilClassificationProvider.

Definition at line 41 of file class.ilTaxonomyClassificationProvider.php.

41 : void
42 {
43 foreach (self::$valid_tax_map[$this->parent_ref_id] as $tax_id) {
44 $tax_exp = new ilTaxonomyClassificationExplorerGUI($a_parent_gui, "", (int) $tax_id, "", "");
45 $tax_exp->setSkipRootNode(true);
46 $tax_exp->setOnClick("il.Classification.toggle({tax_node: '{NODE_CHILD}'});");
47
48 if (isset($this->selection) && is_array($this->selection)) {
49 foreach ($this->selection as $node_id) {
50 $tax_exp->setPathOpen($node_id);
51 $tax_exp->setNodeSelected($node_id);
52 }
53 }
54
55 if (!$tax_exp->handleCommand()) {
56 $a_html[] = array(
57 "title" => ilObject::_lookupTitle((int) $tax_id),
58 "html" => $tax_exp->getHTML(true)
59 );
60 }
61 }
62 }

References ilObject\_lookupTitle().

+ Here is the call graph for this function:

◆ setSelection()

ilTaxonomyClassificationProvider::setSelection ( array  $a_value)

@inheritDoc

Reimplemented from ilClassificationProvider.

Definition at line 87 of file class.ilTaxonomyClassificationProvider.php.

87 : void
88 {
89 $this->selection = $a_value;
90 }

Field Documentation

◆ $incoming_id

int ilTaxonomyClassificationProvider::$incoming_id = 0
protected

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

Referenced by importPostData().

◆ $selection

array ilTaxonomyClassificationProvider::$selection = []
protected

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

◆ $valid_tax_map

array ilTaxonomyClassificationProvider::$valid_tax_map = []
staticprotected

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


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