ILIAS  release_4-3 Revision
 All Data Structures Namespaces Files Functions Variables Groups Pages
ilTagging Class Reference

Class ilTagging. More...

+ Collaboration diagram for ilTagging:

Public Member Functions

 getUsersForTag ($a_tag)
 Get users for tag.

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.
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.
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.
static getTagsForUser ($a_user_id, $a_max=0, $a_only_online=true)
 Get tags for a user.
static getObjectsForTagAndUser ($a_user_id, $a_tag)
 Get objects for tag and user.
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)
static setTagsOfObjectOffline ($a_obj_id, $a_obj_type, $a_sub_obj_id, $a_sub_obj_type, $a_offline=true)
 Set offline.
static deleteTagsOfObject ($a_obj_id, $a_obj_type, $a_sub_obj_id, $a_sub_obj_type)
 Deletes tags of an object.
static _countTags ($a_obj_ids)
 Count all tags for repository objects.

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

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().

{
global $ilDB, $ilUser;
$q = "SELECT count(*) c, obj_id FROM il_tag WHERE ".
$ilDB->in("obj_id", $a_obj_ids, false, "integer")." AND ".
" user_id = ".$ilDB->quote($ilUser->getId(), "integer").
" GROUP BY obj_id";
$cnt = array();
$set = $ilDB->query($q);
while ($rec = $ilDB->fetchAssoc($set))
{
$cnt[$rec["obj_id"]] = $rec["c"];
}
return $cnt;
}

+ Here is the caller graph for this function:

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().

{
$m = ($max == 1)
? 0
: 50 / ($max - 1);
$a = 100 - $m;
$font_size = round($a + ($m * $cnt));
return (int) $font_size;
}

+ Here is the caller graph for this function:

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().

{
global $ilDB;
if ($a_sub_obj_type == "")
{
$a_sub_obj_type = "-";
}
$ilDB->manipulateF("DELETE FROM il_tag ".
"WHERE ".
"obj_id = %s AND ".
"obj_type = %s AND ".
"sub_obj_id = %s AND ".
$ilDB->equals("sub_obj_type", $a_sub_obj_type, "text", true),
array("integer", "text", "integer"),
array($a_obj_id, $a_obj_type, $a_sub_obj_id));
}

+ Here is the caller graph for this function:

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().

{
global $ilDB;
$q = "SELECT * FROM il_tag WHERE ".
"user_id = ".$ilDB->quote($a_user_id, "integer").
" AND tag = ".$ilDB->quote($a_tag, "text");
$set = $ilDB->query($q);
$objects = array();
while($rec = $ilDB->fetchAssoc($set))
{
if (ilObject::_exists($rec["obj_id"]))
{
if ($rec["sub_obj_type"] == "-")
{
$rec["sub_obj_type"] = "";
}
$objects[] = $rec;
}
else
{
ilTagging::deleteTagsOfObject($rec["obj_id"], $rec["obj_type"],
$rec["sub_obj_id"], $rec["sub_obj_type"]);
}
}
return $objects;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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().

{
global $ilDB;
$online_str = ($a_only_online)
? $online_str = " AND is_offline = ".$ilDB->quote(0, "integer")." "
: "";
if ($a_sub_obj_type == "")
{
$a_sub_obj_type = "-";
}
$q = "SELECT count(user_id) as cnt, tag FROM il_tag WHERE ".
"obj_id = ".$ilDB->quote($a_obj_id, "integer")." AND ".
"obj_type = ".$ilDB->quote($a_obj_type, "text")." AND ".
"sub_obj_id = ".$ilDB->quote($a_sub_obj_id, "integer")." AND ".
$ilDB->equals("sub_obj_type", $a_sub_obj_type, "text", true).
$online_str.
"GROUP BY tag ORDER BY tag ASC";
$set = $ilDB->query($q);
$tags = array();
while($rec = $ilDB->fetchAssoc($set))
{
$tags[] = $rec;
}
return $tags;
}

+ Here is the caller graph for this function:

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().

{
global $ilDB;
$online_str = ($a_only_online)
? $online_str = " AND is_offline = ".$ilDB->quote(0, "integer")." "
: "";
$set = $ilDB->query("SELECT count(*) as cnt, tag FROM il_tag WHERE ".
"user_id = ".$ilDB->quote($a_user_id, "integer")." ".
$online_str.
" GROUP BY tag ORDER BY cnt DESC");
$tags = array();
$cnt = 1;
while(($rec = $ilDB->fetchAssoc($set)) &&
($a_max == 0 || $cnt <= $a_max))
{
$tags[] = $rec;
$cnt++;
}
$tags = ilUtil::sortArray($tags, "tag", "asc");
return $tags;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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().

{
global $ilDB;
if ($a_sub_obj_type == "")
{
$a_sub_obj_type = "-";
}
$q = "SELECT * FROM il_tag WHERE ".
"user_id = ".$ilDB->quote($a_user_id, "integer")." AND ".
"obj_id = ".$ilDB->quote($a_obj_id, "integer")." AND ".
"obj_type = ".$ilDB->quote($a_obj_type, "text")." AND ".
"sub_obj_id = ".$ilDB->quote((int) $a_sub_obj_id, "integer")." AND ".
$ilDB->equals("sub_obj_type", $a_sub_obj_type, "text", true).
" ORDER BY tag ASC";
$set = $ilDB->query($q);
$tags = array();
while($rec = $ilDB->fetchAssoc($set))
{
$tags[] = $rec["tag"];
}
return $tags;
}

+ Here is the caller graph for this function:

ilTagging::getUsersForTag (   $a_tag)

Get users for tag.

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

Referenced by ilUserForTagTableGUI\__construct().

{
global $ilDB;
$set = $ilDB->query("SELECT DISTINCT user_id, firstname, lastname FROM il_tag JOIN usr_data ON (user_id = usr_id) ".
" WHERE LOWER(tag) = LOWER(".$ilDB->quote($a_tag, "text").")".
" ORDER BY lastname, firstname"
);
$users = array();
while ($rec = $ilDB->fetchAssoc($set))
{
$users[] = array("id" => $rec["user_id"]);
}
return $users;
}

+ Here is the caller graph for this function:

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().

{
global $ilDB;
if ($a_sub_obj_type == "")
{
$a_sub_obj_type = "-";
}
$ilDB->manipulateF("UPDATE il_tag SET is_offline = %s ".
"WHERE ".
"obj_id = %s AND ".
"obj_type = %s AND ".
"sub_obj_id = %s AND ".
$ilDB->equals("sub_obj_type", $a_sub_obj_type, "text", true),
array("boolean", "integer", "text", "integer"),
array($a_offline, $a_obj_id, $a_obj_type, $a_sub_obj_id));
}

+ Here is the caller graph for this function:

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().

{
global $ilDB;
if ($a_sub_obj_type == "")
{
$a_sub_obj_type = "-";
}
$ilDB->manipulate("DELETE FROM il_tag WHERE ".
"user_id = ".$ilDB->quote($a_user_id, "integer")." AND ".
"obj_id = ".$ilDB->quote($a_obj_id, "integer")." AND ".
"obj_type = ".$ilDB->quote($a_obj_type, "text")." AND ".
"sub_obj_id = ".$ilDB->quote((int) $a_sub_obj_id, "integer")." AND ".
$ilDB->equals("sub_obj_type", $a_sub_obj_type, "text", true));
//"sub_obj_type = ".$ilDB->quote($a_sub_obj_type, "text"));
if (is_array($a_tags))
{
$inserted = array();
foreach($a_tags as $tag)
{
if (!in_array(strtolower($tag), $inserted))
{
$tag = str_replace(" ", "_", trim($tag));
$ilDB->manipulate("INSERT INTO il_tag (user_id, obj_id, obj_type,".
"sub_obj_id, sub_obj_type, tag) VALUES (".
$ilDB->quote($a_user_id, "integer").",".
$ilDB->quote($a_obj_id, "integer").",".
$ilDB->quote($a_obj_type, "text").",".
$ilDB->quote((int) $a_sub_obj_id, "integer").",".
$ilDB->quote($a_sub_obj_type, "text").",".
$ilDB->quote($tag, "text").")");
$inserted[] = strtolower($tag);
}
}
}
}

+ Here is the caller graph for this function:


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