Merge branch 'MDL-80753-main' of https://github.com/andrewnicols/moodle
[moodle.git] / tag / classes / areas_table.php
blob63484c580f8cd2a1fe86d855acf983a14a73477a
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 * Contains class core_tag_areas_table
20 * @package core_tag
21 * @copyright 2015 Marina Glancy
22 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
25 defined('MOODLE_INTERNAL') || die();
27 /**
28 * Table with the list of available tag areas for "Manage tags" page.
30 * @package core_tag
31 * @copyright 2015 Marina Glancy
32 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
34 class core_tag_areas_table extends html_table {
36 /**
37 * Constructor
39 * @param string|moodle_url $pageurl
41 public function __construct($pageurl) {
42 global $OUTPUT;
43 parent::__construct();
45 $this->attributes['class'] = 'generaltable tag-areas-table';
47 $this->head = array(
48 get_string('tagareaname', 'core_tag'),
49 get_string('component', 'tag'),
50 get_string('tagareaenabled', 'core_tag'),
51 get_string('tagcollection', 'tag'),
52 get_string('showstandard', 'tag') .
53 $OUTPUT->help_icon('showstandard', 'tag')
56 $this->data = array();
57 $this->rowclasses = array();
59 $tagareas = core_tag_area::get_areas();
60 $tagcollections = core_tag_collection::get_collections_menu(true);
61 $tagcollectionsall = core_tag_collection::get_collections_menu();
63 $standardchoices = array(
64 core_tag_tag::BOTH_STANDARD_AND_NOT => get_string('standardsuggest', 'tag'),
65 core_tag_tag::STANDARD_ONLY => get_string('standardforce', 'tag'),
66 core_tag_tag::HIDE_STANDARD => get_string('standardhide', 'tag')
69 foreach ($tagareas as $itemtype => $it) {
70 foreach ($it as $component => $record) {
71 $areaname = core_tag_area::display_name($record->component, $record->itemtype);
73 $tmpl = new \core_tag\output\tagareaenabled($record);
74 $enabled = $OUTPUT->render_from_template('core/inplace_editable', $tmpl->export_for_template($OUTPUT));
76 $tmpl = new \core_tag\output\tagareacollection($record);
77 $collectionselect = $OUTPUT->render_from_template('core/inplace_editable', $tmpl->export_for_template($OUTPUT));
79 $tmpl = new \core_tag\output\tagareashowstandard($record);
80 $showstandardselect = $OUTPUT->render_from_template('core/inplace_editable', $tmpl->export_for_template($OUTPUT));
82 $this->data[] = array(
83 $areaname,
84 ($record->component === 'core' || preg_match('/^core_/', $record->component)) ?
85 get_string('coresystem') : get_string('pluginname', $record->component),
86 $enabled,
87 $collectionselect,
88 $showstandardselect
90 $this->rowclasses[] = $record->enabled ? '' : 'dimmed_text';