ILIAS  release_4-4 Revision
ilTagging Class Reference

Class ilTagging. More...

+ Collaboration diagram for ilTagging:

Public Member Functions

 getUsersForTag ($a_tag)
 Get users for tag. More...
 

Static Public Member Functions

static writeTagsForUserAndObject ($a_obj_id, $a_obj_type, $a_sub_obj_id, $a_sub_obj_type, $a_user_id, $a_tags)
 Write tags for a user and an object. More...
 
static getTagsForUserAndObject ($a_obj_id, $a_obj_type, $a_sub_obj_id, $a_sub_obj_type, $a_user_id)
 Get tags for a user and an object. More...
 
static getTagsForObject ($a_obj_id, $a_obj_type, $a_sub_obj_id, $a_sub_obj_type, $a_only_online=true)
 Get tags for an object. More...
 
static getTagsForUser ($a_user_id, $a_max=0, $a_only_online=true)
 Get tags for a user. More...
 
static getObjectsForTagAndUser ($a_user_id, $a_tag)
 Get objects for tag and user. More...
 
static calculateFontSize ($cnt, $max)
 Returns 100(%) for 1 and 150(%) for $max y = a + mx 100 = a + m (1) 150 = a + m * max (2) (1): a = 100 - m (3) (2): a = 150 - max*m (4) (3)&(4): m - 100 = max*m - 150 (5) (5) 50 = (max-1)*m => m = 50/(max -1) => a = 100 - 50/(max -1) More...
 
static setTagsOfObjectOffline ($a_obj_id, $a_obj_type, $a_sub_obj_id, $a_sub_obj_type, $a_offline=true)
 Set offline. More...
 
static deleteTagsOfObject ($a_obj_id, $a_obj_type, $a_sub_obj_id, $a_sub_obj_type)
 Deletes tags of an object. More...
 
static _countTags ($a_obj_ids)
 Count all tags for repository objects. More...
 

Detailed Description

Class ilTagging.

Author
Alex Killing alex..nosp@m.kill.nosp@m.ing@g.nosp@m.mx.d.nosp@m.e
Version
$Id$

Definition at line 15 of file class.ilTagging.php.

Member Function Documentation

◆ _countTags()

static ilTagging::_countTags (   $a_obj_ids)
static

Count all tags for repository objects.

Parameters
array$a_obj_idsrepository object IDs array

Definition at line 310 of file class.ilTagging.php.

References $ilUser.

Referenced by ilObjectListGUI\preloadCommonProperties().

311  {
312  global $ilDB, $ilUser;
313 
314  $q = "SELECT count(*) c, obj_id FROM il_tag WHERE ".
315  $ilDB->in("obj_id", $a_obj_ids, false, "integer")." AND ".
316  " user_id = ".$ilDB->quote($ilUser->getId(), "integer").
317  " GROUP BY obj_id";
318 
319  $cnt = array();
320  $set = $ilDB->query($q);
321  while ($rec = $ilDB->fetchAssoc($set))
322  {
323  $cnt[$rec["obj_id"]] = $rec["c"];
324  }
325 
326  return $cnt;
327  }
global $ilUser
Definition: imgupload.php:15
+ Here is the caller graph for this function:

◆ calculateFontSize()

static ilTagging::calculateFontSize (   $cnt,
  $max 
)
static

Returns 100(%) for 1 and 150(%) for $max y = a + mx 100 = a + m (1) 150 = a + m * max (2) (1): a = 100 - m (3) (2): a = 150 - max*m (4) (3)&(4): m - 100 = max*m - 150 (5) (5) 50 = (max-1)*m => m = 50/(max -1) => a = 100 - 50/(max -1)

Definition at line 220 of file class.ilTagging.php.

Referenced by ilTaggingGUI\getAllUserTagsForObjectHTML(), ilPDTaggingBlockGUI\getTagCloud(), and ilObjBlogGUI\renderNavigation().

221  {
222  $m = ($max == 1)
223  ? 0
224  : 50 / ($max - 1);
225  $a = 100 - $m;
226  $font_size = round($a + ($m * $cnt));
227  return (int) $font_size;
228  }
+ Here is the caller graph for this function:

◆ deleteTagsOfObject()

static ilTagging::deleteTagsOfObject (   $a_obj_id,
  $a_obj_type,
  $a_sub_obj_id,
  $a_sub_obj_type 
)
static

Deletes tags of an object.

Parameters
int$a_obj_idObject ID
string$a_obj_typeObject Type
int$a_sub_obj_idSubobject ID
string$a_sub_obj_typeSubobject Type

Definition at line 267 of file class.ilTagging.php.

Referenced by getObjectsForTagAndUser(), and ilTaggingAppEventListener\handleEvent().

268  {
269  global $ilDB;
270 
271  if ($a_sub_obj_type == "")
272  {
273  $a_sub_obj_type = "-";
274  }
275 
276  $ilDB->manipulateF("DELETE FROM il_tag ".
277  "WHERE ".
278  "obj_id = %s AND ".
279  "obj_type = %s AND ".
280  "sub_obj_id = %s AND ".
281  $ilDB->equals("sub_obj_type", $a_sub_obj_type, "text", true),
282  array("integer", "text", "integer"),
283  array($a_obj_id, $a_obj_type, $a_sub_obj_id));
284  }
+ Here is the caller graph for this function:

◆ getObjectsForTagAndUser()

static ilTagging::getObjectsForTagAndUser (   $a_user_id,
  $a_tag 
)
static

Get objects for tag and user.

Parameters
int$a_user_idUser ID

Definition at line 178 of file class.ilTagging.php.

References ilObject\_exists(), and deleteTagsOfObject().

Referenced by ilPDTaggingBlockGUI\showResourcesForTag().

179  {
180  global $ilDB;
181 
182  $q = "SELECT * FROM il_tag WHERE ".
183  "user_id = ".$ilDB->quote($a_user_id, "integer").
184  " AND tag = ".$ilDB->quote($a_tag, "text");
185 
186  $set = $ilDB->query($q);
187  $objects = array();
188  while($rec = $ilDB->fetchAssoc($set))
189  {
190  if (ilObject::_exists($rec["obj_id"]))
191  {
192  if ($rec["sub_obj_type"] == "-")
193  {
194  $rec["sub_obj_type"] = "";
195  }
196  $objects[] = $rec;
197  }
198  else
199  {
200  ilTagging::deleteTagsOfObject($rec["obj_id"], $rec["obj_type"],
201  $rec["sub_obj_id"], $rec["sub_obj_type"]);
202  }
203  }
204 
205  return $objects;
206  }
static _exists($a_id, $a_reference=false, $a_type=null)
checks if an object exists in object_data
static deleteTagsOfObject($a_obj_id, $a_obj_type, $a_sub_obj_id, $a_sub_obj_type)
Deletes tags of an object.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getTagsForObject()

static ilTagging::getTagsForObject (   $a_obj_id,
  $a_obj_type,
  $a_sub_obj_id,
  $a_sub_obj_type,
  $a_only_online = true 
)
static

Get tags for an object.

Parameters
int$a_obj_idObject ID
string$a_obj_typeObject Type
int$a_sub_obj_idSubobject ID
string$a_sub_obj_typeSubobject Type

Definition at line 112 of file class.ilTagging.php.

Referenced by ilTaggingGUI\getAllUserTagsForObjectHTML().

114  {
115  global $ilDB;
116 
117  $online_str = ($a_only_online)
118  ? $online_str = " AND is_offline = ".$ilDB->quote(0, "integer")." "
119  : "";
120 
121  if ($a_sub_obj_type == "")
122  {
123  $a_sub_obj_type = "-";
124  }
125 
126  $q = "SELECT count(user_id) as cnt, tag FROM il_tag WHERE ".
127  "obj_id = ".$ilDB->quote($a_obj_id, "integer")." AND ".
128  "obj_type = ".$ilDB->quote($a_obj_type, "text")." AND ".
129  "sub_obj_id = ".$ilDB->quote($a_sub_obj_id, "integer")." AND ".
130  $ilDB->equals("sub_obj_type", $a_sub_obj_type, "text", true).
131  $online_str.
132  "GROUP BY tag ORDER BY tag ASC";
133  $set = $ilDB->query($q);
134  $tags = array();
135  while($rec = $ilDB->fetchAssoc($set))
136  {
137  $tags[] = $rec;
138  }
139 
140  return $tags;
141  }
+ Here is the caller graph for this function:

◆ getTagsForUser()

static ilTagging::getTagsForUser (   $a_user_id,
  $a_max = 0,
  $a_only_online = true 
)
static

Get tags for a user.

Parameters
int$a_user_idUser ID

Definition at line 148 of file class.ilTagging.php.

References ilUtil\sortArray().

Referenced by ilPDTaggingBlockGUI\fillDataSection().

149  {
150  global $ilDB;
151 
152  $online_str = ($a_only_online)
153  ? $online_str = " AND is_offline = ".$ilDB->quote(0, "integer")." "
154  : "";
155 
156  $set = $ilDB->query("SELECT count(*) as cnt, tag FROM il_tag WHERE ".
157  "user_id = ".$ilDB->quote($a_user_id, "integer")." ".
158  $online_str.
159  " GROUP BY tag ORDER BY cnt DESC");
160  $tags = array();
161  $cnt = 1;
162  while(($rec = $ilDB->fetchAssoc($set)) &&
163  ($a_max == 0 || $cnt <= $a_max))
164  {
165  $tags[] = $rec;
166  $cnt++;
167  }
168  $tags = ilUtil::sortArray($tags, "tag", "asc");
169 
170  return $tags;
171  }
static sortArray($array, $a_array_sortby, $a_array_sortorder=0, $a_numeric=false, $a_keep_keys=false)
sortArray
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getTagsForUserAndObject()

static ilTagging::getTagsForUserAndObject (   $a_obj_id,
  $a_obj_type,
  $a_sub_obj_id,
  $a_sub_obj_type,
  $a_user_id 
)
static

Get tags for a user and an object.

Parameters
int$a_obj_idObject ID
string$a_obj_typeObject Type
int$a_sub_obj_idSubobject ID
string$a_sub_obj_typeSubobject Type
int$a_user_idUser ID

Definition at line 77 of file class.ilTagging.php.

Referenced by ilObjectListGUI\getHeaderAction(), ilTaggingGUI\getHTML(), and ilTaggingGUI\getTaggingInputHTML().

79  {
80  global $ilDB;
81 
82  if ($a_sub_obj_type == "")
83  {
84  $a_sub_obj_type = "-";
85  }
86 
87  $q = "SELECT * FROM il_tag WHERE ".
88  "user_id = ".$ilDB->quote($a_user_id, "integer")." AND ".
89  "obj_id = ".$ilDB->quote($a_obj_id, "integer")." AND ".
90  "obj_type = ".$ilDB->quote($a_obj_type, "text")." AND ".
91  "sub_obj_id = ".$ilDB->quote((int) $a_sub_obj_id, "integer")." AND ".
92  $ilDB->equals("sub_obj_type", $a_sub_obj_type, "text", true).
93  " ORDER BY tag ASC";
94  $set = $ilDB->query($q);
95  $tags = array();
96  while($rec = $ilDB->fetchAssoc($set))
97  {
98  $tags[] = $rec["tag"];
99  }
100 
101  return $tags;
102  }
+ Here is the caller graph for this function:

◆ getUsersForTag()

ilTagging::getUsersForTag (   $a_tag)

Get users for tag.

Definition at line 289 of file class.ilTagging.php.

Referenced by ilUserForTagTableGUI\__construct().

290  {
291  global $ilDB;
292 
293  $set = $ilDB->query("SELECT DISTINCT user_id, firstname, lastname FROM il_tag JOIN usr_data ON (user_id = usr_id) ".
294  " WHERE LOWER(tag) = LOWER(".$ilDB->quote($a_tag, "text").")".
295  " ORDER BY lastname, firstname"
296  );
297  $users = array();
298  while ($rec = $ilDB->fetchAssoc($set))
299  {
300  $users[] = array("id" => $rec["user_id"]);
301  }
302  return $users;
303  }
+ Here is the caller graph for this function:

◆ setTagsOfObjectOffline()

static ilTagging::setTagsOfObjectOffline (   $a_obj_id,
  $a_obj_type,
  $a_sub_obj_id,
  $a_sub_obj_type,
  $a_offline = true 
)
static

Set offline.

Parameters
int$a_obj_idObject ID
string$a_obj_typeObject Type
int$a_sub_obj_idSubobject ID
string$a_sub_obj_typeSubobject Type
boolean$a_offlineOffline (true/false, true means offline!)

Definition at line 239 of file class.ilTagging.php.

Referenced by ilTaggingAppEventListener\handleEvent().

241  {
242  global $ilDB;
243 
244  if ($a_sub_obj_type == "")
245  {
246  $a_sub_obj_type = "-";
247  }
248 
249  $ilDB->manipulateF("UPDATE il_tag SET is_offline = %s ".
250  "WHERE ".
251  "obj_id = %s AND ".
252  "obj_type = %s AND ".
253  "sub_obj_id = %s AND ".
254  $ilDB->equals("sub_obj_type", $a_sub_obj_type, "text", true),
255  array("boolean", "integer", "text", "integer"),
256  array($a_offline, $a_obj_id, $a_obj_type, $a_sub_obj_id));
257  }
+ Here is the caller graph for this function:

◆ writeTagsForUserAndObject()

static ilTagging::writeTagsForUserAndObject (   $a_obj_id,
  $a_obj_type,
  $a_sub_obj_id,
  $a_sub_obj_type,
  $a_user_id,
  $a_tags 
)
static

Write tags for a user and an object.

Parameters
int$a_obj_idObject ID
string$a_obj_typeObject Type
int$a_sub_obj_idSubobject ID
string$a_sub_obj_typeSubobject Type
int$a_user_idUser ID
array$a_tagsTags

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

Referenced by ilTaggingGUI\saveInput(), and ilTaggingGUI\saveJS().

29  {
30  global $ilDB;
31 
32  if ($a_sub_obj_type == "")
33  {
34  $a_sub_obj_type = "-";
35  }
36 
37  $ilDB->manipulate("DELETE FROM il_tag WHERE ".
38  "user_id = ".$ilDB->quote($a_user_id, "integer")." AND ".
39  "obj_id = ".$ilDB->quote($a_obj_id, "integer")." AND ".
40  "obj_type = ".$ilDB->quote($a_obj_type, "text")." AND ".
41  "sub_obj_id = ".$ilDB->quote((int) $a_sub_obj_id, "integer")." AND ".
42  $ilDB->equals("sub_obj_type", $a_sub_obj_type, "text", true));
43  //"sub_obj_type = ".$ilDB->quote($a_sub_obj_type, "text"));
44 
45  if (is_array($a_tags))
46  {
47  $inserted = array();
48  foreach($a_tags as $tag)
49  {
50  if (!in_array(strtolower($tag), $inserted))
51  {
52  $tag = str_replace(" ", "_", trim($tag));
53  $ilDB->manipulate("INSERT INTO il_tag (user_id, obj_id, obj_type,".
54  "sub_obj_id, sub_obj_type, tag) VALUES (".
55  $ilDB->quote($a_user_id, "integer").",".
56  $ilDB->quote($a_obj_id, "integer").",".
57  $ilDB->quote($a_obj_type, "text").",".
58  $ilDB->quote((int) $a_sub_obj_id, "integer").",".
59  $ilDB->quote($a_sub_obj_type, "text").",".
60  $ilDB->quote($tag, "text").")");
61 
62  $inserted[] = strtolower($tag);
63  }
64  }
65  }
66  }
+ Here is the caller graph for this function:

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