forked from andrewhancox/moodle-filter_translations
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsettings.php
204 lines (171 loc) · 7.38 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
<?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/>.
/**
* @package filter_translations
* @author Andrew Hancox <[email protected]>
* @author Open Source Learning <[email protected]>
* @link https://opensourcelearning.co.uk
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
* @copyright 2021, Andrew Hancox
*/
defined('MOODLE_INTERNAL') || die();
if ($ADMIN->fulltree) {
$list_of_translations = get_string_manager()->get_list_of_translations(true);
$settings->add(new admin_setting_heading(
'managetranslations',
'',
html_writer::link(
new moodle_url('/filter/translations/managetranslations.php'),
get_string('managetranslations', 'filter_translations'),
['class' => "btn btn-primary"]
)
));
$settings->add(new admin_setting_heading(
'managetranslationissues',
'',
html_writer::link(
new moodle_url('/filter/translations/managetranslationissues.php'),
get_string('managetranslationissues', 'filter_translations'),
['class' => "btn btn-primary"]
)
));
$settings->add(new admin_setting_heading('performance', get_string('performance', 'admin'), ''));
$settings->add(new admin_setting_configcheckbox(
'filter_translations/showperfdata',
get_string('showperfdata', 'filter_translations'),
'',
false
));
$options = [];
foreach ([cache_store::MODE_REQUEST, cache_store::MODE_SESSION, cache_store::MODE_APPLICATION] as $mode) {
$options[$mode] = get_string('mode_' . $mode, 'cache');
}
$settings->add(new admin_setting_configselect(
'filter_translations/cachingmode',
get_string('cachingmode', 'filter_translations'),
get_string('cachingmode_desc', 'filter_translations'),
cache_store::MODE_REQUEST,
$options
));
$settings->add(
new admin_setting_configtextarea(
'filter_translations/untranslatedpages',
new lang_string('untranslatedpages', 'filter_translations'),
new lang_string('untranslatedpages_desc', 'filter_translations'),
'/blocks/configurable_reports/viewreport.php'
)
);
$settings->add(new admin_setting_configmultiselect(
'filter_translations/excludelang',
get_string('excludelang', 'filter_translations'),
get_string('excludelang_desc', 'filter_translations'),
[],
$list_of_translations
));
$settings->add(new admin_setting_heading('logging', get_string('logging', 'filter_translations'), ''));
$settings->add(new admin_setting_configmultiselect(
'filter_translations/logexcludelang',
get_string('logexcludelang', 'filter_translations'),
get_string('logexcludelang_desc', 'filter_translations'),
[],
$list_of_translations
));
$settings->add(new admin_setting_configcheckbox(
'filter_translations/logmissing',
get_string('logmissing', 'filter_translations'),
'',
false
));
$settings->add(new admin_setting_configcheckbox(
'filter_translations/logstale',
get_string('logstale', 'filter_translations'),
'',
false
));
$settings->add(new admin_setting_configduration(
'filter_translations/logdebounce',
get_string('logdebounce', 'filter_translations'),
'',
DAYSECS
));
/* $settings->add(new admin_setting_heading('languagestringreverseapi', get_string('languagestringreverse', 'filter_translations'), ''));
$settings->add(new admin_setting_configcheckbox(
'filter_translations/languagestringreverse_enable',
get_string('languagestringreverse_enable', 'filter_translations'),
'',
false
));
$settings->add(new admin_setting_heading('googletranslateapi', get_string('googletranslate', 'filter_translations'), ''));
$settings->add(new admin_setting_configcheckbox(
'filter_translations/google_enable',
get_string('google_enable', 'filter_translations'),
'',
false
));
$settings->add(new admin_setting_configcheckbox(
'filter_translations/google_backoffonerror',
get_string('google_backoffonerror', 'filter_translations'),
'',
false
));
$settings->add(new admin_setting_configtext(
'filter_translations/google_apiendpoint',
get_string('google_apiendpoint', 'filter_translations'),
'',
'https://translation.googleapis.com/language/translate/v2',
PARAM_URL
));
$settings->add(new admin_setting_configtext(
'filter_translations/google_apikey',
get_string('google_apikey', 'filter_translations'),
'',
null,
PARAM_RAW_TRIMMED,
40
)); */
$settings->add(new admin_setting_heading('customapi', get_string('customapi', 'filter_translations', ''), ''));
/* $settings->add(new admin_setting_configcheckbox(
'filter_translations/translatetokinya',
get_string('translatetokinya', 'filter_translations'),
'',
false
)); */
$selectedLanguages = get_config('filter_translations', 'languages');
if (strstr($selectedLanguages, ',')) {
$selectedLanguagesArray = explode(',', $selectedLanguages);
} else {
$selectedLanguagesArray = [$selectedLanguages];
}
foreach ($selectedLanguagesArray as $key => $selectedLanguage) {
$selectedLanguagesArray[$selectedLanguage] = get_string_manager()->get_list_of_languages()[$selectedLanguage];
unset($selectedLanguagesArray[$key]);
}
$setting = new admin_setting_configmultiselect('filter_translations/selectedlanguages', 'Selected Languages', '', [], $selectedLanguagesArray);
$settings->add($setting);
$setting->set_locked_flag_options(admin_setting_flag::DISABLED, true);
$setting = new admin_setting_configmultiselect('filter_translations/languages', 'Languages', '', [], get_string_manager()->get_list_of_languages());
$setting->set_updatedcallback('theme_reset_all_caches');
$settings->add($setting);
$setting = new admin_setting_configselect('filter_translations/contentlanguage', 'Content Language', '', '', $selectedLanguagesArray);
$setting->set_updatedcallback('theme_reset_all_caches');
$settings->add($setting);
$setting = new admin_setting_configselect('filter_translations/widgetlanguage', 'Widget Language', '', '', $selectedLanguagesArray);
$setting->set_updatedcallback('theme_reset_all_caches');
$settings->add($setting);
$setting = new admin_setting_configselect('filter_translations/usepopuptranslation', 'Use popup translation', '', '', ['', 'Yes', 'No']);
$setting->set_updatedcallback('theme_reset_all_caches');
$settings->add($setting);
}