Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 4.3.x will end 7 October 2024 (12 months).
  • Bug fixes for security issues in 4.3.x will end 21 April 2025 (18 months).
  • PHP version: minimum PHP 8.0.0 Note: minimum PHP version has increased since Moodle 4.1. PHP 8.2.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  namespace core_search\external;
  18  
  19  use core\external\exporter;
  20  
  21  /**
  22   * Contains related class for displaying information of a search result.
  23   *
  24   * @package   core_search
  25   * @since     Moodle 4.3
  26   */
  27  class document_exporter extends exporter {
  28  
  29      /**
  30       * Return the list of properties.
  31       *
  32       * @return array
  33       */
  34      protected static function define_properties() {
  35          return [
  36              'itemid' => [
  37                  'type' => PARAM_INT,
  38                  'description' => 'unique id in the search area scope',
  39              ],
  40              'componentname' => [
  41                  'type' => PARAM_ALPHANUMEXT,
  42                  'description' => 'component name',
  43              ],
  44              'areaname' => [
  45                  'type' => PARAM_ALPHANUMEXT,
  46                  'description' => 'search area name',
  47              ],
  48              'courseurl' => [
  49                  'type' => PARAM_URL,
  50                  'description' => 'result course url',
  51              ],
  52              'coursefullname' => [
  53                  'type' => PARAM_RAW,
  54                  'description' => 'result course fullname',
  55              ],
  56              'timemodified' => [
  57                  'type' => PARAM_INT,
  58                  'description' => 'result modified time',
  59              ],
  60              'title' => [
  61                  'type' => PARAM_RAW,
  62                  'description' => 'result title',
  63              ],
  64              'docurl' => [
  65                  'type' => PARAM_URL,
  66                  'description' => 'result url',
  67              ],
  68              'iconurl' => [
  69                  'type' => PARAM_URL,
  70                  'description' => 'icon url',
  71                  'optional' => true,
  72                  'default' => '',
  73                  'null' => NULL_ALLOWED,
  74              ],
  75              'content' => [
  76                  'type' => PARAM_RAW,
  77                  'description' => 'result contents',
  78                  'optional' => true,
  79                  'default' => '',
  80                  'null' => NULL_ALLOWED,
  81              ],
  82              'contextid' => [
  83                  'type' => PARAM_INT,
  84                  'description' => 'result context id',
  85              ],
  86              'contexturl' => [
  87                  'type' => PARAM_URL,
  88                  'description' => 'result context url',
  89              ],
  90              'description1' => [
  91                  'type' => PARAM_RAW,
  92                  'description' => 'extra result contents, depends on the search area',
  93                  'optional' => true,
  94                  'default' => '',
  95                  'null' => NULL_ALLOWED,
  96              ],
  97              'description2' => [
  98                  'type' => PARAM_RAW,
  99                  'description' => 'extra result contents, depends on the search area',
 100                  'optional' => true,
 101                  'default' => '',
 102                  'null' => NULL_ALLOWED,
 103              ],
 104              'multiplefiles' => [
 105                  'type' => PARAM_INT,
 106                  'description' => 'whether multiple files are returned or not',
 107                  'optional' => true,
 108              ],
 109              'filenames' => [
 110                  'type' => PARAM_RAW,
 111                  'description' => 'result file names if present',
 112                  'muultiple' => true,
 113                  'optional' => true,
 114              ],
 115              'filename' => [
 116                  'type' => PARAM_RAW,
 117                  'description' => 'result file name if present',
 118                  'optional' => true,
 119              ],
 120              'userid' => [
 121                  'type' => PARAM_INT,
 122                  'description' => 'user id',
 123                  'optional' => true,
 124              ],
 125              'userurl' => [
 126                  'type' => PARAM_URL,
 127                  'description' => 'user url',
 128                  'optional' => true,
 129              ],
 130              'userfullname' => [
 131                  'type' => PARAM_RAW,
 132                  'description' => 'user fullname',
 133                  'optional' => true,
 134              ],
 135              'textformat' => [
 136                  'type' => PARAM_INT,
 137                  'description' => 'text fields format, it is the same for all of them',
 138              ]
 139          ];
 140      }
 141  }