ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
All Data Structures Namespaces Files Functions Variables Modules Pages
ilTaggingClassificationProvider Class Reference

Tag classification provider. More...

+ Inheritance diagram for ilTaggingClassificationProvider:
+ Collaboration diagram for ilTaggingClassificationProvider:

Public Member Functions

 __construct ($a_parent_ref_id, $a_parent_obj_id, $a_parent_obj_type)
 Constructor. More...
 
 render (array &$a_html, $a_parent_gui)
 
 importPostData ($a_saved=null)
 
 setSelection ($a_value)
 
 getFilteredObjects ()
 
 initListGUI (ilObjectListGUI $a_list_gui)
 
- Public Member Functions inherited from ilClassificationProvider
 __construct ($a_parent_ref_id, $a_parent_obj_id, $a_parent_obj_type)
 Constructor. More...
 
 render (array &$a_html, $a_parent_gui)
 Render HTML chunks. More...
 
 importPostData ($a_saved=null)
 Import post data. More...
 
 setSelection ($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 ($a_parent_ref_id, $a_parent_obj_id, $a_parent_obj_type)
 
- Static Public Member Functions inherited from ilClassificationProvider
static getValidProviders ($a_parent_ref_id, $a_parent_obj_id, $a_parent_obj_type)
 Get all valid providers (for parent container) More...
 
static isActive ($a_parent_ref_id, $a_parent_obj_id, $a_parent_obj_type)
 Is provider currently active? More...
 

Protected Member Functions

 init ()
 
 getSubTreeTags ()
 
- Protected Member Functions inherited from ilClassificationProvider
 init ()
 Instance initialisation. More...
 

Protected Attributes

 $lng
 
 $user
 
 $tree
 
 $obj_definition
 
 $ctrl
 
 $enable_all_users
 
 $selection
 
- Protected Attributes inherited from ilClassificationProvider
 $parent_ref_id
 
 $parent_obj_id
 
 $parent_type
 

Detailed Description

Tag classification provider.

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

Definition at line 14 of file class.ilTaggingClassificationProvider.php.

Constructor & Destructor Documentation

◆ __construct()

ilTaggingClassificationProvider::__construct (   $a_parent_ref_id,
  $a_parent_obj_id,
  $a_parent_obj_type 
)

Constructor.

Definition at line 44 of file class.ilTaggingClassificationProvider.php.

References $DIC, ILIAS\GlobalScreen\Provider\__construct(), and user().

45  {
46  global $DIC;
47  parent::__construct($a_parent_ref_id, $a_parent_obj_id, $a_parent_obj_type);
48 
49  $this->lng = $DIC->language();
50  $this->user = $DIC->user();
51  $this->tree = $DIC->repositoryTree();
52  $this->obj_definition = $DIC["objDefinition"];
53  $this->ctrl = $DIC->ctrl();
54  }
user()
Definition: user.php:4
__construct(Container $dic, ilPlugin $plugin)
$DIC
Definition: xapitoken.php:46
+ Here is the call graph for this function:

Member Function Documentation

◆ getFilteredObjects()

ilTaggingClassificationProvider::getFilteredObjects ( )

Definition at line 201 of file class.ilTaggingClassificationProvider.php.

References $ilUser, $res, $type, $user, and ilTagging\_findObjectsByTag().

202  {
204 
205  if (!$this->selection) {
206  return;
207  }
208 
209  include_once "Services/Tagging/classes/class.ilTagging.php";
210 
211  $types = array("personal");
212  if ($this->enable_all_users) {
213  $types[] = "other";
214  }
215 
216  $found = array();
217  foreach ($types as $type) {
218  if (is_array($this->selection[$type])) {
219  $invert = ($type == "personal")
220  ? false
221  : true;
222 
223  foreach ($this->selection[$type] as $tag) {
224  $found[$tag] = array_keys(ilTagging::_findObjectsByTag($tag, $ilUser->getId(), $invert));
225  }
226  }
227  }
228 
229  /* OR
230  $res = array();
231  foreach($found as $tag => $ids)
232  {
233  $res = array_merge($res, $ids);
234  }
235  */
236 
237  // AND
238  $res = null;
239  foreach ($found as $tag => $ids) {
240  if ($res === null) {
241  $res = $ids;
242  } else {
243  $res = array_intersect($res, $ids);
244  }
245  }
246 
247  if (sizeof($res)) {
248  return array_unique($res);
249  }
250  }
$type
foreach($_POST as $key=> $value) $res
$ilUser
Definition: imgupload.php:18
static _findObjectsByTag($a_tag, $a_user_id=null, $a_invert=false)
Find all objects with given tag.
+ Here is the call graph for this function:

◆ getSubTreeTags()

ilTaggingClassificationProvider::getSubTreeTags ( )
protected

Definition at line 252 of file class.ilTaggingClassificationProvider.php.

References $ilUser, $tree, $user, ilTagging\_getTagCloudForObjects(), and ilObject\_lookupType().

Referenced by importPostData(), and render().

253  {
254  $tree = $this->tree;
256 
257  //$objdefinition = $this->obj_definition;
258 
259  $sub_ids = array();
260 
261  // categories show only direct children and their tags
262  if (ilObject::_lookupType($this->parent_ref_id, true) == "cat") {
263  foreach ($tree->getChilds($this->parent_ref_id) as $sub_item) {
264  if ($sub_item["ref_id"] != $this->parent_ref_id &&
265  $sub_item["type"] != "rolf" &&
266  !$tree->isDeleted($sub_item["ref_id"])) {
267  $sub_ids[$sub_item["obj_id"]] = $sub_item["type"];
268  }
269  }
270  } else {
271  foreach ($tree->getSubTree($tree->getNodeData($this->parent_ref_id)) as $sub_item) {
272  if ($sub_item["ref_id"] != $this->parent_ref_id &&
273  $sub_item["type"] != "rolf" &&
274  !$tree->isDeleted($sub_item["ref_id"])) {
275  $sub_ids[$sub_item["obj_id"]] = $sub_item["type"];
276  }
277  }
278  }
279 
280  if ($sub_ids) {
281  $only_user = $this->enable_all_users
282  ? null
283  : $ilUser->getId();
284 
285  include_once "Services/Tagging/classes/class.ilTagging.php";
286  return ilTagging::_getTagCloudForObjects($sub_ids, $only_user, $ilUser->getId());
287  }
288  }
$ilUser
Definition: imgupload.php:18
static _lookupType($a_id, $a_reference=false)
lookup object type
static _getTagCloudForObjects(array $a_obj_ids, $a_user_id=null, $a_divide=false)
Count tags for given object ids.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ importPostData()

ilTaggingClassificationProvider::importPostData (   $a_saved = null)

Definition at line 156 of file class.ilTaggingClassificationProvider.php.

References $type, and getSubTreeTags().

157  {
158  $type = trim($_REQUEST["tag_type"]);
159  $tag_code = trim($_REQUEST["tag"]); // using codes to avoid encoding issues
160  if ($type && $tag_code) {
161  // code to tag
162  $found = null;
163  foreach ($this->getSubTreeTags() as $tags) {
164  foreach (array_keys($tags) as $tag) {
165  if (md5($tag) == $tag_code) {
166  $found = $tag;
167  break(2);
168  }
169  }
170  }
171  if ($found) {
172  /* single select
173  if(is_array($a_saved[$type]) &&
174  in_array($found, $a_saved[$type]))
175  {
176  return;
177  }
178  return array($type=>array($found));
179  */
180  // multi select
181  if (is_array($a_saved[$type]) &&
182  in_array($found, $a_saved[$type])) {
183  $key = array_search($found, $a_saved[$type]);
184  unset($a_saved[$type][$key]);
185  if (!sizeof($a_saved[$type])) {
186  unset($a_saved[$type]);
187  }
188  } else {
189  $a_saved[$type][] = $found;
190  }
191  }
192  return $a_saved;
193  }
194  }
$type
+ Here is the call graph for this function:

◆ init()

ilTaggingClassificationProvider::init ( )
protected

Definition at line 59 of file class.ilTaggingClassificationProvider.php.

60  {
61  $tags_set = new ilSetting("tags");
62  $this->enable_all_users = (bool) $tags_set->get("enable_all_users", false);
63  }

◆ initListGUI()

ilTaggingClassificationProvider::initListGUI ( ilObjectListGUI  $a_list_gui)

Definition at line 290 of file class.ilTaggingClassificationProvider.php.

References ilObjectListGUI\enableTags().

291  {
292  $a_list_gui->enableTags(true);
293  }
enableTags($a_value)
Toogle tags action status.
+ Here is the call graph for this function:

◆ isActive()

static ilTaggingClassificationProvider::isActive (   $a_parent_ref_id,
  $a_parent_obj_id,
  $a_parent_obj_type 
)
static

Definition at line 65 of file class.ilTaggingClassificationProvider.php.

References $DIC, $ilUser, $valid, ilContainer\_lookupContainerSetting(), and ilObjectServiceSettingsGUI\TAG_CLOUD.

Referenced by ilClassificationProvider\getValidProviders().

66  {
67  global $DIC;
68 
69  $ilUser = $DIC->user();
70 
71  // we currently only check for the parent object setting
72  // might change later on (parent containers)
73  include_once "Services/Object/classes/class.ilObjectServiceSettingsGUI.php";
75  $a_parent_obj_id,
77  false
78  );
79 
80  if ($valid) {
81  $tags_set = new ilSetting("tags");
82  if (!$tags_set->get("enable_all_users", false) &&
83  $ilUser->getId() == ANONYMOUS_USER_ID) {
84  $valid = false;
85  }
86  }
87 
88  return $valid;
89  }
$valid
$ilUser
Definition: imgupload.php:18
$DIC
Definition: xapitoken.php:46
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:

◆ render()

ilTaggingClassificationProvider::render ( array &  $a_html,
  $a_parent_gui 
)

Definition at line 91 of file class.ilTaggingClassificationProvider.php.

References $ctrl, $lng, $tpl, $type, ilTagging\getRelevanceClass(), and getSubTreeTags().

92  {
93  $lng = $this->lng;
95 
96  $lng->loadLanguageModule("tagging");
97 
98  $all_tags = $this->getSubTreeTags();
99  if ($all_tags) {
100  $map = array(
101  "personal" => $lng->txt("tagging_my_tags"),
102  "other" => $lng->txt("tagging_other_users")
103  );
104  foreach ($map as $type => $title) {
105  $tags = $all_tags[$type];
106  if ($tags) {
107  $max = 1;
108  foreach ($tags as $tag => $counter) {
109  $max = max($counter, $max);
110  }
111  reset($tags);
112 
113  $tpl = new ilTemplate("tpl.tag_cloud_block.html", true, true, "Services/Tagging");
114 
115  $tpl->setCurrentBlock("tag_bl");
116  foreach ($tags as $tag => $counter) {
117  $ctrl->setParameter($a_parent_gui, "tag_type", $type);
118  $ctrl->setParameter($a_parent_gui, "tag", md5($tag));
119  $tpl->setVariable("HREF", $ctrl->getLinkTarget($a_parent_gui, "toggle"));
120 
121  $tpl->setVariable("TAG_TYPE", $type);
122  $tpl->setVariable("TAG_TITLE", $tag);
123  $tpl->setVariable("TAG_CODE", md5($tag));
124  $tpl->setVariable(
125  "REL_CLASS",
126  ilTagging::getRelevanceClass($counter, $max)
127  );
128  if (is_array($this->selection[$type]) &&
129  in_array($tag, $this->selection[$type])) {
130  $tpl->setVariable("HIGHL_CLASS", ' ilHighlighted');
131  }
132 
133  $tpl->parseCurrentBlock();
134  }
135 
136  $a_html[] = array(
137  "title" => $title,
138  "html" => $tpl->get()
139  );
140  }
141  }
142 
143  /*
144  if($this->selection)
145  {
146  $a_html[] = array(
147  "title" => "Related Tags",
148  "html" => ":TODO:"
149  );
150  }
151  */
152  }
153  }
if(isset($_FILES['img_file']['size']) && $_FILES['img_file']['size'] > 0) $tpl
$type
static getRelevanceClass($cnt, $max)
Get style class for tag relevance.
+ Here is the call graph for this function:

◆ setSelection()

ilTaggingClassificationProvider::setSelection (   $a_value)

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

197  {
198  $this->selection = $a_value;
199  }

Field Documentation

◆ $ctrl

ilTaggingClassificationProvider::$ctrl
protected

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

Referenced by render().

◆ $enable_all_users

ilTaggingClassificationProvider::$enable_all_users
protected

Definition at line 56 of file class.ilTaggingClassificationProvider.php.

◆ $lng

ilTaggingClassificationProvider::$lng
protected

Definition at line 19 of file class.ilTaggingClassificationProvider.php.

Referenced by render().

◆ $obj_definition

ilTaggingClassificationProvider::$obj_definition
protected

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

◆ $selection

ilTaggingClassificationProvider::$selection
protected

Definition at line 57 of file class.ilTaggingClassificationProvider.php.

◆ $tree

ilTaggingClassificationProvider::$tree
protected

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

Referenced by getSubTreeTags().

◆ $user

ilTaggingClassificationProvider::$user
protected

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

Referenced by getFilteredObjects(), and getSubTreeTags().


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