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