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 2243 2008-03-02 18:56:05Z patdenice $ |
---|
7 | // | last update : $Date: 2008-03-02 18:56:05 +0000 (Sun, 02 Mar 2008) $ |
---|
8 | // | last modifier : $Author: patdenice $ |
---|
9 | // | revision : $Revision: 2243 $ |
---|
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 | $template->set_filenames(array('plugins' => 'admin/plugins_list.tpl')); |
---|
32 | |
---|
33 | //----------------------------------------------------------------sort options |
---|
34 | $order = isset($_GET['order']) ? $_GET['order'] : 'name'; |
---|
35 | |
---|
36 | $template->assign('order', |
---|
37 | array(htmlentities($my_base_url.'&order=name') => l10n('Name'), |
---|
38 | htmlentities($my_base_url.'&order=status') => l10n('Status') |
---|
39 | ) |
---|
40 | ); |
---|
41 | |
---|
42 | $template->assign('selected', htmlentities($my_base_url.'&order=').$order); |
---|
43 | |
---|
44 | |
---|
45 | // +-----------------------------------------------------------------------+ |
---|
46 | // | start template output | |
---|
47 | // +-----------------------------------------------------------------------+ |
---|
48 | |
---|
49 | if ($order == 'status') |
---|
50 | { |
---|
51 | $fs_plugins = sort_plugins_by_state($fs_plugins, $db_plugins_by_id); |
---|
52 | } |
---|
53 | |
---|
54 | foreach($fs_plugins as $plugin_id => $fs_plugin) |
---|
55 | { |
---|
56 | $display_name = $fs_plugin['name']; |
---|
57 | if (!empty($fs_plugin['uri'])) |
---|
58 | { |
---|
59 | $display_name = '<a href="' . $fs_plugin['uri'] |
---|
60 | . '" onclick="window.open(this.href); return false;">' |
---|
61 | . $display_name . '</a>'; |
---|
62 | } |
---|
63 | $desc = $fs_plugin['description']; |
---|
64 | if (!empty($fs_plugin['author'])) |
---|
65 | { |
---|
66 | $desc .= ' (<em>'; |
---|
67 | if (!empty($fs_plugin['author uri'])) |
---|
68 | { |
---|
69 | $desc .= '<a href="' . $fs_plugin['author uri'] . '">' |
---|
70 | . $fs_plugin['author'] . '</a>'; |
---|
71 | } |
---|
72 | else |
---|
73 | { |
---|
74 | $desc .= $fs_plugin['author']; |
---|
75 | } |
---|
76 | $desc .= '</em>)'; |
---|
77 | } |
---|
78 | $tpl_plugin = |
---|
79 | array('NAME' => $display_name, |
---|
80 | 'VERSION' => $fs_plugin['version'], |
---|
81 | 'DESCRIPTION' => $desc); |
---|
82 | |
---|
83 | $action_url = htmlentities($my_base_url) . '&plugin=' . $plugin_id; |
---|
84 | |
---|
85 | if (isset($db_plugins_by_id[$plugin_id])) |
---|
86 | { |
---|
87 | switch ($db_plugins_by_id[$plugin_id]['state']) |
---|
88 | { |
---|
89 | case 'active': |
---|
90 | $tpl_plugin['actions'][] = |
---|
91 | array('U_ACTION' => $action_url . '&action=deactivate', |
---|
92 | 'L_ACTION' => l10n('Deactivate')); |
---|
93 | break; |
---|
94 | |
---|
95 | case 'inactive': |
---|
96 | $tpl_plugin['actions'][] = |
---|
97 | array('U_ACTION' => $action_url . '&action=activate', |
---|
98 | 'L_ACTION' => l10n('Activate')); |
---|
99 | $tpl_plugin['actions'][] = |
---|
100 | array('U_ACTION' => $action_url . '&action=uninstall', |
---|
101 | 'L_ACTION' => l10n('Uninstall'), |
---|
102 | 'CONFIRM' => l10n('Are you sure?')); |
---|
103 | break; |
---|
104 | } |
---|
105 | } |
---|
106 | else |
---|
107 | { |
---|
108 | $tpl_plugin['actions'][] = |
---|
109 | array('U_ACTION' => $action_url . '&action=install', |
---|
110 | 'L_ACTION' => l10n('Install'), |
---|
111 | 'CONFIRM' => l10n('Are you sure?')); |
---|
112 | $tpl_plugin['actions'][] = |
---|
113 | array('U_ACTION' => $action_url . '&action=delete', |
---|
114 | 'L_ACTION' => l10n('plugins_delete'), |
---|
115 | 'CONFIRM' => l10n('plugins_confirm_delete')); |
---|
116 | } |
---|
117 | $template->append('plugins', $tpl_plugin); |
---|
118 | } |
---|
119 | |
---|
120 | $missing_plugin_ids = array_diff( |
---|
121 | array_keys($db_plugins_by_id), array_keys($fs_plugins) |
---|
122 | ); |
---|
123 | |
---|
124 | foreach($missing_plugin_ids as $plugin_id) |
---|
125 | { |
---|
126 | $action_url = $my_base_url.'&plugin='.$plugin_id; |
---|
127 | |
---|
128 | $template->append( 'plugins', |
---|
129 | array( |
---|
130 | 'NAME' => $plugin_id, |
---|
131 | 'VERSION' => $db_plugins_by_id[$plugin_id]['version'], |
---|
132 | 'DESCRIPTION' => "ERROR: THIS PLUGIN IS MISSING BUT IT IS INSTALLED! UNINSTALL IT NOW !", |
---|
133 | 'actions' => array ( array ( |
---|
134 | 'U_ACTION' => $action_url . '&action=uninstall', |
---|
135 | 'L_ACTION' => l10n('Uninstall'), |
---|
136 | ) ) |
---|
137 | ) |
---|
138 | ); |
---|
139 | } |
---|
140 | |
---|
141 | ?> |
---|