Index: /extensions/Google2Piwigo/admin.php =================================================================== --- /extensions/Google2Piwigo/admin.php (revision 26197) +++ /extensions/Google2Piwigo/admin.php (revision 26198) @@ -1,4 +1,4 @@ PICASA_WA_ADMIN, )); + $template->assign_var_from_handle('ADMIN_CONTENT', 'picasa_web_albums'); - -?> Index: /extensions/Google2Piwigo/admin/import.php =================================================================== --- /extensions/Google2Piwigo/admin/import.php (revision 26197) +++ /extensions/Google2Piwigo/admin/import.php (revision 26198) @@ -1,4 +1,4 @@ $userEntry->title->text, 'description' => $userEntry->mediaGroup->description->text, 'photos' => $userEntry->gphotoNumPhotos->text, 'U_LIST' => PICASA_WA_ADMIN . '-import&action=list_photos&album=' . $userEntry->gphotoId->text, - )); + ); } @@ -139,5 +142,5 @@ foreach ($albumFeed as $albumEntry) { - array_push($all_photos, array( + $all_photos[] = array( 'id' => $albumEntry->getGphotoId()->getText(), 'name' => $albumEntry->mediaGroup->title->text, @@ -145,5 +148,5 @@ 'src' => $albumEntry->mediaGroup->content[0]->url, 'url' => $albumEntry->link[2]->href, - )); + ); } @@ -170,6 +173,9 @@ if ($duplicates>0) { - $page['infos'][] = '' - .l10n_dec('One picture is not displayed because already existing in the database.', '%d pictures are not displayed because already existing in the database.', $duplicates) + $page['infos'][] = '' + .l10n_dec( + 'One picture is not displayed because already existing in the database.', + '%d pictures are not displayed because already existing in the database.', + $duplicates) .''; } @@ -260,6 +266,9 @@ if ($duplicates>0) { - $page['infos'][] = '' - .l10n_dec('One picture is not displayed because already existing in the database.', '%d pictures are not displayed because already existing in the database.', $duplicates) + $page['infos'][] = '' + .l10n_dec( + 'One picture is not displayed because already existing in the database.', + '%d pictures are not displayed because already existing in the database.', + $duplicates) .''; } @@ -267,5 +276,5 @@ $template->assign(array( 'nb_elements' => count($all_photos), - 'all_elements' => json_encode($all_photos), + 'all_elements' => $all_photos, 'F_ACTION' => PICASA_WA_ADMIN . '-import&action=import_set', )); @@ -285,5 +294,5 @@ if (isset($_POST['done'])) { - $_SESSION['page_infos'][] = sprintf(l10n('%d pictures imported'), $_POST['done']); + $_SESSION['page_infos'][] = l10n('%d pictures imported', $_POST['done']); } redirect(PICASA_WA_ADMIN . '-import'); @@ -292,10 +301,5 @@ -$template->assign(array( - 'ACTION' => $_GET['action'], - 'GMAPS_LOADED' => !empty($pwg_loaded_plugins['rv_gmaps']) || !empty($pwg_loaded_plugins['piwigo-openstreetmap']), - )); +$template->assign('ACTION', $_GET['action']); $template->set_filename('picasa_web_albums', realpath(PICASA_WA_PATH . '/admin/template/import.tpl')); - -?> Index: /extensions/Google2Piwigo/admin/template/import.list_all.tpl =================================================================== --- /extensions/Google2Piwigo/admin/template/import.list_all.tpl (revision 26197) +++ /extensions/Google2Piwigo/admin/template/import.list_all.tpl (revision 26198) @@ -1,55 +1,67 @@ {footer_script require='jquery.ajaxmanager,jquery.jgrowl'} -/* global vars */ -var errorHead = '{'ERROR'|@translate|@escape:'javascript'}'; -var errorMsg = '{'an error happened'|@translate|@escape:'javascript'}'; -var successHead = '{'Success'|@translate|@escape:'javascript'}'; +(function($){ + /* global vars */ + var all_elements = [{if !empty($all_elements)}{','|@implode:$all_elements}{/if}]; + var import_done = 0; + var import_selected = {$nb_elements}; + var queuedManager = $.manageAjax.create('queued', { + queue: true, + maxRequests: 1 + }); -var import_done = 0; -var import_selected = {$nb_elements}; -var queuedManager = jQuery.manageAjax.create('queued', {ldelim} - queue: true, - maxRequests: 1 -}); + /* import queue */ + function performImport(photo, album, fills, pwa_album) { + queuedManager.add({ + type: 'GET', + dataType: 'json', + url: 'ws.php', + data: { + method: 'pwg.images.addPicasa', + id: photo, + category: album, + fills: fills, + pwa_album: pwa_album, + format: 'json' + }, + success: function(data) { + if (data['stat'] == 'ok') { + $.jGrowl(data['result'], { + theme: 'success', life: 4000, sticky: false, + header: '{'Success'|translate}' + }); + } + else { + $.jGrowl(data['result'], { + theme: 'error', sticky: true, + header: '{'ERROR'|translate}' + }); + } + + import_done++; + $("#progress").html(import_done +"/"+ import_selected); + + if (import_done == import_selected) { + $("#import_form").append(''); + $("#import_form").submit(); + } + }, + error: function(data) { + $.jGrowl('{'an error happened'|translate|escape:javascript}', { + theme: 'error', sticky: true, + header: '{'ERROR'|translate}' + }); + } + }); + } -{literal} -/* import queue */ -function performImport(photo, album, fills, pwa_album) { - queuedManager.add({ - type: 'GET', - dataType: 'json', - url: 'ws.php', - data: { method: 'pwg.images.addPicasa', id: photo, category: album, fills: fills, pwa_album: pwa_album, format: 'json' }, - success: function(data) { - if (data['stat'] == 'ok') { - jQuery.jGrowl(data['result'], { theme: 'success', header: successHead, life: 4000, sticky: false }); - } else { - jQuery.jGrowl(data['result'], { theme: 'error', header: errorHead, sticky: true }); - } - - import_done++; - $("#progress").html(import_done +"/"+ import_selected); - - if (import_done == import_selected) { - $("#import_form").append(''); - $("#import_form").submit(); - } - }, - error: function(data) { - jQuery.jGrowl(errorMsg, { theme: 'error', header: errorHead, sticky: true }); - } - }); -} - - -$(document).ready(function() { - var all_elements = {/literal}{$all_elements}{literal}; /* begin import */ - jQuery('#beginImport').click(function() { + $('#beginImport').click(function() { $("#loader_import").fadeIn(); if ($("input[name='album_mode']:checked").val() == 'identical') { album = ""; - } else { + } + else { album = $("#albumSelect option:selected").val(); } @@ -74,10 +86,10 @@ if ($(this).val() == 'one_album') { $("#albumSelectWrapper").slideDown(); - } else { + } + else { $("#albumSelectWrapper").slideUp(); } }); -}); -{/literal} +}(jQuery)); {/footer_script} @@ -85,19 +97,19 @@
Index: /extensions/Google2Piwigo/admin/template/import.list_photos.tpl =================================================================== --- /extensions/Google2Piwigo/admin/template/import.list_photos.tpl (revision 26197) +++ /extensions/Google2Piwigo/admin/template/import.list_photos.tpl (revision 26198) @@ -1,29 +1,18 @@ {footer_script require='jquery.ajaxmanager,jquery.jgrowl'} -/* global vars */ -var nb_thumbs_page = {$nb_thumbs_page}; -var nb_thumbs_set = {$nb_thumbs_set}; -var all_elements = [{if !empty($all_elements)}{','|@implode:$all_elements}{/if}]; - -var errorHead = '{'ERROR'|@translate|@escape:'javascript'}'; -var errorMsg = '{'an error happened'|@translate|@escape:'javascript'}'; -var successHead = '{'Success'|@translate|@escape:'javascript'}'; -var selectedMessage_pattern = "{'%d of %d photos selected'|@translate}"; -var selectedMessage_none = "{'No photo selected, %d photos in current set'|@translate}"; -var selectedMessage_all = "{'All %d photos are selected'|@translate}"; -var applyOnDetails_pattern = "{'on the %d selected photos'|@translate}"; - -var import_done = 0; -var import_selected = 0; -var queuedManager = jQuery.manageAjax.create('queued', {ldelim} - queue: true, - maxRequests: 1 -}); - -{literal} -/* Shift-click: select all photos between the click and the shift+click */ -jQuery(document).ready(function() { +(function($){ + /* global vars */ + var nb_thumbs_set = {$nb_thumbs_set}; + var all_elements = [{if !empty($all_elements)}{','|@implode:$all_elements}{/if}]; + var import_done = 0; + var import_selected = 0; + var queuedManager = $.manageAjax.create('queued', {ldelim} + queue: true, + maxRequests: 1 + }); + + /* Shift-click: select all photos between the click and the shift+click */ var last_clicked=0; var last_clickedstatus=true; - jQuery.fn.enableShiftClick = function() { + $.fn.enableShiftClick = function() { var inputs = []; var count=0; @@ -60,138 +49,109 @@ return true; }); - $(this).click(function(event) {$(this).triggerHandler("shclick",event)}); - }); - } -}); - -/* sprintf */ -function str_repeat(i, m) { - for (var o = []; m > 0; o[--m] = i); - return o.join(''); -} - -function sprintf() { - var i = 0, a, f = arguments[i++], o = [], m, p, c, x, s = ''; - while (f) { - if (m = /^[^\x25]+/.exec(f)) { - o.push(m[0]); - } - else if (m = /^\x25{2}/.exec(f)) { - o.push('%'); - } - else if (m = /^\x25(?:(\d+)\$)?(\+)?(0|'[^$])?(-)?(\d+)?(?:\.(\d+))?([b-fosuxX])/.exec(f)) { - if (((a = arguments[m[1] || i++]) == null) || (a == undefined)) { - throw('Too few arguments.'); - } - if (/[^s]/.test(m[7]) && (typeof(a) != 'number')) { - throw('Expecting number but found ' + typeof(a)); - } - switch (m[7]) { - case 'b': a = a.toString(2); break; - case 'c': a = String.fromCharCode(a); break; - case 'd': a = parseInt(a); break; - case 'e': a = m[6] ? a.toExponential(m[6]) : a.toExponential(); break; - case 'f': a = m[6] ? parseFloat(a).toFixed(m[6]) : parseFloat(a); break; - case 'o': a = a.toString(8); break; - case 's': a = ((a = String(a)) && m[6] ? a.substring(0, m[6]) : a); break; - case 'u': a = Math.abs(a); break; - case 'x': a = a.toString(16); break; - case 'X': a = a.toString(16).toUpperCase(); break; - } - a = (/[def]/.test(m[7]) && m[2] && a >= 0 ? '+'+ a : a); - c = m[3] ? m[3] == '0' ? '0' : m[3].charAt(1) : ' '; - x = m[5] - String(a).length - s.length; - p = m[5] ? str_repeat(c, x) : ''; - o.push(s + (m[4] ? a + p : p + a)); - } - else { - throw('Huh ?!'); - } - f = f.substring(m[0].length); - } - return o.join(''); -} - -/* update displaying */ -function checkPermitAction() { - var nbSelected = 0; - if ($("input[name=setSelected]").is(':checked')) { - nbSelected = nb_thumbs_set; - } else { - $(".thumbnails input[type=checkbox]").each(function() { - if ($(this).is(':checked')) nbSelected++; - }); - } - - if (nbSelected == 0) { - $("#beginImport").hide(); - } else { - $("#beginImport").show(); - } - - $("#applyOnDetails").text( - sprintf( - applyOnDetails_pattern, - nbSelected - ) - ); - - // display the number of currently selected photos in the "Selection" fieldset - if (nbSelected == 0) { - $("#selectedMessage").text( + $(this).click(function(event) { $(this).triggerHandler("shclick",event); }); + }); + }; + + /* update displaying */ + function checkPermitAction() { + var nbSelected = 0; + if ($("input[name=setSelected]").is(':checked')) { + nbSelected = nb_thumbs_set; + } + else { + $(".thumbnails input[type=checkbox]").each(function() { + if ($(this).is(':checked')) nbSelected++; + }); + } + + if (nbSelected == 0) { + $("#beginImport").hide(); + } + else { + $("#beginImport").show(); + } + + $("#applyOnDetails").text( sprintf( - selectedMessage_none, - nb_thumbs_set + '{'on the %d selected photos'|translate|escape:javascript}', + nbSelected ) ); - } else if (nbSelected == nb_thumbs_set) { - $("#selectedMessage").text( - sprintf( - selectedMessage_all, - nb_thumbs_set - ) - ); - } else { - $("#selectedMessage").text( - sprintf( - selectedMessage_pattern, - nbSelected, - nb_thumbs_set - ) - ); + + // display the number of currently selected photos in the "Selection" fieldset + if (nbSelected == 0) { + $("#selectedMessage").text( + sprintf( + '{'No photo selected, %d photos in current set'|translate|escape:javascript}', + nb_thumbs_set + ) + ); + } + else if (nbSelected == nb_thumbs_set) { + $("#selectedMessage").text( + sprintf( + '{'All %d photos are selected'|translate|escape:javascript}', + nb_thumbs_set + ) + ); + } + else { + $("#selectedMessage").text( + sprintf( + '{'%d of %d photos selected'|translate|escape:javascript}', + nbSelected, + nb_thumbs_set + ) + ); + } } -} - -/* import queue */ -function performImport(photo, album, fills, pwa_album) { - queuedManager.add({ - type: 'GET', - dataType: 'json', - url: 'ws.php', - data: { method: 'pwg.images.addPicasa', id: photo, category: album, fills: fills, pwa_album: pwa_album, format: 'json' }, - success: function(data) { - if (data['stat'] == 'ok') { - jQuery.jGrowl(data['result'], { theme: 'success', header: successHead, life: 4000, sticky: false }); - jQuery("#photo-"+photo).fadeOut(function(){ $(this).remove(); }); - } else { - jQuery.jGrowl(data['result'], { theme: 'error', header: errorHead, sticky: true }); + + /* import queue */ + function performImport(photo, album, fills, pwa_album) { + queuedManager.add({ + type: 'GET', + dataType: 'json', + url: 'ws.php', + data: { + method: 'pwg.images.addPicasa', + id: photo, + category: album, + fills: fills, + pwa_album: pwa_album, + format: 'json' + }, + success: function(data) { + if (data['stat'] == 'ok') { + $.jGrowl(data['result'], { + theme: 'success', life: 4000, sticky: false, + header: '{'Success'|translate}' + }); + $("#photo-"+photo).fadeOut(function(){ $(this).remove(); }); + } + else { + $.jGrowl(data['result'], { + theme: 'error', sticky: true, + header: '{'ERROR'|translate}' + }); + } + + import_done++; + $("#progress").html(import_done +"/"+ import_selected); + + if (import_done == import_selected) { + $("#import_form").append(''); + $("#import_form").submit(); + } + }, + error: function(data) { + $.jGrowl('{'an error happened'|translate|escape:javascript}', { + theme: 'error', sticky: true, + header: '{'ERROR'|translate}' + }); } - - import_done++; - $("#progress").html(import_done +"/"+ import_selected); - - if (import_done == import_selected) { - $("#import_form").append(''); - $("#import_form").submit(); - } - }, - error: function(data) { - jQuery.jGrowl(errorMsg, { theme: 'error', header: errorHead, sticky: true }); - } - }); -} - - -$(document).ready(function() { + }); + } + + checkPermitAction(); $("a.preview-box").colorbox(); @@ -207,5 +167,5 @@ /* thumbnail click */ $(".wrap1 label").click(function (event) { - $("input[name=setSelected]").attr('checked', false); + $("input[name=setSelected]").prop('checked', false); var wrap2 = $(this).children(".wrap2"); @@ -226,5 +186,5 @@ /* select all */ $("#selectAll").click(function () { - $("input[name=setSelected]").attr('checked', false); + $("input[name=setSelected]").prop('checked', false); $(".thumbnails label").each(function() { @@ -232,5 +192,5 @@ var checkbox = $(this).children("input[type=checkbox]"); - $(checkbox).attr('checked', true); + $(checkbox).prop('checked', true); $(wrap2).addClass("thumbSelected"); }); @@ -242,5 +202,5 @@ /* select none */ $("#selectNone").click(function () { - $("input[name=setSelected]").attr('checked', false); + $("input[name=setSelected]").prop('checked', false); $(".thumbnails label").each(function() { @@ -248,5 +208,5 @@ var checkbox = $(this).children("input[type=checkbox]"); - $(checkbox).attr('checked', false); + $(checkbox).prop('checked', false); $(wrap2).removeClass("thumbSelected"); }); @@ -258,5 +218,5 @@ /* select invert */ $("#selectInvert").click(function () { - $("input[name=setSelected]").attr('checked', false); + $("input[name=setSelected]").prop('checked', false); $(".thumbnails label").each(function() { @@ -264,9 +224,10 @@ var checkbox = $(this).children("input[type=checkbox]"); - $(checkbox).attr('checked', !$(checkbox).is(':checked')); + $(checkbox).prop('checked', !$(checkbox).is(':checked')); if ($(checkbox).is(':checked')) { $(wrap2).addClass("thumbSelected"); - } else { + } + else { $(wrap2).removeClass('thumbSelected'); } @@ -279,5 +240,5 @@ /* select set */ $("#selectSet").click(function () { - $("input[name=setSelected]").attr('checked', true); + $("input[name=setSelected]").prop('checked', true); $(".thumbnails label").each(function() { @@ -285,5 +246,5 @@ var checkbox = $(this).children("input[type=checkbox]"); - $(checkbox).attr('checked', true); + $(checkbox).prop('checked', true); $(wrap2).addClass("thumbSelected"); }); @@ -294,8 +255,8 @@ /* begin import */ - jQuery('#beginImport').click(function() { + $('#beginImport').click(function() { $("#loader_import").fadeIn(); var album = $("#albumSelect option:selected").val(); - var pwa_album = "{/literal}{$album}{literal}"; + var pwa_album = "{$album}"; var fills = ''; @@ -304,5 +265,5 @@ }); - if (jQuery('input[name="setSelected"]').attr('checked')) { + if ($('input[name="setSelected"]').prop('checked')) { import_selected = all_elements.length; $("#progress").html("0/"+ import_selected); @@ -311,10 +272,11 @@ performImport(all_elements[i], album, fills, pwa_album); } - } else { + } + else { import_selected = $("input[name='selection[]']:checked").length; $("#progress").html("0/"+ import_selected); - jQuery("input[name='selection[]']:checked").each(function() { - performImport(jQuery(this).attr('value'), album, fills, pwa_album); + $("input[name='selection[]']:checked").each(function() { + performImport($(this).attr('value'), album, fills, pwa_album); }); } @@ -324,10 +286,10 @@ /* pagination loader */ - jQuery('#navigation a').click(function() { + $('#navigation a').click(function() { $("#loader_display").fadeIn(); }); -}); -{/literal} +}(jQuery)); {/footer_script} +{'Help! I get the error "The site [...] has not been registered."'|@translate}
+ +{'Help! I get the error "The site [...] has not been registered."'|translate}