See Release Notes
Long Term Support Release
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. 13 // 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/>. 16 17 /** 18 * Contains class core_tag_collections_table 19 * 20 * @package core_tag 21 * @copyright 2015 Marina Glancy 22 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 23 */ 24 25 defined('MOODLE_INTERNAL') || die(); 26 27 /** 28 * Table with the list of tag collections for "Manage tags" page. 29 * 30 * @package core_tag 31 * @copyright 2015 Marina Glancy 32 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 33 */ 34 class core_tag_collections_table extends html_table { 35 36 /** 37 * Constructor 38 * @param string|moodle_url $pageurl 39 */ 40 public function __construct($pageurl) { 41 global $OUTPUT; 42 parent::__construct(); 43 44 $this->attributes['class'] = 'generaltable tag-collections-table'; 45 46 $this->head = array( 47 get_string('name'), 48 get_string('component', 'tag'), 49 get_string('tagareas', 'tag'), 50 get_string('searchable', 'tag') . $OUTPUT->help_icon('searchable', 'tag'), 51 '' 52 ); 53 54 $this->data = array(); 55 56 $tagcolls = core_tag_collection::get_collections(); 57 $idx = 0; 58 foreach ($tagcolls as $tagcoll) { 59 $actions = ''; 60 $name = core_tag_collection::display_name($tagcoll); 61 $url = new moodle_url($pageurl, array('sesskey' => sesskey(), 'tc' => $tagcoll->id)); 62 if (!$tagcoll->isdefault) { 63 // Move up. 64 if ($idx > 1) { 65 $url->param('action', 'collmoveup'); 66 $actions .= $OUTPUT->action_icon($url, new pix_icon('t/up', get_string('moveup')), null, 67 array('class' => 'action-icon action_moveup')); 68 } 69 // Move down. 70 if ($idx < count($tagcolls) - 1) { 71 $url->param('action', 'collmovedown'); 72 $actions .= $OUTPUT->action_icon($url, new pix_icon('t/down', get_string('movedown')), null, 73 array('class' => 'action-icon action_movedown')); 74 } 75 } 76 if (!$tagcoll->isdefault && empty($tagcoll->component)) { 77 // Delete. 78 $url->param('action', 'colldelete'); 79 $actions .= $OUTPUT->action_icon('#', new pix_icon('t/delete', get_string('delete')), null, 80 array('data-url' => $url->out(false), 'data-collname' => $name, 81 'class' => 'action-icon action_delete')); 82 } 83 $component = ''; 84 if ($tagcoll->component) { 85 $component = ($tagcoll->component === 'core' || preg_match('/^core_/', $tagcoll->component)) ? 86 get_string('coresystem') : get_string('pluginname', $tagcoll->component); 87 } 88 $allareas = core_tag_collection::get_areas_names(null, false); 89 $validareas = core_tag_collection::get_areas_names($tagcoll->id); 90 $areaslist = array_map(function($key) use ($allareas, $validareas) { 91 return "<li data-areaid=\"{$key}\" " . 92 (array_key_exists($key, $validareas) ? "" : "style=\"display:none;\"") . 93 ">{$allareas[$key]}</li>"; 94 }, array_keys($allareas)); 95 $displayname = new \core_tag\output\tagcollname($tagcoll); 96 $searchable = new \core_tag\output\tagcollsearchable($tagcoll); 97 $this->data[] = array( 98 $displayname->render($OUTPUT), 99 $component, 100 "<ul data-collectionid=\"{$tagcoll->id}\">" . join('', $areaslist) . '</ul>', 101 $searchable->render($OUTPUT), 102 $actions); 103 $idx++; 104 } 105 106 } 107 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body