source: extensions/autoupdate/trunk/ajax/update_language.php @ 9712

Revision 9712, 1.6 KB checked in by patdenice, 9 years ago (diff)

Clean code.
Rename files.

Line 
1<?php
2
3define('PHPWG_ROOT_PATH','../../../');
4define('IN_ADMIN', true);
5include_once( PHPWG_ROOT_PATH.'include/common.inc.php' );
6include_once(PHPWG_ROOT_PATH.'admin/include/functions.php');
7
8check_status(ACCESS_ADMINISTRATOR);
9
10if (!is_webmaster())
11{
12  echo json_encode(array(
13    'result' => false,
14    'msg' => l10n('Webmaster status is required.'),
15    )
16  );
17  exit;
18}
19
20if (empty($_REQUEST['id']) or empty($_REQUEST['revision']))
21{
22  echo json_encode(array(
23    'result' => false,
24    'msg' => 'Wrong parameters',
25    )
26  );
27  exit;
28}
29
30include_once(PHPWG_ROOT_PATH.'admin/include/languages.class.php');
31$languages = new languages();
32
33$language_id = $_REQUEST['id'];
34$revision = $_REQUEST['revision'];
35
36$upgrade_status = $languages->extract_language_files('upgrade', $revision, $language_id);
37
38switch ($upgrade_status)
39{
40  case 'ok':
41    $result = array(
42      'result' => true,
43      'msg' => sprintf(l10n('%s has been successfully upgraded.'), $languages->fs_languages[$language_id]['name'])
44    );
45    break;
46
47  case 'temp_path_error':
48    $result = array(
49      'result' => false,
50      'msg' => l10n('Can\'t create temporary file.')
51    );
52    break;
53
54  case 'dl_archive_error':
55    $result = array(
56      'result' => false,
57      'msg' => l10n('Can\'t download archive.')
58    );
59    break;
60
61  case 'archive_error':
62    $result = array(
63      'result' => false,
64      'msg' => l10n('Can\'t read or extract archive.')
65    );
66    break;
67
68  default:
69    $result = array(
70      'result' => false,
71      'msg' => sprintf(l10n('An error occured during extraction (%s).'), $upgrade_status)
72    );
73}
74
75$template->delete_compiled_templates();
76echo json_encode($result);
77exit;
78
79?>
Note: See TracBrowser for help on using the repository browser.