ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
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 185 of file class.ilTaggingClassificationProvider.php.

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

186  {
188 
189  if (!$this->selection) {
190  return;
191  }
192 
193  include_once "Services/Tagging/classes/class.ilTagging.php";
194 
195  $types = array("personal");
196  if ($this->enable_all_users) {
197  $types[] = "other";
198  }
199 
200  $found = array();
201  foreach ($types as $type) {
202  if (is_array($this->selection[$type])) {
203  $invert = ($type == "personal")
204  ? false
205  : true;
206 
207  foreach ($this->selection[$type] as $tag) {
208  $found[$tag] = array_keys(ilTagging::_findObjectsByTag($tag, $ilUser->getId(), $invert));
209  }
210  }
211  }
212 
213  /* OR
214  $res = array();
215  foreach($found as $tag => $ids)
216  {
217  $res = array_merge($res, $ids);
218  }
219  */
220 
221  // AND
222  $res = null;
223  foreach ($found as $tag => $ids) {
224  if ($res === null) {
225  $res = $ids;
226  } else {
227  $res = array_intersect($res, $ids);
228  }
229  }
230 
231  if (sizeof($res)) {
232  return array_unique($res);
233  }
234  }
$type
foreach($_POST as $key=> $value) $res
$ilUser
Definition: imgupload.php:18
Create styles array
The data for the language used.
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 236 of file class.ilTaggingClassificationProvider.php.

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

Referenced by importPostData(), and render().

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

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

141  {
142  $type = trim($_REQUEST["tag_type"]);
143  $tag_code = trim($_REQUEST["tag"]); // using codes to avoid encoding issues
144  if ($type && $tag_code) {
145  // code to tag
146  $found = null;
147  foreach ($this->getSubTreeTags() as $tags) {
148  foreach (array_keys($tags) as $tag) {
149  if (md5($tag) == $tag_code) {
150  $found = $tag;
151  break(2);
152  }
153  }
154  }
155  if ($found) {
156  /* single select
157  if(is_array($a_saved[$type]) &&
158  in_array($found, $a_saved[$type]))
159  {
160  return;
161  }
162  return array($type=>array($found));
163  */
164  // multi select
165  if (is_array($a_saved[$type]) &&
166  in_array($found, $a_saved[$type])) {
167  $key = array_search($found, $a_saved[$type]);
168  unset($a_saved[$type][$key]);
169  if (!sizeof($a_saved[$type])) {
170  unset($a_saved[$type]);
171  }
172  } else {
173  $a_saved[$type][] = $found;
174  }
175  }
176  return $a_saved;
177  }
178  }
$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 260 of file class.ilTaggingClassificationProvider.php.

References ilObjectListGUI\enableTags().

261  {
262  $a_list_gui->enableTags(true);
263  }
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 $counter, $lng, $tag, $tags, $title, $tpl, $type, array, ilTagging\getRelevanceClass(), and getSubTreeTags().

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

181  {
182  $this->selection = $a_value;
183  }

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: