class vB_Tags

Traits

Properties

protected $nodeid
protected $contentinfo
protected $tags
protected $currentUserId
protected $owner
protected $assertor

Methods

__sleep()

No description

__wakeup()

No description

__construct(int $nodeid = 0, array $contentinfo = false)

Create a taggable content item.

array
filterTagList(string|array $taglist, array $errors, boolean $evalerrors = true)

Takes a list of tags and returns a list of valid tags

deleteTagAttachmentsList($nodeids)

Delete tag attachments for a list of content items

isTagValid($tagtext, $errors)

No description

array
splitTagList(string $taglist)

Splits the tag list based on an admin-specified set of delimiters (and comma).

array
convertSynonyms(array $tags, array $errors)

Converts synomyns to canonical tags

bool
canDeleteTag($tag, $errors = array())

Determines if a user can delete a tag associated with this content item

bool
canModerateTag()

Checks to see if the user has permission to "moderate" tags for this content items.

bool
canAddTag($targetid = false)

Checks to see if the user can add tags to this content item

bool
canManageTag($nodeid = 0)

Can the current user manage existing tags?

bool
isOwnedByCurrentUser()

Determines if the current user owns this content item

getNodeOwner($node)

Get the id of the node owner

bool
checkUserPermission()

Get the user permission to create tags

array
fetchTagLimits()

Get the tag limits for the content type

array
addTagsToContent(string|array $taglist)

Adds tags to the content item. Tags are created if they don't already exist (assuming the user has permissions)

copyTagAttachments($sourceid)

Copy the tag attachments from one item to another

moveTagAttachments($sourceid)

No description

removeTagInfo($nodeid, $isMoving = false, $remaining = 0)

No description

mergeTagAttachments(array $sourceids)

Merge the tag attachments for one or more tagged items to this item

deleteTagAttachments($nodeid, $taglist, $errors)

Delete tag attachments for this item

getSpace($sourceNode)

No description

updateNode()

Update the node value

deleteTags($tags = '')

Delete all tag attachments for this item

array
filterTagListContentLimits(string|array $taglist, array $limits, int $errors, boolean $checkBrowserPerms = true, boolean $evalerrors = true)

Filters the tag list to exclude invalid tags based on the content item the tags are assigned to.

int
fetchExistingTagCount()

Get the number of existing tags for this item

array
fetchExistingTagList()

Get the list of tags associated with this item

array
fetchContentInfo()

Allow access to the content array

getNodeTags()

No description

array
loadContentInfo()

Load the Content Info

invalidateTagList()

Invalidates the cached list of tags for this item.

fetchTagInfo($tag)

No description

Details

in vB_Trait_NoSerialize at line 15
__sleep()

in vB_Trait_NoSerialize at line 20
__wakeup()

at line 43
__construct(int $nodeid = 0, array $contentinfo = false)

Create a taggable content item.

Parameters

int $nodeid id for the content item to be tagged. Can be 0 if it is used only for validating tags
array $contentinfo content info -- database record for item to be tagged, values vary by specific content item. For performance reasons this can be included, otherwise the data will be fetched if needed from the provided id.

at line 81
array filterTagList(string|array $taglist, array $errors, boolean $evalerrors = true)

Takes a list of tags and returns a list of valid tags

Tags are transformed to removed tabs and newlines Tags may be lowercased based on options Tags matching synomyns will Duplicate will be eliminated (case insensitive) Invalid tags will be removed.

Fetch the valid tags from a list. Filters are length, censorship, perms (if desired).

Parameters

string|array $taglist List of tags to add (comma delimited, or an array as is). If array, ensure there are no commas.
array $errors (output) List of errors that happens
boolean $evalerrors Whether to expand the error phrase

Return Value

array List of valid tags

at line 133
protected deleteTagAttachmentsList($nodeids)

Delete tag attachments for a list of content items

Parameters

$nodeids

at line 179
protected isTagValid($tagtext, $errors)

Parameters

$tagtext
$errors

at line 270
protected array splitTagList(string $taglist)

Splits the tag list based on an admin-specified set of delimiters (and comma).

Parameters

string $taglist List of tags

Return Value

array Tags in seperate array entries temporarily make public

at line 317
protected array convertSynonyms(array $tags, array $errors)

Converts synomyns to canonical tags

If a tag is converted a message will be added to the error array to alert the user Does not handle removing duplicates created by the coversion process

Parameters

array $tags array of tags to convert
array $errors array of errors (in/out param)

Return Value

array the new list of tags

at line 368
protected bool canDeleteTag($tag, $errors = array())

Determines if a user can delete a tag associated with this content item

A user can delete his or her own tags. A user with moderator rights can delete a tag. If not otherwise specified a user can delete a tag if they own the content item

This function requires that content info is set.

Parameters

$tag
$errors

Return Value

bool

at line 410
protected bool canModerateTag()

Checks to see if the user has permission to "moderate" tags for this content items.

This is specific to the content type and defaults to false. This function requires that content info be set.

Return Value

bool

at line 425
protected bool canAddTag($targetid = false)

Checks to see if the user can add tags to this content item

This function requires that content info be set.

Parameters

$targetid

Return Value

bool

at line 463
bool canManageTag($nodeid = 0)

Can the current user manage existing tags?

The only current operation on existing tags is to remove them from the content item.

This is odd. It controls whether or not we show the checkboxes beside the tags in tagUI (and if we check at all for deletes). It exists primarily to capture some logic in the thread to handle the situation where a user can delete tags but not add them (if a user can add tags we'll always display the delete UI in the legacy logic). Note that there is a seperate check for each tag to determine if the user can actually delete that particular tag. Most new types aren't likely to require that kind of granularity and probably won't need to to extend this function.

This function requires that content info be set.

Parameters

$nodeid

Return Value

bool

at line 496
protected bool isOwnedByCurrentUser()

Determines if the current user owns this content item

Ownership is a content specific concept. For example the "owner" of a thread is the thread starter. This function requires that content info be set.

Return Value

bool

at line 517
protected getNodeOwner($node)

Get the id of the node owner

Parameters

$node

Return Value

the id of the owner

at line 528
bool checkUserPermission()

Get the user permission to create tags

Return Value

bool

at line 542
array fetchTagLimits()

Get the tag limits for the content type

This function requires that content info be set.

Return Value

array ('content_limit' => total tags for content type, 'user_limit' => total tags the current user can have on this item)

at line 571
array addTagsToContent(string|array $taglist)

Adds tags to the content item. Tags are created if they don't already exist (assuming the user has permissions)

If a tag cannot be processed it is dropped from the list and an error is returned, however this does not prevent valid tags from being processed.

Parameters

string|array $taglist List of tags to add (comma delimited, or an array as is). If array, ensure there are no commas.

Return Value

array Array of errors, if any

at line 658
copyTagAttachments($sourceid)

Copy the tag attachments from one item to another

Copying of tag attachements from an item of a different type is supported.

Parameters

$sourceid The id of the item whose tags should be copied

at line 688
moveTagAttachments($sourceid)

Parameters

$sourceid

at line 725
protected removeTagInfo($nodeid, $isMoving = false, $remaining = 0)

Parameters

$nodeid
$isMoving
$remaining

at line 785
mergeTagAttachments(array $sourceids)

Merge the tag attachments for one or more tagged items to this item

Designed to handle the results of merging items (the tags also need to be merged). Items merged are assumed to be the same type as this item. Merged tags are detached from the items they are merged from.

Parameters

array $sourceids The id of the item whose tags should be merged

at line 859
protected deleteTagAttachments($nodeid, $taglist, $errors)

Delete tag attachments for this item

Parameters

$nodeid
$taglist
$errors

at line 909
protected getSpace($sourceNode)

Parameters

$sourceNode

at line 962
protected updateNode()

Update the node value

at line 982
deleteTags($tags = '')

Delete all tag attachments for this item

Parameters

$tags

at line 1018
protected array filterTagListContentLimits(string|array $taglist, array $limits, int $errors, boolean $checkBrowserPerms = true, boolean $evalerrors = true)

Filters the tag list to exclude invalid tags based on the content item the tags are assigned to.

Calls filterTagList internally to handle invalid tags.

Parameters

string|array $taglist List of tags to add (comma delimited, or an array as is). If array, ensure there are no commas.
array $limits array of tag limit constraints. If a limit is not specified a suitable default will be used (currently unlimited, but a specific default should not be relied on). Current limits recognized are 'content_limit' which is the maximum number of tags for a content item and 'user_limit' which is the maximum number of tags the current user can add to the content item.
int $errors The maximum number of tags the current user can assign to this item (0 is unlimited)
boolean $checkBrowserPerms Whether to check the browsing user's create tag perms
boolean $evalerrors Whether to expand the error phrase

Return Value

array List of valid tags. If there are too many tags to add, the list will be truncated first. An error will be set in this case.

at line 1129
int fetchExistingTagCount()

Get the number of existing tags for this item

Return Value

int the tag count

at line 1144
array fetchExistingTagList()

Get the list of tags associated with this item

Return Value

array Array of tag text for the associated tags

at line 1182
protected array fetchContentInfo()

Allow access to the content array

Lazy loads content info array. Used internally so that we only load this if we actually need it (and don't load it multiple times).

This function is exposed publicly for the benefit of code that needs the content array but may not know precisely how to load it (because it isn't aware of the type of content being tagged).

Actually, this is a bad idea precisely because the code doesn't know what type its dealing with. Its a paint to have to create a bunch of getters for the details, but we need to do just that to ensure a consistant interface.

Return Value

array Content info array.

at line 1195
getNodeTags()

at line 1216
protected array loadContentInfo()

Load the Content Info

Actually loads the content info for this type

Return Value

array The content info

at line 1242
protected invalidateTagList()

Invalidates the cached list of tags for this item.

Should be called by any method that alters the tag types.

at line 1247
protected fetchTagInfo($tag)

Parameters

$tag