// Force clearstatcache on product image upload
This commit is contained in:
@@ -88,26 +88,34 @@
|
||||
if (data.result) {
|
||||
if (typeof data.result.{$name} !== 'undefined') {
|
||||
for (var i=0; i<data.result.{$name}.length; i++) {
|
||||
|
||||
if (data.result.{$name}[i] !== null && data.result.{$name}[i].status == 'ok') {
|
||||
var response = data.result.{$name}[i];
|
||||
var cover = "icon-check-empty";
|
||||
|
||||
if (response.cover == "1")
|
||||
cover = "icon-check-sign";
|
||||
|
||||
imageLine(response.id, response.path, response.position, cover, response.shops,
|
||||
response.legend[{$default_language|intval}])
|
||||
$("#countImage").html(parseInt($("#countImage").html()) + 1);
|
||||
$("#img" + id).remove();
|
||||
$("#imageTable").tableDnDUpdate();
|
||||
if (typeof data.result.{$name}[i].error !== 'undefined' && data.result.{$name}[i].error != '') {
|
||||
$('#{$id}-errors').html('<strong>'+data.result.{$name}[i].name+'</strong> : '+data.result.{$name}[i].error).parent().show();
|
||||
}
|
||||
else
|
||||
{
|
||||
$(data.context).appendTo($('#{$id}-success'));
|
||||
$('#{$id}-success').parent().show();
|
||||
|
||||
if (data.result.{$name}[i] !== null && data.result.{$name}[i].status == 'ok')
|
||||
{
|
||||
var response = data.result.{$name}[i];
|
||||
var cover = "icon-check-empty";
|
||||
|
||||
if (response.cover == "1")
|
||||
cover = "icon-check-sign";
|
||||
|
||||
imageLine(response.id, response.path, response.position, cover, response.shops,
|
||||
response.legend[{$default_language|intval}])
|
||||
$("#countImage").html(parseInt($("#countImage").html()) + 1);
|
||||
$("#img" + id).remove();
|
||||
$("#imageTable").tableDnDUpdate();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
$(data.context).find('button').remove();
|
||||
$(data.context).appendTo($('#{$id}-success'));
|
||||
$('#{$id}-success').parent().show();
|
||||
}
|
||||
},
|
||||
}).on('fileuploadalways', function (e, data) {
|
||||
|
||||
@@ -122,25 +122,32 @@
|
||||
if (typeof data.result.{$name} !== 'undefined') {
|
||||
for (var i=0; i<data.result.{$name}.length; i++) {
|
||||
if (data.result.{$name}[i] !== null) {
|
||||
if (typeof data.result.{$name}[i].image !== 'undefined') {
|
||||
var template = '<div class="img-thumbnail text-center">';
|
||||
template += '<p>'+data.result.{$name}[i].image+'</p>';
|
||||
|
||||
if (typeof data.result.{$name}[i].delete_url !== 'undefined') {
|
||||
template += '<p><a class="btn btn-default" href="'+data.result.{$name}[i].delete_url+'"><i class="icon-trash"></i> {l s='Delete'}</a></p>';
|
||||
}
|
||||
if (typeof data.result.{$name}[i].error !== 'undefined' && data.result.{$name}[i].error != '') {
|
||||
$('#{$id}-errors').html('<strong>'+data.result.{$name}[i].name+'</strong> : '+data.result.{$name}[i].error).parent().show();
|
||||
}
|
||||
else
|
||||
{
|
||||
$(data.context).appendTo($('#{$id}-success'));
|
||||
$('#{$id}-success').parent().show();
|
||||
|
||||
template += '</div>';
|
||||
$('#{$id}-images-thumbnails').html($('#{$id}-images-thumbnails').html()+template);
|
||||
$('#{$id}-images-thumbnails').parent().show();
|
||||
if (typeof data.result.{$name}[i].image !== 'undefined')
|
||||
{
|
||||
var template = '<div class="img-thumbnail text-center">';
|
||||
template += '<p>'+data.result.{$name}[i].image+'</p>';
|
||||
|
||||
if (typeof data.result.{$name}[i].delete_url !== 'undefined')
|
||||
template += '<p><a class="btn btn-default" href="'+data.result.{$name}[i].delete_url+'"><i class="icon-trash"></i> {l s='Delete'}</a></p>';
|
||||
|
||||
template += '</div>';
|
||||
$('#{$id}-images-thumbnails').html($('#{$id}-images-thumbnails').html()+template);
|
||||
$('#{$id}-images-thumbnails').parent().show();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$(data.context).find('button').remove();
|
||||
$(data.context).appendTo($('#{$id}-success'));
|
||||
$('#{$id}-success').parent().show();
|
||||
$(data.context).find('button').remove();
|
||||
}
|
||||
},
|
||||
}).on('fileuploadalways', function (e, data) {
|
||||
|
||||
@@ -168,25 +168,24 @@ class UploaderCore
|
||||
file_put_contents($file_path, fopen('php://input', 'r'));
|
||||
}
|
||||
|
||||
$file_size = $this->_getFileSize($file_path);
|
||||
$file_size = $this->_getFileSize($file_path, true);
|
||||
|
||||
if ($file_size === $file['size'])
|
||||
{
|
||||
$file['save_path'] = $file_path;
|
||||
//TODO do image processing
|
||||
}
|
||||
else
|
||||
{
|
||||
$file['size'] = $file_size;
|
||||
unlink($file_path);
|
||||
$file['error'] = 'abort';
|
||||
$file['error'] = Tools::displayError('Server file size is different from local file size');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return $file;
|
||||
}
|
||||
|
||||
protected function validate($file)
|
||||
protected function validate(&$file)
|
||||
{
|
||||
$post_max_size = $this->getPostMaxSizeBytes();
|
||||
|
||||
|
||||
@@ -42,7 +42,7 @@ class HelperImageUploaderCore extends HelperUploader
|
||||
return tempnam($this->getSavePath(), $this->getUniqueFileName());
|
||||
}
|
||||
|
||||
protected function validate($file)
|
||||
protected function validate(&$file)
|
||||
{
|
||||
$post_max_size = $this->getPostMaxSizeBytes();
|
||||
|
||||
@@ -62,7 +62,10 @@ class HelperImageUploaderCore extends HelperUploader
|
||||
}
|
||||
|
||||
if ($error = ImageManager::validateUpload($file, Tools::getMaxUploadSize($this->getMaxSize())))
|
||||
{
|
||||
$file['error'] = $error;
|
||||
return false;
|
||||
}
|
||||
|
||||
if ($file['size'] > $this->getMaxSize())
|
||||
{
|
||||
|
||||
@@ -3648,6 +3648,9 @@ class AdminProductsControllerCore extends AdminController
|
||||
else
|
||||
$image->cover = 0;
|
||||
|
||||
if (isset($file['error']))
|
||||
continue;
|
||||
|
||||
if (!$image->add())
|
||||
$file['error'] = Tools::displayError('Error while creating additional image');
|
||||
else
|
||||
|
||||
Reference in New Issue
Block a user