Skip to content

Commit f63b618

Browse files
authored
Merge pull request #2398 from dpalou/MOBILE-3411
Mobile 3411
2 parents 68a8003 + 857f3da commit f63b618

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+2038
-203
lines changed

scripts/get_ws_changes.php

Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
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+
* Script for detecting changes in a WS params or return data, version by version.
19+
*
20+
* The first parameter (required) is the path to the Moodle installation to use.
21+
* The second parameter (required) is the name to the WS to convert.
22+
* The third parameter (optional) is a number: 1 to convert the params structure,
23+
* 0 to convert the returns structure. Defaults to 0.
24+
*/
25+
26+
if (!isset($argv[1])) {
27+
echo "ERROR: Please pass the path to the folder containing the Moodle installations as the first parameter.\n";
28+
die();
29+
}
30+
31+
32+
if (!isset($argv[2])) {
33+
echo "ERROR: Please pass the WS name as the second parameter.\n";
34+
die();
35+
}
36+
37+
define('CLI_SCRIPT', true);
38+
require_once('ws_to_ts_functions.php');
39+
40+
$versions = array('master', '38', '37', '36', '35', '34', '33', '32', '31');
41+
42+
$moodlespath = $argv[1];
43+
$wsname = $argv[2];
44+
$useparams = !!(isset($argv[3]) && $argv[3]);
45+
$pathseparator = '/';
46+
47+
// Get the path to the script.
48+
$index = strrpos(__FILE__, $pathseparator);
49+
if ($index === false) {
50+
$pathseparator = '\\';
51+
$index = strrpos(__FILE__, $pathseparator);
52+
}
53+
$scriptfolder = substr(__FILE__, 0, $index);
54+
$scriptpath = concatenate_paths($scriptfolder, 'get_ws_structure.php', $pathseparator);
55+
56+
$previousstructure = null;
57+
$previousversion = null;
58+
$libsloaded = false;
59+
60+
foreach ($versions as $version) {
61+
$moodlepath = concatenate_paths($moodlespath, 'stable_' . $version, $pathseparator);
62+
63+
if (!$libsloaded) {
64+
$libsloaded = true;
65+
66+
require($moodlepath . '/config.php');
67+
require($CFG->dirroot . '/webservice/lib.php');
68+
}
69+
70+
// Get the structure in this Moodle version.
71+
$structure = shell_exec("php $scriptpath $moodlepath $wsname " . ($useparams ? 'true' : ''));
72+
73+
if (strpos($structure, 'ERROR:') === 0) {
74+
echo "WS not found in version $version. Stop.\n";
75+
break;
76+
}
77+
78+
$structure = unserialize($structure);
79+
80+
if ($previousstructure != null) {
81+
echo "*** Check changes from version $version to $previousversion ***\n";
82+
83+
$messages = detect_ws_changes($previousstructure, $structure);
84+
85+
if (count($messages) > 0) {
86+
$haschanged = true;
87+
88+
foreach($messages as $message) {
89+
echo "$message\n";
90+
}
91+
} else {
92+
echo "No changes found.\n";
93+
}
94+
echo "\n";
95+
}
96+
97+
$previousstructure = $structure;
98+
$previousversion = $version;
99+
}

scripts/get_ws_structure.php

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
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+
* Script for getting the PHP structure of a WS returns or params.
19+
*
20+
* The first parameter (required) is the path to the Moodle installation to use.
21+
* The second parameter (required) is the name to the WS to convert.
22+
* The third parameter (optional) is a number: 1 to convert the params structure,
23+
* 0 to convert the returns structure. Defaults to 0.
24+
*/
25+
26+
if (!isset($argv[1])) {
27+
echo "ERROR: Please pass the Moodle path as the first parameter.\n";
28+
die();
29+
}
30+
31+
32+
if (!isset($argv[2])) {
33+
echo "ERROR: Please pass the WS name as the second parameter.\n";
34+
die();
35+
}
36+
37+
$moodlepath = $argv[1];
38+
$wsname = $argv[2];
39+
$useparams = !!(isset($argv[3]) && $argv[3]);
40+
41+
define('CLI_SCRIPT', true);
42+
43+
require($moodlepath . '/config.php');
44+
require($CFG->dirroot . '/webservice/lib.php');
45+
require_once('ws_to_ts_functions.php');
46+
47+
$structure = get_ws_structure($wsname, $useparams);
48+
49+
if ($structure === false) {
50+
echo "ERROR: The WS wasn't found in this Moodle installation.\n";
51+
die();
52+
}
53+
54+
remove_default_closures($structure);
55+
echo serialize($structure);

scripts/get_ws_ts.php

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
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+
* Script for converting a PHP WS structure to a TS type.
19+
*
20+
* The first parameter (required) is the path to the Moodle installation to use.
21+
* The second parameter (required) is the name to the WS to convert.
22+
* The third parameter (optional) is the name to put to the TS type. Defaults to "TypeName".
23+
* The fourth parameter (optional) is a number: 1 to convert the params structure,
24+
* 0 to convert the returns structure. Defaults to 0.
25+
*/
26+
27+
if (!isset($argv[1])) {
28+
echo "ERROR: Please pass the Moodle path as the first parameter.\n";
29+
die();
30+
}
31+
32+
33+
if (!isset($argv[2])) {
34+
echo "ERROR: Please pass the WS name as the second parameter.\n";
35+
die();
36+
}
37+
38+
$moodlepath = $argv[1];
39+
$wsname = $argv[2];
40+
$typename = isset($argv[3]) ? $argv[3] : 'TypeName';
41+
$useparams = !!(isset($argv[4]) && $argv[4]);
42+
43+
define('CLI_SCRIPT', true);
44+
45+
require($moodlepath . '/config.php');
46+
require($CFG->dirroot . '/webservice/lib.php');
47+
require_once('ws_to_ts_functions.php');
48+
49+
$structure = get_ws_structure($wsname, $useparams);
50+
51+
if ($structure === false) {
52+
echo "ERROR: The WS wasn't found in this Moodle installation.\n";
53+
die();
54+
}
55+
56+
if ($useparams) {
57+
$description = "Params of WS $wsname.";
58+
} else {
59+
$description = "Result of WS $wsname.";
60+
}
61+
62+
echo get_ts_doc(null, $description, '') . "export type $typename = " . convert_to_ts(null, $structure, $useparams) . ";\n";

scripts/langindex.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -659,6 +659,12 @@
659659
"addon.mod_glossary.noentriesfound": "local_moodlemobileapp",
660660
"addon.mod_glossary.searchquery": "local_moodlemobileapp",
661661
"addon.mod_glossary.tagarea_glossary_entries": "glossary",
662+
"addon.mod_h5pactivity.downloadh5pfile": "local_moodlemobileapp",
663+
"addon.mod_h5pactivity.errorgetactivity": "local_moodlemobileapp",
664+
"addon.mod_h5pactivity.filestatenotdownloaded": "local_moodlemobileapp",
665+
"addon.mod_h5pactivity.filestateoutdated": "local_moodlemobileapp",
666+
"addon.mod_h5pactivity.modulenameplural": "h5pactivity",
667+
"addon.mod_h5pactivity.offlinedisabledwarning": "local_moodlemobileapp",
662668
"addon.mod_imscp.deploymenterror": "imscp",
663669
"addon.mod_imscp.modulenameplural": "imscp",
664670
"addon.mod_imscp.showmoduledescription": "local_moodlemobileapp",
@@ -2033,6 +2039,7 @@
20332039
"core.sort": "moodle",
20342040
"core.sortby": "moodle",
20352041
"core.start": "grouptool",
2042+
"core.storingfiles": "local_moodlemobileapp",
20362043
"core.strftimedate": "langconfig",
20372044
"core.strftimedatefullshort": "langconfig",
20382045
"core.strftimedateshort": "langconfig",

0 commit comments

Comments
 (0)