Skip to content

Commit

Permalink
merge r11043 from branch 2.2 to trunk
Browse files Browse the repository at this point in the history
feature:2250
Add obsolete_extensions.list file in install directory.
Incompatible plugins is checked through ajax.

git-svn-id: http://piwigo.org/svn/trunk@11047 68402e56-0260-453c-a942-63ccdbb3a9ee
  • Loading branch information
patdenice committed May 25, 2011
1 parent d9fbe9b commit d8718a6
Show file tree
Hide file tree
Showing 4 changed files with 61 additions and 39 deletions.
24 changes: 7 additions & 17 deletions admin/include/plugins.class.php
Expand Up @@ -534,30 +534,20 @@ function extract_plugin_files($action, $revision, $dest)

function get_merged_extensions($version=PHPWG_VERSION)
{
if (isset($_SESSION['merged_extensions']) and $_SESSION['merged_extensions']['~~expire~~'] > time())
{
return $_SESSION['merged_extensions'];
}

$_SESSION['merged_extensions'] = array('~~expire~~' => time() + 600);
$file = PHPWG_ROOT_PATH.'install/obsolete_extensions.list';
$merged_extensions = array();

if (fetchRemote(PHPWG_URL.'/download/merged_extensions.txt', $result))
if (file_exists($file) and $obsolete_ext = file($file, FILE_IGNORE_NEW_LINES) and !empty($obsolete_ext))
{
$rows = explode("\n", $result);
foreach ($rows as $row)
foreach ($obsolete_ext as $ext)
{
if (preg_match('/^(\d+\.\d+): *(.*)$/', $row, $match))
if (preg_match('/^(\d+) ?: ?(.*?)$/', $ext, $matches))
{
if (version_compare($version, $match[1], '>='))
{
$extensions = explode(',', trim($match[2]));
$_SESSION['merged_extensions'] = array_merge($_SESSION['merged_extensions'], $extensions);
}
$merged_extensions[$matches[1]] = $matches[2];
}
}
}

return $_SESSION['merged_extensions'];
return $merged_extensions;
}

/**
Expand Down
22 changes: 17 additions & 5 deletions admin/plugins_installed.php
Expand Up @@ -64,13 +64,26 @@
}
}

//--------------------------------------------------------Incompatible Plugins
if (isset($_GET['incompatible_plugins']))
{
$incompatible_plugins = array();
foreach ($plugins->get_incompatible_plugins() as $plugin => $version)
{
if ($plugin == '~~expire~~') continue;
array_push($incompatible_plugins, $plugin);

}
echo json_encode($incompatible_plugins);
exit;
}

// +-----------------------------------------------------------------------+
// | start template output |
// +-----------------------------------------------------------------------+

$plugins->sort_fs_plugins('name');
$plugins->get_merged_extensions();
$plugins->get_incompatible_plugins();
$merged_extensions = $plugins->get_merged_extensions();
$merged_plugins = false;
$tpl_plugins = array();

Expand All @@ -80,7 +93,7 @@
and $fs_plugin['version'] != $_SESSION['incompatible_plugins'][$plugin_id])
{
// Incompatible plugins must be reinitilized
$plugins->get_incompatible_plugins(true);
unset($_SESSION['incompatible_plugins']);
}

$tpl_plugin = array(
Expand All @@ -92,7 +105,6 @@
'AUTHOR' => $fs_plugin['author'],
'AUTHOR_URL' => @$fs_plugin['author uri'],
'U_ACTION' => sprintf($action_url, $plugin_id),
'INCOMPATIBLE' => isset($_SESSION['incompatible_plugins'][$plugin_id]),
);

if (isset($plugins->db_plugins_by_id[$plugin_id]))
Expand All @@ -104,7 +116,7 @@
$tpl_plugin['STATE'] = 'inactive';
}

if (isset($fs_plugin['extension']) and in_array($fs_plugin['extension'], $_SESSION['merged_extensions']))
if (isset($fs_plugin['extension']) and isset($merged_extensions[$fs_plugin['extension']]))
{
$plugins->perform_action('uninstall', $plugin_id);
$tpl_plugin['STATE'] = 'merged';
Expand Down
49 changes: 32 additions & 17 deletions admin/themes/default/template/plugins_list.tpl
Expand Up @@ -3,8 +3,7 @@
{footer_script require='jquery.ajaxmanager'}
/* incompatible message */
var incompatible_msg = '{'WARNING! This plugin does not seem to be compatible with this version of Piwigo.'|@translate|@escape:'javascript'}';
incompatible_msg += '\n';
incompatible_msg += '{'Do you want to activate anyway?'|@translate|@escape:'javascript'}';
var activate_msg = '\n{'Do you want to activate anyway?'|@translate|@escape:'javascript'}';

/* group action */
var pwg_token = '{$PWG_TOKEN}';
Expand Down Expand Up @@ -39,18 +38,36 @@ jQuery(document).ready(function() {
});
};

/* incompatible message */
jQuery('.incompatible a.incompatible').click(function() {
return confirm(incompatible_msg);
/* incompatible plugins */
jQuery(document).ready(function() {
jQuery.ajax({
method: 'GET',
url: 'admin.php',
data: { page: 'plugins_installed', incompatible_plugins: true },
dataType: 'json',
success: function(data) {
for (i=0;i<data.length;i++) {
{/literal}
{if $plugin_display == 'complete'}
jQuery('#'+data[i]+' .pluginBoxNameCell').prepend('<a class="warning" title="'+incompatible_msg+'"></a>')
{else}
jQuery('#'+data[i]+' .pluginMiniBoxNameCell').prepend('<span class="warning" title="'+incompatible_msg+'"></span>')
{/if}
{literal}
jQuery('#'+data[i]).addClass('incompatible');
jQuery('#'+data[i]+' .activate').attr('onClick', 'return confirm(incompatible_msg + activate_msg);');
}
jQuery('.warning').tipTip({
'delay' : 0,
'fadeIn' : 200,
'fadeOut' : 200,
'maxWidth':'250px'
});
}
});
});

/* TipTips */
jQuery('.warning').tipTip({
'delay' : 0,
'fadeIn' : 200,
'fadeOut' : 200,
'maxWidth':'250px'
});
jQuery('.plugin-restore').tipTip({
'delay' : 0,
'fadeIn' : 200,
Expand Down Expand Up @@ -117,11 +134,10 @@ jQuery(document).ready(function() {
{/if}

{if $plugin_display == 'complete'}
<div id="{$plugin.ID}" class="pluginBox {$plugin.STATE}{if $plugin.INCOMPATIBLE} incompatible{/if}">
<div id="{$plugin.ID}" class="pluginBox">
<table>
<tr>
<td class="pluginBoxNameCell">
{if $plugin.INCOMPATIBLE}<a class="warning" title="{'WARNING! This plugin does not seem to be compatible with this version of Piwigo.'|@translate|@escape:'html'}"></a>{/if}
{$plugin.NAME}
</td>
<td>{$plugin.DESC}</td>
Expand All @@ -133,7 +149,7 @@ jQuery(document).ready(function() {
| <a href="{$plugin.U_ACTION}&amp;action=restore" class="plugin-restore" title="{'Restore default configuration. You will lost your plugin settings!'|@translate}" onclick="return confirm('{'Are you sure?'|@translate|@escape:'javascript'}');">{'Restore'|@translate}</a>

{elseif $plugin.STATE == 'inactive'}
<a href="{$plugin.U_ACTION}&amp;action=activate" {if $plugin.INCOMPATIBLE}class="incompatible"{/if}>{'Activate'|@translate}</a>
<a href="{$plugin.U_ACTION}&amp;action=activate" class="activate">{'Activate'|@translate}</a>
| <a href="{$plugin.U_ACTION}&amp;action=delete" onclick="return confirm('{'Are you sure?'|@translate|@escape:'javascript'}');">{'Delete'|@translate}</a>

{elseif $plugin.STATE == 'missing'}
Expand Down Expand Up @@ -165,9 +181,8 @@ jQuery(document).ready(function() {
{assign var='version' value=$plugin.VERSION}
{/if}

<div id="{$plugin.ID}" class="pluginMiniBox {$plugin.STATE}{if $plugin.INCOMPATIBLE} incompatible{/if}">
<div id="{$plugin.ID}" class="pluginMiniBox">
<div class="pluginMiniBoxNameCell">
{if $plugin.INCOMPATIBLE}<span class="warning" title="{'WARNING! This plugin does not seem to be compatible with this version of Piwigo.'|@translate|@escape:'html'}"></span>{/if}
{$plugin.NAME}
<a class="showInfo" title="{if !empty($author)}{'By %s'|@translate|@sprintf:$author} | {/if}{'Version'|@translate} {$version}<br/>{$plugin.DESC|@escape:'html'}">i</a>
</div>
Expand All @@ -178,7 +193,7 @@ jQuery(document).ready(function() {
| <a href="{$plugin.U_ACTION}&amp;action=restore" class="plugin-restore" title="{'Restore default configuration. You will lost all your settings !'|@translate}" onclick="return confirm('{'Are you sure?'|@translate|@escape:'javascript'}');">{'Restore'|@translate}</a>

{elseif $plugin.STATE == 'inactive'}
<a href="{$plugin.U_ACTION}&amp;action=activate" {if $plugin.INCOMPATIBLE}class="incompatible"{/if}>{'Activate'|@translate}</a>
<a href="{$plugin.U_ACTION}&amp;action=activate" class="activate">{'Activate'|@translate}</a>
| <a href="{$plugin.U_ACTION}&amp;action=delete" onclick="return confirm('{'Are you sure?'|@translate|@escape:'javascript'}');">{'Delete'|@translate}</a>

{elseif $plugin.STATE == 'missing'}
Expand Down
5 changes: 5 additions & 0 deletions install/obsolete_extensions.list
@@ -0,0 +1,5 @@
411: pwg_images_addSimple
396: albums
449: Photos
405: unTagged
440: bulk_manager

0 comments on commit d8718a6

Please sign in to comment.