Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 4.0.x will end 8 May 2023 (12 months).
  • Bug fixes for security issues in 4.0.x will end 13 November 2023 (18 months).
  • PHP version: minimum PHP 7.3.0 Note: the minimum PHP version has increased since Moodle 3.10. PHP 7.4.x is also supported.

Differences Between: [Versions 310 and 400] [Versions 39 and 400] [Versions 400 and 401] [Versions 400 and 402] [Versions 400 and 403]

   1  <?php
   2  
   3  // This file is part of Moodle - http://moodle.org/
   4  //
   5  // Moodle is free software: you can redistribute it and/or modify
   6  // it under the terms of the GNU General Public License as published by
   7  // the Free Software Foundation, either version 3 of the License, or
   8  // (at your option) any later version.
   9  //
  10  // Moodle is distributed in the hope that it will be useful,
  11  // but WITHOUT ANY WARRANTY; without even the implied warranty of
  12  // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  13  // GNU General Public License for more details.
  14  //
  15  // You should have received a copy of the GNU General Public License
  16  // along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
  17  
  18  /**
  19   * Web services API documentation
  20   *
  21   * @package   webservice
  22   * @copyright 2011 Moodle Pty Ltd (http://moodle.com)
  23   * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  24   * @author Jerome Mouneyrac
  25   */
  26  require_once('../../config.php');
  27  require_once($CFG->libdir . '/adminlib.php');
  28  require_once($CFG->dirroot . '/webservice/lib.php');
  29  
  30  admin_externalpage_setup('webservicedocumentation');
  31  
  32  // get all the function descriptions
  33  $functions = $DB->get_records('external_functions', array(), 'name');
  34  $functiondescs = array();
  35  foreach ($functions as $function) {
  36      $functiondescs[$function->name] = external_api::external_function_info($function);
  37  }
  38  
  39  //display the documentation for all documented protocols,
  40  //regardless if they are activated or not
  41  $protocols = array();
  42  $protocols['rest'] = true;
  43  $protocols['xmlrpc'] = true;
  44  
  45  /// Check if we are in printable mode
  46  $printableformat = optional_param('print', false, PARAM_BOOL);
  47  
  48  /// OUTPUT
  49  echo $OUTPUT->header();
  50  
  51  $renderer = $PAGE->get_renderer('core', 'webservice');
  52  echo $renderer->documentation_html($functiondescs,
  53          $printableformat, $protocols, array(), $PAGE->url);
  54  
  55  /// trigger browser print operation
  56  if (!empty($printableformat)) {
  57      $PAGE->requires->js_function_call('window.print', array());
  58  }
  59  
  60  echo $OUTPUT->footer();
  61