1 |
efrain |
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_external;
|
|
|
18 |
|
|
|
19 |
/**
|
|
|
20 |
* External structure representing a set of files.
|
|
|
21 |
*
|
|
|
22 |
* @package core_external
|
|
|
23 |
* @copyright 2016 Juan Leyva
|
|
|
24 |
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
|
|
25 |
*/
|
|
|
26 |
class external_files extends external_multiple_structure {
|
|
|
27 |
/**
|
|
|
28 |
* Constructor
|
|
|
29 |
* @param string $desc Description for the multiple structure.
|
|
|
30 |
* @param int $required The type of value (VALUE_REQUIRED OR VALUE_OPTIONAL).
|
|
|
31 |
*/
|
|
|
32 |
public function __construct($desc = 'List of files.', $required = VALUE_REQUIRED) {
|
|
|
33 |
parent::__construct(
|
|
|
34 |
new external_single_structure([
|
|
|
35 |
'filename' => new external_value(PARAM_FILE, 'File name.', VALUE_OPTIONAL),
|
|
|
36 |
'filepath' => new external_value(PARAM_PATH, 'File path.', VALUE_OPTIONAL),
|
|
|
37 |
'filesize' => new external_value(PARAM_INT, 'File size.', VALUE_OPTIONAL),
|
|
|
38 |
'fileurl' => new external_value(PARAM_URL, 'Downloadable file url.', VALUE_OPTIONAL),
|
|
|
39 |
'timemodified' => new external_value(PARAM_INT, 'Time modified.', VALUE_OPTIONAL),
|
|
|
40 |
'mimetype' => new external_value(PARAM_RAW, 'File mime type.', VALUE_OPTIONAL),
|
|
|
41 |
'isexternalfile' => new external_value(PARAM_BOOL, 'Whether is an external file.', VALUE_OPTIONAL),
|
|
|
42 |
'repositorytype' => new external_value(PARAM_PLUGIN, 'The repository type for external files.', VALUE_OPTIONAL),
|
|
|
43 |
'icon' => new external_value(PARAM_RAW,
|
|
|
44 |
'The relative path to the relevant file type icon based on the file\'s mime type.', VALUE_OPTIONAL),
|
|
|
45 |
], 'File.'),
|
|
|
46 |
$desc,
|
|
|
47 |
$required,
|
|
|
48 |
);
|
|
|
49 |
}
|
|
|
50 |
|
|
|
51 |
/**
|
|
|
52 |
* Return the properties ready to be used by an exporter.
|
|
|
53 |
*
|
|
|
54 |
* @return array properties
|
|
|
55 |
* @since Moodle 3.3
|
|
|
56 |
*/
|
|
|
57 |
public static function get_properties_for_exporter() {
|
|
|
58 |
return [
|
|
|
59 |
'filename' => [
|
|
|
60 |
'type' => PARAM_FILE,
|
|
|
61 |
'description' => 'File name.',
|
|
|
62 |
'optional' => true,
|
|
|
63 |
'null' => NULL_NOT_ALLOWED,
|
|
|
64 |
],
|
|
|
65 |
'filepath' => [
|
|
|
66 |
'type' => PARAM_PATH,
|
|
|
67 |
'description' => 'File path.',
|
|
|
68 |
'optional' => true,
|
|
|
69 |
'null' => NULL_NOT_ALLOWED,
|
|
|
70 |
],
|
|
|
71 |
'filesize' => [
|
|
|
72 |
'type' => PARAM_INT,
|
|
|
73 |
'description' => 'File size.',
|
|
|
74 |
'optional' => true,
|
|
|
75 |
'null' => NULL_NOT_ALLOWED,
|
|
|
76 |
],
|
|
|
77 |
'fileurl' => [
|
|
|
78 |
'type' => PARAM_URL,
|
|
|
79 |
'description' => 'Downloadable file url.',
|
|
|
80 |
'optional' => true,
|
|
|
81 |
'null' => NULL_NOT_ALLOWED,
|
|
|
82 |
],
|
|
|
83 |
'timemodified' => [
|
|
|
84 |
'type' => PARAM_INT,
|
|
|
85 |
'description' => 'Time modified.',
|
|
|
86 |
'optional' => true,
|
|
|
87 |
'null' => NULL_NOT_ALLOWED,
|
|
|
88 |
],
|
|
|
89 |
'mimetype' => [
|
|
|
90 |
'type' => PARAM_RAW,
|
|
|
91 |
'description' => 'File mime type.',
|
|
|
92 |
'optional' => true,
|
|
|
93 |
'null' => NULL_NOT_ALLOWED,
|
|
|
94 |
],
|
|
|
95 |
'isexternalfile' => [
|
|
|
96 |
'type' => PARAM_BOOL,
|
|
|
97 |
'description' => 'Whether is an external file.',
|
|
|
98 |
'optional' => true,
|
|
|
99 |
'null' => NULL_NOT_ALLOWED,
|
|
|
100 |
],
|
|
|
101 |
'repositorytype' => [
|
|
|
102 |
'type' => PARAM_PLUGIN,
|
|
|
103 |
'description' => 'The repository type for the external files.',
|
|
|
104 |
'optional' => true,
|
|
|
105 |
'null' => NULL_ALLOWED,
|
|
|
106 |
],
|
|
|
107 |
'icon' => [
|
|
|
108 |
'type' => PARAM_RAW,
|
|
|
109 |
'description' => 'Relative path to the relevant file type icon based on the file\'s mime type.',
|
|
|
110 |
'optional' => true,
|
|
|
111 |
'null' => NULL_ALLOWED,
|
|
|
112 |
],
|
|
|
113 |
];
|
|
|
114 |
}
|
|
|
115 |
}
|