Moodle  2.2.1
http://www.collinsharper.com
C:/xampp/htdocs/moodle/tag/lib.php File Reference

Go to the source code of this file.

Namespaces

namespace  core

Enumerations

enum  TAG_RETURN_ARRAY
enum  TAG_RETURN_OBJECT
enum  TAG_RETURN_TEXT
enum  TAG_RETURN_HTML
enum  TAG_CASE_LOWER
enum  TAG_CASE_ORIGINAL
enum  TAG_RELATED_ALL
enum  TAG_RELATED_MANUAL
enum  TAG_RELATED_CORRELATED

Functions

 tag_set ($record_type, $record_id, $tags)
 Functions for settings tags //////////////////////.
 tag_set_add ($record_type, $record_id, $tag)
 tag_set_delete ($record_type, $record_id, $tag)
 tag_type_set ($tagid, $type)
 tag_description_set ($tagid, $description, $descriptionformat)
 tag_get ($field, $value, $returnfields='id, name, rawname')
 Functions for getting information about tags //////.
 tag_get_tags ($record_type, $record_id, $type=null, $userid=0)
 tag_get_tags_array ($record_type, $record_id, $type=null)
 tag_get_tags_csv ($record_type, $record_id, $html=TAG_RETURN_HTML, $type=null)
 tag_get_tags_ids ($record_type, $record_id)
 tag_get_id ($tags, $return_value=null)
 tag_get_related_tags ($tagid, $type=TAG_RELATED_ALL, $limitnum=10)
 tag_get_related_tags_csv ($related_tags, $html=TAG_RETURN_HTML)
 tag_rename ($tagid, $newrawname)
 tag_delete ($tagids)
 tag_delete_instance ($record_type, $record_id, $tagid)
 tag_display_name ($tagobject, $html=TAG_RETURN_HTML)
 tag_find_records ($tag, $type, $limitfrom='', $limitnum='')
 tag_add ($tags, $type="default")
 tag_assign ($record_type, $record_id, $tagid, $ordering, $userid=0)
 tag_autocomplete ($text)
 tag_cleanup ()
 tag_compute_correlations ($mincorrelation=2)
 tag_process_computed_correlation (stdClass $tagcorrelation)
 tag_cron ()
 tag_find_tags ($text, $ordered=true, $limitfrom='', $limitnum='')
 tag_get_name ($tagids)
 tag_get_correlated ($tag_id, $limitnum=null)
 tag_normalize ($rawtags, $case=TAG_CASE_LOWER)
 tag_record_count ($record_type, $tagid)
 tag_record_tagged_with ($record_type, $record_id, $tag)
 tag_set_flag ($tagids)
 tag_unset_flag ($tagids)
 tag_page_type_list ($pagetype, $parentcontext, $currentcontext)

Enumeration Type Documentation

Definition at line 58 of file lib.php.

Definition at line 59 of file lib.php.

Definition at line 61 of file lib.php.

Definition at line 63 of file lib.php.

Definition at line 62 of file lib.php.

Definition at line 53 of file lib.php.

Definition at line 56 of file lib.php.

Definition at line 54 of file lib.php.

Definition at line 55 of file lib.php.


Function Documentation

tag_add ( tags,
type = "default" 
)

Adds one or more tag in the database. This function should not be called directly : you should use tag_set.

Parameters:
mixed$tagsone tag, or an array of tags, to be created
string$typetype of tag to be created ("default" is the default value and "official" is the only other supported value at this time). An official tag is kept even if there are no records tagged with it.
Returns:
an array of tags ids, indexed by their lowercase normalized names. Any boolean false in the array indicates an error while adding the tag.

Definition at line 670 of file lib.php.

Here is the call graph for this function:

Here is the caller graph for this function:

tag_assign ( record_type,
record_id,
tagid,
ordering,
userid = 0 
)

Assigns a tag to a record: if the record already exists, the time and ordering will be updated.

Parameters:
string$record_typethe type of the record that will be tagged
int$record_idthe id of the record that will be tagged
string$tagidthe tag id to set on the record.
int$orderingthe order of the instance for this record
int$useridoptional only required for course tagging
Returns:
bool true on success, false otherwise

Definition at line 714 of file lib.php.

Here is the caller graph for this function:

tag_autocomplete ( text)

Function that returns tags that start with some text, for use by the autocomplete feature

Parameters:
string$textstring that the tag names will be matched against
Returns:
mixed an array of objects, or false if no records were found or an error occured.

Definition at line 739 of file lib.php.

Here is the call graph for this function:

Clean up the tag tables, making sure all tagged object still exists.

This should normally not be necessary, but in case related tags are not deleted when the tagged record is removed, this should be done once in a while, perhaps on an occasional cron run. On a site with lots of tags, this could become an expensive function to call: don't run at peak time.

Definition at line 754 of file lib.php.

Here is the call graph for this function:

Here is the caller graph for this function:

tag_compute_correlations ( mincorrelation = 2)

Calculates and stores the correlated tags of all tags. The correlations are stored in the 'tag_correlation' table.

Two tags are correlated if they appear together a lot. Ex.: Users tagged with "computers" will probably also be tagged with "algorithms".

The rationale for the 'tag_correlation' table is performance. It works as a cache for a potentially heavy load query done at the 'tag_instance' table. So, the 'tag_correlation' table stores redundant information derived from the 'tag_instance' table.

moodle_database $DB

Parameters:
int$mincorrelationOnly tags with more than $mincorrelation correlations will be identified.
Returns:
void

Definition at line 823 of file lib.php.

Here is the call graph for this function:

Here is the caller graph for this function:

tag_cron ( )

Tasks that should be performed at cron time

Definition at line 930 of file lib.php.

Here is the call graph for this function:

Here is the caller graph for this function:

tag_delete ( tagids)

Delete one or more tag, and all their instances if there are any left.

Parameters:
mixed$tagidsone tagid (int), or one array of tagids to delete
Returns:
bool true on success, false otherwise

Definition at line 532 of file lib.php.

Here is the call graph for this function:

Here is the caller graph for this function:

tag_delete_instance ( record_type,
record_id,
tagid 
)

Delete one instance of a tag. If the last instance was deleted, it will also delete the tag, unless its type is 'official'.

Parameters:
string$record_typethe type of the record for which to remove the instance
int$record_idthe id of the record for which to remove the instance
int$tagidthe tagid that needs to be removed
Returns:
bool true on success, false otherwise

Definition at line 571 of file lib.php.

Here is the call graph for this function:

Here is the caller graph for this function:

tag_description_set ( tagid,
description,
descriptionformat 
)

Set the description of a tag

Parameters:
int$tagidthe id of the tag
string$descriptionthe description
int$descriptionformatthe moodle text format of the description
Returns:
true on success, false otherwise

Definition at line 212 of file lib.php.

tag_display_name ( tagobject,
html = TAG_RETURN_HTML 
)

Function that returns the name that should be displayed for a specific tag

Parameters:
object$tag_objecta line out of tag table, as returned by the adobd functions
int$htmlTAG_RETURN_HTML (default) will return htmlspecialchars encoded string, TAG_RETURN_TEXT will not encode.
Returns:
string

Definition at line 599 of file lib.php.

Here is the call graph for this function:

Here is the caller graph for this function:

tag_find_records ( tag,
type,
limitfrom = '',
limitnum = '' 
)

Find all records tagged with a tag of a given type ('post', 'user', etc.)

Parameters:
string$tagtag to look for
string$typetype to restrict search to. If null, every matching record will be returned
int$limitfromreturn a subset of records, starting at this point (optional, required if $limitnum is set).
int$limitnumreturn a subset comprising this many records (optional, required if $limitfrom is set).
Returns:
array of matching objects, indexed by record id, from the table containing the type requested

Definition at line 636 of file lib.php.

Here is the call graph for this function:

Here is the caller graph for this function:

tag_find_tags ( text,
ordered = true,
limitfrom = '',
limitnum = '' 
)

Search for tags with names that match some text

Parameters:
string$textescaped string that the tag names will be matched against
boolean$orderedIf true, tags are ordered by their popularity. If false, no ordering.
int$limitfromreturn a subset of records, starting at this point (optional, required if $limitnum is set).
int$limitnumreturn a subset comprising this many records (optional, required if $limitfrom is set).
Returns:
mixed an array of objects, or false if no records were found or an error occured.

Definition at line 944 of file lib.php.

Here is the call graph for this function:

Here is the caller graph for this function:

tag_get ( field,
value,
returnfields = 'id,
name  ,
rawname'   
)

Functions for getting information about tags //////.

Simple function to just return a single tag object when you know the name or something

Parameters:
string$fieldwhich field do we use to identify the tag: id, name or rawname
string$valuethe required value of the aforementioned field
string$returnfieldswhich fields do we want returned?
Returns:
tag object

Definition at line 240 of file lib.php.

Here is the call graph for this function:

Here is the caller graph for this function:

tag_get_correlated ( tag_id,
limitnum = null 
)

Returns the correlated tags of a tag, retrieved from the tag_correlation table. Make sure cron runs, otherwise the table will be empty and this function won't return anything.

Parameters:
int$tag_idis a single tag id
Returns:
array an array of tag objects, empty if no correlated tags are found

Definition at line 996 of file lib.php.

Here is the caller graph for this function:

tag_get_id ( tags,
return_value = null 
)

Returns the database ID of a set of tags.

Parameters:
mixed$tagsone tag, or array of tags, to look for.
bool$return_valuespecify the type of the returned value. Either TAG_RETURN_OBJECT, or TAG_RETURN_ARRAY (default). If TAG_RETURN_ARRAY is specified, an array will be returned even if only one tag was passed in $tags.
Returns:
mixed tag-indexed array of ids (or objects, if second parameter is TAG_RETURN_OBJECT), or only an int, if only one tag is given *and* the second parameter is null. No value for a key means the tag wasn't found.

Definition at line 378 of file lib.php.

Here is the call graph for this function:

Here is the caller graph for this function:

tag_get_name ( tagids)

Get the name of a tag

Parameters:
mixed$tagidsthe id of the tag, or an array of ids
Returns:
mixed string name of one tag, or id-indexed array of strings

Definition at line 970 of file lib.php.

Here is the caller graph for this function:

tag_get_related_tags ( tagid,
type = TAG_RELATED_ALL,
limitnum = 10 
)

Returns tags related to a tag

Related tags of a tag come from two sources:

  • manually added related tags, which are tag_instance entries for that tag
  • correlated tags, which are a calculated
Parameters:
string$tag_name_or_idis a single **normalized** tag name or the id of a tag
int$typethe function will return either manually (TAG_RELATED_MANUAL) related tags or correlated (TAG_RELATED_CORRELATED) tags. Default is TAG_RELATED_ALL, which returns everything.
int$limitnumreturn a subset comprising this many records (optional, default is 10)
Returns:
array an array of tag objects

Definition at line 448 of file lib.php.

Here is the call graph for this function:

Here is the caller graph for this function:

tag_get_related_tags_csv ( related_tags,
html = TAG_RETURN_HTML 
)

Get a comma-separated list of tags related to another tag.

Parameters:
array$related_tagsthe array returned by tag_get_related_tags
int$htmleither TAG_RETURN_HTML (default) or TAG_RETURN_TEXT : return html links, or just text.
Returns:
string comma-separated list

Definition at line 475 of file lib.php.

Here is the call graph for this function:

Here is the caller graph for this function:

tag_get_tags ( record_type,
record_id,
type = null,
userid = 0 
)

Get the array of db record of tags associated to a record (instances). Use tag_get_tags_csv to get the same information in a comma-separated string. This should really be called tag_get_tag_instances()

Parameters:
string$record_typethe record type for which we want to get the tags
int$record_idthe record id for which we want to get the tags
string$typethe tag type (either 'default' or 'official'). By default, all tags are returned.
int$useridoptional only required for course tagging
Returns:
array the array of tags

Definition at line 262 of file lib.php.

Here is the caller graph for this function:

tag_get_tags_array ( record_type,
record_id,
type = null 
)

Get the array of tags display names, indexed by id.

Parameters:
string$record_typethe record type for which we want to get the tags
int$record_idthe record id for which we want to get the tags
string$typethe tag type (either 'default' or 'official'). By default, all tags are returned.
Returns:
array the array of tags (with the value returned by tag_display_name), indexed by id

Definition at line 309 of file lib.php.

Here is the call graph for this function:

Here is the caller graph for this function:

tag_get_tags_csv ( record_type,
record_id,
html = TAG_RETURN_HTML,
type = null 
)

Get a comma-separated string of tags associated to a record. Use tag_get_tags to get the same information in an array.

Parameters:
string$record_typethe record type for which we want to get the tags
int$record_idthe record id for which we want to get the tags
int$htmleither TAG_RETURN_HTML or TAG_RETURN_TEXT, depending on the type of output desired
string$typeeither 'official' or 'default', if null, all tags are returned
Returns:
string the comma-separated list of tags.

Definition at line 329 of file lib.php.

Here is the call graph for this function:

Here is the caller graph for this function:

tag_get_tags_ids ( record_type,
record_id 
)

Get an array of tag ids associated to a record.

Parameters:
string$record_typethe record type for which we want to get the tags
int$record_idthe record id for which we want to get the tags
Returns:
array of tag ids, indexed and sorted by 'ordering'

Definition at line 350 of file lib.php.

Here is the call graph for this function:

Here is the caller graph for this function:

tag_normalize ( rawtags,
case = TAG_CASE_LOWER 
)

Function that normalizes a list of tag names.

Parameters:
mixed$tagsarray of tags, or a single tag.
int$casecase to use for returned value (default: lower case). Either TAG_CASE_LOWER (default) or TAG_CASE_ORIGINAL
Returns:
array of lowercased normalized tags, indexed by the normalized tag, in the same order as the original array. (Eg: 'Banana' => 'banana').

Definition at line 1027 of file lib.php.

Here is the call graph for this function:

Here is the caller graph for this function:

tag_page_type_list ( pagetype,
parentcontext,
currentcontext 
)

Return a list of page types

Parameters:
string$pagetypecurrent page type
stdClass$parentcontextBlock's parent context
stdClass$currentcontextCurrent context of block

Definition at line 1127 of file lib.php.

tag_process_computed_correlation ( stdClass $  tagcorrelation)

This function processes a tag correlation and makes changes in the database as required.

The tag correlation object needs have both a tagid property and a correlatedtags property that is an array.

Parameters:
stdClass$tagcorrelation
Returns:
int The id of the tag correlation that was just processed.

Definition at line 908 of file lib.php.

Here is the caller graph for this function:

tag_record_count ( record_type,
tagid 
)

Count how many records are tagged with a specific tag,

Parameters:
string$recordrecord to look for ('post', 'user', etc.)
int$tagis a single tag id
Returns:
int number of mathing tags.

Definition at line 1064 of file lib.php.

tag_record_tagged_with ( record_type,
record_id,
tag 
)

Determine if a record is tagged with a specific tag

Parameters:
string$record_typethe record type to look for
int$record_idthe record id to look for
string$taga tag name
Returns:
bool true if it is tagged, false otherwise

Definition at line 1077 of file lib.php.

Here is the call graph for this function:

Here is the caller graph for this function:

tag_rename ( tagid,
newrawname 
)

Change the "value" of a tag, and update the associated 'name'.

Parameters:
int$tagidthe id of the tag to modify
string$newtagthe new rawname
Returns:
bool true on success, false otherwise

Definition at line 498 of file lib.php.

Here is the call graph for this function:

tag_set ( record_type,
record_id,
tags 
)

Functions for settings tags //////////////////////.

Set the tags assigned to a record. This overwrites the current tags.

This function is meant to be fed the string coming up from the user interface, which contains all tags assigned to a record.

Parameters:
string$record_typethe type of record to tag ('post' for blogs, 'user' for users, 'tag' for tags, etc.
int$record_idthe id of the record to tag
array$tagsthe array of tags to set on the record. If given an empty array, all tags will be removed.
Returns:
void

Definition at line 83 of file lib.php.

Here is the call graph for this function:

Here is the caller graph for this function:

tag_set_add ( record_type,
record_id,
tag 
)

Adds a tag to a record, without overwriting the current tags.

Parameters:
string$record_typethe type of record to tag ('post' for blogs, 'user' for users, etc.
int$record_idthe id of the record to tag
string$tagthe tag to add
Returns:
void

Definition at line 151 of file lib.php.

Here is the call graph for this function:

Here is the caller graph for this function:

tag_set_delete ( record_type,
record_id,
tag 
)

Removes a tag from a record, without overwriting other current tags.

Parameters:
string$record_typethe type of record to tag ('post' for blogs, 'user' for users, etc.
int$record_idthe id of the record to tag
string$tagthe tag to delete
Returns:
void

Definition at line 171 of file lib.php.

Here is the call graph for this function:

tag_set_flag ( tagids)

Flag a tag as inapropriate

Parameters:
mixed$tagidsone (int) tagid, or an array of tagids
Returns:
void

Definition at line 1092 of file lib.php.

tag_type_set ( tagid,
type 
)

Set the type of a tag. At this time (version 1.9) the possible values are 'default' or 'official'. Official tags will be displayed separately "at tagging time" (while selecting the tags to apply to a record).

Parameters:
string$tagidtagid to modify
string$typeeither 'default' or 'official'
Returns:
true on success, false otherwise

Definition at line 192 of file lib.php.

Here is the caller graph for this function:

tag_unset_flag ( tagids)

Remove the inapropriate flag on a tag

Parameters:
mixed$tagidsone (int) tagid, or an array of tagids
Returns:
bool true if function succeeds, false otherwise

Definition at line 1110 of file lib.php.

 All Data Structures Namespaces Files Functions Variables Enumerations