forked from microweber-dev/multilang-old
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathadmin.php
More file actions
45 lines (37 loc) · 1.6 KB
/
admin.php
File metadata and controls
45 lines (37 loc) · 1.6 KB
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
<?php only_admin_access(); ?>
<?php require isset($params['backend']) ? 'admin_backend.php' : 'admin_live_edit.php'; ?>
<script type="text/javascript" src="<?php echo $config['url_to_module']; ?>langs.js"></script>
<script type="text/javascript">mw.require('options.js');</script>
<script type="text/javascript">
function reload_after_save() {
mw.reload_module("#<?php echo $params['id']; ?>");
mw.reload_module_parent("#<?php echo $params['id']; ?>");
mw.notification.success("<?php _e('Settings are saved!'); ?>");
}
$(document).ready(function() {
mw.options.form('#<?php echo $params['id']; ?>', function() {
mw.notification.success("<?php _e("Settings are saved!"); ?>");
});
$('#default_lang').on('change', function() {
$.post('<?php print api_url() ?>multilang_set_default', { lang: $(this).val() }, reload_after_save);
});
$('#add_lang').click(function(e) {
e.preventDefault();
var lang = $('#site_langs').val();
if(lang && typeof(MULTILANG_LOCALES[lang]) !== 'undefined') {
$.post('<?php print api_url() ?>multilang_add', { 'lang': lang }, reload_after_save);
}
});
$('.remove_lang').click(function(e) {
e.preventDefault();
var lang = $(this).data('lang');
if(lang && confirm("<?php _e('Are you sure you want to remove this language?'); ?>"))
$.post('<?php print api_url() ?>multilang_remove', { 'lang': lang }, reload_after_save);
});
for(var lk in MULTILANG_LOCALES) {
if(mw.ml_locales.indexOf(lk) >= 0) continue;
$('#site_langs').append($('<option></option>').val(lk).text(MULTILANG_LOCALES[lk]));
}
});
mw.ml_locales = ['<?php echo implode('\',\'', multilang_locales()); ?>'];
</script>