Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
feature 2616, customizations for plupload
* bug fixed, remove debug inserts in table "plupload"
* display photo title as tooltip on thumbnail
* hide useless .plupload_header
* hide any other form fieldset until an album is selected


git-svn-id: http://piwigo.org/svn/trunk@28552 68402e56-0260-453c-a942-63ccdbb3a9ee
  • Loading branch information
plegall committed May 28, 2014
1 parent be60fee commit 682148e
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 90 deletions.
2 changes: 1 addition & 1 deletion admin/themes/default/js/addAlbum.js
Expand Up @@ -83,7 +83,7 @@ jQuery.fn.pwgAddAlbum = function(options) {
}

albumParent.val('');
jQuery('#albumSelection').show();
jQuery('#albumSelection, .selectFiles, .showFieldset').show();
},
error: function(XMLHttpRequest, textStatus, errorThrows) {
jQuery('#albumCreationLoading').hide();
Expand Down
95 changes: 18 additions & 77 deletions admin/themes/default/template/photos_add_direct.tpl
Expand Up @@ -25,7 +25,7 @@ var categoriesCache = new CategoriesCache({
categoriesCache.selectize(jQuery('[data-selectize=categories]'), {
filter: function(categories, options) {
if (categories.length > 0) {
jQuery("#albumSelection").show();
jQuery("#albumSelection, .selectFiles, .showFieldset").show();
options.default = categories[0].id;
}

Expand All @@ -42,70 +42,10 @@ var pwg_token = '{$pwg_token}';
var buttonText = "{'Select files'|@translate}";
var sizeLimit = Math.round({$upload_max_filesize} / 1024); /* in KBytes */

var noAlbum_message = "{'Select an album'|translate}";

{literal}
jQuery(document).ready(function(){
function checkUploadStart() {
var nbErrors = 0;
jQuery("#formErrors").hide();
jQuery("#formErrors li").hide();
if (jQuery("select[name=category]").val() == '') {
jQuery("#formErrors #noAlbum").show();
nbErrors++;
}

var nbFiles = 0;
if (jQuery("#uploadBoxes").size() == 1) {
jQuery("input[name^=image_upload]").each(function() {
if (jQuery(this).val() != "") {
nbFiles++;
}
});
}
else {
nbFiles = jQuery(".uploadifyQueueItem").size();
}

if (nbFiles == 0) {
jQuery("#formErrors #noPhoto").show();
nbErrors++;
}

if (nbErrors != 0) {
jQuery("#formErrors").show();
return false;
}
else {
return true;
}

}

function humanReadableFileSize(bytes) {
var byteSize = Math.round(bytes / 1024 * 100) * .01;
var suffix = 'KB';
if (byteSize > 1000) {
byteSize = Math.round(byteSize *.001 * 100) * .01;
suffix = 'MB';
}

var sizeParts = byteSize.toString().split('.');
if (sizeParts.length > 1) {
byteSize = sizeParts[0] + '.' + sizeParts[1].substr(0,2);
}
else {
byteSize = sizeParts[0];
}

return byteSize+suffix;
}

jQuery("#hideErrors").click(function() {
jQuery("#formErrors").hide();
return false;
});

jQuery("#uploadWarningsSummary a.showInfo").click(function() {
jQuery("#uploadWarningsSummary").hide();
jQuery("#uploadWarnings").show();
Expand Down Expand Up @@ -176,10 +116,12 @@ jQuery(document).ready(function(){
jQuery("#uploadedPhotos").parent("fieldset").show();
html = '<a href="admin.php?page=photo-'+data.result.image_id+'" target="_blank">';
html += '<img src="'+data.result.src+'" class="thumbnail">';
html += '<img src="'+data.result.src+'" class="thumbnail" title="'+data.result.name+'">';
html += '</a> ';
jQuery("#uploadedPhotos").prepend(html);
up.removeFile(file);
}
}
});
Expand All @@ -194,6 +136,14 @@ jQuery(document).ready(function(){

<div id="photosAddContent">

{*
<div class="infos">
<ul>
<li>%d photos added..</li>
</ul>
</div>
*}

{if count($setup_errors) > 0}
<div class="errors">
<ul>
Expand Down Expand Up @@ -231,16 +181,7 @@ jQuery(document).ready(function(){
<p style="margin:10px"><a href="{$another_upload_link}">{'Add another set of photos'|@translate}</a></p>
{else}

<div id="formErrors" class="errors" style="display:none">
<ul>
<li id="noAlbum">{'Select an album'|@translate}</li>
<li id="noPhoto">{'Select at least one photo'|@translate}</li>
</ul>
<div class="hideButton" style="text-align:center"><a href="#" id="hideErrors">{'Hide'|@translate}</a></div>
</div>


<form id="uploadForm" enctype="multipart/form-data" method="post" action="{$form_action}" class="properties">
<form id="uploadForm" enctype="multipart/form-data" method="post" action="{$form_action}">
{if $upload_mode eq 'multiple'}
<input name="upload_id" value="{$upload_id}" type="hidden">
{/if}
Expand All @@ -255,7 +196,7 @@ jQuery(document).ready(function(){
<a href="#" data-add-album="category" title="{'create a new album'|@translate}">{'create a new album'|@translate}</a>
</fieldset>

<p class="showFieldset"><a id="showPermissions" href="#">{'Manage Permissions'|@translate}</a></p>
<p class="showFieldset" style="display:none"><a id="showPermissions" href="#">{'Manage Permissions'|@translate}</a></p>

<fieldset id="permissions" style="display:none">
<legend>{'Who can see these photos?'|@translate}</legend>
Expand All @@ -265,7 +206,7 @@ jQuery(document).ready(function(){
</select>
</fieldset>

<fieldset>
<fieldset class="selectFiles" style="display:none">
<legend>{'Select files'|@translate}</legend>

{if isset($original_resize_maxheight)}<p class="uploadInfo">{'The picture dimensions will be reduced to %dx%d pixels.'|@translate:$original_resize_maxwidth:$original_resize_maxheight}</p>{/if}
Expand All @@ -282,7 +223,7 @@ jQuery(document).ready(function(){


<div id="uploader">
<p>Your browser doesn't have Flash, Silverlight or HTML5 support.</p>
<p>Your browser doesn't have HTML5 support.</p>
</div>

</fieldset>
Expand Down
5 changes: 5 additions & 0 deletions admin/themes/default/theme.css
Expand Up @@ -983,6 +983,11 @@ LEGEND {
#order_filters .order_by_is_custom {display:block;font-weight:normal;font-style:italic;margin-left:20px;}

/* Upload Form */
.plupload_header {display:none;}
#uploadForm .plupload_container {padding:0}
#uploadForm .plupload_scroll .plupload_filelist {height:250px;}
#uploadForm li.plupload_droptext {line-height:230px;font-size:2em;}

#uploadBoxes .file {margin-bottom:5px;text-align:left;}
#uploadBoxes {margin-top:20px;}
#addUploadBox {margin-bottom:2em;}
Expand Down
15 changes: 3 additions & 12 deletions include/ws_functions/pwg.images.php
Expand Up @@ -1302,18 +1302,7 @@ function ws_images_upload($params, $service)
$chunk = isset($_REQUEST["chunk"]) ? intval($_REQUEST["chunk"]) : 0;
$chunks = isset($_REQUEST["chunks"]) ? intval($_REQUEST["chunks"]) : 0;

file_put_contents('/tmp/plupload.log', "[".date('c')."] ".__FUNCTION__.', '.$fileName.' '.($chunk+1).'/'.$chunks."\n", FILE_APPEND);

single_insert(
'plupload',
array(
'received_on' => date('c'),
'filename' => $fileName,
'chunk' => $chunk+1,
'chunks' => $chunks,
)
);

// file_put_contents('/tmp/plupload.log', "[".date('c')."] ".__FUNCTION__.', '.$fileName.' '.($chunk+1).'/'.$chunks."\n", FILE_APPEND);

// Open temp file
if (!$out = @fopen("{$filePath}.part", $chunks ? "ab" : "wb"))
Expand Down Expand Up @@ -1369,6 +1358,7 @@ function ws_images_upload($params, $service)
$query = '
SELECT
id,
name,
path
FROM '.IMAGES_TABLE.'
WHERE id = '.$image_id.'
Expand All @@ -1378,6 +1368,7 @@ function ws_images_upload($params, $service)
return array(
'image_id' => $image_id,
'src' => DerivativeImage::thumb_url($image_infos),
'name' => $image_infos['name'],
);
}
}
Expand Down

0 comments on commit 682148e

Please sign in to comment.