Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 4.0.x will end 8 May 2023 (12 months).
  • Bug fixes for security issues in 4.0.x will end 13 November 2023 (18 months).
  • PHP version: minimum PHP 7.3.0 Note: the minimum PHP version has increased since Moodle 3.10. PHP 7.4.x is also supported.

Differences Between: [Versions 400 and 402] [Versions 400 and 403]

Class to manage tag collections

Copyright: 2015 Marina Glancy
License: http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
File Size: 418 lines (15 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 0 files

Defines 1 class

core_tag_collection:: (14 methods):
  get_collections()
  get_by_id()
  get_collections_menu()
  get_default()
  display_name()
  get_areas()
  get_areas_names()
  create()
  update()
  delete()
  change_sortorder()
  cleanup_unused_tags()
  get_tag_cloud()
  cloud_sort()


Class: core_tag_collection  - X-Ref

Class to manage tag collections

get_collections($onlysearchable = false)   X-Ref
Returns the list of tag collections defined in the system.

return: array array of objects where each object has properties: id, name, isdefault, itemtypes, sortorder
param: bool $onlysearchable only return collections that can be searched.

get_by_id($tagcollid)   X-Ref
Returns the tag collection object

return: stdClass
param: int $tagcollid

get_collections_menu($unlockedonly = false, $onlysearchable = false,$selectalllabel = null)   X-Ref
Returns the list of existing tag collections as id=>name

return: array
param: bool $unlockedonly
param: bool $onlysearchable
param: string $selectalllabel

get_default()   X-Ref
Returns id of the default tag collection

return: int

display_name($record)   X-Ref
Returns formatted name of the tag collection

return: string
param: stdClass $record record from DB table tag_coll

get_areas($tagcollid)   X-Ref
Returns all tag areas in the given tag collection

return: array
param: int $tagcollid

get_areas_names($tagcollid, $enabledonly = true)   X-Ref
Returns the list of names of areas (enabled only) that are in this collection.

return: array
param: int $tagcollid

create($data)   X-Ref
Creates a new tag collection

return: int|false id of created tag collection or false if failed
param: stdClass $data data from form core_tag_collection_form

update($tagcoll, $data)   X-Ref
Updates the tag collection information

return: bool wether the record was updated
param: stdClass $tagcoll existing record in DB table tag_coll
param: stdClass $data data to update

delete($tagcoll)   X-Ref
Deletes a custom tag collection

return: bool wether the tag collection was deleted
param: stdClass $tagcoll existing record in DB table tag_coll

change_sortorder($tagcoll, $direction)   X-Ref
Moves the tag collection in the list one position up or down

return: bool
param: stdClass $tagcoll existing record in DB table tag_coll
param: int $direction move direction: +1 or -1

cleanup_unused_tags($collections = null)   X-Ref
Permanently deletes all non-standard tags that no longer have any instances pointing to them

param: array $collections optional list of tag collections ids to cleanup

get_tag_cloud($tagcollid, $isstandard = false, $limit = 150, $sort = 'name',$search = '', $fromctx = 0, $ctx = 0, $rec = 1)   X-Ref
Returns the list of tags with number of items tagged

return: \core_tag\output\tagcloud
param: int $tagcollid
param: null|bool $isstandard return only standard tags
param: int $limit maximum number of tags to retrieve, tags are sorted by the instance count
param: string $sort sort order for display, default 'name' - tags will be sorted after they are retrieved
param: string $search search string
param: int $fromctx context id where this tag cloud is displayed
param: int $ctx only retrieve tag instances in this context
param: int $rec retrieve tag instances in the $ctx context and it's children (default 1)

cloud_sort($a, $b)   X-Ref
This function is used to sort the tags in the cloud.

return: int    The result of the comparison/validation 1, 0 or -1
param: string $a Tag name to compare against $b
param: string $b Tag name to compare against $a