ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
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
 
 $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 35 of file class.ilTaggingClassificationProvider.php.

References $DIC, and user().

36  {
37  global $DIC;
38  parent::__construct($a_parent_ref_id, $a_parent_obj_id, $a_parent_obj_type);
39 
40  $this->lng = $DIC->language();
41  $this->user = $DIC->user();
42  $this->tree = $DIC->repositoryTree();
43  }
global $DIC
Definition: saml.php:7
user()
Definition: user.php:4
+ Here is the call graph for this function:

Member Function Documentation

◆ getFilteredObjects()

ilTaggingClassificationProvider::getFilteredObjects ( )

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

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

188  {
190 
191  if (!$this->selection) {
192  return;
193  }
194 
195  include_once "Services/Tagging/classes/class.ilTagging.php";
196 
197  $types = array("personal");
198  if ($this->enable_all_users) {
199  $types[] = "other";
200  }
201 
202  $found = array();
203  foreach ($types as $type) {
204  if (is_array($this->selection[$type])) {
205  $invert = ($type == "personal")
206  ? false
207  : true;
208 
209  foreach ($this->selection[$type] as $tag) {
210  $found[$tag] = array_keys(ilTagging::_findObjectsByTag($tag, $ilUser->getId(), $invert));
211  }
212  }
213  }
214 
215  /* OR
216  $res = array();
217  foreach($found as $tag => $ids)
218  {
219  $res = array_merge($res, $ids);
220  }
221  */
222 
223  // AND
224  $res = null;
225  foreach ($found as $tag => $ids) {
226  if ($res === null) {
227  $res = $ids;
228  } else {
229  $res = array_intersect($res, $ids);
230  }
231  }
232 
233  if (sizeof($res)) {
234  return array_unique($res);
235  }
236  }
$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.
if(function_exists('posix_getuid') &&posix_getuid()===0) if(!array_key_exists('t', $options)) $tag
Definition: cron.php:35
+ Here is the call graph for this function:

◆ getSubTreeTags()

ilTaggingClassificationProvider::getSubTreeTags ( )
protected

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

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

Referenced by importPostData(), and render().

239  {
240  $tree = $this->tree;
242 
243  $sub_ids = array();
244  foreach ($tree->getSubTree($tree->getNodeData($this->parent_ref_id)) as $sub_item) {
245  if ($sub_item["ref_id"] != $this->parent_ref_id &&
246  $sub_item["type"] != "rolf" &&
247  !$tree->isDeleted($sub_item["ref_id"])) {
248  $sub_ids[$sub_item["obj_id"]] = $sub_item["type"];
249  }
250  }
251 
252  if ($sub_ids) {
253  $only_user = $this->enable_all_users
254  ? null
255  : $ilUser->getId();
256 
257  include_once "Services/Tagging/classes/class.ilTagging.php";
258  return ilTagging::_getTagCloudForObjects($sub_ids, $only_user, $ilUser->getId());
259  }
260  }
$ilUser
Definition: imgupload.php:18
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 142 of file class.ilTaggingClassificationProvider.php.

References $key, $tag, $tags, $type, and getSubTreeTags().

143  {
144  $type = trim($_REQUEST["tag_type"]);
145  $tag_code = trim($_REQUEST["tag"]); // using codes to avoid encoding issues
146  if ($type && $tag_code) {
147  // code to tag
148  $found = null;
149  foreach ($this->getSubTreeTags() as $tags) {
150  foreach (array_keys($tags) as $tag) {
151  if (md5($tag) == $tag_code) {
152  $found = $tag;
153  break(2);
154  }
155  }
156  }
157  if ($found) {
158  /* single select
159  if(is_array($a_saved[$type]) &&
160  in_array($found, $a_saved[$type]))
161  {
162  return;
163  }
164  return array($type=>array($found));
165  */
166  // multi select
167  if (is_array($a_saved[$type]) &&
168  in_array($found, $a_saved[$type])) {
169  $key = array_search($found, $a_saved[$type]);
170  unset($a_saved[$type][$key]);
171  if (!sizeof($a_saved[$type])) {
172  unset($a_saved[$type]);
173  }
174  } else {
175  $a_saved[$type][] = $found;
176  }
177  }
178  return $a_saved;
179  }
180  }
$type
$tags
Definition: croninfo.php:19
$key
Definition: croninfo.php:18
if(function_exists('posix_getuid') &&posix_getuid()===0) if(!array_key_exists('t', $options)) $tag
Definition: cron.php:35
+ Here is the call graph for this function:

◆ init()

ilTaggingClassificationProvider::init ( )
protected

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

49  {
50  $tags_set = new ilSetting("tags");
51  $this->enable_all_users = (bool) $tags_set->get("enable_all_users", false);
52  }

◆ initListGUI()

ilTaggingClassificationProvider::initListGUI ( ilObjectListGUI  $a_list_gui)

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

References ilObjectListGUI\enableTags().

263  {
264  $a_list_gui->enableTags(true);
265  }
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 54 of file class.ilTaggingClassificationProvider.php.

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

Referenced by ilClassificationProvider\getValidProviders().

55  {
56  global $DIC;
57 
58  $ilUser = $DIC->user();
59 
60  // we currently only check for the parent object setting
61  // might change later on (parent containers)
62  include_once "Services/Object/classes/class.ilObjectServiceSettingsGUI.php";
64  $a_parent_obj_id,
66  false
67  );
68 
69  if ($valid) {
70  $tags_set = new ilSetting("tags");
71  if (!$tags_set->get("enable_all_users", false) &&
72  $ilUser->getId() == ANONYMOUS_USER_ID) {
73  $valid = false;
74  }
75  }
76 
77  return $valid;
78  }
global $DIC
Definition: saml.php:7
$valid
$ilUser
Definition: imgupload.php:18
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 80 of file class.ilTaggingClassificationProvider.php.

References $lng, $map, $tag, $tags, $title, $tpl, $type, ilTagging\getRelevanceClass(), and getSubTreeTags().

81  {
82  $lng = $this->lng;
83 
84  $lng->loadLanguageModule("tagging");
85 
86  $all_tags = $this->getSubTreeTags();
87  if ($all_tags) {
88  // see ilPDTaggingBlockGUI::getTagCloud();
89 
90  $map = array(
91  "personal" => $lng->txt("tagging_my_tags"),
92  "other" => $lng->txt("tagging_other_users")
93  );
94  foreach ($map as $type => $title) {
95  $tags = $all_tags[$type];
96  if ($tags) {
97  $max = 1;
98  foreach ($tags as $tag => $counter) {
99  $max = max($counter, $max);
100  }
101  reset($tags);
102 
103  $tpl = new ilTemplate("tpl.tag_cloud_block.html", true, true, "Services/Tagging");
104 
105  $tpl->setCurrentBlock("tag_bl");
106  foreach ($tags as $tag => $counter) {
107  $tpl->setVariable("TAG_TYPE", $type);
108  $tpl->setVariable("TAG_TITLE", $tag);
109  $tpl->setVariable("TAG_CODE", md5($tag));
110  $tpl->setVariable(
111  "REL_CLASS",
112  ilTagging::getRelevanceClass($counter, $max)
113  );
114  if (is_array($this->selection[$type]) &&
115  in_array($tag, $this->selection[$type])) {
116  $tpl->setVariable("HIGHL_CLASS", ' ilHighlighted');
117  }
118 
119  $tpl->parseCurrentBlock();
120  }
121 
122  $a_html[] = array(
123  "title" => $title,
124  "html" => $tpl->get()
125  );
126  }
127  }
128 
129  /*
130  if($this->selection)
131  {
132  $a_html[] = array(
133  "title" => "Related Tags",
134  "html" => ":TODO:"
135  );
136  }
137  */
138  }
139  }
$type
$tpl
Definition: ilias.php:10
$tags
Definition: croninfo.php:19
special template class to simplify handling of ITX/PEAR
static getRelevanceClass($cnt, $max)
Get style class for tag relevance.
if(function_exists('posix_getuid') &&posix_getuid()===0) if(!array_key_exists('t', $options)) $tag
Definition: cron.php:35
+ Here is the call graph for this function:

◆ setSelection()

ilTaggingClassificationProvider::setSelection (   $a_value)

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

183  {
184  $this->selection = $a_value;
185  }

Field Documentation

◆ $enable_all_users

ilTaggingClassificationProvider::$enable_all_users
protected

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

◆ $lng

ilTaggingClassificationProvider::$lng
protected

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

Referenced by render().

◆ $selection

ilTaggingClassificationProvider::$selection
protected

Definition at line 46 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: