aboutsummaryrefslogtreecommitdiffstats
path: root/admin/plugins_list.php
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--admin/plugins_list.php188
1 files changed, 29 insertions, 159 deletions
diff --git a/admin/plugins_list.php b/admin/plugins_list.php
index 5c333968f..90a8ef722 100644
--- a/admin/plugins_list.php
+++ b/admin/plugins_list.php
@@ -1,7 +1,7 @@
<?php
// +-----------------------------------------------------------------------+
// | PhpWebGallery - a PHP based picture gallery |
-// | Copyright (C) 2003-2008 PhpWebGallery Team - http://phpwebgallery.net |
+// | Copyright (C) 2003-2007 PhpWebGallery Team - http://phpwebgallery.net |
// +-----------------------------------------------------------------------+
// | file : $Id$
// | last update : $Date$
@@ -28,164 +28,34 @@ if( !defined("PHPWG_ROOT_PATH") )
die ("Hacking attempt!");
}
+include_once(PHPWG_ROOT_PATH.'admin/include/plugins.class.php');
-// +-----------------------------------------------------------------------+
-// | perform requested actions |
-// +-----------------------------------------------------------------------+
-if (isset($_GET['action']) and isset($_GET['plugin']) and !is_adviser())
-{
- $plugin_id = $_GET['plugin'];
- $crt_db_plugin = get_db_plugins('', $plugin_id);
- if (!empty($crt_db_plugin))
- {
- $crt_db_plugin = $crt_db_plugin[0];
- }
- else
- {
- unset($crt_db_plugin);
- }
-
- $errors = array();
- $file_to_include = PHPWG_PLUGINS_PATH . $plugin_id . '/maintain.inc.php';
-
- switch ($_GET['action'])
- {
- case 'install':
- if (!empty($crt_db_plugin))
- {
- array_push($errors, 'CANNOT install - ALREADY INSTALLED');
- break;
- }
- $fs_plugins = get_fs_plugins();
- if (!isset($fs_plugins[$plugin_id]))
- {
- array_push($errors, 'CANNOT install - NO SUCH PLUGIN');
- break;
- }
- if (file_exists($file_to_include))
- {
- include_once($file_to_include);
- if (function_exists('plugin_install'))
- {
- plugin_install($plugin_id, $fs_plugins[$plugin_id]['version'], $errors);
- }
- }
- if (empty($errors))
- {
- $query = '
-INSERT INTO ' . PLUGINS_TABLE . ' (id,version) VALUES ("'
-. $plugin_id . '","' . $fs_plugins[$plugin_id]['version'] . '"
-)';
- pwg_query($query);
- }
- break;
-
- case 'activate':
- activate_plugin($plugin_id, $errors);
- break;
- case 'deactivate':
- deactivate_plugin($plugin_id, $errors);
- break;
-
- case 'uninstall':
- if (!isset($crt_db_plugin))
- {
- die ('CANNOT ' . $_GET['action'] . ' - NOT INSTALLED');
- }
- $query = '
-DELETE FROM ' . PLUGINS_TABLE . ' WHERE id="' . $plugin_id . '"';
- pwg_query($query);
- if (file_exists($file_to_include))
- {
- include_once($file_to_include);
- if (function_exists('plugin_uninstall'))
- {
- plugin_uninstall($plugin_id);
- }
- }
- break;
-
- case 'delete':
- if (!empty($crt_db_plugin))
- {
- array_push($errors, 'CANNOT delete - PLUGIN IS INSTALLED');
- }
- elseif (!deltree(PHPWG_PLUGINS_PATH . $plugin_id))
- {
- send_to_trash(PHPWG_PLUGINS_PATH . $plugin_id);
- }
- break;
- }
- if (empty($errors))
- {
- redirect(
- get_root_url()
- .'admin.php'
- .get_query_string_diff( array('action', 'plugin') )
- );
- }
- else
- {
- $page['errors'] = array_merge($page['errors'], $errors);
- }
-}
+$template->set_filenames(array('plugins' => 'admin/plugins_list.tpl'));
+$order = isset($_GET['order']) ? $_GET['order'] : 'name';
+$plugins = new plugins($page['page'], $order);
-$fs_plugins = get_fs_plugins();
-$db_plugins = get_db_plugins();
-$db_plugins_by_id = array();
-foreach ($db_plugins as $db_plugin)
+//--------------------------------------------------perform requested actions
+if (isset($_GET['action']) and isset($_GET['plugin']) and !is_adviser())
{
- $db_plugins_by_id[$db_plugin['id']] = $db_plugin;
+ $page['errors'] =
+ $plugins->perform_action($_GET['action'], $_GET['plugin'], $page['errors']);
+
+ if (empty($page['errors'])) redirect($plugins->my_base_url);
}
-
// +-----------------------------------------------------------------------+
// | start template output |
// +-----------------------------------------------------------------------+
-
-$template->set_filenames(array('plugins' => 'admin/plugins_list.tpl'));
-
-$base_url = get_root_url().'admin.php';
-
-//----------------------------------------------------------------sort options
-$selected_order = isset($_GET['order']) ? $_GET['order'] : 'name';
-
-$url = $base_url.get_query_string_diff( array('action', 'plugin', 'order'));
-
-$template->assign('order',
- array(
- $url.'&amp;order=name' => l10n('Name'),
- $url.'&amp;order=status' => l10n('Status'),
- $url.'&amp;order=author' => l10n('Author'),
- $url.'&amp;order=id' => 'Id',
- )
- );
-
-$template->assign('selected', $url.'&amp;order='.$selected_order);
-
-switch ($selected_order)
-{
- case 'name':
- uasort($fs_plugins, 'name_compare');
- break;
- case 'id':
- uksort($fs_plugins, 'strcasecmp');
- break;
- case 'author':
- uasort($fs_plugins, 'plugin_author_compare');
- break;
- case 'status':
- $fs_plugins = sort_plugins_by_state($fs_plugins, $db_plugins_by_id);
- break;
-}
-
-
-//--------------------------------------------------------------display plugins
-
-$url = $base_url.get_query_string_diff( array('action', 'plugin') );
-
-foreach($fs_plugins as $plugin_id => $fs_plugin)
+$plugins->tabsheet();
+$plugins->sort_fs_plugins();
+$plugins->set_order_options(array(
+ 'name' => l10n('Name'),
+ 'status' => l10n('Status'),
+ 'author' => l10n('Author'),
+ 'id' => 'Id'));
+
+foreach($plugins->fs_plugins as $plugin_id => $fs_plugin)
{
$display_name = $fs_plugin['name'];
if (!empty($fs_plugin['uri']))
@@ -214,11 +84,11 @@ foreach($fs_plugins as $plugin_id => $fs_plugin)
'VERSION' => $fs_plugin['version'],
'DESCRIPTION' => $desc);
- $action_url = $url.'&amp;plugin='.$plugin_id;
+ $action_url = $plugins->html_base_url . '&amp;plugin=' . $plugin_id;
- if (isset($db_plugins_by_id[$plugin_id]))
- {
- switch ($db_plugins_by_id[$plugin_id]['state'])
+ if (isset($plugins->db_plugins_by_id[$plugin_id]))
+ {
+ switch ($plugins->db_plugins_by_id[$plugin_id]['state'])
{
case 'active':
$tpl_plugin['actions'][] =
@@ -245,24 +115,24 @@ foreach($fs_plugins as $plugin_id => $fs_plugin)
'CONFIRM' => l10n('Are you sure?'));
$tpl_plugin['actions'][] =
array('U_ACTION' => $action_url . '&amp;action=delete',
- 'L_ACTION' => l10n('plugins_delete'),
- 'CONFIRM' => l10n('plugins_confirm_delete'));
+ 'L_ACTION' => l10n('plugins_delete'),
+ 'CONFIRM' => l10n('plugins_confirm_delete'));
}
$template->append('plugins', $tpl_plugin);
}
$missing_plugin_ids = array_diff(
- array_keys($db_plugins_by_id), array_keys($fs_plugins)
+ array_keys($plugins->db_plugins_by_id), array_keys($plugins->fs_plugins)
);
foreach($missing_plugin_ids as $plugin_id)
{
- $action_url = $url.'&amp;plugin='.$plugin_id;
+ $action_url = $plugins->html_base_url.'&amp;plugin='.$plugin_id;
$template->append( 'plugins',
array(
'NAME' => $plugin_id,
- 'VERSION' => $db_plugins_by_id[$plugin_id]['version'],
+ 'VERSION' => $plugins->db_plugins_by_id[$plugin_id]['version'],
'DESCRIPTION' => "ERROR: THIS PLUGIN IS MISSING BUT IT IS INSTALLED! UNINSTALL IT NOW !",
'actions' => array ( array (
'U_ACTION' => $action_url . '&amp;action=uninstall',