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 related class for displaying information of a tag area.
  19   *
  20   * @package   core_tag
  21   * @copyright 2019 Juan Leyva <juan@moodle.com>
  22   * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  23   */
  24  
  25  namespace core_tag\external;
  26  
  27  defined('MOODLE_INTERNAL') || die();
  28  
  29  use core\external\exporter;
  30  use renderer_base;
  31  
  32  /**
  33   * Contains related class for displaying information of a tag area.
  34   *
  35   * @package   core_tag
  36   * @copyright 2019 Juan Leyva <juan@moodle.com>
  37   * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  38   */
  39  class tag_area_exporter extends exporter {
  40  
  41      /**
  42       * Return the list of properties.
  43       *
  44       * @return array
  45       */
  46      protected static function define_properties() {
  47          return [
  48              'id' => [
  49                  'type' => PARAM_INT,
  50                  'description' => 'Area id.',
  51              ],
  52              'component' => [
  53                  'type' => PARAM_COMPONENT,
  54                  'description' => 'Component the area is related to.',
  55              ],
  56              'itemtype' => [
  57                  'type' => PARAM_ALPHANUMEXT,
  58                  'description' => 'Type of item in the component.',
  59              ],
  60              'enabled' => [
  61                  'type' => PARAM_BOOL,
  62                  'description' => 'Whether this area is enabled.',
  63                  'default' => true,
  64              ],
  65              'tagcollid' => [
  66                  'type' => PARAM_INT,
  67                  'description' => 'The tag collection this are belongs to.',
  68              ],
  69              'callback' => [
  70                  'type' => PARAM_RAW,
  71                  'description' => 'Component callback for processing tags.',
  72                  'null' => NULL_ALLOWED,
  73              ],
  74              'callbackfile' => [
  75                  'type' => PARAM_RAW,
  76                  'description' => 'Component callback file.',
  77                  'null' => NULL_ALLOWED,
  78              ],
  79              'showstandard' => [
  80                  'type' => PARAM_INT,
  81                  'description' => 'Return whether to display only standard, only non-standard or both tags.',
  82                  'default' => 0,
  83              ],
  84              'multiplecontexts' => [
  85                  'type' => PARAM_BOOL,
  86                  'description' => 'Whether the tag area allows tag instances to be created in multiple contexts. ',
  87                  'default' => false,
  88              ],
  89          ];
  90      }
  91  
  92      protected static function define_related() {
  93          return array(
  94              'locked' => 'bool?'
  95          );
  96      }
  97  
  98      protected static function define_other_properties() {
  99          return array(
 100              'locked' => [
 101                  'type' => PARAM_BOOL,
 102                  'description' => 'Whether the area is locked.',
 103                  'null' => NULL_ALLOWED,
 104                  'default' => false,
 105                  'optional' => true,
 106              ]
 107          );
 108      }
 109  
 110      protected function get_other_values(renderer_base $output) {
 111  
 112          $values['locked'] = $this->related['locked'] ? true : false;
 113  
 114          return $values;
 115      }
 116  }