|
Moodle
2.2.1
http://www.collinsharper.com
|
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) | |
| enum TAG_CASE_LOWER |
| enum TAG_CASE_ORIGINAL |
| enum TAG_RELATED_ALL |
| enum TAG_RELATED_MANUAL |
| enum TAG_RETURN_ARRAY |
| enum TAG_RETURN_HTML |
| enum TAG_RETURN_OBJECT |
| enum TAG_RETURN_TEXT |
| 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.
| mixed | $tags | one tag, or an array of tags, to be created |
| string | $type | type 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. |
Definition at line 670 of file lib.php.


| 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.
| string | $record_type | the type of the record that will be tagged |
| int | $record_id | the id of the record that will be tagged |
| string | $tagid | the tag id to set on the record. |
| int | $ordering | the order of the instance for this record |
| int | $userid | optional only required for course tagging |
Definition at line 714 of file lib.php.

| tag_autocomplete | ( | $ | text | ) |
Function that returns tags that start with some text, for use by the autocomplete feature
| string | $text | string that the tag names will be matched against |
Definition at line 739 of file lib.php.

| tag_cleanup | ( | ) |
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.


| 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
| int | $mincorrelation | Only tags with more than $mincorrelation correlations will be identified. |
Definition at line 823 of file lib.php.


| tag_cron | ( | ) |
| tag_delete | ( | $ | tagids | ) |
Delete one or more tag, and all their instances if there are any left.
| mixed | $tagids | one tagid (int), or one array of tagids to delete |
Definition at line 532 of file lib.php.


| 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'.
| string | $record_type | the type of the record for which to remove the instance |
| int | $record_id | the id of the record for which to remove the instance |
| int | $tagid | the tagid that needs to be removed |
Definition at line 571 of file lib.php.


| tag_description_set | ( | $ | tagid, |
| $ | description, | ||
| $ | descriptionformat | ||
| ) |
| tag_display_name | ( | $ | tagobject, |
| $ | html = TAG_RETURN_HTML |
||
| ) |
Function that returns the name that should be displayed for a specific tag
| object | $tag_object | a line out of tag table, as returned by the adobd functions |
| int | $html | TAG_RETURN_HTML (default) will return htmlspecialchars encoded string, TAG_RETURN_TEXT will not encode. |
Definition at line 599 of file lib.php.


| tag_find_records | ( | $ | tag, |
| $ | type, | ||
| $ | limitfrom = '', |
||
| $ | limitnum = '' |
||
| ) |
Find all records tagged with a tag of a given type ('post', 'user', etc.)
| string | $tag | tag to look for |
| string | $type | type to restrict search to. If null, every matching record will be returned |
| int | $limitfrom | return a subset of records, starting at this point (optional, required if $limitnum is set). |
| int | $limitnum | return a subset comprising this many records (optional, required if $limitfrom is set). |
Definition at line 636 of file lib.php.


| tag_find_tags | ( | $ | text, |
| $ | ordered = true, |
||
| $ | limitfrom = '', |
||
| $ | limitnum = '' |
||
| ) |
Search for tags with names that match some text
| string | $text | escaped string that the tag names will be matched against |
| boolean | $ordered | If true, tags are ordered by their popularity. If false, no ordering. |
| int | $limitfrom | return a subset of records, starting at this point (optional, required if $limitnum is set). |
| int | $limitnum | return a subset comprising this many records (optional, required if $limitfrom is set). |
Definition at line 944 of file lib.php.


Functions for getting information about tags //////.
Simple function to just return a single tag object when you know the name or something
| string | $field | which field do we use to identify the tag: id, name or rawname |
| string | $value | the required value of the aforementioned field |
| string | $returnfields | which fields do we want returned? |
Definition at line 240 of file lib.php.


| 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.
| int | $tag_id | is a single tag id |
Definition at line 996 of file lib.php.

| tag_get_id | ( | $ | tags, |
| $ | return_value = null |
||
| ) |
Returns the database ID of a set of tags.
| mixed | $tags | one tag, or array of tags, to look for. |
| bool | $return_value | specify 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. |
Definition at line 378 of file lib.php.


| tag_get_name | ( | $ | tagids | ) |
| 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:
| string | $tag_name_or_id | is a single **normalized** tag name or the id of a tag |
| int | $type | the 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 | $limitnum | return a subset comprising this many records (optional, default is 10) |
Definition at line 448 of file lib.php.


| tag_get_related_tags_csv | ( | $ | related_tags, |
| $ | html = TAG_RETURN_HTML |
||
| ) |
Get a comma-separated list of tags related to another tag.
| array | $related_tags | the array returned by tag_get_related_tags |
| int | $html | either TAG_RETURN_HTML (default) or TAG_RETURN_TEXT : return html links, or just text. |
Definition at line 475 of file lib.php.


| 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()
| string | $record_type | the record type for which we want to get the tags |
| int | $record_id | the record id for which we want to get the tags |
| string | $type | the tag type (either 'default' or 'official'). By default, all tags are returned. |
| int | $userid | optional only required for course tagging |
Definition at line 262 of file lib.php.

| tag_get_tags_array | ( | $ | record_type, |
| $ | record_id, | ||
| $ | type = null |
||
| ) |
Get the array of tags display names, indexed by id.
| string | $record_type | the record type for which we want to get the tags |
| int | $record_id | the record id for which we want to get the tags |
| string | $type | the tag type (either 'default' or 'official'). By default, all tags are returned. |
Definition at line 309 of file lib.php.


| 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.
| string | $record_type | the record type for which we want to get the tags |
| int | $record_id | the record id for which we want to get the tags |
| int | $html | either TAG_RETURN_HTML or TAG_RETURN_TEXT, depending on the type of output desired |
| string | $type | either 'official' or 'default', if null, all tags are returned |
Definition at line 329 of file lib.php.


| tag_get_tags_ids | ( | $ | record_type, |
| $ | record_id | ||
| ) |
Get an array of tag ids associated to a record.
| string | $record_type | the record type for which we want to get the tags |
| int | $record_id | the record id for which we want to get the tags |
Definition at line 350 of file lib.php.


| tag_normalize | ( | $ | rawtags, |
| $ | case = TAG_CASE_LOWER |
||
| ) |
Function that normalizes a list of tag names.
| mixed | $tags | array of tags, or a single tag. |
| int | $case | case to use for returned value (default: lower case). Either TAG_CASE_LOWER (default) or TAG_CASE_ORIGINAL |
Definition at line 1027 of file lib.php.


| tag_page_type_list | ( | $ | pagetype, |
| $ | parentcontext, | ||
| $ | currentcontext | ||
| ) |
| 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.
| stdClass | $tagcorrelation |
Definition at line 908 of file lib.php.

| tag_record_count | ( | $ | record_type, |
| $ | tagid | ||
| ) |
| tag_record_tagged_with | ( | $ | record_type, |
| $ | record_id, | ||
| $ | tag | ||
| ) |
Determine if a record is tagged with a specific tag
| string | $record_type | the record type to look for |
| int | $record_id | the record id to look for |
| string | $tag | a tag name |
Definition at line 1077 of file lib.php.


| tag_rename | ( | $ | tagid, |
| $ | newrawname | ||
| ) |
| 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.
| string | $record_type | the type of record to tag ('post' for blogs, 'user' for users, 'tag' for tags, etc. |
| int | $record_id | the id of the record to tag |
| array | $tags | the array of tags to set on the record. If given an empty array, all tags will be removed. |
Definition at line 83 of file lib.php.


| tag_set_add | ( | $ | record_type, |
| $ | record_id, | ||
| $ | tag | ||
| ) |
Adds a tag to a record, without overwriting the current tags.
| string | $record_type | the type of record to tag ('post' for blogs, 'user' for users, etc. |
| int | $record_id | the id of the record to tag |
| string | $tag | the tag to add |
Definition at line 151 of file lib.php.


| tag_set_delete | ( | $ | record_type, |
| $ | record_id, | ||
| $ | tag | ||
| ) |
Removes a tag from a record, without overwriting other current tags.
| string | $record_type | the type of record to tag ('post' for blogs, 'user' for users, etc. |
| int | $record_id | the id of the record to tag |
| string | $tag | the tag to delete |
Definition at line 171 of file lib.php.

| tag_set_flag | ( | $ | tagids | ) |
| 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).
| string | $tagid | tagid to modify |
| string | $type | either 'default' or 'official' |
Definition at line 192 of file lib.php.

| tag_unset_flag | ( | $ | tagids | ) |