Documentation

Content_Tagger

Copyright 2008-2017 Horde LLC (http://www.horde.org/)

Tags
author

Chuck Hagenbuch chuck@horde.org

author

Michael J. Rubinsky mrubinsk@horde.org

license

http://www.horde.org/licenses/bsd BSD

category

Horde

TODO:

need to add type_id to the rampage_tagged table for performance? need stat tables by type_id?

Potential features: Infer data from combined tags (capital + washington d.c. - http://www.slideshare.net/kakul/tagging-web-2-expo-2008/) Normalize tag text (http://tagsonomy.com/index.php/interview-with-gordon-luk-freetag/)

Table of Contents

$_db  : Horde_Db_Adapter
Database connection
$_defaultRadius  : int
Default radius for relationship queries.
$_objectManager  : Content_Objects_Manager
Object manager
$_tables  : array<string|int, mixed>
Tables
$_typeManager  : Content_Types_Manager
Type management object
$_userManager  : Content_Users_Manager
User manager object
__construct()  : mixed
Constructor
browseTags()  : array<string|int, mixed>
Retrieve a set of tags with relationships to the specified set of tags.
ensureTags()  : array<string|int, mixed>
Ensure that an array of tags exist, create any that don't, and return ids for all of them.
getObjects()  : array<string|int, mixed>
Get objects matching search criteria.
getRecentObjects()  : array<string|int, mixed>
Get the most recently tagged objects.
getRecentTags()  : array<string|int, mixed>
Get the most recently used tags.
getRecentUsers()  : array<string|int, mixed>
Get the users who have most recently tagged objects.
getSimilarObjects()  : array<string|int, mixed>
Return objects related to the given object via tags, along with a similarity rank.
getSimilarUsers()  : mixed
Return users related to a given user along with a similarity rank.
getTagCloud()  : array<string|int, mixed>
Generate a tag cloud. Same syntax as getTags, except that fetching a cloud for a userId + objectId combination doesn't make sense - the counts would all be one. In addition, this method returns counts for each tag.
getTagIds()  : mixed
getTags()  : array<string|int, mixed>
Retrieve tags based on criteria.
getTagsByObjects()  : array<string|int, mixed>
Obtain all the tags for a given set of objects.
getUsers()  : mixed
Find users through objects, tags, or other users.
removeTagFromObject()  : void
Remove all occurrences of a specific tag from an object regardless of the username who tagged the object originally.
splitTags()  : array<string|int, mixed>
Split a string into an array of tag names, respecting tags with spaces and ones that are quoted in some way. For example: this, "somecompany, llc", "and ""this"" w,o.rks", foo bar
tag()  : void
Adds a tag or several tags to an object_id. This method does not remove other tags.
toDriver()  : mixed
untag()  : mixed
Undo a user's tagging of an object.
_checkTags()  : array<string|int, mixed>
Check if tags exists, optionally create them if they don't and return ids for all that exist (including those that are optionally created).
_ensureObject()  : mixed
Convenience method - if $object is an array, it is taken as an array of 'object' and 'type' to pass to objectManager::ensureObjects() if it's a scalar value, it's taken as the object_id and simply returned.
_t()  : string
Shortcut for getting a table name.

Properties

$_db

Database connection

protected Horde_Db_Adapter $_db

$_defaultRadius

Default radius for relationship queries.

protected int $_defaultRadius = 10

$_tables

Tables

protected array<string|int, mixed> $_tables = array('tags' => 'rampage_tags', 'tagged' => 'rampage_tagged', 'objects' => 'rampage_objects', 'tag_stats' => 'rampage_tag_stats', 'user_tag_stats' => 'rampage_user_tag_stats', 'users' => 'rampage_users', 'types' => 'rampage_types')

Methods

browseTags()

Retrieve a set of tags with relationships to the specified set of tags.

public browseTags(array<string|int, mixed> $ids, mixed $object_type, string $user) : array<string|int, mixed>
Parameters
$ids : array<string|int, mixed>

An array of tag_ids.

$object_type : mixed
$user : string

The user to limit to.

Return values
array<string|int, mixed>

A hash of tag_id -> tag_name

ensureTags()

Ensure that an array of tags exist, create any that don't, and return ids for all of them.

public ensureTags(array<string|int, mixed> $tags) : array<string|int, mixed>
Parameters
$tags : array<string|int, mixed>

Array of tag names or ids.

Return values
array<string|int, mixed>

Hash of tag_name => tag_id values.

getObjects()

Get objects matching search criteria.

public getObjects(array<string|int, mixed> $args) : array<string|int, mixed>
Parameters
$args : array<string|int, mixed>

Search criteria: limit Maximum number of objects to return. offset Offset the results. Only useful for paginating, and not recommended. tagId Return objects related through one or more tags. notTagId Don't return objects tagged with one or more tags. typeId Only return objects with a specific type. objectId Return objects with the same tags as $objectId. userId Limit results to objects tagged by a specific user. radius Radius setting for relationship queries e.g., objectId

Return values
array<string|int, mixed>

An array of object ids.

getRecentObjects()

Get the most recently tagged objects.

public getRecentObjects([array<string|int, mixed> $args = array() ]) : array<string|int, mixed>
Parameters
$args : array<string|int, mixed> = array()

Search criteria: limit Maximum number of objects to return. offset Offset the results. Only useful for paginating, and not recommended. userId Only return objects that have been tagged by a specific user. typeId Only return objects of a specific object type.

Return values
array<string|int, mixed>

getRecentTags()

Get the most recently used tags.

public getRecentTags([array<string|int, mixed> $args = array() ]) : array<string|int, mixed>
Parameters
$args : array<string|int, mixed> = array()

Search criteria: limit Maximum number of tags to return. offset Offset the results. Only useful for paginating, and not recommended. userId Only return tags that have been used by a specific user. typeId Only return tags applied to objects of a specific type.

Return values
array<string|int, mixed>

getRecentUsers()

Get the users who have most recently tagged objects.

public getRecentUsers([array<string|int, mixed> $args = array() ]) : array<string|int, mixed>
Parameters
$args : array<string|int, mixed> = array()

Search criteria: limit Maximum number of users to return. offset Offset the results. Only useful for paginating, and not recommended. typeId Only return users who have tagged objects of a specific object type.

Return values
array<string|int, mixed>

getSimilarObjects()

Return objects related to the given object via tags, along with a similarity rank.

public getSimilarObjects(mixed $object_id[, array<string|int, mixed> $args = array() ]) : array<string|int, mixed>
Parameters
$object_id : mixed

The object to find relations for.

$args : array<string|int, mixed> = array()

limit Maximum number of objects to return (default 10). userId Only return objects that have been tagged by a specific user. typeId Only return objects of a specific type. threshold Number of tags-in-common objects must have to match (default 1).

Return values
array<string|int, mixed>

An array of (client) object ids => similarity rank

getSimilarUsers()

Return users related to a given user along with a similarity rank.

public getSimilarUsers(mixed $args) : mixed
Parameters
$args : mixed
Return values
mixed

getTagCloud()

Generate a tag cloud. Same syntax as getTags, except that fetching a cloud for a userId + objectId combination doesn't make sense - the counts would all be one. In addition, this method returns counts for each tag.

public getTagCloud([array<string|int, mixed> $args = array() ]) : array<string|int, mixed>
Parameters
$args : array<string|int, mixed> = array()

Search criteria:

  • limit: (integer) Maximum number of tags to return.
  • offset: (integet) Offset the results. Only useful for paginating, and not recommended.
  • userId: (string) Only return tags that have been applied by a specific user.
  • typeId: (array) Only return tags that have been applied by specific object types.
  • objectId: (array) Only return tags that have been applied to specific objects all objects must be of the same type and specified by typeId.
  • tagIds: (array) Only return information on specific tag (an array of tag ids).
Return values
array<string|int, mixed>

An array of hashes, each containing tag_id, tag_name, and count.

getTagIds()

public getTagIds(mixed $tags) : mixed
Parameters
$tags : mixed
Return values
mixed

getTags()

Retrieve tags based on criteria.

public getTags(array<string|int, mixed> $args) : array<string|int, mixed>
Parameters
$args : array<string|int, mixed>

Search criteria: q Starts-with search on tag_name. limit Maximum number of tags to return. offset Offset the results. Only useful for paginating, and not recommended. userId Only return tags that have been applied by a specific user. typeId Only return tags that have been applied by a specific object type. objectId Only return tags that have been applied to a specific object.

Return values
array<string|int, mixed>

An array of tags, id => name.

getTagsByObjects()

Obtain all the tags for a given set of objects.

public getTagsByObjects(mixed $objects, mixed $type) : array<string|int, mixed>
Parameters
$objects : mixed
$type : mixed

Either a string type description, or an integer content type_id

Return values
array<string|int, mixed>

An array in the form of:

     array('localobjectId' => array('tagone', 'tagtwo'),
           'anotherobjectid' => array('anothertag', 'yetanother'))

getUsers()

Find users through objects, tags, or other users.

public getUsers(mixed $args) : mixed
Parameters
$args : mixed
Return values
mixed

removeTagFromObject()

Remove all occurrences of a specific tag from an object regardless of the username who tagged the object originally.

public removeTagFromObject(mixed $objectId, mixed $tags) : void
Parameters
$objectId : mixed
$tags : mixed

The tags to remove. @see Content_Tagger::tag()

Return values
void

splitTags()

Split a string into an array of tag names, respecting tags with spaces and ones that are quoted in some way. For example: this, "somecompany, llc", "and ""this"" w,o.rks", foo bar

public splitTags(string $text) : array<string|int, mixed>

Would parse to: array('this', 'somecompany, llc', 'and "this" w,o.rks', 'foo bar')

Parameters
$text : string

String to split into 1 or more tags.

Return values
array<string|int, mixed>

Split tag array.

tag()

Adds a tag or several tags to an object_id. This method does not remove other tags.

public tag(mixed $userId, mixed $objectId, array<string|int, mixed> $tags[, Horde_Date $created = null ]) : void
Parameters
$userId : mixed

The user tagging the object.

$objectId : mixed

The object id to tag or an array containing the object_name and type.

$tags : array<string|int, mixed>

An array of tag name or ids.

$created : Horde_Date = null

The datetime of the tagging operation.

Return values
void

toDriver()

public toDriver(mixed $value) : mixed
Parameters
$value : mixed
Return values
mixed

untag()

Undo a user's tagging of an object.

public untag(mixed $userId, mixed $objectId, array<string|int, mixed> $tags) : mixed
Parameters
$userId : mixed

The user who tagged the object.

$objectId : mixed

The object to remove the tag from.

$tags : array<string|int, mixed>

An array of tag name or ids to remove.

Return values
mixed

_checkTags()

Check if tags exists, optionally create them if they don't and return ids for all that exist (including those that are optionally created).

protected _checkTags(string|array<string|int, mixed> $tags[, bool $create = true ]) : array<string|int, mixed>
Parameters
$tags : string|array<string|int, mixed>

The tag names to check.

$create : bool = true

If true, create the tag in the tags table.

Return values
array<string|int, mixed>

A hash of tag_name => tag_id values.

_ensureObject()

Convenience method - if $object is an array, it is taken as an array of 'object' and 'type' to pass to objectManager::ensureObjects() if it's a scalar value, it's taken as the object_id and simply returned.

protected _ensureObject(mixed $object) : mixed
Parameters
$object : mixed
Return values
mixed

_t()

Shortcut for getting a table name.

protected _t(string $tableType) : string
Parameters
$tableType : string
Return values
string

Configured table name.

Search results