source: trunk/admin/languages_new.php @ 25005

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

feature 2978: remove useless sprintf in the core

File size: 5.0 KB
Line 
1<?php
2// +-----------------------------------------------------------------------+
3// | Piwigo - a PHP based photo gallery                                    |
4// +-----------------------------------------------------------------------+
5// | Copyright(C) 2008-2009 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    array_push($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      array_push($page['infos'],
77        l10n('Language has been successfully installed')
78      );
79      break;
80
81    case 'temp_path_error':
82      array_push($page['errors'], l10n('Can\'t create temporary file.'));
83      break;
84
85    case 'dl_archive_error':
86      array_push($page['errors'], l10n('Can\'t download archive.'));
87      break;
88
89    case 'archive_error':
90      array_push($page['errors'], l10n('Can\'t read or extract archive.'));
91      break;
92
93    default:
94      array_push(
95        $page['errors'],
96        l10n('An error occured during extraction (%s).', htmlspecialchars($_GET['installstatus']))
97      );
98  } 
99}
100
101// +-----------------------------------------------------------------------+
102// |                     start template output                             |
103// +-----------------------------------------------------------------------+
104if ($languages->get_server_languages(true))
105{
106  foreach($languages->server_languages as $language)
107  {
108    list($date, ) = explode(' ', $language['revision_date']);
109
110    $url_auto_install = htmlentities($base_url)
111      . '&amp;revision=' . $language['revision_id']
112      . '&amp;pwg_token='.get_pwg_token()
113    ;
114
115    $template->append('languages', array(
116      'EXT_NAME' => $language['extension_name'],
117      'EXT_DESC' => $language['extension_description'],
118      'EXT_URL' => PEM_URL.'/extension_view.php?eid='.$language['extension_id'],
119      'VERSION' => $language['revision_name'],
120      'VER_DESC' => $language['revision_description'],
121      'DATE' => $date,
122      'AUTHOR' => $language['author_name'],
123      'URL_INSTALL' => $url_auto_install,
124      'URL_DOWNLOAD' => $language['download_url'] . '&amp;origin=piwigo_download'));
125  }
126}
127else
128{
129  array_push($page['errors'], l10n('Can\'t connect to server.'));
130}
131
132$template->assign_var_from_handle('ADMIN_CONTENT', 'languages');
133?>
Note: See TracBrowser for help on using the repository browser.