[2242] | 1 | <?php |
---|
| 2 | // +-----------------------------------------------------------------------+ |
---|
[2297] | 3 | // | Piwigo - a PHP based picture gallery | |
---|
| 4 | // +-----------------------------------------------------------------------+ |
---|
[3046] | 5 | // | Copyright(C) 2008-2009 Piwigo Team http://piwigo.org | |
---|
[2297] | 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 | // +-----------------------------------------------------------------------+ |
---|
[2242] | 23 | |
---|
| 24 | if( !defined("PHPWG_ROOT_PATH") ) |
---|
| 25 | { |
---|
| 26 | die ("Hacking attempt!"); |
---|
| 27 | } |
---|
| 28 | |
---|
[2263] | 29 | include_once(PHPWG_ROOT_PATH.'admin/include/plugins.class.php'); |
---|
[2255] | 30 | |
---|
[2530] | 31 | $template->set_filenames(array('plugins' => 'plugins_list.tpl')); |
---|
[2255] | 32 | |
---|
[2263] | 33 | $order = isset($_GET['order']) ? $_GET['order'] : 'name'; |
---|
[2293] | 34 | $base_url = get_root_url().'admin.php?page='.$page['page'].'&order='.$order; |
---|
[4901] | 35 | $action_url = $base_url.'&plugin='.'%s'.'&pwg_token='.get_pwg_token(); |
---|
[2255] | 36 | |
---|
[2264] | 37 | $plugins = new plugins(); |
---|
| 38 | |
---|
[2263] | 39 | //--------------------------------------------------perform requested actions |
---|
| 40 | if (isset($_GET['action']) and isset($_GET['plugin']) and !is_adviser()) |
---|
[2255] | 41 | { |
---|
[4506] | 42 | check_pwg_token(); |
---|
| 43 | |
---|
[3949] | 44 | $page['errors'] = $plugins->perform_action($_GET['action'], $_GET['plugin']); |
---|
[2264] | 45 | |
---|
[3949] | 46 | if (empty($page['errors'])) |
---|
| 47 | { |
---|
| 48 | if ($_GET['action'] == 'activate' or $_GET['action'] == 'deactivate') |
---|
| 49 | { |
---|
| 50 | $template->delete_compiled_templates(); |
---|
| 51 | } |
---|
| 52 | redirect($base_url); |
---|
| 53 | } |
---|
[2255] | 54 | } |
---|
| 55 | |
---|
[2264] | 56 | //--------------------------------------------------------------------Tabsheet |
---|
[2272] | 57 | set_plugins_tabsheet($page['page']); |
---|
[2264] | 58 | |
---|
| 59 | //---------------------------------------------------------------Order options |
---|
[2272] | 60 | $link = get_root_url().'admin.php?page='.$page['page'].'&order='; |
---|
[2264] | 61 | $template->assign('order_options', |
---|
| 62 | array( |
---|
| 63 | $link.'name' => l10n('Name'), |
---|
| 64 | $link.'status' => l10n('Status'), |
---|
| 65 | $link.'author' => l10n('Author'), |
---|
| 66 | $link.'id' => 'Id')); |
---|
| 67 | $template->assign('order_selected', $link.$order); |
---|
| 68 | |
---|
[2255] | 69 | // +-----------------------------------------------------------------------+ |
---|
| 70 | // | start template output | |
---|
| 71 | // +-----------------------------------------------------------------------+ |
---|
[2264] | 72 | $plugins->sort_fs_plugins($order); |
---|
| 73 | |
---|
[2263] | 74 | foreach($plugins->fs_plugins as $plugin_id => $fs_plugin) |
---|
[2242] | 75 | { |
---|
| 76 | $display_name = $fs_plugin['name']; |
---|
| 77 | if (!empty($fs_plugin['uri'])) |
---|
| 78 | { |
---|
| 79 | $display_name = '<a href="' . $fs_plugin['uri'] |
---|
| 80 | . '" onclick="window.open(this.href); return false;">' |
---|
| 81 | . $display_name . '</a>'; |
---|
| 82 | } |
---|
| 83 | $desc = $fs_plugin['description']; |
---|
| 84 | if (!empty($fs_plugin['author'])) |
---|
| 85 | { |
---|
| 86 | $desc .= ' (<em>'; |
---|
| 87 | if (!empty($fs_plugin['author uri'])) |
---|
| 88 | { |
---|
| 89 | $desc .= '<a href="' . $fs_plugin['author uri'] . '">' |
---|
| 90 | . $fs_plugin['author'] . '</a>'; |
---|
| 91 | } |
---|
| 92 | else |
---|
| 93 | { |
---|
| 94 | $desc .= $fs_plugin['author']; |
---|
| 95 | } |
---|
| 96 | $desc .= '</em>)'; |
---|
| 97 | } |
---|
| 98 | $tpl_plugin = |
---|
| 99 | array('NAME' => $display_name, |
---|
| 100 | 'VERSION' => $fs_plugin['version'], |
---|
[2631] | 101 | 'DESCRIPTION' => $desc, |
---|
[4901] | 102 | 'U_ACTION' => sprintf($action_url, $plugin_id)); |
---|
[2242] | 103 | |
---|
[2263] | 104 | if (isset($plugins->db_plugins_by_id[$plugin_id])) |
---|
[2293] | 105 | { |
---|
| 106 | $tpl_plugin['STATE'] = $plugins->db_plugins_by_id[$plugin_id]['state']; |
---|
[2242] | 107 | } |
---|
| 108 | else |
---|
| 109 | { |
---|
[2631] | 110 | $tpl_plugin['STATE'] = 'uninstalled'; |
---|
[2242] | 111 | } |
---|
| 112 | $template->append('plugins', $tpl_plugin); |
---|
| 113 | } |
---|
| 114 | |
---|
| 115 | $missing_plugin_ids = array_diff( |
---|
[2263] | 116 | array_keys($plugins->db_plugins_by_id), array_keys($plugins->fs_plugins) |
---|
[2242] | 117 | ); |
---|
| 118 | |
---|
| 119 | foreach($missing_plugin_ids as $plugin_id) |
---|
| 120 | { |
---|
| 121 | $template->append( 'plugins', |
---|
| 122 | array( |
---|
| 123 | 'NAME' => $plugin_id, |
---|
[2263] | 124 | 'VERSION' => $plugins->db_plugins_by_id[$plugin_id]['version'], |
---|
[2242] | 125 | 'DESCRIPTION' => "ERROR: THIS PLUGIN IS MISSING BUT IT IS INSTALLED! UNINSTALL IT NOW !", |
---|
[4901] | 126 | 'U_ACTION' => sprintf($action_url, $plugin_id), |
---|
[2631] | 127 | 'STATE' => 'missing' |
---|
| 128 | ) |
---|
| 129 | ); |
---|
[2242] | 130 | } |
---|
| 131 | |
---|
[2255] | 132 | $template->assign_var_from_handle('ADMIN_CONTENT', 'plugins'); |
---|
[2242] | 133 | ?> |
---|