source: trunk/admin/plugins_list.php @ 2403

Last change on this file since 2403 was 2299, checked in by plg, 17 years ago

Bug fixed: as rvelices notified me by email, my header replacement script was
bugged (r2297 was repeating new and old header).

By the way, I've also removed the replacement keywords. We were using them
because it was a common usage with CVS but it is advised not to use them with
Subversion. Personnaly, it is a problem when I search differences between 2
Piwigo installations outside Subversion.

  • Property svn:eol-style set to LF
  • Property svn:keywords set to Author Date Id Revision
File size: 5.8 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
24if( !defined("PHPWG_ROOT_PATH") )
25{
26  die ("Hacking attempt!");
27}
28
29include_once(PHPWG_ROOT_PATH.'admin/include/plugins.class.php');
30
31$template->set_filenames(array('plugins' => 'admin/plugins_list.tpl'));
32
33$order = isset($_GET['order']) ? $_GET['order'] : 'name';
34$base_url = get_root_url().'admin.php?page='.$page['page'].'&amp;order='.$order;
35
36$plugins = new plugins();
37
38//--------------------------------------------------perform requested actions
39if (isset($_GET['action']) and isset($_GET['plugin']) and !is_adviser())
40{
41  $page['errors'] =
42    $plugins->perform_action($_GET['action'], $_GET['plugin']);
43
44  if (empty($page['errors'])) redirect($base_url);
45}
46
47//--------------------------------------------------------------------Tabsheet
48set_plugins_tabsheet($page['page']);
49
50//---------------------------------------------------------------Order options
51$link = get_root_url().'admin.php?page='.$page['page'].'&amp;order=';
52$template->assign('order_options',
53  array(
54    $link.'name' => l10n('Name'),
55    $link.'status' => l10n('Status'),
56    $link.'author' => l10n('Author'),
57    $link.'id' => 'Id'));
58$template->assign('order_selected', $link.$order);
59
60// +-----------------------------------------------------------------------+
61// |                     start template output                             |
62// +-----------------------------------------------------------------------+
63$plugins->sort_fs_plugins($order);
64
65foreach($plugins->fs_plugins as $plugin_id => $fs_plugin)
66{
67  $display_name = $fs_plugin['name'];
68  if (!empty($fs_plugin['uri']))
69  {
70    $display_name = '<a href="' . $fs_plugin['uri']
71                    . '" onclick="window.open(this.href); return false;">'
72                    . $display_name . '</a>';
73  }
74  $desc = $fs_plugin['description'];
75  if (!empty($fs_plugin['author']))
76  {
77    $desc .= ' (<em>';
78    if (!empty($fs_plugin['author uri']))
79    {
80      $desc .= '<a href="' . $fs_plugin['author uri'] . '">'
81               . $fs_plugin['author'] . '</a>';
82    }
83    else
84    {
85      $desc .= $fs_plugin['author'];
86    }
87    $desc .= '</em>)';
88  }
89  $tpl_plugin =
90    array('NAME' => $display_name,
91          'VERSION' => $fs_plugin['version'],
92          'DESCRIPTION' => $desc);
93
94  $action_url = $base_url.'&amp;plugin='.$plugin_id;
95
96  if (isset($plugins->db_plugins_by_id[$plugin_id]))
97  {
98    $tpl_plugin['STATE'] = $plugins->db_plugins_by_id[$plugin_id]['state'];
99    switch ($plugins->db_plugins_by_id[$plugin_id]['state'])
100    {
101      case 'active':
102        $tpl_plugin['actions'][] =
103            array('U_ACTION' => $action_url . '&amp;action=deactivate',
104                  'L_ACTION' => l10n('Deactivate'));
105        break;
106
107      case 'inactive':
108        $tpl_plugin['actions'][] =
109            array('U_ACTION' => $action_url . '&amp;action=activate',
110                  'L_ACTION' => l10n('Activate'));
111        $tpl_plugin['actions'][] =
112            array('U_ACTION' => $action_url . '&amp;action=uninstall',
113                  'L_ACTION' => l10n('Uninstall'),
114                  'CONFIRM' => l10n('Are you sure?'));
115        break;
116    }
117  }
118  else
119  {
120    $tpl_plugin['actions'][] =
121        array('U_ACTION' => $action_url . '&amp;action=install',
122              'L_ACTION' => l10n('Install'),
123              'CONFIRM' => l10n('Are you sure?'));
124    $tpl_plugin['actions'][] =
125        array('U_ACTION' => $action_url . '&amp;action=delete',
126              'L_ACTION' => l10n('plugins_delete'),
127              'CONFIRM' => l10n('plugins_confirm_delete'));
128  }
129  $template->append('plugins', $tpl_plugin);
130}
131
132$missing_plugin_ids = array_diff(
133    array_keys($plugins->db_plugins_by_id), array_keys($plugins->fs_plugins)
134    );
135
136foreach($missing_plugin_ids as $plugin_id)
137{
138  $action_url = $base_url.'&amp;plugin='.$plugin_id;
139
140  $template->append( 'plugins',
141      array(
142        'NAME' => $plugin_id,
143        'VERSION' => $plugins->db_plugins_by_id[$plugin_id]['version'],
144        'DESCRIPTION' => "ERROR: THIS PLUGIN IS MISSING BUT IT IS INSTALLED! UNINSTALL IT NOW !",
145        'actions' => array ( array (
146              'U_ACTION' => $action_url . '&amp;action=uninstall',
147              'L_ACTION' => l10n('Uninstall'),
148          ) )
149        )
150     );
151}
152
153$template->assign_var_from_handle('ADMIN_CONTENT', 'plugins');
154?>
Note: See TracBrowser for help on using the repository browser.