source: trunk/admin/languages_new.php @ 10638

Last change on this file since 10638 was 10638, checked in by patdenice, 10 years ago

Bug corrected on install extension pages (plugins, themes and languages).

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  array_push(
46    $page['errors'],
47    sprintf(
48      l10n('Add write access to the "%s" directory'),
49      'language'
50      )
51    );
52}
53
54// +-----------------------------------------------------------------------+
55// |                       perform installation                            |
56// +-----------------------------------------------------------------------+
57
58if (isset($_GET['revision']))
59{
60  if (!is_webmaster())
61  {
62    array_push($page['errors'], l10n('Webmaster status is required.'));
63  }
64  else
65  {
66    check_pwg_token();
67
68    $install_status = $languages->extract_language_files('install', $_GET['revision']);
69
70    redirect($base_url.'&installstatus='.$install_status);
71  }
72}
73
74// +-----------------------------------------------------------------------+
75// |                        installation result                            |
76// +-----------------------------------------------------------------------+
77if (isset($_GET['installstatus']))
78{
79  switch ($_GET['installstatus'])
80  {
81    case 'ok':
82      array_push($page['infos'],
83        l10n('Language has been successfully installed')
84      );
85      break;
86
87    case 'temp_path_error':
88      array_push($page['errors'], l10n('Can\'t create temporary file.'));
89      break;
90
91    case 'dl_archive_error':
92      array_push($page['errors'], l10n('Can\'t download archive.'));
93      break;
94
95    case 'archive_error':
96      array_push($page['errors'], l10n('Can\'t read or extract archive.'));
97      break;
98
99    default:
100      array_push($page['errors'],
101        sprintf(l10n('An error occured during extraction (%s).'), $_GET['installstatus'])
102      );
103  } 
104}
105
106// +-----------------------------------------------------------------------+
107// |                     start template output                             |
108// +-----------------------------------------------------------------------+
109if ($languages->get_server_languages(true))
110{
111  foreach($languages->server_languages as $language)
112  {
113    list($date, ) = explode(' ', $language['revision_date']);
114
115    $url_auto_install = htmlentities($base_url)
116      . '&amp;revision=' . $language['revision_id']
117      . '&amp;pwg_token='.get_pwg_token()
118    ;
119
120    $template->append('languages', array(
121      'EXT_NAME' => $language['extension_name'],
122      'EXT_DESC' => $language['extension_description'],
123      'EXT_URL' => PEM_URL.'/extension_view.php?eid='.$language['extension_id'],
124      'VERSION' => $language['revision_name'],
125      'VER_DESC' => $language['revision_description'],
126      'DATE' => $date,
127      'AUTHOR' => $language['author_name'],
128      'URL_INSTALL' => $url_auto_install,
129      'URL_DOWNLOAD' => $language['download_url'] . '&amp;origin=piwigo_download'));
130  }
131}
132else
133{
134  array_push($page['errors'], l10n('Can\'t connect to server.'));
135}
136
137$template->assign_var_from_handle('ADMIN_CONTENT', 'languages');
138?>
Note: See TracBrowser for help on using the repository browser.