From 491e8adc7467de9f9aa6dbbebfcb8b82c676b46a Mon Sep 17 00:00:00 2001 From: patdenice Date: Wed, 20 Apr 2011 14:52:52 +0000 Subject: feature:2271 Merge autoupdate plugin into piwigo core. git-svn-id: http://piwigo.org/svn/trunk@10511 68402e56-0260-453c-a942-63ccdbb3a9ee --- admin/themes/default/images/ajax-loader-bar.gif | Bin 0 -> 10819 bytes admin/themes/default/template/admin.tpl | 1 + admin/themes/default/template/updates_ext.tpl | 272 ++++++++++++++++++++++++ admin/themes/default/template/updates_pwg.tpl | 99 +++++++++ 4 files changed, 372 insertions(+) create mode 100644 admin/themes/default/images/ajax-loader-bar.gif create mode 100644 admin/themes/default/template/updates_ext.tpl create mode 100644 admin/themes/default/template/updates_pwg.tpl (limited to 'admin/themes/default') diff --git a/admin/themes/default/images/ajax-loader-bar.gif b/admin/themes/default/images/ajax-loader-bar.gif new file mode 100644 index 000000000..d84f65378 Binary files /dev/null and b/admin/themes/default/images/ajax-loader-bar.gif differ diff --git a/admin/themes/default/template/admin.tpl b/admin/themes/default/template/admin.tpl index 2daad8118..56a92a75e 100644 --- a/admin/themes/default/template/admin.tpl +++ b/admin/themes/default/template/admin.tpl @@ -75,6 +75,7 @@ jQuery(document).ready(function(){ldelim} {/if}
  • {'Maintenance'|@translate}
  • {'Pending Comments'|@translate}
  • +
  • {'Updates'|@translate}
  • diff --git a/admin/themes/default/template/updates_ext.tpl b/admin/themes/default/template/updates_ext.tpl new file mode 100644 index 000000000..d0cd7a2a7 --- /dev/null +++ b/admin/themes/default/template/updates_ext.tpl @@ -0,0 +1,272 @@ +{combine_script id='jquery.ajaxmanager' load='footer' require='jquery' path='themes/default/js/plugins/jquery.ajaxmanager.js'} +{combine_script id='jquery.jgrowl' load='footer' require='jquery' path='themes/default/js/plugins/jquery.jgrowl_minimized.js'} +{combine_css path="admin/themes/default/uploadify.jGrowl.css"} + +{footer_script require='jquery.effects.blind,jquery.ajaxmanager,jquery.jgrowl'} +var pwg_token = '{$PWG_TOKEN}'; +var extList = new Array(); +var confirmMsg = '{'Are you sure?'|@translate|@escape:'javascript'}'; +var errorHead = '{'ERROR'|@translate|@escape:'javascript'}'; +var successHead = '{'Update Complete'|@translate|@escape:'javascript'}'; +var errorMsg = '{'an error happened'|@translate|@escape:'javascript'}'; +var restoreMsg = '{'Reset ignored updates'|@translate|@escape:'javascript'}'; + +{literal} +var todo = 0; +var queuedManager = $.manageAjax.create('queued', { + queue: true, + maxRequests: 1, + beforeSend: function() { autoupdate_bar_toggle(1); }, + complete: function() { autoupdate_bar_toggle(-1); } +}); + +function updateAll() { + if (confirm(confirmMsg)) { + jQuery('.updateExtension').each( function() { + if (jQuery(this).parents('div').css('display') == 'block') + jQuery(this).click(); + }); + } +}; + +function resetIgnored() { + jQuery.ajax({ + type: 'GET', + url: 'ws.php', + dataType: 'json', + data: { method: 'pwg.extensions.ignoreUpdate', reset: true, pwg_token: pwg_token, format: 'json' }, + success: function(data) { + if (data['stat'] == 'ok') { + jQuery(".pluginBox, fieldset").show(); + jQuery("#update_all").show(); + jQuery("#up_to_date").hide(); + jQuery("#reset_ignore").hide(); + jQuery("#ignored").hide(); + checkFieldsets(); + } + } + }); +}; + +function checkFieldsets() { + var types = new Array('plugins', 'themes', 'languages'); + var total = 0; + var ignored = 0; + for (i=0;i<3;i++) { + nbExtensions = 0; + jQuery("div[id^='"+types[i]+"_']").each(function(index) { + if (jQuery(this).css('display') == 'block') + nbExtensions++; + else + ignored++; + }); + total = total + nbExtensions; + if (nbExtensions == 0) + jQuery("#"+types[i]).hide(); + } + + if (total == 0) { + jQuery("#update_all").hide(); + jQuery("#up_to_date").show(); + } + if (ignored > 0) { + jQuery("#reset_ignore").val(restoreMsg + ' (' + ignored + ')'); + } +}; + +function updateExtension(type, id, revision) { + queuedManager.add({ + type: 'GET', + dataType: 'json', + url: 'ws.php', + data: { method: 'pwg.extensions.update', type: type, id: id, revision: revision, pwg_token: pwg_token, format: 'json' }, + success: function(data) { + if (data['stat'] == 'ok') { + jQuery.jGrowl( data['result'], { theme: 'success', header: successHead, life: 4000, sticky: false }); + jQuery("#"+type+"_"+id).remove(); + checkFieldsets(); + } else { + jQuery.jGrowl( data['result'], { theme: 'error', header: errorHead, sticky: true }); + } + }, + error: function(data) { + jQuery.jGrowl( errorMsg, { theme: 'error', header: errorHead, sticky: true }); + } + }); +}; + +function ignoreExtension(type, id) { + jQuery.ajax({ + type: 'GET', + url: 'ws.php', + dataType: 'json', + data: { method: 'pwg.extensions.ignoreUpdate', type: type, id: id, pwg_token: pwg_token, format: 'json' }, + success: function(data) { + if (data['stat'] == 'ok') { + jQuery("#"+type+"_"+id).hide(); + jQuery("#reset_ignore").show(); + checkFieldsets(); + } + } + }); +}; + +function autoupdate_bar_toggle(i) { + todo = todo + i; + if ((i == 1 && todo == 1) || (i == -1 && todo == 0)) + jQuery('.autoupdate_bar').toggle(); +} + +jQuery(document).ready(function() { + jQuery("td[id^='desc_'], p[id^='revdesc_']").click(function() { + id = this.id.split('_'); + jQuery("#revdesc_"+id[1]).toggle('blind'); + jQuery(".button_"+id[1]).toggle(); + return false; + }); +}); + +checkFieldsets(); +{/literal} +{/footer_script} + +
    +

    {'Updates'|@translate}

    +
    + +
    +
    + + +
    + + + + +{if not empty($update_plugins)} +
    +
    +{'Plugins'|@translate} +{foreach from=$update_plugins item=plugin name=plugins_loop} +
    + + + + + + + + + + + + + +
    + {$plugin.EXT_NAME} + + {'Install'|@translate} + | {'Download'|@translate} + | {'Ignore this update'|@translate} +
    + {'Version'|@translate} {$plugin.CURRENT_VERSION} + + {'Downloads'|@translate}: {$plugin.DOWNLOADS} + + + {'New Version'|@translate} : {$plugin.NEW_VERSION} + | {'By %s'|@translate|@sprintf:$plugin.AUTHOR} +
    + +
    +
    +{/foreach} +
    +
    +{/if} + +{if not empty($update_themes)} +
    +
    +{'Themes'|@translate} +{foreach from=$update_themes item=theme name=themes_loop} +
    + + + + + + + + + + + + + +
    + {$theme.EXT_NAME} + + {'Install'|@translate} + | {'Download'|@translate} + | {'autoupdate_ignore'|@translate} +
    + {'Version'|@translate} {$theme.CURRENT_VERSION} + + {'Downloads'|@translate}: {$theme.DOWNLOADS} + + + {'New Version'|@translate} : {$theme.NEW_VERSION} + | {'By %s'|@translate|@sprintf:$theme.AUTHOR} +
    + +
    +
    +{/foreach} +
    +
    +{/if} + +{if not empty($update_languages)} +
    +
    +{'Languages'|@translate} +{foreach from=$update_languages item=language name=languages_loop} +
    + + + + + + + + + + + + + +
    + {$language.EXT_NAME} + + {'Install'|@translate} + | {'Download'|@translate} + | {'autoupdate_ignore'|@translate} +
    + {'Version'|@translate} {$language.CURRENT_VERSION} + + {'Downloads'|@translate}: {$language.DOWNLOADS} + + + {'New Version'|@translate} : {$language.NEW_VERSION} + | {'By %s'|@translate|@sprintf:$language.AUTHOR} +
    + +
    +
    +{/foreach} +
    +
    +{/if} diff --git a/admin/themes/default/template/updates_pwg.tpl b/admin/themes/default/template/updates_pwg.tpl new file mode 100644 index 000000000..c85e1fb6b --- /dev/null +++ b/admin/themes/default/template/updates_pwg.tpl @@ -0,0 +1,99 @@ +{footer_script} +jQuery(document).ready(function() {ldelim} + jQuery('input[name="submit"]').click(function() {ldelim} + if(!confirm('{'autoupdate_alert'|@translate}')) + return false; + jQuery(this).hide(); + jQuery('.autoupdate_bar').show(); + }); + jQuery('[name="understand"]').click(function() {ldelim} + jQuery('[name="submit"]').attr('disabled', !this.checked); + }); +}); +{/footer_script} + +{html_head} +{literal} + +{/literal} +{/html_head} + +
    +

    {'Updates'|@translate}

    +
    + +{if $STEP == 0} + {if $CHECK_VERSION} +

    {'You are running the latest version of Piwigo.'|@translate}

    + {elseif $DEV_VERSION} +

    {'You are running on development sources, no check possible.'|@translate}

    + {else} +

    {'Check for update failed for unknown reasons.'|@translate}

    + {/if} +{/if} + +{if $STEP == 1} +

    {'Two updates are available'|@translate}:

    +

    +

    +

    +

    {'You can update to Piwigo %s directly, without upgrading to Piwigo %s (recommended).'|@translate|@sprintf:$MAJOR_VERSION:$MINOR_VERSION}

    +{/if} + +{if $STEP == 2} +

    + {'A new version of Piwigo is available.'|@translate}
    + {'This is a minor update, with only bug corrections.'|@translate} +

    +
    +

    + +

    +
    +{/if} + +{if $STEP == 3} +

    + {'A new version of Piwigo is available.'|@translate}
    + {'This is a major update, with new exciting features.'|@translate|@sprintf:$RELEASE_URL} {'Some themes and plugins may be not available yet.'|@translate} +

    +
    + +{counter assign=i} +
    + {'Dump Database'|@translate} +

      {'Include history data (Warning: server memory limit may be exceeded)'|@translate}

    +

    +
    + +{counter assign=i} +
    + {'Update to Piwigo %s'|@translate|@sprintf:$UPGRADE_TO} + {if !empty($missing.plugins)} +

    {'Following plugins may not be compatible with the new version of Piwigo:'|@translate}

    +


    + {/if} + {if !empty($missing.themes)} +

    {'Following themes may not be compatible with the new version of Piwigo:'|@translate}

    +


    + {/if} +

    + {if !empty($missing.plugins) or !empty($missing.themes)} +

    + {/if} +

    +

    + +
    + +

    +
    +{/if} \ No newline at end of file -- cgit v1.2.3