Show spartacus errors, maka ajax detection global

This commit is contained in:
onli 2015-01-30 22:07:08 +01:00
parent 147a9ab43e
commit f7c0fa23bc
5 changed files with 28 additions and 5 deletions

View File

@ -341,9 +341,14 @@ if (isset($_GET['serendipity']['plugin_to_conf'])) {
if (serendipity_checkPermission('adminPluginsMaintainOthers')) {
$authorid = '0';
}
if ($serendipity['ajax']) {
// we need to catch the spartacus messages to return only them to the ajax call (used by the update all button)
ob_start();
}
$fetchplugin_data = array('GET' => &$serendipity['GET'],
'install' => true);
serendipity_plugin_api::hook_event('backend_plugins_fetchplugin', $fetchplugin_data);
// we now have to check that the plugin is not already installed, or stackable, to prevent invalid double instances
@ -397,6 +402,10 @@ if (isset($_GET['serendipity']['plugin_to_conf'])) {
} else {
serendipity_plugin_api::hook_event('backend_plugins_update', $serendipity['GET']['install_plugin'], $fetchplugin_data);
}
if ($serendipity['ajax']) {
$data['ajax_output'] = ob_get_contents();
ob_end_clean();
}
}
if (isset($_POST['REMOVE']) && serendipity_checkFormToken()) {
@ -415,7 +424,11 @@ if (isset($_GET['serendipity']['plugin_to_conf'])) {
$data['timestamp'] = serendipity_strftime('%H:%M:%S');
}
ob_start();
serendipity_plugin_api::hook_event('backend_pluginlisting_header', $null);
$data['backend_pluginlisting_header'] = ob_get_contents();
ob_end_clean();
ob_start();
serendipity_plugin_api::hook_event('backend_plugins_sidebar_header', $serendipity);
@ -439,4 +452,5 @@ if (isset($_GET['serendipity']['plugin_to_conf'])) {
echo serendipity_smarty_show('admin/plugins.inc.tpl', $data);
/* vim: set sts=4 ts=4 expandtab : */

View File

@ -354,6 +354,7 @@ class serendipity_event_spartacus extends serendipity_event
}
function outputMSG($status, $msg) {
global $serendipity;
switch($status) {
case 'notice':
echo '<span class="msg_notice"><span class="icon-info-circled"></span> '. $msg .'</span>' . "\n";
@ -361,6 +362,10 @@ class serendipity_event_spartacus extends serendipity_event
case 'error':
echo '<span class="msg_error"><span class="icon-attention-circled"></span> '. $msg .'</span>' . "\n";
if ($serendipity['ajax']) {
// we need to set an actual error header so the ajax request can react to the error state
header('HTTP/1.1 400');
}
break;
default:
@ -573,7 +578,6 @@ class serendipity_event_spartacus extends serendipity_event
} else {
$mirror = $mirrors[$this->get_config('mirror_xml', 0)];
$url = $mirror . '/package_' . $url_type . $lang . '.xml';
$cacheTimeout = 60*60*12; // XML file is cached for half a day
$target = $serendipity['serendipityPath'] . PATH_SMARTY_COMPILE . '/package_' . $url_type . $lang . '.xml';

View File

@ -71,7 +71,7 @@ if ($is_logged_in) {
$self_info = '';
}
$ajax = (!empty($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest');
$serendipity['ajax'] = $ajax = (!empty($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest');
$no_banner = (isset($serendipity['GET']['noBanner']) || isset($serendipity['POST']['noBanner']));
$no_sidebar = (isset($serendipity['GET']['noSidebar']) || isset($serendipity['POST']['noSidebar']));
$no_footer = (isset($serendipity['GET']['noFooter']) || isset($serendipity['POST']['noFooter']));

View File

@ -151,7 +151,10 @@
<progress id="updateProgress" value="0" />
</div>
<script src="{serendipity_getFile file='admin/js/progress-polyfill.min.js'}"></script>
{elseif isset($ajax_output)}
{$ajax_output}
{else}
{$backend_pluginlisting_header}
<h2>{$CONST.CONFIGURE_PLUGINS}</h2>
{if $save}
<span class="msg_success"><span class="icon-ok-circled"></span> {$CONST.DONE}:{$CONST.SETTINGS_SAVED_AT|sprintf:"$timestamp"}</span>

View File

@ -808,7 +808,7 @@
serendipity.updateNext = function() {
$('#updateMessage').text("Updating " + $('.plugins_installable > li:visible h4').first().text());
$.get($('.plugin_status .button_link:visible').first().attr('href'))
.done(function() {
.done(function(messages) {
$('.plugins_installable > li:visible').first().fadeOut();
$('#updateProgress').attr('value', parseInt($('#updateProgress').attr('value')) + 1);
if ($('.plugins_installable > li:visible').length > 0) {
@ -819,7 +819,9 @@
});
}
})
.fail(function() {
.fail(function(data) {
$('#content').prepend(data.responseText);
$('#updateAll').hide();
$('#overlay').fadeOut();
});
}