Merge branch 'MDL-79830' of https://github.com/paulholden/moodle
[moodle.git] / tag / lib.php
bloba0c4027b6e34ef0fcf0c7462600cfcb06d3ed034
1 <?php
2 // This file is part of Moodle - http://moodle.org/
3 //
4 // Moodle is free software: you can redistribute it and/or modify
5 // it under the terms of the GNU General Public License as published by
6 // the Free Software Foundation, either version 3 of the License, or
7 // (at your option) any later version.
8 //
9 // Moodle is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU General Public License for more details.
14 // You should have received a copy of the GNU General Public License
15 // along with Moodle. If not, see <http://www.gnu.org/licenses/>.
17 /**
18 * Functions for component core_tag
20 * To set or get item tags refer to the class {@link core_tag_tag}
22 * @package core_tag
23 * @copyright 2007 Luiz Cruz <luiz.laydner@gmail.com>
24 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
27 use core_external\external_api;
29 /**
30 * Return a list of page types
32 * @package core_tag
33 * @param string $pagetype current page type
34 * @param stdClass $parentcontext Block's parent context
35 * @param stdClass $currentcontext Current context of block
37 function tag_page_type_list($pagetype, $parentcontext, $currentcontext) {
38 return array(
39 'tag-*'=>get_string('page-tag-x', 'tag'),
40 'tag-index'=>get_string('page-tag-index', 'tag'),
41 'tag-search'=>get_string('page-tag-search', 'tag'),
42 'tag-manage'=>get_string('page-tag-manage', 'tag')
46 /**
47 * Implements callback inplace_editable() allowing to edit values in-place
49 * @param string $itemtype
50 * @param int $itemid
51 * @param mixed $newvalue
52 * @return \core\output\inplace_editable
54 function core_tag_inplace_editable($itemtype, $itemid, $newvalue) {
55 external_api::validate_context(context_system::instance());
56 if ($itemtype === 'tagname') {
57 return \core_tag\output\tagname::update($itemid, $newvalue);
58 } else if ($itemtype === 'tagareaenable') {
59 return \core_tag\output\tagareaenabled::update($itemid, $newvalue);
60 } else if ($itemtype === 'tagareacollection') {
61 return \core_tag\output\tagareacollection::update($itemid, $newvalue);
62 } else if ($itemtype === 'tagareashowstandard') {
63 return \core_tag\output\tagareashowstandard::update($itemid, $newvalue);
64 } else if ($itemtype === 'tagcollname') {
65 return \core_tag\output\tagcollname::update($itemid, $newvalue);
66 } else if ($itemtype === 'tagcollsearchable') {
67 return \core_tag\output\tagcollsearchable::update($itemid, $newvalue);
68 } else if ($itemtype === 'tagflag') {
69 return \core_tag\output\tagflag::update($itemid, $newvalue);
70 } else if ($itemtype === 'tagisstandard') {
71 return \core_tag\output\tagisstandard::update($itemid, $newvalue);