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