PHP 클래스 Content_Tagger, horde

파일 보기 프로젝트 열기: horde/horde 1 사용 예제들

보호된 프로퍼티들

프로퍼티 타입 설명
$_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

공개 메소드들

메소드 설명
__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.

보호된 메소드들

메소드 설명
_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.

메소드 상세

__construct() 공개 메소드

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() 보호된 메소드

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.
리턴 array 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 ( $object )

_t() 보호된 메소드

Shortcut for getting a table name.
protected _t ( string $tableType ) : string
$tableType string
리턴 string Configured table name.

browseTags() 공개 메소드

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.
리턴 array 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 $tags ) : array
$tags array Array of tag names or ids.
리턴 array Hash of tag_name => tag_id values.

getObjects() 공개 메소드

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
리턴 array An array of object ids.

getRecentObjects() 공개 메소드

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.
리턴 array

getRecentTags() 공개 메소드

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.
리턴 array

getRecentUsers() 공개 메소드

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.
리턴 array

getSimilarObjects() 공개 메소드

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).
리턴 array An array of (client) object ids => similarity rank

getSimilarUsers() 공개 메소드

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

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 $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).
리턴 array An array of hashes, each containing tag_id, tag_name, and count.

getTagIds() 공개 메소드

public getTagIds ( $tags )

getTags() 공개 메소드

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.
리턴 array An array of tags, id => name.

getTagsByObjects() 공개 메소드

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
리턴 array 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 ( $args )

removeTagFromObject() 공개 메소드

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()
리턴 void

splitTags() 공개 메소드

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.
리턴 array 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 $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.
리턴 void

toDriver() 공개 메소드

public toDriver ( $value )

untag() 공개 메소드

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.

프로퍼티 상세

$_db 보호되어 있는 프로퍼티

Database connection
protected Horde_Db_Adapter $_db
리턴 Horde_Db_Adapter

$_defaultRadius 보호되어 있는 프로퍼티

Default radius for relationship queries.
protected int $_defaultRadius
리턴 integer

$_objectManager 보호되어 있는 프로퍼티

Object manager
protected Content_Objects_Manager $_objectManager
리턴 Content_Objects_Manager

$_tables 보호되어 있는 프로퍼티

Tables
protected array $_tables
리턴 array

$_typeManager 보호되어 있는 프로퍼티

Type management object
protected Content_Types_Manager $_typeManager
리턴 Content_Types_Manager

$_userManager 보호되어 있는 프로퍼티

User manager object
protected Content_Users_Manager $_userManager
리턴 Content_Users_Manager