Search moodle.org's
Developer Documentation

See Release Notes
Long Term Support Release

  • Bug fixes for general core bugs in 4.1.x will end 13 November 2023 (12 months).
  • Bug fixes for security issues in 4.1.x will end 10 November 2025 (36 months).
  • PHP version: minimum PHP 7.4.0 Note: minimum PHP version has increased since Moodle 4.0. PHP 8.0.x is supported too.
   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_areas_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 available tag areas 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_areas_table extends html_table {
  35  
  36      /**
  37       * Constructor
  38       *
  39       * @param string|moodle_url $pageurl
  40       */
  41      public function __construct($pageurl) {
  42          global $OUTPUT;
  43          parent::__construct();
  44  
  45          $this->attributes['class'] = 'generaltable tag-areas-table';
  46  
  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')
  54          );
  55  
  56          $this->data = array();
  57          $this->rowclasses = array();
  58  
  59          $tagareas = core_tag_area::get_areas();
  60          $tagcollections = core_tag_collection::get_collections_menu(true);
  61          $tagcollectionsall = core_tag_collection::get_collections_menu();
  62  
  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')
  67          );
  68  
  69          foreach ($tagareas as $itemtype => $it) {
  70              foreach ($it as $component => $record) {
  71                  $areaname = core_tag_area::display_name($record->component, $record->itemtype);
  72  
  73                  $tmpl = new \core_tag\output\tagareaenabled($record);
  74                  $enabled = $OUTPUT->render_from_template('core/inplace_editable', $tmpl->export_for_template($OUTPUT));
  75  
  76                  $tmpl = new \core_tag\output\tagareacollection($record);
  77                  $collectionselect = $OUTPUT->render_from_template('core/inplace_editable', $tmpl->export_for_template($OUTPUT));
  78  
  79                  $tmpl = new \core_tag\output\tagareashowstandard($record);
  80                  $showstandardselect = $OUTPUT->render_from_template('core/inplace_editable', $tmpl->export_for_template($OUTPUT));
  81  
  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
  89                  );
  90                  $this->rowclasses[] = $record->enabled ? '' : 'dimmed_text';
  91              }
  92          }
  93  
  94      }
  95  
  96  }