Moodle APIs  3.8
Moodle 3.8.6 (Build: 20201109)
Static Public Member Functions | Static Public Attributes | List of all members
core_tag_collection Class Reference

Class to manage tag collections. More...

Static Public Member Functions

static change_sortorder ($tagcoll, $direction)
 Moves the tag collection in the list one position up or down. More...
 
static cleanup_unused_tags ($collections=null)
 Permanently deletes all non-standard tags that no longer have any instances pointing to them. More...
 
static cloud_sort ($a, $b)
 This function is used to sort the tags in the cloud. More...
 
static create ($data)
 Creates a new tag collection. More...
 
static delete ($tagcoll)
 Deletes a custom tag collection. More...
 
static display_name ($record)
 Returns formatted name of the tag collection. More...
 
static get_areas ($tagcollid)
 Returns all tag areas in the given tag collection. More...
 
static get_areas_names ($tagcollid, $enabledonly=true)
 Returns the list of names of areas (enabled only) that are in this collection. More...
 
static get_by_id ($tagcollid)
 Returns the tag collection object. More...
 
static get_collections ($onlysearchable=false)
 Returns the list of tag collections defined in the system. More...
 
static get_collections_menu ($unlockedonly=false, $onlysearchable=false, $selectalllabel=null)
 Returns the list of existing tag collections as id=>name. More...
 
static get_default ()
 Returns id of the default tag collection. More...
 
static get_tag_cloud ($tagcollid, $isstandard=false, $limit=150, $sort='name', $search='', $fromctx=0, $ctx=0, $rec=1)
 Returns the list of tags with number of items tagged. More...
 
static update ($tagcoll, $data)
 Updates the tag collection information. More...
 

Static Public Attributes

static string $cloudsortfield = 'name'
 used for function cloud_sort()
 

Detailed Description

Class to manage tag collections.

License
http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later

Member Function Documentation

◆ change_sortorder()

static core_tag_collection::change_sortorder (   $tagcoll,
  $direction 
)
static

Moves the tag collection in the list one position up or down.

Parameters
stdClass$tagcollexisting record in DB table tag_coll
int$directionmove direction: +1 or -1
Return values
bool

◆ cleanup_unused_tags()

static core_tag_collection::cleanup_unused_tags (   $collections = null)
static

Permanently deletes all non-standard tags that no longer have any instances pointing to them.

Parameters
array$collectionsoptional list of tag collections ids to cleanup

◆ cloud_sort()

static core_tag_collection::cloud_sort (   $a,
  $b 
)
static

This function is used to sort the tags in the cloud.

Parameters
string$aTag name to compare against $b
string$bTag name to compare against $a
Return values
intThe result of the comparison/validation 1, 0 or -1

◆ create()

static core_tag_collection::create (   $data)
static

Creates a new tag collection.

Parameters
stdClass$datadata from form core_tag_collection_form
Return values
int|falseid of created tag collection or false if failed

◆ delete()

static core_tag_collection::delete (   $tagcoll)
static

Deletes a custom tag collection.

Parameters
stdClass$tagcollexisting record in DB table tag_coll
Return values
boolwether the tag collection was deleted

◆ display_name()

static core_tag_collection::display_name (   $record)
static

Returns formatted name of the tag collection.

Parameters
stdClass$recordrecord from DB table tag_coll
Return values
string

◆ get_areas()

static core_tag_collection::get_areas (   $tagcollid)
static

Returns all tag areas in the given tag collection.

Parameters
int$tagcollid
Return values
array

◆ get_areas_names()

static core_tag_collection::get_areas_names (   $tagcollid,
  $enabledonly = true 
)
static

Returns the list of names of areas (enabled only) that are in this collection.

Parameters
int$tagcollid
Return values
array

◆ get_by_id()

static core_tag_collection::get_by_id (   $tagcollid)
static

Returns the tag collection object.

Parameters
int$tagcollid
Return values
stdClass

◆ get_collections()

static core_tag_collection::get_collections (   $onlysearchable = false)
static

Returns the list of tag collections defined in the system.

Parameters
bool$onlysearchableonly return collections that can be searched.
Return values
arrayarray of objects where each object has properties: id, name, isdefault, itemtypes, sortorder

◆ get_collections_menu()

static core_tag_collection::get_collections_menu (   $unlockedonly = false,
  $onlysearchable = false,
  $selectalllabel = null 
)
static

Returns the list of existing tag collections as id=>name.

Parameters
bool$unlockedonly
bool$onlysearchable
string$selectalllabel
Return values
array

◆ get_default()

static core_tag_collection::get_default ( )
static

Returns id of the default tag collection.

Return values
int

◆ get_tag_cloud()

static core_tag_collection::get_tag_cloud (   $tagcollid,
  $isstandard = false,
  $limit = 150,
  $sort = 'name',
  $search = '',
  $fromctx = 0,
  $ctx = 0,
  $rec = 1 
)
static

Returns the list of tags with number of items tagged.

Parameters
int$tagcollid
null | bool$isstandardreturn only standard tags
int$limitmaximum number of tags to retrieve, tags are sorted by the instance count descending here regardless of $sort parameter
string$sortsort order for display, default 'name' - tags will be sorted after they are retrieved
string$searchsearch string
int$fromctxcontext id where this tag cloud is displayed
int$ctxonly retrieve tag instances in this context
int$recretrieve tag instances in the $ctx context and it's children (default 1)
Return values
core_tag

◆ update()

static core_tag_collection::update (   $tagcoll,
  $data 
)
static

Updates the tag collection information.

Parameters
stdClass$tagcollexisting record in DB table tag_coll
stdClass$datadata to update
Return values
boolwether the record was updated

The documentation for this class was generated from the following file: