source: trunk/admin/plugins_list.php @ 2297

Last change on this file since 2297 was 2297, checked in by plg, 16 years ago

Modification: new header on PHP files, PhpWebGallery renamed Piwigo.

  • Property svn:eol-style set to LF
  • Property svn:keywords set to Author Date Id Revision
File size: 7.3 KB
Line 
1<?php
2// +-----------------------------------------------------------------------+
3// | Piwigo - a PHP based picture gallery                                  |
4// +-----------------------------------------------------------------------+
5// | Copyright(C) 2008      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// | PhpWebGallery - a PHP based picture gallery                           |
25// | Copyright (C) 2003-2007 PhpWebGallery Team - http://phpwebgallery.net |
26// +-----------------------------------------------------------------------+
27// | file          : $Id: plugins_list.php 2297 2008-04-04 22:57:23Z plg $
28// | last update   : $Date: 2008-04-04 22:57:23 +0000 (Fri, 04 Apr 2008) $
29// | last modifier : $Author: plg $
30// | revision      : $Revision: 2297 $
31// +-----------------------------------------------------------------------+
32// | This program is free software; you can redistribute it and/or modify  |
33// | it under the terms of the GNU General Public License as published by  |
34// | the Free Software Foundation                                          |
35// |                                                                       |
36// | This program is distributed in the hope that it will be useful, but   |
37// | WITHOUT ANY WARRANTY; without even the implied warranty of            |
38// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU      |
39// | General Public License for more details.                              |
40// |                                                                       |
41// | You should have received a copy of the GNU General Public License     |
42// | along with this program; if not, write to the Free Software           |
43// | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, |
44// | USA.                                                                  |
45// +-----------------------------------------------------------------------+
46
47if( !defined("PHPWG_ROOT_PATH") )
48{
49  die ("Hacking attempt!");
50}
51
52include_once(PHPWG_ROOT_PATH.'admin/include/plugins.class.php');
53
54$template->set_filenames(array('plugins' => 'admin/plugins_list.tpl'));
55
56$order = isset($_GET['order']) ? $_GET['order'] : 'name';
57$base_url = get_root_url().'admin.php?page='.$page['page'].'&amp;order='.$order;
58
59$plugins = new plugins();
60
61//--------------------------------------------------perform requested actions
62if (isset($_GET['action']) and isset($_GET['plugin']) and !is_adviser())
63{
64  $page['errors'] =
65    $plugins->perform_action($_GET['action'], $_GET['plugin']);
66
67  if (empty($page['errors'])) redirect($base_url);
68}
69
70//--------------------------------------------------------------------Tabsheet
71set_plugins_tabsheet($page['page']);
72
73//---------------------------------------------------------------Order options
74$link = get_root_url().'admin.php?page='.$page['page'].'&amp;order=';
75$template->assign('order_options',
76  array(
77    $link.'name' => l10n('Name'),
78    $link.'status' => l10n('Status'),
79    $link.'author' => l10n('Author'),
80    $link.'id' => 'Id'));
81$template->assign('order_selected', $link.$order);
82
83// +-----------------------------------------------------------------------+
84// |                     start template output                             |
85// +-----------------------------------------------------------------------+
86$plugins->sort_fs_plugins($order);
87
88foreach($plugins->fs_plugins as $plugin_id => $fs_plugin)
89{
90  $display_name = $fs_plugin['name'];
91  if (!empty($fs_plugin['uri']))
92  {
93    $display_name = '<a href="' . $fs_plugin['uri']
94                    . '" onclick="window.open(this.href); return false;">'
95                    . $display_name . '</a>';
96  }
97  $desc = $fs_plugin['description'];
98  if (!empty($fs_plugin['author']))
99  {
100    $desc .= ' (<em>';
101    if (!empty($fs_plugin['author uri']))
102    {
103      $desc .= '<a href="' . $fs_plugin['author uri'] . '">'
104               . $fs_plugin['author'] . '</a>';
105    }
106    else
107    {
108      $desc .= $fs_plugin['author'];
109    }
110    $desc .= '</em>)';
111  }
112  $tpl_plugin =
113    array('NAME' => $display_name,
114          'VERSION' => $fs_plugin['version'],
115          'DESCRIPTION' => $desc);
116
117  $action_url = $base_url.'&amp;plugin='.$plugin_id;
118
119  if (isset($plugins->db_plugins_by_id[$plugin_id]))
120  {
121    $tpl_plugin['STATE'] = $plugins->db_plugins_by_id[$plugin_id]['state'];
122    switch ($plugins->db_plugins_by_id[$plugin_id]['state'])
123    {
124      case 'active':
125        $tpl_plugin['actions'][] =
126            array('U_ACTION' => $action_url . '&amp;action=deactivate',
127                  'L_ACTION' => l10n('Deactivate'));
128        break;
129
130      case 'inactive':
131        $tpl_plugin['actions'][] =
132            array('U_ACTION' => $action_url . '&amp;action=activate',
133                  'L_ACTION' => l10n('Activate'));
134        $tpl_plugin['actions'][] =
135            array('U_ACTION' => $action_url . '&amp;action=uninstall',
136                  'L_ACTION' => l10n('Uninstall'),
137                  'CONFIRM' => l10n('Are you sure?'));
138        break;
139    }
140  }
141  else
142  {
143    $tpl_plugin['actions'][] =
144        array('U_ACTION' => $action_url . '&amp;action=install',
145              'L_ACTION' => l10n('Install'),
146              'CONFIRM' => l10n('Are you sure?'));
147    $tpl_plugin['actions'][] =
148        array('U_ACTION' => $action_url . '&amp;action=delete',
149              'L_ACTION' => l10n('plugins_delete'),
150              'CONFIRM' => l10n('plugins_confirm_delete'));
151  }
152  $template->append('plugins', $tpl_plugin);
153}
154
155$missing_plugin_ids = array_diff(
156    array_keys($plugins->db_plugins_by_id), array_keys($plugins->fs_plugins)
157    );
158
159foreach($missing_plugin_ids as $plugin_id)
160{
161  $action_url = $base_url.'&amp;plugin='.$plugin_id;
162
163  $template->append( 'plugins',
164      array(
165        'NAME' => $plugin_id,
166        'VERSION' => $plugins->db_plugins_by_id[$plugin_id]['version'],
167        'DESCRIPTION' => "ERROR: THIS PLUGIN IS MISSING BUT IT IS INSTALLED! UNINSTALL IT NOW !",
168        'actions' => array ( array (
169              'U_ACTION' => $action_url . '&amp;action=uninstall',
170              'L_ACTION' => l10n('Uninstall'),
171          ) )
172        )
173     );
174}
175
176$template->assign_var_from_handle('ADMIN_CONTENT', 'plugins');
177?>
Note: See TracBrowser for help on using the repository browser.