-
Notifications
You must be signed in to change notification settings - Fork 17
/
Copy pathsettings.php
executable file
·292 lines (256 loc) · 10.8 KB
/
settings.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* MathType filter settings.
*
* @package filter_wiris
* @subpackage wiris
* @copyright WIRIS Europe (Maths for more S.L)
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
defined('MOODLE_INTERNAL') || die();
// Moodle notification API: https://docs.moodle.org/dev/Notifications.
use core\notification;
if ($ADMIN->fulltree) {
global $CFG;
global $wirisconfigurationclass;
// Moodle doesn't render page headings on some cases, but saves them for later, causing multiple headings
// Using fetch immediately renders without saving.
notification::fetch();
require_once("$CFG->dirroot/filter/wiris/lib.php");
// Automatic class loading not avaliable for Moodle 2.4 and 2.5.
wrs_loadclasses();
$wirisplugin = new filter_wiris_pluginwrapper();
$editorplugininstalled = filter_wiris_pluginwrapper::get_wiris_plugin();
$warningoutput = '';
if (!empty($editorplugininstalled)) {
// Editor checkbox.
$output = '';
$wirisplugin->begin();
$waseditorenabled = $wirisplugin->was_editor_enabled();
$waschemeditorenabled = $wirisplugin->was_chem_editor_enabled();
$conf = $wirisplugin->get_instance()->getConfiguration();
$wirisplugin->end();
// Backwards compatibility: some old installations could have the configuration
// file into the editor plugin inestad of filter. Show a notification to advise
// users to copy the file from the older location to the new one.
if ($oldconfile = filter_wiris_pluginwrapper::get_old_configuration()) {
$warningoutput .= get_string('oldconfiguration', 'filter_wiris', $oldconfile);
}
$settings->add(
new admin_setting_heading(
'filter_wiris/editorsettings',
get_string('editorsettings', 'filter_wiris'),
get_string('editorsettings_text', 'filter_wiris')
)
);
if ($waseditorenabled) {
$settings->add(
new admin_setting_configcheckbox(
'filter_wiris/editor_enable',
get_string('wirismatheditor', 'filter_wiris'),
get_string('wirismatheditor_help', 'filter_wiris'),
'1'
)
);
}
if ($waschemeditorenabled) {
$settings->add(
new admin_setting_configcheckbox(
'filter_wiris/chem_editor_enable',
get_string('wirischemeditor', 'filter_wiris'),
get_string('wirischemeditor_help', 'filter_wiris'),
'1'
)
);
}
// Allow MathType be enabled despite of the filter is disabled on a course.
$settings->add(
new admin_setting_configcheckbox(
'filter_wiris/allow_editorplugin_active_course',
get_string('alloweditorpluginactive', 'filter_wiris'),
get_string('alloweditorpluginactive_help', 'filter_wiris'),
'0'
)
);
// Configuration.ini wrapper.
// Connection properties.
$settings->add(
new admin_setting_heading(
'filter_wiris/connectionsettings',
get_string('connectionsettings', 'filter_wiris'),
get_string('connectionsettings_text', 'filter_wiris')
)
);
$settings->add(
new admin_setting_configtext(
'filter_wiris/imageservicehost',
get_string('imageservicehost', 'filter_wiris'),
get_string('imageservicehost_help', 'filter_wiris'),
'www.wiris.net',
PARAM_URL
)
);
$settings->add(
new admin_setting_configtext(
'filter_wiris/imageservicepath',
get_string('imageservicepath', 'filter_wiris'),
get_string('imageservicepath_help', 'filter_wiris'),
'/demo/editor/render',
PARAM_LOCALURL
)
);
$settings->add(
new admin_setting_configselect(
'filter_wiris/imageserviceprotocol',
get_string('imageserviceprotocol', 'filter_wiris'),
get_string('imageserviceprotocol_help', 'filter_wiris'),
'https',
['http' => 'http', 'https' => 'https']
)
);
// Image properties.
$settings->add(
new admin_setting_heading(
'filter_wiris/imagesettings',
get_string('imagesettings', 'filter_wiris'),
get_string('imagesettings_text', 'filter_wiris')
)
);
$settings->add(
new admin_setting_configselect(
'filter_wiris/rendertype',
get_string('rendertype', 'filter_wiris'),
get_string('rendertype_help', 'filter_wiris'),
'php',
['php' => 'PHP', 'client' => 'Client']
)
);
$settings->add(
new admin_setting_configselect(
'filter_wiris/imageformat',
get_string('imageformat', 'filter_wiris'),
get_string('imageformat_help', 'filter_wiris'),
'svg',
['svg' => 'svg', 'png' => 'png']
)
);
$settings->add(
new admin_setting_configcheckbox(
'filter_wiris/pluginperformance',
get_string('pluginperformance', 'filter_wiris'),
get_string('pluginperformance_help', 'filter_wiris'),
'1'
)
);
// Window properties.
$settings->add(
new admin_setting_heading(
'filter_wiris/windowsettings',
get_string('windowsettings', 'filter_wiris'),
get_string('windowsettings_text', 'filter_wiris')
)
);
$settings->add(
new admin_setting_configcheckbox(
'filter_wiris/editormodalwindowfullscreen',
get_string('editormodalwindowfullscreen', 'filter_wiris'),
get_string('editormodalwindowfullscreen_help', 'filter_wiris'),
'0'
)
);
// Access Provider: If enabled MathType services can not be accessed from non logged users.
$settings->add(
new admin_setting_heading(
'securitysettings',
get_string('securitysettings', 'filter_wiris'),
get_string('securitysettings_text', 'filter_wiris')
)
);
$settings->add(
new admin_setting_configcheckbox(
'filter_wiris/access_provider_enabled',
get_string('accessproviderenabled', 'filter_wiris'),
get_string('accessproviderenabled_help', 'filter_wiris'),
'0'
)
);
} else {
if (!get_config('filter_wiris', 'filter_standalone')) {
// Moodle notification API since Moodel 3.1.
if ($CFG->version >= 2016052300) {
// Due to Moodle doesn't support circular dependencies between plugins, if any editor plugin is installed
// a warning message is shown as a notification.
$tinyurl = '';
if ($CFG->branch < 402) {
$tinyurl .= 'https://moodle.org/plugins/tinymce_tiny_mce_wiris';
} else {
$tinyurl .= 'https://moodle.org/plugins/tiny_wiris';
}
$attourl = 'https://moodle.org/plugins/atto_wiris';
$linkattributes = ['target' => '_blank'];
$attributes = [];
$warningoutput .= html_writer::link($attourl, get_string('wirispluginforatto', 'filter_wiris'), $attributes);
$warningoutput .= ' ' . get_string('or', 'filter_wiris') . ' ';
$warningoutput .= html_writer::link($tinyurl, get_string('wirispluginfortinymce', 'filter_wiris'), $attributes);
$warningoutput .= ' ' . get_string('arenotinstalled', 'filter_wiris') . ' ';
$warningoutput .= get_string('furtherinformation', 'filter_wiris') . ' ';
$imageurl = "https://www.wiris.com/system/files/attachments/1689/WIRIS_manual_icon_17_17.png";
$image = html_writer::empty_tag('img', ['src' => $imageurl, 'style' => 'vertical-align:-3px;']);
$troubleshootingurl = 'http://www.wiris.com/plugins/docs/moodle/troubleshooting?utm_source=moodle&utm_medium=referral';
$imagelink = html_writer::link($troubleshootingurl, $image, $linkattributes);
$warningoutput .= $imagelink;
}
}
$settings->add(
new admin_setting_configcheckbox(
'filter_wiris/filter_standalone',
get_string(
'filter_standalone',
'filter_wiris'
),
get_string(
'filter_standalonedesc',
'filter_wiris'
),
false,
true,
false
)
);
}
// If Moodle is 4.2
if ($CFG->version > 2022112807) {
// If TinyMCE legacy is already installed
if (is_dir($CFG->dirroot . '/lib/editor/tinymce/plugins/tiny_mce_wiris')) {
$warningoutput .= get_string('tinymceincompatibility', 'filter_wiris');
}
}
if (!empty($warningoutput)) {
if ($CFG->version > 2016052300) {
notification::warning($warningoutput);
} else {
$settings->add(new admin_setting_heading('filter_wiris_old_configuration', '', $warningoutput));
}
}
$wirisquizzes = dirname(__FILE__) . '/../../question/type/wq/';
$quizzesinstalled = file_exists($wirisquizzes);
if ($quizzesinstalled) {
$url = $CFG->wwwroot . '/admin/settings.php?section=qtypesettingwq';
$url = '<a href="' . $url . '">Wiris Quizzes settings</a>';
$settings->add(new admin_setting_heading('filter_wirisquizzesheading', $url, ''));
}
}