1 |
efrain |
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 |
|
|
|
27 |
use core_external\external_api;
|
|
|
28 |
|
|
|
29 |
require_once('../../config.php');
|
|
|
30 |
require_once($CFG->libdir . '/adminlib.php');
|
|
|
31 |
require_once($CFG->dirroot . '/webservice/lib.php');
|
|
|
32 |
|
|
|
33 |
admin_externalpage_setup('webservicedocumentation');
|
|
|
34 |
|
|
|
35 |
// TODO: MDL-76078 - Incorrect inter-communication, core cannot have plugin dependencies like this.
|
|
|
36 |
|
|
|
37 |
//display the documentation for all documented protocols,
|
|
|
38 |
//regardless if they are activated or not
|
|
|
39 |
$protocols = array();
|
|
|
40 |
$protocols['rest'] = true;
|
|
|
41 |
$protocols['xmlrpc'] = true;
|
|
|
42 |
|
|
|
43 |
/// Check if we are in printable mode
|
|
|
44 |
$printableformat = optional_param('print', false, PARAM_BOOL);
|
|
|
45 |
|
|
|
46 |
/// OUTPUT
|
|
|
47 |
echo $OUTPUT->header();
|
|
|
48 |
|
|
|
49 |
// Get all the function descriptions.
|
|
|
50 |
$functions = $DB->get_records('external_functions', [], 'name');
|
|
|
51 |
$functiondescs = [];
|
|
|
52 |
foreach ($functions as $function) {
|
|
|
53 |
|
|
|
54 |
// Skip invalid or otherwise incorrectly defined functions, otherwise the entire page is rendered inaccessible.
|
|
|
55 |
try {
|
|
|
56 |
$functiondescs[$function->name] = external_api::external_function_info($function);
|
|
|
57 |
} catch (Throwable $exception) {
|
|
|
58 |
echo $OUTPUT->notification($exception->getMessage(), \core\output\notification::NOTIFY_ERROR);
|
|
|
59 |
}
|
|
|
60 |
}
|
|
|
61 |
|
|
|
62 |
$renderer = $PAGE->get_renderer('core', 'webservice');
|
|
|
63 |
echo $renderer->documentation_html($functiondescs,
|
|
|
64 |
$printableformat, $protocols, array(), $PAGE->url);
|
|
|
65 |
|
|
|
66 |
/// trigger browser print operation
|
|
|
67 |
if (!empty($printableformat)) {
|
|
|
68 |
$PAGE->requires->js_function_call('window.print', array());
|
|
|
69 |
}
|
|
|
70 |
|
|
|
71 |
echo $OUTPUT->footer();
|
|
|
72 |
|