source: trunk/admin/languages_new.php @ 28567

Last change on this file since 28567 was 26461, checked in by mistic100, 11 years ago

Update headers to 2014. Happy new year!!

File size: 4.9 KB
Line 
1<?php
2// +-----------------------------------------------------------------------+
3// | Piwigo - a PHP based photo gallery                                    |
4// +-----------------------------------------------------------------------+
5// | Copyright(C) 2008-2014 Piwigo Team                  http://piwigo.org |
6// | Copyright(C) 2003-2008 PhpWebGallery Team    http://phpwebgallery.net |
7// | Copyright(C) 2002-2003 Pierrick LE GALL   http://le-gall.net/pierrick |
8// +-----------------------------------------------------------------------+
9// | This program is free software; you can redistribute it and/or modify  |
10// | it under the terms of the GNU General Public License as published by  |
11// | the Free Software Foundation                                          |
12// |                                                                       |
13// | This program is distributed in the hope that it will be useful, but   |
14// | WITHOUT ANY WARRANTY; without even the implied warranty of            |
15// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU      |
16// | General Public License for more details.                              |
17// |                                                                       |
18// | You should have received a copy of the GNU General Public License     |
19// | along with this program; if not, write to the Free Software           |
20// | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, |
21// | USA.                                                                  |
22// +-----------------------------------------------------------------------+
23
24if( !defined("PHPWG_ROOT_PATH") )
25{
26  die ("Hacking attempt!");
27}
28
29include_once(PHPWG_ROOT_PATH.'admin/include/languages.class.php');
30
31$template->set_filenames(array('languages' => 'languages_new.tpl'));
32
33$base_url = get_root_url().'admin.php?page='.$page['page'].'&tab='.$page['tab'];
34
35$languages = new languages();
36$languages->get_db_languages();
37
38// +-----------------------------------------------------------------------+
39// |                           setup check                                 |
40// +-----------------------------------------------------------------------+
41
42$languages_dir = PHPWG_ROOT_PATH.'language';
43if (!is_writable($languages_dir))
44{
45  $page['errors'][] = l10n('Add write access to the "%s" directory', 'language');
46}
47
48// +-----------------------------------------------------------------------+
49// |                       perform installation                            |
50// +-----------------------------------------------------------------------+
51
52if (isset($_GET['revision']))
53{
54  if (!is_webmaster())
55  {
56    $page['errors'][] = l10n('Webmaster status is required.');
57  }
58  else
59  {
60    check_pwg_token();
61
62    $install_status = $languages->extract_language_files('install', $_GET['revision']);
63
64    redirect($base_url.'&installstatus='.$install_status);
65  }
66}
67
68// +-----------------------------------------------------------------------+
69// |                        installation result                            |
70// +-----------------------------------------------------------------------+
71if (isset($_GET['installstatus']))
72{
73  switch ($_GET['installstatus'])
74  {
75    case 'ok':
76      $page['infos'][] = l10n('Language has been successfully installed');
77      break;
78
79    case 'temp_path_error':
80      $page['errors'][] = l10n('Can\'t create temporary file.');
81      break;
82
83    case 'dl_archive_error':
84      $page['errors'][] = l10n('Can\'t download archive.');
85      break;
86
87    case 'archive_error':
88      $page['errors'][] = l10n('Can\'t read or extract archive.');
89      break;
90
91    default:
92      $page['errors'][] = l10n('An error occured during extraction (%s).', htmlspecialchars($_GET['installstatus']));
93  } 
94}
95
96// +-----------------------------------------------------------------------+
97// |                     start template output                             |
98// +-----------------------------------------------------------------------+
99if ($languages->get_server_languages(true))
100{
101  foreach($languages->server_languages as $language)
102  {
103    list($date, ) = explode(' ', $language['revision_date']);
104
105    $url_auto_install = htmlentities($base_url)
106      . '&amp;revision=' . $language['revision_id']
107      . '&amp;pwg_token='.get_pwg_token()
108    ;
109
110    $template->append('languages', array(
111      'EXT_NAME' => $language['extension_name'],
112      'EXT_DESC' => $language['extension_description'],
113      'EXT_URL' => PEM_URL.'/extension_view.php?eid='.$language['extension_id'],
114      'VERSION' => $language['revision_name'],
115      'VER_DESC' => $language['revision_description'],
116      'DATE' => $date,
117      'AUTHOR' => $language['author_name'],
118      'URL_INSTALL' => $url_auto_install,
119      'URL_DOWNLOAD' => $language['download_url'] . '&amp;origin=piwigo_download'));
120  }
121}
122else
123{
124  $page['errors'][] = l10n('Can\'t connect to server.');
125}
126
127$template->assign_var_from_handle('ADMIN_CONTENT', 'languages');
128?>
Note: See TracBrowser for help on using the repository browser.