source: trunk/admin/themes_update.php @ 9493

Last change on this file since 9493 was 9493, checked in by patdenice, 13 years ago

Improve display for plugins and themes update page.

File size: 4.9 KB
Line 
1<?php
2// +-----------------------------------------------------------------------+
3// | Piwigo - a PHP based photo gallery                                    |
4// +-----------------------------------------------------------------------+
5// | Copyright(C) 2008-2011 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
24
25if( !defined("PHPWG_ROOT_PATH") )
26{
27  die ("Hacking attempt!");
28}
29
30include_once(PHPWG_ROOT_PATH.'admin/include/themes.class.php');
31
32$base_url = get_root_url().'admin.php?page='.$page['page'];
33
34$themes = new themes();
35
36$themes->set_tabsheet($page['page']);
37
38//-----------------------------------------------------------automatic upgrade
39if (isset($_GET['theme']) and isset($_GET['revision']))
40{
41  if (!is_webmaster())
42  {
43    array_push($page['errors'], l10n('Webmaster status is required.'));
44  }
45  else
46  {
47    check_pwg_token();
48   
49    $theme_id = $_GET['theme'];
50    $revision = $_GET['revision'];
51
52    $upgrade_status = $themes->extract_theme_files('upgrade', $revision, $theme_id);
53
54    switch ($upgrade_status)
55    {
56      case 'ok':
57        array_push($page['infos'],
58           sprintf(
59              l10n('%s has been successfully upgraded.'),
60              $themes->fs_themes[$_GET['theme']]['name']));
61        break;
62
63      case 'temp_path_error':
64        array_push($page['errors'], l10n('Can\'t create temporary file.'));
65        break;
66
67      case 'dl_archive_error':
68        array_push($page['errors'], l10n('Can\'t download archive.'));
69        break;
70
71      case 'archive_error':
72        array_push($page['errors'], l10n('Can\'t read or extract archive.'));
73        break;
74
75      default:
76        array_push($page['errors'],
77          sprintf(l10n('An error occured during extraction (%s).'), $_GET['upgradestatus'])
78        );
79    }
80
81    $themes->themes();
82    $template->delete_compiled_templates();
83  }
84}
85
86// +-----------------------------------------------------------------------+
87// |                     start template output                             |
88// +-----------------------------------------------------------------------+
89$template->set_filenames(array('themes' => 'themes_update.tpl'));
90
91if ($themes->get_server_themes())
92{
93  foreach($themes->fs_themes as $theme_id => $fs_theme)
94  {
95    if (isset($fs_theme['extension'])
96      and isset($themes->server_themes[$fs_theme['extension']]))
97    {
98      $theme_info = $themes->server_themes[$fs_theme['extension']];
99
100      if (!$themes->theme_version_compare($fs_theme['version'], $theme_info['revision_name']))
101      {
102        $url_auto_update = $base_url
103          . '&amp;revision=' . $theme_info['revision_id']
104          . '&amp;theme=' . $theme_id
105          . '&amp;pwg_token='.get_pwg_token()
106          ;
107
108        $template->append('update_themes', array(
109          'ID' => $theme_info['extension_id'],
110          'EXT_NAME' => $fs_theme['name'],
111          'EXT_URL' => PEM_URL.'/extension_view.php?eid='.$theme_info['extension_id'],
112          'EXT_DESC' => trim($theme_info['extension_description'], " \n\r"),
113          'REV_DESC' => trim($theme_info['revision_description'], " \n\r"),
114          'CURRENT_VERSION' => $fs_theme['version'],
115          'NEW_VERSION' => $theme_info['revision_name'],
116          'AUTHOR' => $theme_info['author_name'],
117          'DOWNLOADS' => $theme_info['extension_nb_downloads'],
118          'URL_UPDATE' => $url_auto_update,
119          'URL_DOWNLOAD' => $theme_info['download_url'] . '&amp;origin=piwigo_download'
120          )
121        );
122      }
123    }
124  }
125}
126else
127{
128  $template->assign('SERVER_ERROR', true);
129  array_push($page['errors'], l10n('Can\'t connect to server.'));
130}
131
132$template->assign_var_from_handle('ADMIN_CONTENT', 'themes');
133?>
Note: See TracBrowser for help on using the repository browser.