mirror of
https://github.com/Piwigo/Piwigo.git
synced 2026-07-05 17:32:25 +02:00
Corrections in plugins management.
Add "Last revisions" sort order. git-svn-id: http://piwigo.org/svn/trunk@2272 68402e56-0260-453c-a942-63ccdbb3a9ee
This commit is contained in:
@@ -46,4 +46,22 @@ function get_admin_plugin_menu_link($file)
|
||||
}
|
||||
return $url;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set tabsheet for plugins pages.
|
||||
* @param string selected page.
|
||||
*/
|
||||
function set_plugins_tabsheet($selected)
|
||||
{
|
||||
include_once(PHPWG_ROOT_PATH.'admin/include/tabsheet.class.php');
|
||||
|
||||
$link = get_root_url().'admin.php?page=';
|
||||
|
||||
$tabsheet = new tabsheet();
|
||||
$tabsheet->add('plugins_list', l10n('plugins_tab_list'), $link.'plugins_list');
|
||||
$tabsheet->add('plugins_update', l10n('plugins_tab_update'), $link.'plugins_update');
|
||||
$tabsheet->add('plugins_new', l10n('plugins_tab_new'), $link.'plugins_new');
|
||||
$tabsheet->select($selected);
|
||||
$tabsheet->assign();
|
||||
}
|
||||
?>
|
||||
@@ -28,7 +28,7 @@ class plugins
|
||||
{
|
||||
var $fs_plugins = array();
|
||||
var $db_plugins_by_id = array();
|
||||
var $server_plugins = array();
|
||||
var $server_plugins;
|
||||
|
||||
/**
|
||||
* Initialize $fs_plugins and $db_plugins_by_id
|
||||
@@ -49,7 +49,7 @@ class plugins
|
||||
* @param string - plugin id
|
||||
* @param array - errors
|
||||
*/
|
||||
function perform_action($action, $plugin_id, $errors=array())
|
||||
function perform_action($action, $plugin_id)
|
||||
{
|
||||
if (isset($this->db_plugins_by_id[$plugin_id]))
|
||||
{
|
||||
@@ -57,6 +57,8 @@ class plugins
|
||||
}
|
||||
$file_to_include = PHPWG_PLUGINS_PATH . $plugin_id . '/maintain.inc.php';
|
||||
|
||||
$errors = array();
|
||||
|
||||
switch ($action)
|
||||
{
|
||||
case 'install':
|
||||
@@ -279,10 +281,6 @@ DELETE FROM ' . PLUGINS_TABLE . ' WHERE id="' . $plugin_id . '"';
|
||||
{
|
||||
$this->server_plugins = @unserialize($source);
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->server_plugins = false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -295,6 +293,9 @@ DELETE FROM ' . PLUGINS_TABLE . ' WHERE id="' . $plugin_id . '"';
|
||||
case 'date':
|
||||
krsort($this->server_plugins);
|
||||
break;
|
||||
case 'revision':
|
||||
usort($this->server_plugins, array($this, 'extension_revision_compare'));
|
||||
break;
|
||||
case 'name':
|
||||
uasort($this->server_plugins, array($this, 'extension_name_compare'));
|
||||
break;
|
||||
@@ -427,9 +428,18 @@ DELETE FROM ' . PLUGINS_TABLE . ' WHERE id="' . $plugin_id . '"';
|
||||
*/
|
||||
function plugin_version_compare($a, $b)
|
||||
{
|
||||
$r = version_compare($a['version'], $b['version']);
|
||||
if ($r == 0) return strcasecmp($a['version'], $b['version']);
|
||||
else return $r;
|
||||
$pattern = array('/([a-z])/ei', '/\.+/', '/\.\Z|\A\./');
|
||||
$replacement = array( "'.'.intval('\\1', 36).'.'", '.', '');
|
||||
|
||||
$array = preg_replace($pattern, $replacement, array($a['version'], $b['version']));
|
||||
|
||||
return version_compare($array[0], $array[1], '>=');
|
||||
}
|
||||
|
||||
function extension_revision_compare($a, $b)
|
||||
{
|
||||
if ($a['date'] < $b['date']) return 1;
|
||||
else return -1;
|
||||
}
|
||||
|
||||
function extension_name_compare($a, $b)
|
||||
|
||||
+3
-10
@@ -41,23 +41,16 @@ $plugins = new plugins();
|
||||
if (isset($_GET['action']) and isset($_GET['plugin']) and !is_adviser())
|
||||
{
|
||||
$page['errors'] =
|
||||
$plugins->perform_action($_GET['action'], $_GET['plugin'], $page['errors']);
|
||||
$plugins->perform_action($_GET['action'], $_GET['plugin']);
|
||||
|
||||
if (empty($page['errors'])) redirect($base_url);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------Tabsheet
|
||||
include_once(PHPWG_ROOT_PATH.'admin/include/tabsheet.class.php');
|
||||
$link = get_root_url().'admin.php?page=';
|
||||
$tabsheet = new tabsheet();
|
||||
$tabsheet->add('plugins_list', l10n('plugins_tab_list'), $link.'plugins_list');
|
||||
$tabsheet->add('plugins_update', l10n('plugins_tab_update'), $link.'plugins_update');
|
||||
$tabsheet->add('plugins_new', l10n('plugins_tab_new'), $link.'plugins_new');
|
||||
$tabsheet->select($page['page']);
|
||||
$tabsheet->assign();
|
||||
set_plugins_tabsheet($page['page']);
|
||||
|
||||
//---------------------------------------------------------------Order options
|
||||
$link .= $page['page'].'&order=';
|
||||
$link = get_root_url().'admin.php?page='.$page['page'].'&order=';
|
||||
$template->assign('order_options',
|
||||
array(
|
||||
$link.'name' => l10n('Name'),
|
||||
|
||||
+7
-11
@@ -77,20 +77,14 @@ if (isset($_GET['installstatus']))
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------Tabsheet
|
||||
include_once(PHPWG_ROOT_PATH.'admin/include/tabsheet.class.php');
|
||||
$link = get_root_url().'admin.php?page=';
|
||||
$tabsheet = new tabsheet();
|
||||
$tabsheet->add('plugins_list', l10n('plugins_tab_list'), $link.'plugins_list');
|
||||
$tabsheet->add('plugins_update', l10n('plugins_tab_update'), $link.'plugins_update');
|
||||
$tabsheet->add('plugins_new', l10n('plugins_tab_new'), $link.'plugins_new');
|
||||
$tabsheet->select($page['page']);
|
||||
$tabsheet->assign();
|
||||
set_plugins_tabsheet($page['page']);
|
||||
|
||||
//---------------------------------------------------------------Order options
|
||||
$link .= $page['page'].'&order=';
|
||||
$link = get_root_url().'admin.php?page='.$page['page'].'&order=';
|
||||
$template->assign('order_options',
|
||||
array(
|
||||
$link.'date' => l10n('Post date'),
|
||||
$link.'revision' => l10n('plugins_revisions'),
|
||||
$link.'name' => l10n('Name'),
|
||||
$link.'author' => l10n('Author')));
|
||||
$template->assign('order_selected', $link.$order);
|
||||
@@ -99,10 +93,11 @@ $template->assign('order_selected', $link.$order);
|
||||
// | start template output |
|
||||
// +-----------------------------------------------------------------------+
|
||||
$plugins->get_server_plugins(true);
|
||||
$plugins->sort_server_plugins($order);
|
||||
|
||||
if ($plugins->server_plugins !== false)
|
||||
if (is_array($plugins->server_plugins))
|
||||
{
|
||||
$plugins->sort_server_plugins($order);
|
||||
|
||||
foreach($plugins->server_plugins as $plugin)
|
||||
{
|
||||
$ext_desc = nl2br(htmlspecialchars(strip_tags(
|
||||
@@ -130,6 +125,7 @@ if ($plugins->server_plugins !== false)
|
||||
'EXT_DESC' => $ext_desc,
|
||||
'VERSION' => $plugin['version'],
|
||||
'VERSION_URL' => PEM_URL.'/revision_view.php?rid='.$plugin['id_revision'],
|
||||
'DATE' => date('Y-m-d', $plugin['date']),
|
||||
'VER_DESC' => $ver_desc,
|
||||
'AUTHOR' => $plugin['author'],
|
||||
'URL_INSTALL' => $url_auto_install,
|
||||
|
||||
@@ -94,21 +94,14 @@ if (isset($_GET['upgradestatus']) and isset($_GET['plugin']))
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------Tabsheet
|
||||
include_once(PHPWG_ROOT_PATH.'admin/include/tabsheet.class.php');
|
||||
$link = get_root_url().'admin.php?page=';
|
||||
$tabsheet = new tabsheet();
|
||||
$tabsheet->add('plugins_list', l10n('plugins_tab_list'), $link.'plugins_list');
|
||||
$tabsheet->add('plugins_update', l10n('plugins_tab_update'), $link.'plugins_update');
|
||||
$tabsheet->add('plugins_new', l10n('plugins_tab_new'), $link.'plugins_new');
|
||||
$tabsheet->select($page['page']);
|
||||
$tabsheet->assign();
|
||||
set_plugins_tabsheet($page['page']);
|
||||
|
||||
// +-----------------------------------------------------------------------+
|
||||
// | start template output |
|
||||
// +-----------------------------------------------------------------------+
|
||||
$plugins->get_server_plugins();
|
||||
|
||||
if ($plugins->server_plugins !== false)
|
||||
if (is_array($plugins->server_plugins))
|
||||
{
|
||||
foreach($plugins->fs_plugins as $plugin_id => $fs_plugin)
|
||||
{
|
||||
@@ -126,7 +119,7 @@ if ($plugins->server_plugins !== false)
|
||||
nl2br(htmlspecialchars(strip_tags(
|
||||
utf8_encode($plugin_info['description'])))));
|
||||
|
||||
if ($plugins->plugin_version_compare($fs_plugin, $plugin_info) >= 0)
|
||||
if ($plugins->plugin_version_compare($fs_plugin, $plugin_info))
|
||||
{
|
||||
// Plugin is up to date
|
||||
$template->append('plugins_uptodate',
|
||||
|
||||
Reference in New Issue
Block a user