Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feature 2548 multisize - added a page to build missing derivatives
- browser driven, chained ws calls to retrieve urls, visual feedback of progress through slideshow git-svn-id: http://piwigo.org/svn/trunk@12865 68402e56-0260-453c-a942-63ccdbb3a9ee
- Loading branch information
rvelices
committed
Jan 8, 2012
1 parent
028729f
commit 225b45f
Showing
11 changed files
with
446 additions
and
54 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
<?php | ||
// +-----------------------------------------------------------------------+ | ||
// | Piwigo - a PHP based photo gallery | | ||
// +-----------------------------------------------------------------------+ | ||
// | Copyright(C) 2008-2011 Piwigo Team http://piwigo.org | | ||
// | Copyright(C) 2003-2008 PhpWebGallery Team http://phpwebgallery.net | | ||
// | Copyright(C) 2002-2003 Pierrick LE GALL http://le-gall.net/pierrick | | ||
// +-----------------------------------------------------------------------+ | ||
// | This program is free software; you can redistribute it and/or modify | | ||
// | it under the terms of the GNU General Public License as published by | | ||
// | the Free Software Foundation | | ||
// | | | ||
// | This program is distributed in the hope that it will be useful, but | | ||
// | WITHOUT ANY WARRANTY; without even the implied warranty of | | ||
// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | | ||
// | General Public License for more details. | | ||
// | | | ||
// | You should have received a copy of the GNU General Public License | | ||
// | along with this program; if not, write to the Free Software | | ||
// | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, | | ||
// | USA. | | ||
// +-----------------------------------------------------------------------+ | ||
|
||
defined('PHPWG_ROOT_PATH') or trigger_error('Hacking attempt!', E_USER_ERROR); | ||
|
||
$template->assign('derivatives', array_keys(ImageStdParams::get_defined_type_map())); | ||
|
||
$template->set_filename('derivatives', 'derivatives_build.tpl'); | ||
$template->assign_var_from_handle('ADMIN_CONTENT', 'derivatives'); | ||
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,152 @@ | ||
{html_head}{literal} | ||
<style type="text/css"> | ||
TABLE { | ||
font-size: larger; | ||
} | ||
</style> | ||
{/literal}{/html_head} | ||
|
||
<p> | ||
<select id="types" name="types[]" multiple="multiple"> | ||
{foreach from=$derivatives item=type} | ||
<option value="{$type}" selected="selected">{$type|@translate}</option> | ||
{/foreach} | ||
</select> | ||
<input id="startLink" value="{'Start'|@translate}" onclick="start()" type="button"> | ||
<input id="pauseLink" value="{'Pause'|@translate}" onclick="pause()" type="button" disabled="disbled"> | ||
<input id="stopLink" value="{'Stop'|@translate}" onclick="stop()" type="button" disabled="disbled"> | ||
</p> | ||
<hr/> | ||
<p> | ||
<table> | ||
<tr> | ||
<td>Errors</td> | ||
<td id="errors">0</td> | ||
</tr> | ||
<tr> | ||
<td>Loaded</td> | ||
<td id="loaded">0</td> | ||
</tr> | ||
<tr> | ||
<td>Remaining</td> | ||
<td id="remaining">0</td> | ||
</tr> | ||
</table> | ||
<div id="feedbackWrap" style="height:320px; min-height:320px;"> | ||
<img id="feedbackImg"> | ||
</div> | ||
</p> | ||
|
||
<div id="errorList"> | ||
</div> | ||
|
||
{combine_script id='iloader' load='footer' path='themes/default/js/image.loader.js'} | ||
|
||
{footer_script require='jquery.effects.slide'}{literal} | ||
|
||
var loader = new ImageLoader( {onChanged: loaderChanged} ) | ||
, pending_next_page = null | ||
, last_image_show_time = 0 | ||
, allDoneDfd, urlDfd; | ||
|
||
function start() { | ||
allDoneDfd = jQuery.Deferred(); | ||
urlDfd = jQuery.Deferred(); | ||
allDoneDfd.always( function() { | ||
jQuery("#startLink").attr('disabled', false).css("opacity", 1); | ||
jQuery("#pauseLink,#stopLink").attr('disabled', true).css("opacity", 0.5); | ||
} ); | ||
|
||
urlDfd.always( function() { | ||
if (loader.remaining()==0) | ||
allDoneDfd.resolve(); | ||
} ); | ||
|
||
jQuery("#startLink").attr('disabled', true).css("opacity", 0.5); | ||
jQuery("#pauseLink,#stopLink").attr('disabled', false).css("opacity", 1); | ||
|
||
loader.pause(false); | ||
updateStats(); | ||
getUrls(); | ||
} | ||
|
||
function pause() { | ||
loader.pause( !loader.pause() ); | ||
} | ||
|
||
function stop() { | ||
loader.clear(); | ||
urlDfd.resolve(); | ||
} | ||
|
||
function getUrls(page_token) { | ||
data = {max_urls: 500, types: []}; | ||
jQuery.each(jQuery("#types").serializeArray(), function(i, t) { | ||
data.types.push( t.value ); | ||
} ); | ||
|
||
if (page_token) | ||
data['prev_page'] = page_token; | ||
jQuery.post( '{/literal}{$ROOT_URL}{literal}ws.php?format=json&method=pwg.getMissingDerivatives', | ||
data, wsData, "json").fail( wsError ); | ||
} | ||
|
||
function wsData(data) { | ||
if (!data.stat || data.stat != "ok") { | ||
wsError(); | ||
return; | ||
} | ||
loader.add( data.result.urls ); | ||
if (data.result.next_page) { | ||
if (loader.pause() || loader.remaining() > 100) { | ||
pending_next_page = data.result.next_page; | ||
} | ||
else { | ||
getUrls(data.result.next_page); | ||
} | ||
} | ||
} | ||
|
||
function wsError() { | ||
urlDfd.reject(); | ||
} | ||
|
||
function updateStats() { | ||
jQuery("#loaded").text( loader.loaded ); | ||
jQuery("#errors").text( loader.errors ); | ||
jQuery("#remaining").text( loader.remaining() ); | ||
} | ||
|
||
function loaderChanged(type, img) { | ||
updateStats(); | ||
if (img) { | ||
if (type==="load") { | ||
var now = jQuery.now(); | ||
if (now - last_image_show_time > 3000) { | ||
last_image_show_time = now; | ||
var h=img.height, url=img.src; | ||
jQuery("#feedbackWrap").hide("slide", {direction:'down'}, function() { | ||
last_image_show_time = jQuery.now(); | ||
if (h > 300 ) | ||
jQuery("#feedbackImg").attr("height", 300); | ||
else | ||
jQuery("#feedbackImg").removeAttr("height"); | ||
jQuery("#feedbackImg").attr("src", url); | ||
jQuery("#feedbackWrap").show("slide", {direction:'up'} ); | ||
} ); | ||
} | ||
} | ||
else { | ||
jQuery("#errorList").prepend( '<a href="'+img.src+'">'+img.src+'</a>' + "<br>"); | ||
} | ||
} | ||
if (pending_next_page && 100 > loader.remaining() ) { | ||
getUrls(pending_next_page); | ||
pending_next_page = null; | ||
} | ||
else if (loader.remaining() == 0 && (urlDfd.isResolved() || urlDfd.isRejected())) { | ||
allDoneDfd.resolve(); | ||
} | ||
} | ||
{/literal}{/footer_script} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.