source: trunk/admin/themes_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-2013 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/themes.class.php');
30
31$base_url = get_root_url().'admin.php?page='.$page['page'].'&tab='.$page['tab'];
32
33$themes = new themes();
34
35// +-----------------------------------------------------------------------+
36// |                           setup check                                 |
37// +-----------------------------------------------------------------------+
38
39$themes_dir = PHPWG_ROOT_PATH.'themes';
40if (!is_writable($themes_dir))
41{
42  $page['errors'][] = l10n('Add write access to the "%s" directory', 'themes');
43}
44
45// +-----------------------------------------------------------------------+
46// |                       perform installation                            |
47// +-----------------------------------------------------------------------+
48
49if (isset($_GET['revision']) and isset($_GET['extension']))
50{
51  if (!is_webmaster())
52  {
53    array_push($page['errors'], l10n('Webmaster status is required.'));
54  }
55  else
56  {
57    check_pwg_token();
58
59    $install_status = $themes->extract_theme_files(
60      'install',
61      $_GET['revision'],
62      $_GET['extension']
63      );
64   
65    redirect($base_url.'&installstatus='.$install_status);
66  }
67}
68
69// +-----------------------------------------------------------------------+
70// |                        installation result                            |
71// +-----------------------------------------------------------------------+
72
73if (isset($_GET['installstatus']))
74{
75  switch ($_GET['installstatus'])
76  {
77    case 'ok':
78      array_push(
79        $page['infos'],
80        l10n('Theme has been successfully installed')
81        );
82      break;
83
84    case 'temp_path_error':
85      array_push($page['errors'], l10n('Can\'t create temporary file.'));
86      break;
87
88    case 'dl_archive_error':
89      array_push($page['errors'], l10n('Can\'t download archive.'));
90      break;
91
92    case 'archive_error':
93      array_push($page['errors'], l10n('Can\'t read or extract archive.'));
94      break;
95
96    default:
97      array_push(
98        $page['errors'],
99        l10n('An error occured during extraction (%s).', htmlspecialchars($_GET['installstatus']))
100        );
101  } 
102}
103
104// +-----------------------------------------------------------------------+
105// |                          template output                              |
106// +-----------------------------------------------------------------------+
107
108$template->set_filenames(array('themes' => 'themes_new.tpl'));
109
110if ($themes->get_server_themes(true)) // only new themes
111{
112  foreach($themes->server_themes as $theme)
113  {
114    $url_auto_install = htmlentities($base_url)
115      . '&amp;revision=' . $theme['revision_id']
116      . '&amp;extension=' . $theme['extension_id']
117      . '&amp;pwg_token='.get_pwg_token()
118      ;
119
120    $template->append(
121      'new_themes',
122      array(
123        'name' => $theme['extension_name'],
124        'thumbnail' => PEM_URL.'/upload/extension-'.$theme['extension_id'].'/thumbnail.jpg',
125        'screenshot' => PEM_URL.'/upload/extension-'.$theme['extension_id'].'/screenshot.jpg',
126        'install_url' => $url_auto_install,
127        )
128      );
129  }
130}
131else
132{
133  array_push($page['errors'], l10n('Can\'t connect to server.'));
134}
135
136$template->assign('default_screenshot',
137  get_root_url().'admin/themes/'.$conf['admin_theme'].'/images/missing_screenshot.png'
138);
139
140$template->assign_var_from_handle('ADMIN_CONTENT', 'themes');
141?>
Note: See TracBrowser for help on using the repository browser.