PHP Class Content_Tagger, horde

Afficher le fichier Open project: horde/horde Class Usage Examples

Protected Properties

Свойство Type Description
$_db Horde_Db_Adapter Database connection
$_defaultRadius integer Default radius for relationship queries.
$_objectManager Content_Objects_Manager Object manager
$_tables array Tables
$_typeManager Content_Types_Manager Type management object
$_userManager Content_Users_Manager User manager object

Méthodes publiques

Méthode Description
__construct ( Horde_Db_Adapter $db, Content_Users_Manager $userManager, Content_Types_Manager $typeManager, Content_Objects_Manager $objectManager ) Constructor
browseTags ( array $ids, $object_type, string $user ) : array Retrieve a set of tags with relationships to the specified set of tags.
ensureTags ( array $tags ) : array Ensure that an array of tags exist, create any that don't, and return ids for all of them.
getObjects ( array $args ) : array Get objects matching search criteria.
getRecentObjects ( array $args = [] ) : array Get the most recently tagged objects.
getRecentTags ( array $args = [] ) : array Get the most recently used tags.
getRecentUsers ( array $args = [] ) : array Get the users who have most recently tagged objects.
getSimilarObjects ( mixed $object_id, array $args = [] ) : array Return objects related to the given object via tags, along with a similarity rank.
getSimilarUsers ( $args ) Return users related to a given user along with a similarity rank.
getTagCloud ( array $args = [] ) : array 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 ( $tags )
getTags ( array $args ) : array Retrieve tags based on criteria.
getTagsByObjects ( $objects, mixed $type ) : array Obtain all the tags for a given set of objects.
getUsers ( $args ) Find users through objects, tags, or other users.
removeTagFromObject ( $objectId, mixed $tags ) : void Remove all occurrences of a specific tag from an object regardless of the username who tagged the object originally.
splitTags ( string $text ) : array 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 ( mixed $userId, mixed $objectId, array $tags, Horde_Date $created = null ) : void Adds a tag or several tags to an object_id. This method does not remove other tags.
toDriver ( $value )
untag ( mixed $userId, mixed $objectId, array $tags ) Undo a user's tagging of an object.

Méthodes protégées

Méthode Description
_checkTags ( string | array $tags, boolean $create = true ) : array 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 ( $object ) 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 $tableType ) : string Shortcut for getting a table name.

Method Details

__construct() public méthode

Constructor
public __construct ( Horde_Db_Adapter $db, Content_Users_Manager $userManager, Content_Types_Manager $typeManager, Content_Objects_Manager $objectManager )
$db Horde_Db_Adapter
$userManager Content_Users_Manager
$typeManager Content_Types_Manager
$objectManager Content_Objects_Manager

_checkTags() protected méthode

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 $tags, boolean $create = true ) : array
$tags string | array The tag names to check.
$create boolean If true, create the tag in the tags table.
Résultat array A hash of tag_name => tag_id values.

_ensureObject() protected méthode

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 ( $object )

_t() protected méthode

Shortcut for getting a table name.
protected _t ( string $tableType ) : string
$tableType string
Résultat string Configured table name.

browseTags() public méthode

Retrieve a set of tags with relationships to the specified set of tags.
public browseTags ( array $ids, $object_type, string $user ) : array
$ids array An array of tag_ids.
$user string The user to limit to.
Résultat array A hash of tag_id -> tag_name

ensureTags() public méthode

Ensure that an array of tags exist, create any that don't, and return ids for all of them.
public ensureTags ( array $tags ) : array
$tags array Array of tag names or ids.
Résultat array Hash of tag_name => tag_id values.

getObjects() public méthode

Get objects matching search criteria.
public getObjects ( array $args ) : array
$args array 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
Résultat array An array of object ids.

getRecentObjects() public méthode

Get the most recently tagged objects.
public getRecentObjects ( array $args = [] ) : array
$args 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.
Résultat array

getRecentTags() public méthode

Get the most recently used tags.
public getRecentTags ( array $args = [] ) : array
$args 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.
Résultat array

getRecentUsers() public méthode

Get the users who have most recently tagged objects.
public getRecentUsers ( array $args = [] ) : array
$args 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.
Résultat array

getSimilarObjects() public méthode

Return objects related to the given object via tags, along with a similarity rank.
public getSimilarObjects ( mixed $object_id, array $args = [] ) : array
$object_id mixed The object to find relations for.
$args 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).
Résultat array An array of (client) object ids => similarity rank

getSimilarUsers() public méthode

Return users related to a given user along with a similarity rank.
public getSimilarUsers ( $args )

getTagCloud() public méthode

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 $args = [] ) : array
$args 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).
Résultat array An array of hashes, each containing tag_id, tag_name, and count.

getTagIds() public méthode

public getTagIds ( $tags )

getTags() public méthode

Retrieve tags based on criteria.
public getTags ( array $args ) : array
$args array 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.
Résultat array An array of tags, id => name.

getTagsByObjects() public méthode

Obtain all the tags for a given set of objects.
public getTagsByObjects ( $objects, mixed $type ) : array
$type mixed Either a string type description, or an integer content type_id
Résultat array An array in the form of:
     array('localobjectId' => array('tagone', 'tagtwo'),
           'anotherobjectid' => array('anothertag', 'yetanother'))

getUsers() public méthode

Find users through objects, tags, or other users.
public getUsers ( $args )

removeTagFromObject() public méthode

Remove all occurrences of a specific tag from an object regardless of the username who tagged the object originally.
public removeTagFromObject ( $objectId, mixed $tags ) : void
$tags mixed The tags to remove. @see Content_Tagger::tag()
Résultat void

splitTags() public méthode

Would parse to: array('this', 'somecompany, llc', 'and "this" w,o.rks', 'foo bar')
public splitTags ( string $text ) : array
$text string String to split into 1 or more tags.
Résultat array Split tag array.

tag() public méthode

Adds a tag or several tags to an object_id. This method does not remove other tags.
public tag ( mixed $userId, mixed $objectId, array $tags, Horde_Date $created = null ) : void
$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 An array of tag name or ids.
$created Horde_Date The datetime of the tagging operation.
Résultat void

toDriver() public méthode

public toDriver ( $value )

untag() public méthode

Undo a user's tagging of an object.
public untag ( mixed $userId, mixed $objectId, array $tags )
$userId mixed The user who tagged the object.
$objectId mixed The object to remove the tag from.
$tags array An array of tag name or ids to remove.

Property Details

$_db protected_oe property

Database connection
protected Horde_Db_Adapter $_db
Résultat Horde_Db_Adapter

$_defaultRadius protected_oe property

Default radius for relationship queries.
protected int $_defaultRadius
Résultat integer

$_objectManager protected_oe property

Object manager
protected Content_Objects_Manager $_objectManager
Résultat Content_Objects_Manager

$_tables protected_oe property

Tables
protected array $_tables
Résultat array

$_typeManager protected_oe property

Type management object
protected Content_Types_Manager $_typeManager
Résultat Content_Types_Manager

$_userManager protected_oe property

User manager object
protected Content_Users_Manager $_userManager
Résultat Content_Users_Manager