ILIAS  release_7 Revision v7.30-3-g800a261c036
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
global $DIC
Definition: goto.php:24
__construct(Container $dic, ilPlugin $plugin)
+ Here is the call graph for this function:

Member Function Documentation

◆ getFilteredObjects()

ilTaggingClassificationProvider::getFilteredObjects ( )

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

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

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

◆ getSubTreeTags()

ilTaggingClassificationProvider::getSubTreeTags ( )
protected

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

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

Referenced by importPostData(), and render().

255  {
256  $tree = $this->tree;
258 
259  //$objdefinition = $this->obj_definition;
260 
261  $sub_ids = array();
262 
263  // categories show only direct children and their tags
264  if (ilObject::_lookupType($this->parent_ref_id, true) == "cat") {
265  foreach ($tree->getChilds($this->parent_ref_id) as $sub_item) {
266  if ($sub_item["ref_id"] != $this->parent_ref_id &&
267  $sub_item["type"] != "rolf" &&
268  !$tree->isDeleted($sub_item["ref_id"])) {
269  $sub_ids[$sub_item["obj_id"]] = $sub_item["type"];
270  }
271  }
272  } else {
273  foreach ($tree->getSubTree($tree->getNodeData($this->parent_ref_id)) as $sub_item) {
274  if ($sub_item["ref_id"] != $this->parent_ref_id &&
275  $sub_item["type"] != "rolf" &&
276  !$tree->isDeleted($sub_item["ref_id"])) {
277  $sub_ids[$sub_item["obj_id"]] = $sub_item["type"];
278  }
279  }
280  }
281 
282  if ($sub_ids) {
283  $only_user = $this->enable_all_users
284  ? null
285  : $ilUser->getId();
286 
287  include_once "Services/Tagging/classes/class.ilTagging.php";
288  return ilTagging::_getTagCloudForObjects($sub_ids, $only_user, $ilUser->getId());
289  }
290  }
static _lookupType($a_id, $a_reference=false)
lookup object type
$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 158 of file class.ilTaggingClassificationProvider.php.

References $type, and getSubTreeTags().

159  {
160  $type = trim($_REQUEST["tag_type"]);
161  $tag_code = trim($_REQUEST["tag"]); // using codes to avoid encoding issues
162  if ($type && $tag_code) {
163  // code to tag
164  $found = null;
165  foreach ($this->getSubTreeTags() as $tags) {
166  foreach (array_keys($tags) as $tag) {
167  if (md5($tag) == $tag_code) {
168  $found = $tag;
169  break(2);
170  }
171  }
172  }
173  if ($found) {
174  /* single select
175  if(is_array($a_saved[$type]) &&
176  in_array($found, $a_saved[$type]))
177  {
178  return;
179  }
180  return array($type=>array($found));
181  */
182  // multi select
183  if (is_array($a_saved[$type]) &&
184  in_array($found, $a_saved[$type])) {
185  $key = array_search($found, $a_saved[$type]);
186  unset($a_saved[$type][$key]);
187  if (!sizeof($a_saved[$type])) {
188  unset($a_saved[$type]);
189  }
190  } else {
191  $a_saved[$type][] = $found;
192  }
193  }
194  return $a_saved;
195  }
196  }
$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 292 of file class.ilTaggingClassificationProvider.php.

References ilObjectListGUI\enableTags().

293  {
294  $a_list_gui->enableTags(true);
295  }
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(), ANONYMOUS_USER_ID, 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  }
const ANONYMOUS_USER_ID
Definition: constants.php:25
$valid
global $DIC
Definition: goto.php:24
$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 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  $ctrl->setParameter($a_parent_gui, "tag_type", "");
135  $ctrl->setParameter($a_parent_gui, "tag", "");
136  }
137 
138  $a_html[] = array(
139  "title" => $title,
140  "html" => $tpl->get()
141  );
142  }
143  }
144 
145  /*
146  if($this->selection)
147  {
148  $a_html[] = array(
149  "title" => "Related Tags",
150  "html" => ":TODO:"
151  );
152  }
153  */
154  }
155  }
$type
static getRelevanceClass($cnt, $max)
Get style class for tag relevance.
if($DIC->http() ->request() ->getMethod()=="GET" &&isset($DIC->http() ->request() ->getQueryParams()['tex'])) $tpl
Definition: latex.php:41
+ Here is the call graph for this function:

◆ setSelection()

ilTaggingClassificationProvider::setSelection (   $a_value)

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

199  {
200  $this->selection = $a_value;
201  }

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: