source: trunk/admin/plugins_list.php @ 5123

Last change on this file since 5123 was 3950, checked in by patdenice, 15 years ago

merge r3949 from branch 2.0 to trunk
Purge compiled templates when activate or deactivate a plugin.
Cf topic:16250 on french forum.

  • Property svn:eol-style set to LF
File size: 4.8 KB
Line 
1<?php
2// +-----------------------------------------------------------------------+
3// | Piwigo - a PHP based picture gallery                                  |
4// +-----------------------------------------------------------------------+
5// | Copyright(C) 2008-2009 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' => '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'] = $plugins->perform_action($_GET['action'], $_GET['plugin']);
42
43  if (empty($page['errors']))
44  {
45    if ($_GET['action'] == 'activate' or $_GET['action'] == 'deactivate')
46    {
47      $template->delete_compiled_templates();
48    }
49    redirect($base_url);
50  }
51}
52
53//--------------------------------------------------------------------Tabsheet
54set_plugins_tabsheet($page['page']);
55
56//---------------------------------------------------------------Order options
57$link = get_root_url().'admin.php?page='.$page['page'].'&amp;order=';
58$template->assign('order_options',
59  array(
60    $link.'name' => l10n('Name'),
61    $link.'status' => l10n('Status'),
62    $link.'author' => l10n('Author'),
63    $link.'id' => 'Id'));
64$template->assign('order_selected', $link.$order);
65
66// +-----------------------------------------------------------------------+
67// |                     start template output                             |
68// +-----------------------------------------------------------------------+
69$plugins->sort_fs_plugins($order);
70
71foreach($plugins->fs_plugins as $plugin_id => $fs_plugin)
72{
73  $display_name = $fs_plugin['name'];
74  if (!empty($fs_plugin['uri']))
75  {
76    $display_name = '<a href="' . $fs_plugin['uri']
77                    . '" onclick="window.open(this.href); return false;">'
78                    . $display_name . '</a>';
79  }
80  $desc = $fs_plugin['description'];
81  if (!empty($fs_plugin['author']))
82  {
83    $desc .= ' (<em>';
84    if (!empty($fs_plugin['author uri']))
85    {
86      $desc .= '<a href="' . $fs_plugin['author uri'] . '">'
87               . $fs_plugin['author'] . '</a>';
88    }
89    else
90    {
91      $desc .= $fs_plugin['author'];
92    }
93    $desc .= '</em>)';
94  }
95  $tpl_plugin =
96    array('NAME' => $display_name,
97          'VERSION' => $fs_plugin['version'],
98          'DESCRIPTION' => $desc,
99          'U_ACTION' => $base_url.'&amp;plugin='.$plugin_id);
100
101  if (isset($plugins->db_plugins_by_id[$plugin_id]))
102  {
103    $tpl_plugin['STATE'] = $plugins->db_plugins_by_id[$plugin_id]['state'];
104  }
105  else
106  {
107    $tpl_plugin['STATE'] = 'uninstalled';
108  }
109  $template->append('plugins', $tpl_plugin);
110}
111
112$missing_plugin_ids = array_diff(
113    array_keys($plugins->db_plugins_by_id), array_keys($plugins->fs_plugins)
114    );
115
116foreach($missing_plugin_ids as $plugin_id)
117{
118  $action_url = $base_url.'&amp;plugin='.$plugin_id;
119
120  $template->append( 'plugins',
121      array(
122        'NAME' => $plugin_id,
123        'VERSION' => $plugins->db_plugins_by_id[$plugin_id]['version'],
124        'DESCRIPTION' => "ERROR: THIS PLUGIN IS MISSING BUT IT IS INSTALLED! UNINSTALL IT NOW !",
125        'U_ACTION' => $base_url.'&amp;plugin='.$plugin_id,
126        'STATE' => 'missing'
127      )
128    );
129}
130
131$template->assign_var_from_handle('ADMIN_CONTENT', 'plugins');
132?>
Note: See TracBrowser for help on using the repository browser.