source: trunk/admin/plugins_update.php @ 2263

Last change on this file since 2263 was 2263, checked in by patdenice, 16 years ago

Use class for plugins management

  • Property svn:eol-style set to LF
  • Property svn:keywords set to Author Date Id Revision
File size: 4.8 KB
Line 
1<?php
2// +-----------------------------------------------------------------------+
3// | PhpWebGallery - a PHP based picture gallery                           |
4// | Copyright (C) 2003-2007 PhpWebGallery Team - http://phpwebgallery.net |
5// +-----------------------------------------------------------------------+
6// | file          : $Id: plugins_update.php 2263 2008-03-07 10:42:51Z patdenice $
7// | last update   : $Date: 2008-03-07 10:42:51 +0000 (Fri, 07 Mar 2008) $
8// | last modifier : $Author: patdenice $
9// | revision      : $Revision: 2263 $
10// +-----------------------------------------------------------------------+
11// | This program is free software; you can redistribute it and/or modify  |
12// | it under the terms of the GNU General Public License as published by  |
13// | the Free Software Foundation                                          |
14// |                                                                       |
15// | This program is distributed in the hope that it will be useful, but   |
16// | WITHOUT ANY WARRANTY; without even the implied warranty of            |
17// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU      |
18// | General Public License for more details.                              |
19// |                                                                       |
20// | You should have received a copy of the GNU General Public License     |
21// | along with this program; if not, write to the Free Software           |
22// | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, |
23// | USA.                                                                  |
24// +-----------------------------------------------------------------------+
25
26if( !defined("PHPWG_ROOT_PATH") )
27{
28  die ("Hacking attempt!");
29}
30
31include_once(PHPWG_ROOT_PATH.'admin/include/plugins.class.php');
32
33$template->set_filenames(array('plugins' => 'admin/plugins_update.tpl'));
34
35$plugins = new plugins($page['page']);
36
37//-----------------------------------------------------------automatic upgrade
38if (isset($_GET['upgrade']) and isset($_GET['plugin']) and !is_adviser())
39{
40  $plugins->upgrade($_GET['upgrade'], $_GET['plugin']);
41}
42
43//--------------------------------------------------------------upgrade result
44if (isset($_GET['upgradestatus']) and isset($_GET['plugin']))
45{
46  $plugins->get_result($_GET['upgradestatus'], $_GET['plugin']);
47}
48
49// +-----------------------------------------------------------------------+
50// |                     start template output                             |
51// +-----------------------------------------------------------------------+
52$plugins->tabsheet();
53$plugins->check_server_plugins();
54
55if ($plugins->server_plugins !== false)
56{
57  foreach($plugins->fs_plugins as $plugin_id => $fs_plugin)
58  {
59    if (isset($fs_plugin['extension'])
60      and isset($plugins->server_plugins[$fs_plugin['extension']]))
61    {
62      $plugin_info = $plugins->server_plugins[$fs_plugin['extension']];
63
64      $ext_desc = nl2br(htmlspecialchars(strip_tags(
65                    utf8_encode($plugin_info['ext_description']))));
66
67      $ver_desc = sprintf(l10n('plugins_description'),
68          $plugin_info['version'],
69          date('Y-m-d', $plugin_info['date']),
70          nl2br(htmlspecialchars(strip_tags(
71              utf8_encode($plugin_info['description'])))));
72
73      if ($plugins->plugin_version_compare($fs_plugin, $plugin_info) >= 0)
74      {
75        // Plugin is up to date
76        $template->append('plugins_uptodate',
77              array('URL' => $fs_plugin['uri'],
78                'NAME' => $fs_plugin['name'],
79                'EXT_DESC' => $ext_desc,
80                'VERSION' => $fs_plugin['version']));
81      }
82      else
83      {
84        // Plugin need upgrade
85        $url_auto_update = $plugins->html_base_url
86          . '&amp;plugin=' . $plugin_id
87          . '&amp;upgrade=%2Fupload%2Fextension-' . $fs_plugin['extension']
88          . '%2Frevision-' . $plugin_info['id_revision']
89          . '%2F' . str_replace(' ', '%20',$plugin_info['url']);
90
91        $url_download = PEM_URL.'/upload/extension-'. $fs_plugin['extension']
92          . '/revision-' . $plugin_info['id_revision']
93          . '/' . str_replace(' ', '%20',$plugin_info['url']);
94
95        $template->append('plugins_not_uptodate',
96          array('EXT_NAME' => $fs_plugin['name'],
97            'EXT_URL' => $fs_plugin['uri'],
98            'EXT_DESC' => $ext_desc,
99            'VERSION' => $fs_plugin['version'],
100            'VERSION_URL' => PEM_URL.'/revision_view.php?rid='.$plugin_info['id_revision'],
101            'NEW_VERSION' => $plugin_info['version'],
102            'NEW_VER_DESC' => $ver_desc,
103            'URL_UPDATE' => $url_auto_update,
104            'URL_DOWNLOAD' => $url_download));
105      }
106    }
107    else
108    {
109      // Can't check plugin
110      $template->append('plugins_cant_check',
111          array('NAME' => $fs_plugin['name'],
112            'VERSION' => $fs_plugin['version']));
113    }
114  }
115}
116else
117{
118  array_push($page['errors'], l10n('plugins_server_error'));
119}
120
121$template->assign_var_from_handle('ADMIN_CONTENT', 'plugins');
122?>
Note: See TracBrowser for help on using the repository browser.