Working : Image management set on Category
This commit is contained in:
@@ -37,7 +37,8 @@
|
||||
|
||||
"imagine/imagine": "dev-master",
|
||||
"symfony/icu": "1.0",
|
||||
"swiftmailer/swiftmailer": "5.0.*"
|
||||
"swiftmailer/swiftmailer": "5.0.*",
|
||||
"symfony/serializer": "2.3.*"
|
||||
},
|
||||
"require-dev" : {
|
||||
"phpunit/phpunit": "3.7.*",
|
||||
|
||||
67
composer.lock
generated
67
composer.lock
generated
@@ -3,7 +3,7 @@
|
||||
"This file locks the dependencies of your project to a known state",
|
||||
"Read more about it at http://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file"
|
||||
],
|
||||
"hash": "a40be01c82e68ba0c446dc204d2667da",
|
||||
"hash": "097481390dc87b3482d895b3b6a65479",
|
||||
"packages": [
|
||||
{
|
||||
"name": "imagine/imagine",
|
||||
@@ -1456,6 +1456,53 @@
|
||||
"homepage": "http://symfony.com",
|
||||
"time": "2013-08-23 14:06:02"
|
||||
},
|
||||
{
|
||||
"name": "symfony/serializer",
|
||||
"version": "v2.3.4",
|
||||
"target-dir": "Symfony/Component/Serializer",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/symfony/Serializer.git",
|
||||
"reference": "457ba76395955926a67ea692957b0872dead5278"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/symfony/Serializer/zipball/457ba76395955926a67ea692957b0872dead5278",
|
||||
"reference": "457ba76395955926a67ea692957b0872dead5278",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"php": ">=5.3.3"
|
||||
},
|
||||
"type": "library",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "2.3-dev"
|
||||
}
|
||||
},
|
||||
"autoload": {
|
||||
"psr-0": {
|
||||
"Symfony\\Component\\Serializer\\": ""
|
||||
}
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"MIT"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Fabien Potencier",
|
||||
"email": "fabien@symfony.com"
|
||||
},
|
||||
{
|
||||
"name": "Symfony Community",
|
||||
"homepage": "http://symfony.com/contributors"
|
||||
}
|
||||
],
|
||||
"description": "Symfony Serializer Component",
|
||||
"homepage": "http://symfony.com",
|
||||
"time": "2013-07-21 12:12:18"
|
||||
},
|
||||
{
|
||||
"name": "symfony/translation",
|
||||
"version": "v2.2.6",
|
||||
@@ -1722,12 +1769,12 @@
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/sebastianbergmann/php-code-coverage.git",
|
||||
"reference": "1.2.12"
|
||||
"reference": "0e9958c459d675fb497d8dc5001c91d335734e48"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/1.2.12",
|
||||
"reference": "1.2.12",
|
||||
"url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/0e9958c459d675fb497d8dc5001c91d335734e48",
|
||||
"reference": "0e9958c459d675fb497d8dc5001c91d335734e48",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
@@ -1916,12 +1963,12 @@
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/sebastianbergmann/php-token-stream.git",
|
||||
"reference": "1.2.0"
|
||||
"reference": "31babf400e5b5868573bf49a000a3519d3978233"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/sebastianbergmann/php-token-stream/zipball/1.2.0",
|
||||
"reference": "1.2.0",
|
||||
"url": "https://api.github.com/repos/sebastianbergmann/php-token-stream/zipball/31babf400e5b5868573bf49a000a3519d3978233",
|
||||
"reference": "31babf400e5b5868573bf49a000a3519d3978233",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
@@ -1966,12 +2013,12 @@
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/sebastianbergmann/phpunit.git",
|
||||
"reference": "3.7.24"
|
||||
"reference": "af7b77ccb5c64458bdfca95665d29558d1df7d08"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/3.7.24",
|
||||
"reference": "3.7.24",
|
||||
"url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/af7b77ccb5c64458bdfca95665d29558d1df7d08",
|
||||
"reference": "af7b77ccb5c64458bdfca95665d29558d1df7d08",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
|
||||
@@ -28,6 +28,7 @@ use Symfony\Component\EventDispatcher\EventSubscriberInterface;
|
||||
|
||||
use Symfony\Component\HttpFoundation\File\UploadedFile;
|
||||
use Thelia\Core\Event\ImageCreateOrUpdateEvent;
|
||||
use Thelia\Core\Event\ImagesCreateOrUpdateEvent;
|
||||
use Thelia\Core\Event\ImageDeleteEvent;
|
||||
use Thelia\Core\Event\ImageEvent;
|
||||
use Thelia\Model\CategoryImage;
|
||||
@@ -252,21 +253,20 @@ class Image extends BaseCachedFile implements EventSubscriberInterface
|
||||
}
|
||||
|
||||
/**
|
||||
* Take care of saving images in the database and file storage
|
||||
* Take care of saving image in the database and file storage
|
||||
*
|
||||
* @param ImageCreateOrUpdateEvent $event Image event
|
||||
*
|
||||
* @throws \Thelia\Exception\ImageException
|
||||
* @todo refactor make all pictures using propel inheritance and factorise image behaviour into one single clean action
|
||||
*/
|
||||
public function saveImages(ImageCreateOrUpdateEvent $event)
|
||||
public function saveImage(ImageCreateOrUpdateEvent $event)
|
||||
{
|
||||
$fileManager = new FileManager($this->container);
|
||||
|
||||
$this->adminLogAppend(
|
||||
$this->container->get('thelia.translator')->trans(
|
||||
'Saving images for parent id %parentId% (%parentType%)',
|
||||
'Saving images for %parentName% parent id %parentId% (%parentType%)',
|
||||
array(
|
||||
'%parentName%' => $event->getParentName(),
|
||||
'%parentId%' => $event->getParentId(),
|
||||
'%parentType%' => $event->getImageType()
|
||||
),
|
||||
@@ -274,37 +274,75 @@ class Image extends BaseCachedFile implements EventSubscriberInterface
|
||||
)
|
||||
);
|
||||
|
||||
$newUploadedFiles = array();
|
||||
$uploadedFiles = $event->getUploadedFiles();
|
||||
$fileManager = new FileManager($this->container);
|
||||
$model = $event->getModelImage();
|
||||
|
||||
foreach ($event->getModelImages() as $i => $modelImage) {
|
||||
// Save image to database in order to get image id
|
||||
$fileManager->saveImage($event, $modelImage);
|
||||
$nbModifiedLines = $model->save();
|
||||
$event->setModelImage($model);
|
||||
|
||||
if (isset($uploadedFiles) && isset($uploadedFiles[$i])) {
|
||||
/** @var UploadedFile $uploadedFile */
|
||||
$uploadedFile = $uploadedFiles[$i]['file'];
|
||||
|
||||
// Copy uploaded file into the storage directory
|
||||
$newUploadedFiles = $fileManager->copyUploadedFile($event->getParentId(), $event->getImageType(), $modelImage, $uploadedFile, $newUploadedFiles);
|
||||
} else {
|
||||
if (!$nbModifiedLines) {
|
||||
throw new ImageException(
|
||||
sprintf(
|
||||
'File with name %s not found on the server',
|
||||
$modelImage->getFile()
|
||||
'Image "%s" with parent id %s (%s) failed to be saved',
|
||||
$event->getParentName(),
|
||||
$event->getParentId(),
|
||||
$event->getImageType()
|
||||
)
|
||||
);
|
||||
}
|
||||
$event->setUploadedFiles($newUploadedFiles);
|
||||
|
||||
$newUploadedFile = $fileManager->copyUploadedFile($event->getParentId(), $event->getImageType(), $event->getModelImage(), $event->getUploadedFile());
|
||||
$event->setUploadedFile($newUploadedFile);
|
||||
}
|
||||
|
||||
/**
|
||||
* Take care of updating image in the database and file storage
|
||||
*
|
||||
* @param ImageCreateOrUpdateEvent $event Image event
|
||||
*
|
||||
* @throws \Thelia\Exception\ImageException
|
||||
* @todo refactor make all pictures using propel inheritance and factorise image behaviour into one single clean action
|
||||
*/
|
||||
public function updateImage(ImageCreateOrUpdateEvent $event)
|
||||
{
|
||||
$this->adminLogAppend(
|
||||
$this->container->get('thelia.translator')->trans(
|
||||
'Updating images for %parentName% parent id %parentId% (%parentType%)',
|
||||
array(
|
||||
'%parentName%' => $event->getParentName(),
|
||||
'%parentId%' => $event->getParentId(),
|
||||
'%parentType%' => $event->getImageType()
|
||||
),
|
||||
'image'
|
||||
)
|
||||
);
|
||||
|
||||
$fileManager = new FileManager($this->container);
|
||||
// Copy and save file
|
||||
if ($event->getUploadedFile()) {
|
||||
// Remove old picture file from file storage
|
||||
$url = $fileManager->getUploadDir($event->getImageType()) . '/' . $event->getOldModelImage()->getFile();
|
||||
unlink(str_replace('..', '', $url));
|
||||
|
||||
$newUploadedFile = $fileManager->copyUploadedFile(
|
||||
$event->getModelImage()->getParentId(),
|
||||
$event->getImageType(),
|
||||
$event->getModelImage(), $event->getUploadedFile());
|
||||
$event->setUploadedFile($newUploadedFile);
|
||||
}
|
||||
|
||||
// Update image modifications
|
||||
$event->getModelImage()->save();
|
||||
$event->setModelImage($event->getModelImage());
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Take care of deleting image in the database and file storage
|
||||
*
|
||||
* @param ImageCreateOrUpdateEvent $event Image event
|
||||
* @param ImageDeleteEvent $event Image event
|
||||
*
|
||||
* @throws \Thelia\Exception\ImageException
|
||||
* @throws \Exception
|
||||
* @todo refactor make all pictures using propel inheritance and factorise image behaviour into one single clean action
|
||||
*/
|
||||
public function deleteImage(ImageDeleteEvent $event)
|
||||
@@ -312,7 +350,7 @@ class Image extends BaseCachedFile implements EventSubscriberInterface
|
||||
$fileManager = new FileManager($this->container);
|
||||
|
||||
try {
|
||||
$fileManager->deleteImage($event->getImageToDelete());
|
||||
$fileManager->deleteImage($event->getImageToDelete(), $event->getImageType());
|
||||
|
||||
$this->adminLogAppend(
|
||||
$this->container->get('thelia.translator')->trans(
|
||||
@@ -336,22 +374,10 @@ class Image extends BaseCachedFile implements EventSubscriberInterface
|
||||
'image'
|
||||
)
|
||||
);
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* The absolute directory path where uploaded
|
||||
* documents should be saved
|
||||
*
|
||||
* @param $modelImage Image model
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getUploadRootDir($modelImage)
|
||||
{
|
||||
return __DIR__.'/../../../../' . $modelImage->getUploadDir();
|
||||
}
|
||||
|
||||
/**
|
||||
* Process image resizing, with borders or cropping. If $dest_width and $dest_height
|
||||
* are both null, no resize is performed.
|
||||
@@ -474,8 +500,9 @@ class Image extends BaseCachedFile implements EventSubscriberInterface
|
||||
return array(
|
||||
TheliaEvents::IMAGE_PROCESS => array("processImage", 128),
|
||||
TheliaEvents::IMAGE_CLEAR_CACHE => array("clearCache", 128),
|
||||
TheliaEvents::IMAGE_SAVE => array("saveImages", 128),
|
||||
TheliaEvents::IMAGE_DELETE => array("deleteImage", 128),
|
||||
TheliaEvents::IMAGE_SAVE => array("saveImage", 128),
|
||||
TheliaEvents::IMAGE_UPDATE => array("updateImage", 128),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -58,7 +58,7 @@
|
||||
|
||||
<form name="thelia.admin.category.creation" class="Thelia\Form\CategoryCreationForm"/>
|
||||
<form name="thelia.admin.category.modification" class="Thelia\Form\CategoryModificationForm"/>
|
||||
<form name="thelia.admin.category.image.creation" class="Thelia\Form\CategoryImageCreationForm"/>
|
||||
<form name="thelia.admin.category.image.modification" class="Thelia\Form\CategoryImageModification"/>
|
||||
|
||||
<form name="thelia.admin.product.creation" class="Thelia\Form\ProductCreationForm"/>
|
||||
<form name="thelia.admin.product.modification" class="Thelia\Form\ProductModificationForm"/>
|
||||
|
||||
@@ -39,11 +39,24 @@
|
||||
|
||||
<!-- Route to the file controller -->
|
||||
|
||||
<route id="admin.image.save" path="/admin/image/type/{parentType}/{parentId}/save">
|
||||
<default key="_controller">Thelia\Controller\Admin\FileController::saveImagesAction</default>
|
||||
<route id="admin.image.save-ajax" path="/admin/image/type/{parentType}/{parentId}/save-ajax">
|
||||
<default key="_controller">Thelia\Controller\Admin\FileController::saveImageAjaxAction</default>
|
||||
<requirement key="parentType">.*</requirement>
|
||||
<requirement key="parentId">\d+</requirement>
|
||||
</route>
|
||||
<route id="admin.image.list-ajax" path="/admin/image/type/{parentType}/{parentId}/list-ajax">
|
||||
<default key="_controller">Thelia\Controller\Admin\FileController::getImageListAjaxAction</default>
|
||||
<requirement key="parentType">.*</requirement>
|
||||
<requirement key="parentId">\d+</requirement>
|
||||
</route>
|
||||
<route id="admin.image.update.view" path="/admin/image/type/{parentType}/{imageId}/update" methods="get">
|
||||
<default key="_controller">Thelia\Controller\Admin\FileController::viewImageAction</default>
|
||||
<requirement key="customer_id">\d+</requirement>
|
||||
</route>
|
||||
<route id="admin.image.update.process" path="/admin/image/type/{parentType}/{imageId}/update" methods="post">
|
||||
<default key="_controller">Thelia\Controller\Admin\FileController::updateImageAction</default>
|
||||
<requirement key="customer_id">\d+</requirement>
|
||||
</route>
|
||||
<route id="admin.image.delete" path="/admin/image/type/{parentType}/delete/{imageId}">
|
||||
<default key="_controller">Thelia\Controller\Admin\FileController::deleteImagesAction</default>
|
||||
<requirement key="parentType">.*</requirement>
|
||||
|
||||
@@ -23,20 +23,20 @@
|
||||
|
||||
namespace Thelia\Controller\Admin;
|
||||
|
||||
use Propel\Runtime\Exception\PropelException;
|
||||
use Symfony\Component\HttpFoundation\File\UploadedFile;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Component\Routing\Router;
|
||||
use Thelia\Core\Event\ImageCreateOrUpdateEvent;
|
||||
use Thelia\Core\Event\ImagesCreateOrUpdateEvent;
|
||||
use Thelia\Core\Event\ImageDeleteEvent;
|
||||
use Thelia\Core\Event\TheliaEvents;
|
||||
use Thelia\Core\Translation\Translator;
|
||||
use Thelia\Form\CategoryImageCreationForm;
|
||||
use Thelia\Form\Exception\FormValidationException;
|
||||
use Thelia\Log\Tlog;
|
||||
use Thelia\Model\CategoryImageQuery;
|
||||
use Thelia\Model\ContentImageQuery;
|
||||
use Thelia\Model\FolderImageQuery;
|
||||
use Thelia\Model\ProductImageQuery;
|
||||
use Thelia\Tools\FileManager;
|
||||
use Thelia\Tools\Rest\ResponseRest;
|
||||
|
||||
/**
|
||||
* Created by JetBrains PhpStorm.
|
||||
@@ -57,13 +57,14 @@ class FileController extends BaseAdminController
|
||||
*
|
||||
* @param int $parentId Parent id owning files being saved
|
||||
* @param string $parentType Parent Type owning files being saved
|
||||
* @param string $successUrl Success URL to be redirected to
|
||||
*
|
||||
* @return Response
|
||||
*/
|
||||
public function saveFilesAction($parentId, $parentType, $successUrl)
|
||||
public function saveFilesAction($parentId, $parentType)
|
||||
{
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -74,41 +75,37 @@ class FileController extends BaseAdminController
|
||||
*
|
||||
* @return Response
|
||||
*/
|
||||
public function saveImagesAction($parentId, $parentType)
|
||||
public function saveImageAjaxAction($parentId, $parentType)
|
||||
{
|
||||
// Check current user authorization
|
||||
if (null !== $response = $this->checkAuth("admin.image.save")) {
|
||||
return $response;
|
||||
}
|
||||
|
||||
$message = $this->getTranslator()
|
||||
->trans(
|
||||
'Images saved successfully',
|
||||
array(),
|
||||
'image'
|
||||
);
|
||||
$this->checkAuth('ADMIN', 'admin.image.save');
|
||||
$this->checkXmlHttpRequest();
|
||||
|
||||
if ($this->isParentTypeValid($parentType)) {
|
||||
if ($this->getRequest()->isMethod('POST')) {
|
||||
// Create the form from the request
|
||||
$creationForm = $this->getImageForm($parentType, $this->getRequest());
|
||||
|
||||
try {
|
||||
// Check the form against constraints violations
|
||||
$form = $this->validateForm($creationForm, 'POST');
|
||||
/** @var UploadedFile $fileBeingUploaded */
|
||||
$fileBeingUploaded = $this->getRequest()->files->get('file');
|
||||
|
||||
// Get the form field values
|
||||
$data = $form->getData();
|
||||
$fileManager = new FileManager($this->container);
|
||||
$parentModel = $fileManager->getParentImageModel($parentType, $parentId);
|
||||
$imageModel = $fileManager->getImageModel($parentType);
|
||||
|
||||
if ($parentModel === null || $imageModel === null || $fileBeingUploaded === null) {
|
||||
return new Response('', 404);
|
||||
}
|
||||
|
||||
$defaultTitle = $parentModel->getTitle();
|
||||
$imageModel->setParentId($parentId);
|
||||
$imageModel->setTitle($defaultTitle);
|
||||
|
||||
// Feed event
|
||||
$imageCreateOrUpdateEvent = new ImageCreateOrUpdateEvent(
|
||||
$parentType,
|
||||
$parentId
|
||||
);
|
||||
if (isset($data) && isset($data['pictures'])) {
|
||||
$imageCreateOrUpdateEvent->setModelImages($data['pictures']);
|
||||
$imageCreateOrUpdateEvent->setUploadedFiles($this->getRequest()->files->get($creationForm->getName())['pictures']);
|
||||
}
|
||||
$imageCreateOrUpdateEvent->setModelImage($imageModel);
|
||||
$imageCreateOrUpdateEvent->setUploadedFile($fileBeingUploaded);
|
||||
$imageCreateOrUpdateEvent->setParentName($parentModel->getTitle());
|
||||
|
||||
|
||||
// Dispatch Event to the Action
|
||||
$this->dispatch(
|
||||
@@ -116,35 +113,127 @@ class FileController extends BaseAdminController
|
||||
$imageCreateOrUpdateEvent
|
||||
);
|
||||
|
||||
} catch (FormValidationException $e) {
|
||||
// Invalid data entered
|
||||
$message = 'Please check your input:';
|
||||
$this->logError($parentType, 'image saving', $message, $e);
|
||||
|
||||
return new ResponseRest(array('status' => true, 'message' => ''));
|
||||
}
|
||||
}
|
||||
|
||||
return new Response('', 404);
|
||||
}
|
||||
|
||||
/**
|
||||
* Manage how a image list will be displayed in AJAX
|
||||
*
|
||||
* @param int $parentId Parent id owning images being saved
|
||||
* @param string $parentType Parent Type owning images being saved
|
||||
*
|
||||
* @return Response
|
||||
*/
|
||||
public function getImageListAjaxAction($parentId, $parentType)
|
||||
{
|
||||
$this->checkAuth('ADMIN', 'admin.image.save');
|
||||
$this->checkXmlHttpRequest();
|
||||
$args = array('imageType' => $parentType, 'parentId' => $parentId);
|
||||
|
||||
return $this->render('includes/image-upload-list-ajax', $args);
|
||||
}
|
||||
|
||||
/**
|
||||
* Manage how an image is viewed
|
||||
*
|
||||
* @param int $imageId Parent id owning images being saved
|
||||
* @param string $parentType Parent Type owning images being saved
|
||||
*
|
||||
* @return Response
|
||||
*/
|
||||
public function viewImageAction($imageId, $parentType)
|
||||
{
|
||||
if (null !== $response = $this->checkAuth('admin.image.view')) return $response;
|
||||
try {
|
||||
$fileManager = new FileManager($this->container);
|
||||
$image = $fileManager->getImageModelQuery($parentType)->findPk($imageId);
|
||||
$redirectUrl = $fileManager->getRedirectionUrl($parentType, $image->getParentId());
|
||||
|
||||
return $this->render('image-edit', array(
|
||||
'imageId' => $imageId,
|
||||
'imageType' => $parentType,
|
||||
'redirectUrl' => $redirectUrl
|
||||
));
|
||||
} catch (Exception $e) {
|
||||
$this->pageNotFound();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Manage how an image is updated
|
||||
*
|
||||
* @param int $imageId Parent id owning images being saved
|
||||
* @param string $parentType Parent Type owning images being saved
|
||||
*
|
||||
* @return Response
|
||||
*/
|
||||
public function updateImageAction($imageId, $parentType)
|
||||
{
|
||||
if (null !== $response = $this->checkAuth('admin.image.update')) return $response;
|
||||
|
||||
$message = false;
|
||||
|
||||
$fileManager = new FileManager($this->container);
|
||||
$imageModification = $fileManager->getImageForm($parentType, $this->getRequest());
|
||||
|
||||
try {
|
||||
$image = $fileManager->getImageModelQuery($parentType)->findPk($imageId);
|
||||
$oldImage = clone $image;
|
||||
if(null === $image) {
|
||||
throw new \InvalidArgumentException(sprintf('%d image id does not exists', $imageId));
|
||||
}
|
||||
|
||||
$form = $this->validateForm($imageModification);
|
||||
|
||||
$event = $this->createEventInstance($parentType, $image, $form->getData());
|
||||
$event->setOldModelImage($oldImage);
|
||||
|
||||
$files = $this->getRequest()->files;
|
||||
$fileForm = $files->get($imageModification->getName());
|
||||
if(isset($fileForm['file'])) {
|
||||
$event->setUploadedFile($fileForm['file']);
|
||||
}
|
||||
|
||||
$this->dispatch(TheliaEvents::IMAGE_UPDATE, $event);
|
||||
|
||||
$imageUpdated = $event->getModelImage();
|
||||
|
||||
$this->adminLogAppend(sprintf('Image with Ref %s (ID %d) modified', $imageUpdated->getTitle() , $imageUpdated->getId()));
|
||||
|
||||
if($this->getRequest()->get('save_mode') == 'close') {
|
||||
$this->redirectToRoute('admin.images');
|
||||
} else {
|
||||
$this->redirectSuccess($imageModification);
|
||||
}
|
||||
|
||||
} catch (FormValidationException $e) {
|
||||
$message = sprintf('Please check your input: %s', $e->getMessage());
|
||||
} catch (PropelException $e) {
|
||||
$message = $e->getMessage();
|
||||
} catch (\Exception $e) {
|
||||
// Any other error
|
||||
$message = 'Sorry, an error occurred:';
|
||||
$this->logError($parentType, 'image saving', $message, $e);
|
||||
$message = sprintf('Sorry, an error occurred: %s', $e->getMessage().' '.$e->getFile());
|
||||
}
|
||||
|
||||
if ($message !== false) {
|
||||
// Mark the form as with error
|
||||
$creationForm->setErrorMessage($message);
|
||||
Tlog::getInstance()->error(sprintf('Error during image editing : %s.', $message));
|
||||
|
||||
$imageModification->setErrorMessage($message);
|
||||
|
||||
// Send the form and the error to the parser
|
||||
$this->getParserContext()
|
||||
->addForm($creationForm)
|
||||
->setGeneralError($message);
|
||||
|
||||
// Set flash message to be displayed
|
||||
$flashMessage = $this->getSession()->get('flashMessage');
|
||||
$flashMessage['imageMessage'] = $message;
|
||||
$this->getSession()->set('flashMessage', $flashMessage);
|
||||
}
|
||||
}
|
||||
->addForm($imageModification)
|
||||
->setGeneralError($message)
|
||||
;
|
||||
}
|
||||
|
||||
$this->redirectSuccess($creationForm);
|
||||
return $this->render('image-edit', array(
|
||||
'imageId' => $imageId,
|
||||
'imageType' => $parentType
|
||||
));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -160,14 +249,18 @@ class FileController extends BaseAdminController
|
||||
$this->checkAuth('ADMIN', 'admin.image.delete');
|
||||
$this->checkXmlHttpRequest();
|
||||
|
||||
$model = $this->getImageModel($parentType, $imageId);
|
||||
$fileManager = new FileManager($this->container);
|
||||
$imageModelQuery = $fileManager->getImageModelQuery($parentType);
|
||||
$model = $imageModelQuery->findPk($imageId);
|
||||
|
||||
if ($model == null) {
|
||||
return $this->pageNotFound();
|
||||
}
|
||||
|
||||
// Feed event
|
||||
$imageDeleteEvent = new ImageDeleteEvent(
|
||||
$model
|
||||
$model,
|
||||
$parentType
|
||||
);
|
||||
|
||||
// Dispatch Event to the Action
|
||||
@@ -218,73 +311,42 @@ class FileController extends BaseAdminController
|
||||
*/
|
||||
public function isParentTypeValid($parentType)
|
||||
{
|
||||
return (in_array($parentType, ImageCreateOrUpdateEvent::getAvailableType()));
|
||||
return (in_array($parentType, ImagesCreateOrUpdateEvent::getAvailableType()));
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Image form
|
||||
* Create Event instance
|
||||
*
|
||||
* @param string $parentType Parent type
|
||||
* @param Request $request Request Service
|
||||
* @param string $parentType Parent Type owning images being saved
|
||||
* @param \Thelia\Model\CategoryImage|\Thelia\Model\ProductImage|\Thelia\Model\ContentImage|\Thelia\Model\FolderImage $model Image model
|
||||
* @param array $data Post data
|
||||
*
|
||||
* @return null|CategoryImageCreationForm|ContentImageCreationForm|FolderImageCreationForm|ProductImageCreationForm
|
||||
*
|
||||
* @todo refactor make all pictures using propel inheritance and factorise image behaviour into one single clean action
|
||||
* @return ImageCreateOrUpdateEvent
|
||||
*/
|
||||
public function getImageForm($parentType, Request $request)
|
||||
private function createEventInstance($parentType, $model, $data)
|
||||
{
|
||||
// @todo implement other forms
|
||||
switch ($parentType) {
|
||||
// case ImageCreateOrUpdateEvent::TYPE_PRODUCT:
|
||||
// $creationForm = new ProductImageCreationForm($request);
|
||||
// break;
|
||||
case ImageCreateOrUpdateEvent::TYPE_CATEGORY:
|
||||
$creationForm = new CategoryImageCreationForm($request);
|
||||
break;
|
||||
// case ImageCreateOrUpdateEvent::TYPE_CONTENT:
|
||||
// $creationForm = new ContentImageCreationForm($request);
|
||||
// break;
|
||||
// case ImageCreateOrUpdateEvent::TYPE_FOLDER:
|
||||
// $creationForm = new FolderImageCreationForm($request);
|
||||
// break;
|
||||
default:
|
||||
$creationForm = null;
|
||||
$imageCreateEvent = new ImageCreateOrUpdateEvent($parentType, null);
|
||||
|
||||
if (isset($data['title'])) {
|
||||
$model->setTitle($data['title']);
|
||||
}
|
||||
if (isset($data['chapo'])) {
|
||||
$model->setChapo($data['chapo']);
|
||||
}
|
||||
if (isset($data['description'])) {
|
||||
$model->setDescription($data['description']);
|
||||
}
|
||||
if (isset($data['file'])) {
|
||||
$model->setFile($data['file']);
|
||||
}
|
||||
if (isset($data['postscriptum'])) {
|
||||
$model->setPostscriptum($data['postscriptum']);
|
||||
}
|
||||
|
||||
return $creationForm;
|
||||
$imageCreateEvent->setModelImage($model);
|
||||
|
||||
return $imageCreateEvent;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get image model from type
|
||||
*
|
||||
* @param string $parentType
|
||||
* @param int $imageId
|
||||
*
|
||||
* @return null|\Thelia\Model\CategoryImage|\Thelia\Model\ContentImage|\Thelia\Model\FolderImage|\Thelia\Model\ProductImage
|
||||
*
|
||||
* @todo refactor make all pictures using propel inheritance and factorise image behaviour into one single clean action
|
||||
*/
|
||||
public function getImageModel($parentType, $imageId)
|
||||
{
|
||||
switch ($parentType) {
|
||||
case ImageCreateOrUpdateEvent::TYPE_PRODUCT:
|
||||
$model = ProductImageQuery::create()->findPk($imageId);
|
||||
break;
|
||||
case ImageCreateOrUpdateEvent::TYPE_CATEGORY:
|
||||
$model = CategoryImageQuery::create()->findPk($imageId);
|
||||
break;
|
||||
case ImageCreateOrUpdateEvent::TYPE_CONTENT:
|
||||
$model = ContentImageQuery::create()->findPk($imageId);
|
||||
break;
|
||||
case ImageCreateOrUpdateEvent::TYPE_FOLDER:
|
||||
$model = FolderImageQuery::create()->findPk($imageId);
|
||||
break;
|
||||
default:
|
||||
$model = null;
|
||||
}
|
||||
|
||||
return $model;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,13 +22,14 @@
|
||||
/*************************************************************************************/
|
||||
|
||||
namespace Thelia\Core\Event;
|
||||
use Symfony\Component\HttpFoundation\File\UploadedFile;
|
||||
|
||||
/**
|
||||
* Created by JetBrains PhpStorm.
|
||||
* Date: 9/18/13
|
||||
* Time: 3:56 PM
|
||||
*
|
||||
* Occurring when a Image list is saved
|
||||
* Occurring when an Image is saved
|
||||
*
|
||||
* @package Image
|
||||
* @author Guillaume MOREL <gmorel@openstudio.fr>
|
||||
@@ -36,16 +37,15 @@ namespace Thelia\Core\Event;
|
||||
*/
|
||||
class ImageCreateOrUpdateEvent extends ActionEvent
|
||||
{
|
||||
CONST TYPE_PRODUCT = 'product';
|
||||
CONST TYPE_CATEGORY = 'category';
|
||||
CONST TYPE_CONTENT = 'content';
|
||||
CONST TYPE_FOLDER = 'folder';
|
||||
|
||||
/** @var array Images model to save */
|
||||
protected $modelImages = array();
|
||||
/** @var \Thelia\Model\CategoryImage|\Thelia\Model\ProductImage|\Thelia\Model\ContentImage|\Thelia\Model\FolderImage model to save */
|
||||
protected $modelImage = array();
|
||||
|
||||
/** @var array Images file to save */
|
||||
protected $uploadedFiles = array();
|
||||
/** @var \Thelia\Model\CategoryImage|\Thelia\Model\ProductImage|\Thelia\Model\ContentImage|\Thelia\Model\FolderImage model to save */
|
||||
protected $oldModelImage = array();
|
||||
|
||||
/** @var UploadedFile Image file to save */
|
||||
protected $uploadedFile = null;
|
||||
|
||||
/** @var int Image parent id */
|
||||
protected $parentId = null;
|
||||
@@ -53,85 +53,56 @@ class ImageCreateOrUpdateEvent extends ActionEvent
|
||||
/** @var string Image type */
|
||||
protected $imageType = null;
|
||||
|
||||
/** @var array Available image parent type */
|
||||
protected static $availableType = array(
|
||||
self::TYPE_PRODUCT,
|
||||
self::TYPE_CATEGORY,
|
||||
self::TYPE_CONTENT,
|
||||
self::TYPE_FOLDER,
|
||||
);
|
||||
/** @var string Parent name */
|
||||
protected $parentName = null;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param string $pictureType Picture type
|
||||
* ex : ImageCreateOrUpdateEvent::TYPE_CATEGORY
|
||||
* @param string $imageType Image type
|
||||
* ex : FileManager::TYPE_CATEGORY
|
||||
* @param int $parentId Image parent id
|
||||
*/
|
||||
public function __construct($pictureType, $parentId)
|
||||
public function __construct($imageType, $parentId)
|
||||
{
|
||||
$this->imageType = $pictureType;
|
||||
$this->imageType = $imageType;
|
||||
$this->parentId = $parentId;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Images to save
|
||||
* Set Image to save
|
||||
*
|
||||
* @param array $images Thelia\Model\CategoryImage Array
|
||||
* @param $image \Thelia\Model\CategoryImage|\Thelia\Model\ProductImage|\Thelia\Model\ContentImage|\Thelia\Model\FolderImage
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setModelImages($images)
|
||||
public function setModelImage($image)
|
||||
{
|
||||
$this->modelImages = $images;
|
||||
$this->modelImage = $image;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Images being saved
|
||||
* Get Image being saved
|
||||
*
|
||||
* @return array Array of Thelia\Model\CategoryImage
|
||||
* @return \Thelia\Model\CategoryImage|\Thelia\Model\ProductImage|\Thelia\Model\ContentImage|\Thelia\Model\FolderImage
|
||||
*/
|
||||
public function getModelImages()
|
||||
public function getModelImage()
|
||||
{
|
||||
return $this->modelImages;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Images to save
|
||||
*
|
||||
* @param array $images Thelia\Model\CategoryImage Array
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setUploadedFiles($images)
|
||||
{
|
||||
$this->uploadedFiles = $images;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Images being saved
|
||||
*
|
||||
* @return array Array of Thelia\Model\CategoryImage
|
||||
*/
|
||||
public function getUploadedFiles()
|
||||
{
|
||||
return $this->uploadedFiles;
|
||||
return $this->modelImage;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set picture type
|
||||
*
|
||||
* @param string $pictureType Picture type
|
||||
* @param string $imageType Image type
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setImageType($pictureType)
|
||||
public function setImageType($imageType)
|
||||
{
|
||||
$this->imageType = $pictureType;
|
||||
$this->imageType = $imageType;
|
||||
|
||||
return $this;
|
||||
}
|
||||
@@ -146,16 +117,6 @@ class ImageCreateOrUpdateEvent extends ActionEvent
|
||||
return $this->imageType;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all image parent type available
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function getAvailableType()
|
||||
{
|
||||
return self::$availableType;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Image parent id
|
||||
*
|
||||
@@ -180,5 +141,73 @@ class ImageCreateOrUpdateEvent extends ActionEvent
|
||||
return $this->parentId;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set uploaded file
|
||||
*
|
||||
* @param UploadedFile $uploadedFile File being uploaded
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setUploadedFile($uploadedFile)
|
||||
{
|
||||
$this->uploadedFile = $uploadedFile;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get uploaded file
|
||||
*
|
||||
* @return UploadedFile
|
||||
*/
|
||||
public function getUploadedFile()
|
||||
{
|
||||
return $this->uploadedFile;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set parent name
|
||||
*
|
||||
* @param string $parentName Parent name
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setParentName($parentName)
|
||||
{
|
||||
$this->parentName = $parentName;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get parent name
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getParentName()
|
||||
{
|
||||
return $this->parentName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set old model value
|
||||
*
|
||||
* @param \Thelia\Model\CategoryImage|\Thelia\Model\ContentImage|\Thelia\Model\FolderImage|\Thelia\Model\ProductImage $oldModelImage
|
||||
*/
|
||||
public function setOldModelImage($oldModelImage)
|
||||
{
|
||||
$this->oldModelImage = $oldModelImage;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get old model value
|
||||
*
|
||||
* @return \Thelia\Model\CategoryImage|\Thelia\Model\ContentImage|\Thelia\Model\FolderImage|\Thelia\Model\ProductImage
|
||||
*/
|
||||
public function getOldModelImage()
|
||||
{
|
||||
return $this->oldModelImage;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -41,6 +41,9 @@ use Thelia\Model\ProductImage;
|
||||
*/
|
||||
class ImageDeleteEvent extends ActionEvent
|
||||
{
|
||||
/** @var string Image type */
|
||||
protected $imageType = null;
|
||||
|
||||
/** @var CategoryImage|ProductImage|ContentImage|FolderImage Image about to be deleted */
|
||||
protected $imageToDelete = null;
|
||||
|
||||
@@ -48,10 +51,37 @@ class ImageDeleteEvent extends ActionEvent
|
||||
* Constructor
|
||||
*
|
||||
* @param CategoryImage|ProductImage|ContentImage|FolderImage $imageToDelete Image about to be deleted
|
||||
* @param string $imageType Image type
|
||||
* ex : FileManager::TYPE_CATEGORY
|
||||
*/
|
||||
public function __construct($imageToDelete)
|
||||
public function __construct($imageToDelete, $imageType)
|
||||
{
|
||||
$this->imageToDelete = $imageToDelete;
|
||||
$this->imageType = $imageType;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set picture type
|
||||
*
|
||||
* @param string $imageType Image type
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setImageType($imageType)
|
||||
{
|
||||
$this->imageType = $imageType;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get picture type
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getImageType()
|
||||
{
|
||||
return $this->imageType;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
184
core/lib/Thelia/Core/Event/ImagesCreateOrUpdateEvent.php
Executable file
184
core/lib/Thelia/Core/Event/ImagesCreateOrUpdateEvent.php
Executable file
@@ -0,0 +1,184 @@
|
||||
<?php
|
||||
/*************************************************************************************/
|
||||
/* */
|
||||
/* Thelia */
|
||||
/* */
|
||||
/* Copyright (c) OpenStudio */
|
||||
/* email : info@thelia.net */
|
||||
/* web : http://www.thelia.net */
|
||||
/* */
|
||||
/* 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; either version 3 of the License */
|
||||
/* */
|
||||
/* 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, see <http://www.gnu.org/licenses/>. */
|
||||
/* */
|
||||
/*************************************************************************************/
|
||||
|
||||
namespace Thelia\Core\Event;
|
||||
|
||||
/**
|
||||
* Created by JetBrains PhpStorm.
|
||||
* Date: 9/18/13
|
||||
* Time: 3:56 PM
|
||||
*
|
||||
* Occurring when a Image list is saved
|
||||
*
|
||||
* @package Image
|
||||
* @author Guillaume MOREL <gmorel@openstudio.fr>
|
||||
*
|
||||
*/
|
||||
class ImagesCreateOrUpdateEvent extends ActionEvent
|
||||
{
|
||||
CONST TYPE_PRODUCT = 'product';
|
||||
CONST TYPE_CATEGORY = 'category';
|
||||
CONST TYPE_CONTENT = 'content';
|
||||
CONST TYPE_FOLDER = 'folder';
|
||||
|
||||
/** @var array Images model to save */
|
||||
protected $modelImages = array();
|
||||
|
||||
/** @var array Images file to save */
|
||||
protected $uploadedFiles = array();
|
||||
|
||||
/** @var int Image parent id */
|
||||
protected $parentId = null;
|
||||
|
||||
/** @var string Image type */
|
||||
protected $imageType = null;
|
||||
|
||||
/** @var array Available image parent type */
|
||||
protected static $availableType = array(
|
||||
self::TYPE_PRODUCT,
|
||||
self::TYPE_CATEGORY,
|
||||
self::TYPE_CONTENT,
|
||||
self::TYPE_FOLDER,
|
||||
);
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param string $pictureType Picture type
|
||||
* ex : ImageCreateOrUpdateEvent::TYPE_CATEGORY
|
||||
* @param int $parentId Image parent id
|
||||
*/
|
||||
public function __construct($pictureType, $parentId)
|
||||
{
|
||||
$this->imageType = $pictureType;
|
||||
$this->parentId = $parentId;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Images to save
|
||||
*
|
||||
* @param array $images Thelia\Model\CategoryImage Array
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setModelImages($images)
|
||||
{
|
||||
$this->modelImages = $images;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Images being saved
|
||||
*
|
||||
* @return array Array of Thelia\Model\CategoryImage
|
||||
*/
|
||||
public function getModelImages()
|
||||
{
|
||||
return $this->modelImages;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Images to save
|
||||
*
|
||||
* @param array $images Thelia\Model\CategoryImage Array
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setUploadedFiles($images)
|
||||
{
|
||||
$this->uploadedFiles = $images;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Images being saved
|
||||
*
|
||||
* @return array Array of Thelia\Model\CategoryImage
|
||||
*/
|
||||
public function getUploadedFiles()
|
||||
{
|
||||
return $this->uploadedFiles;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set picture type
|
||||
*
|
||||
* @param string $pictureType Picture type
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setImageType($pictureType)
|
||||
{
|
||||
$this->imageType = $pictureType;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get picture type
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getImageType()
|
||||
{
|
||||
return $this->imageType;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all image parent type available
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function getAvailableType()
|
||||
{
|
||||
return self::$availableType;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Image parent id
|
||||
*
|
||||
* @param int $parentId Image parent id
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setParentId($parentId)
|
||||
{
|
||||
$this->parentId = $parentId;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Image parent id
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getParentId()
|
||||
{
|
||||
return $this->parentId;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -304,6 +304,11 @@ final class TheliaEvents
|
||||
*/
|
||||
const IMAGE_SAVE = "action.saveImages";
|
||||
|
||||
/**
|
||||
* Save given images
|
||||
*/
|
||||
const IMAGE_UPDATE = "action.updateImages";
|
||||
|
||||
/**
|
||||
* Delete given image
|
||||
*/
|
||||
|
||||
@@ -22,8 +22,9 @@
|
||||
/*************************************************************************************/
|
||||
namespace Thelia\Form;
|
||||
|
||||
|
||||
use Thelia\Core\Translation\Translator;
|
||||
use Thelia\Form\Type\ImageCategoryType;
|
||||
use Thelia\Form\Image\ImageModification;
|
||||
|
||||
/**
|
||||
* Created by JetBrains PhpStorm.
|
||||
@@ -36,36 +37,17 @@ use Thelia\Form\Type\ImageCategoryType;
|
||||
* @author Guillaume MOREL <gmorel@openstudio.fr>
|
||||
*
|
||||
*/
|
||||
class CategoryImageCreationForm extends BaseForm
|
||||
class CategoryImageModification extends ImageModification
|
||||
{
|
||||
/**
|
||||
* Allow to build a form
|
||||
*/
|
||||
protected function buildForm()
|
||||
{
|
||||
$this->formBuilder
|
||||
->add('pictures',
|
||||
'collection',
|
||||
array(
|
||||
'type' => new ImageCategoryType(),
|
||||
'options' => array(
|
||||
'required' => false
|
||||
),
|
||||
'allow_add' => true,
|
||||
'allow_delete' => true,
|
||||
'by_reference' => false,
|
||||
)
|
||||
)
|
||||
->add('formSuccessUrl');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get form name
|
||||
* This name must be unique
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getName()
|
||||
{
|
||||
return 'thelia_category_image_creation';
|
||||
return 'thelia_category_image_modification';
|
||||
}
|
||||
}
|
||||
@@ -20,60 +20,34 @@
|
||||
/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||
/* */
|
||||
/*************************************************************************************/
|
||||
namespace Thelia\Form\Type;
|
||||
namespace Thelia\Form;
|
||||
|
||||
use Symfony\Component\Form\FormBuilderInterface;
|
||||
use Symfony\Component\OptionsResolver\OptionsResolverInterface;
|
||||
use Thelia\Form\Type\ImageType;
|
||||
|
||||
use Thelia\Core\Translation\Translator;
|
||||
use Thelia\Form\Image\ImageModification;
|
||||
|
||||
/**
|
||||
* Created by JetBrains PhpStorm.
|
||||
* Date: 9/18/13
|
||||
* Time: 3:56 PM
|
||||
*
|
||||
* Form allowing to process a category picture
|
||||
* Form allowing to process an image collection
|
||||
*
|
||||
* @package Image
|
||||
* @author Guillaume MOREL <gmorel@openstudio.fr>
|
||||
*
|
||||
*/
|
||||
class ImageCategoryType extends ImageType
|
||||
class ContentImageModification extends ImageModification
|
||||
{
|
||||
/**
|
||||
* Build a Picture form
|
||||
*
|
||||
* @param FormBuilderInterface $builder Form builder
|
||||
* @param array $options Form options
|
||||
*/
|
||||
public function buildForm(FormBuilderInterface $builder, array $options)
|
||||
{
|
||||
$builder->add('category_id', 'integer');
|
||||
|
||||
parent::buildForm($builder, $options);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set default options
|
||||
* Map the form to the given Model
|
||||
*
|
||||
* @param OptionsResolverInterface $resolver Option resolver
|
||||
*/
|
||||
public function setDefaultOptions(OptionsResolverInterface $resolver)
|
||||
{
|
||||
$resolver->setDefaults(
|
||||
array(
|
||||
'data_class' => 'Thelia\Model\CategoryImage'
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get form name
|
||||
* This name must be unique
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getName()
|
||||
{
|
||||
return 'thelia_category_picture_creation_type';
|
||||
return 'thelia_content_image_modification';
|
||||
}
|
||||
}
|
||||
@@ -20,63 +20,34 @@
|
||||
/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||
/* */
|
||||
/*************************************************************************************/
|
||||
namespace Thelia\Form\Type;
|
||||
namespace Thelia\Form;
|
||||
|
||||
use Symfony\Component\Form\AbstractType;
|
||||
use Symfony\Component\Form\FormBuilderInterface;
|
||||
use Symfony\Component\Validator\Constraints\Image;
|
||||
use Symfony\Component\Validator\Constraints\NotBlank;
|
||||
|
||||
use Thelia\Core\Translation\Translator;
|
||||
use Thelia\Form\Image\ImageModification;
|
||||
|
||||
/**
|
||||
* Created by JetBrains PhpStorm.
|
||||
* Date: 9/18/13
|
||||
* Time: 3:56 PM
|
||||
*
|
||||
* Form allowing to process a picture
|
||||
*
|
||||
* @todo refactor make all pictures using propel inheritance and factorise image behaviour into one single clean action
|
||||
* Form allowing to process an image collection
|
||||
*
|
||||
* @package Image
|
||||
* @author Guillaume MOREL <gmorel@openstudio.fr>
|
||||
*
|
||||
*/
|
||||
abstract class ImageType extends AbstractType
|
||||
class FolderImageModification extends ImageModification
|
||||
{
|
||||
|
||||
/**
|
||||
* Build a Picture form
|
||||
* Get form name
|
||||
* This name must be unique
|
||||
*
|
||||
* @param FormBuilderInterface $builder Form builder
|
||||
* @param array $options Form options
|
||||
* @return string
|
||||
*/
|
||||
public function buildForm(FormBuilderInterface $builder, array $options)
|
||||
public function getName()
|
||||
{
|
||||
// $builder->add('position');
|
||||
$builder->add(
|
||||
'title',
|
||||
'text',
|
||||
array(
|
||||
'constraints' => new NotBlank()
|
||||
)
|
||||
);
|
||||
$builder->add(
|
||||
'file',
|
||||
'file',
|
||||
array(
|
||||
'constraints' => array(
|
||||
new NotBlank(),
|
||||
new Image(
|
||||
array(
|
||||
'minWidth' => 200,
|
||||
// 'maxWidth' => 400,
|
||||
'minHeight' => 200,
|
||||
// 'maxHeight' => 400,
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
);
|
||||
// $builder->add('description');
|
||||
// $builder->add('chapo');
|
||||
// $builder->add('postscriptum');
|
||||
return 'thelia_folder_image_modification';
|
||||
}
|
||||
}
|
||||
183
core/lib/Thelia/Form/Image/ImageModification.php
Normal file
183
core/lib/Thelia/Form/Image/ImageModification.php
Normal file
@@ -0,0 +1,183 @@
|
||||
<?php
|
||||
/*************************************************************************************/
|
||||
/* */
|
||||
/* Thelia */
|
||||
/* */
|
||||
/* Copyright (c) OpenStudio */
|
||||
/* email : info@thelia.net */
|
||||
/* web : http://www.thelia.net */
|
||||
/* */
|
||||
/* 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; either version 3 of the License */
|
||||
/* */
|
||||
/* 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, see <http://www.gnu.org/licenses/>. */
|
||||
/* */
|
||||
/*************************************************************************************/
|
||||
namespace Thelia\Form\Image;
|
||||
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\Validator\Constraints\Image;
|
||||
use Symfony\Component\Validator\Constraints\NotBlank;
|
||||
use Thelia\Core\Translation\Translator;
|
||||
use Thelia\Form\BaseForm;
|
||||
|
||||
/**
|
||||
* Created by JetBrains PhpStorm.
|
||||
* Date: 9/18/13
|
||||
* Time: 3:56 PM
|
||||
*
|
||||
* Form allowing to process an image
|
||||
* @todo refactor make all pictures using propel inheritance and factorise image behaviour into one single clean action
|
||||
*
|
||||
* @package Image
|
||||
* @author Guillaume MOREL <gmorel@openstudio.fr>
|
||||
*
|
||||
*/
|
||||
abstract class ImageModification extends BaseForm
|
||||
{
|
||||
|
||||
// public function __construct(Request $request, $type= "form", $data = array(), $options = array(), $isUpdate = false)
|
||||
// {
|
||||
// parent::__construct($request, $type, $data, $options);
|
||||
// $this->setIsUpdate($isUpdate);
|
||||
// }
|
||||
|
||||
// /** @var bool Flag for update/create mode */
|
||||
// protected $isUpdate = false;
|
||||
|
||||
/**
|
||||
*
|
||||
* in this function you add all the fields you need for your Form.
|
||||
* Form this you have to call add method on $this->form attribute :
|
||||
*
|
||||
* $this->form->add('name', 'text')
|
||||
* ->add('email', 'email', array(
|
||||
* 'attr' => array(
|
||||
* 'class' => 'field'
|
||||
* ),
|
||||
* 'label' => 'email',
|
||||
* 'constraints' => array(
|
||||
* new NotBlank()
|
||||
* )
|
||||
* )
|
||||
* )
|
||||
* ->add('age', 'integer');
|
||||
*
|
||||
* @return null
|
||||
*/
|
||||
protected function buildForm()
|
||||
{
|
||||
// if (false === $this->isUpdate) {
|
||||
$this->formBuilder->add(
|
||||
'file',
|
||||
'file',
|
||||
array(
|
||||
'constraints' => array(
|
||||
// new NotBlank(),
|
||||
new Image(
|
||||
array(
|
||||
'minWidth' => 200,
|
||||
'minHeight' => 200
|
||||
)
|
||||
)
|
||||
),
|
||||
'label' => Translator::getInstance()->trans('File'),
|
||||
'label_attr' => array(
|
||||
'for' => 'file'
|
||||
)
|
||||
)
|
||||
);
|
||||
// }
|
||||
|
||||
$this->formBuilder
|
||||
->add(
|
||||
'title',
|
||||
'text',
|
||||
array(
|
||||
'constraints' => array(
|
||||
new NotBlank()
|
||||
),
|
||||
'label' => Translator::getInstance()->trans('Title'),
|
||||
'label_attr' => array(
|
||||
'for' => 'title'
|
||||
)
|
||||
)
|
||||
)
|
||||
->add(
|
||||
'description',
|
||||
'text',
|
||||
array(
|
||||
'constraints' => array(),
|
||||
'label' => Translator::getInstance()->trans('Description'),
|
||||
'label_attr' => array(
|
||||
'for' => 'description'
|
||||
)
|
||||
)
|
||||
)
|
||||
->add(
|
||||
'chapo',
|
||||
'text',
|
||||
array(
|
||||
'constraints' => array(),
|
||||
'label' => Translator::getInstance()->trans('Chapo'),
|
||||
'label_attr' => array(
|
||||
'for' => 'chapo'
|
||||
)
|
||||
)
|
||||
)
|
||||
->add(
|
||||
'postscriptum',
|
||||
'text',
|
||||
array(
|
||||
'constraints' => array(),
|
||||
'label' => Translator::getInstance()->trans('Post Scriptum'),
|
||||
'label_attr' => array(
|
||||
'for' => 'postscriptum'
|
||||
)
|
||||
)
|
||||
)
|
||||
->add(
|
||||
'postscriptum',
|
||||
'text',
|
||||
array(
|
||||
'constraints' => array(),
|
||||
'label' => Translator::getInstance()->trans('Post Scriptum'),
|
||||
'label_attr' => array(
|
||||
'for' => 'postscriptum'
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
|
||||
}
|
||||
|
||||
// /**
|
||||
// * Set form in update or create mode
|
||||
// *
|
||||
// * @param boolean $isUpdate
|
||||
// */
|
||||
// public function setIsUpdate($isUpdate)
|
||||
// {
|
||||
// $this->isUpdate = $isUpdate;
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * Get for mode
|
||||
// *
|
||||
// * @return boolean
|
||||
// */
|
||||
// public function getIsUpdate()
|
||||
// {
|
||||
// return $this->isUpdate;
|
||||
// }
|
||||
|
||||
|
||||
|
||||
}
|
||||
53
core/lib/Thelia/Form/ProductImageModification.php
Normal file
53
core/lib/Thelia/Form/ProductImageModification.php
Normal file
@@ -0,0 +1,53 @@
|
||||
<?php
|
||||
/*************************************************************************************/
|
||||
/* */
|
||||
/* Thelia */
|
||||
/* */
|
||||
/* Copyright (c) OpenStudio */
|
||||
/* email : info@thelia.net */
|
||||
/* web : http://www.thelia.net */
|
||||
/* */
|
||||
/* 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; either version 3 of the License */
|
||||
/* */
|
||||
/* 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, see <http://www.gnu.org/licenses/>. */
|
||||
/* */
|
||||
/*************************************************************************************/
|
||||
namespace Thelia\Form;
|
||||
|
||||
|
||||
use Thelia\Core\Translation\Translator;
|
||||
use Thelia\Form\Image\ImageModification;
|
||||
|
||||
/**
|
||||
* Created by JetBrains PhpStorm.
|
||||
* Date: 9/18/13
|
||||
* Time: 3:56 PM
|
||||
*
|
||||
* Form allowing to process an image collection
|
||||
*
|
||||
* @package Image
|
||||
* @author Guillaume MOREL <gmorel@openstudio.fr>
|
||||
*
|
||||
*/
|
||||
class ProductImageModification extends ImageModification
|
||||
{
|
||||
|
||||
/**
|
||||
* Get form name
|
||||
* This name must be unique
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getName()
|
||||
{
|
||||
return 'thelia_product_image_modification';
|
||||
}
|
||||
}
|
||||
@@ -29,40 +29,17 @@ class CategoryImage extends BaseCategoryImage
|
||||
}
|
||||
|
||||
/**
|
||||
* Get picture absolute path
|
||||
* @todo refactor make all pictures using propel inheritance and factorise image behaviour into one single clean action
|
||||
* Set Image parent id
|
||||
*
|
||||
* @return null|string
|
||||
*/
|
||||
public function getAbsolutePath()
|
||||
{
|
||||
return null === $this->file
|
||||
? null
|
||||
: $this->getUploadDir().'/'.$this->file;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get picture web path
|
||||
* @todo refactor make all pictures using propel inheritance and factorise image behaviour into one single clean action
|
||||
* @param int $parentId parent id
|
||||
*
|
||||
* @return null|string
|
||||
* @return $this
|
||||
*/
|
||||
public function getWebPath()
|
||||
public function setParentId($parentId)
|
||||
{
|
||||
return null === $this->file
|
||||
? null
|
||||
: $this->getUploadDir().'/'.$this->file;
|
||||
}
|
||||
$this->setCategoryId($parentId);
|
||||
|
||||
|
||||
/**
|
||||
* Get rid of the __DIR__ so it doesn't screw up
|
||||
* when displaying uploaded doc/image in the view.
|
||||
* @return string
|
||||
*/
|
||||
public function getUploadDir()
|
||||
{
|
||||
return THELIA_LOCAL_DIR . 'media/images/category';
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -26,6 +26,20 @@ class ContentImage extends BaseContentImage
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Image parent id
|
||||
*
|
||||
* @param int $parentId parent id
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setParentId($parentId)
|
||||
{
|
||||
$this->setContentId($parentId);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Image parent id
|
||||
*
|
||||
|
||||
@@ -26,6 +26,20 @@ class FolderImage extends BaseFolderImage
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Image parent id
|
||||
*
|
||||
* @param int $parentId parent id
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setParentId($parentId)
|
||||
{
|
||||
$this->setFolderId($parentId);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Image parent id
|
||||
*
|
||||
|
||||
@@ -26,6 +26,20 @@ class ProductImage extends BaseProductImage
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Image parent id
|
||||
*
|
||||
* @param int $parentId parent id
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setParentId($parentId)
|
||||
{
|
||||
$this->setProductId($parentId);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Image parent id
|
||||
*
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
namespace Thelia\Tests\Type;
|
||||
|
||||
|
||||
use Thelia\Core\Event\ImageCreateOrUpdateEvent;
|
||||
use Thelia\Core\Event\ImagesCreateOrUpdateEvent;
|
||||
use Thelia\Exception\ImageException;
|
||||
use Thelia\Model\Admin;
|
||||
use Thelia\Model\ProductImage;
|
||||
@@ -94,7 +94,7 @@ class FileManagerTest extends \PHPUnit_Framework_TestCase {
|
||||
|
||||
$newUploadedFiles = array();
|
||||
|
||||
$actual = $fileManager->copyUploadedFile(24, ImageCreateOrUpdateEvent::TYPE_PRODUCT, $stubProductImage, $stubUploadedFile, $newUploadedFiles);
|
||||
$actual = $fileManager->copyUploadedFile(24, ImagesCreateOrUpdateEvent::TYPE_PRODUCT, $stubProductImage, $stubUploadedFile, $newUploadedFiles);
|
||||
|
||||
$this->assertCount(1, $actual);
|
||||
}
|
||||
@@ -176,7 +176,7 @@ class FileManagerTest extends \PHPUnit_Framework_TestCase {
|
||||
|
||||
$newUploadedFiles = array();
|
||||
|
||||
$actual = $fileManager->copyUploadedFile(24, ImageCreateOrUpdateEvent::TYPE_PRODUCT, $stubProductImage, $stubUploadedFile, $newUploadedFiles);
|
||||
$actual = $fileManager->copyUploadedFile(24, ImagesCreateOrUpdateEvent::TYPE_PRODUCT, $stubProductImage, $stubUploadedFile, $newUploadedFiles);
|
||||
|
||||
}
|
||||
|
||||
@@ -198,7 +198,7 @@ class FileManagerTest extends \PHPUnit_Framework_TestCase {
|
||||
|
||||
$fileManager = new FileManager($stubContainer);
|
||||
|
||||
$event = new ImageCreateOrUpdateEvent(ImageCreateOrUpdateEvent::TYPE_PRODUCT, 24);
|
||||
$event = new ImagesCreateOrUpdateEvent(ImagesCreateOrUpdateEvent::TYPE_PRODUCT, 24);
|
||||
|
||||
$expected = 10;
|
||||
$actual = $fileManager->saveImage($event, $stubProductImage);
|
||||
@@ -224,7 +224,7 @@ class FileManagerTest extends \PHPUnit_Framework_TestCase {
|
||||
|
||||
$fileManager = new FileManager($stubContainer);
|
||||
|
||||
$event = new ImageCreateOrUpdateEvent(ImageCreateOrUpdateEvent::TYPE_CATEGORY, 24);
|
||||
$event = new ImagesCreateOrUpdateEvent(ImagesCreateOrUpdateEvent::TYPE_CATEGORY, 24);
|
||||
|
||||
$expected = 10;
|
||||
$actual = $fileManager->saveImage($event, $stubCategoryImage);
|
||||
@@ -250,7 +250,7 @@ class FileManagerTest extends \PHPUnit_Framework_TestCase {
|
||||
|
||||
$fileManager = new FileManager($stubContainer);
|
||||
|
||||
$event = new ImageCreateOrUpdateEvent(ImageCreateOrUpdateEvent::TYPE_FOLDER, 24);
|
||||
$event = new ImagesCreateOrUpdateEvent(ImagesCreateOrUpdateEvent::TYPE_FOLDER, 24);
|
||||
|
||||
$expected = 10;
|
||||
$actual = $fileManager->saveImage($event, $stubFolderImage);
|
||||
@@ -276,7 +276,7 @@ class FileManagerTest extends \PHPUnit_Framework_TestCase {
|
||||
|
||||
$fileManager = new FileManager($stubContainer);
|
||||
|
||||
$event = new ImageCreateOrUpdateEvent(ImageCreateOrUpdateEvent::TYPE_CONTENT, 24);
|
||||
$event = new ImagesCreateOrUpdateEvent(ImagesCreateOrUpdateEvent::TYPE_CONTENT, 24);
|
||||
|
||||
$expected = 10;
|
||||
$actual = $fileManager->saveImage($event, $stubContentImage);
|
||||
@@ -302,7 +302,7 @@ class FileManagerTest extends \PHPUnit_Framework_TestCase {
|
||||
->method('save')
|
||||
->will($this->returnValue(10));
|
||||
|
||||
$event = new ImageCreateOrUpdateEvent('bad', 24);
|
||||
$event = new ImagesCreateOrUpdateEvent('bad', 24);
|
||||
$modelImage = new ProductImage();
|
||||
|
||||
$fileManager->saveImage($event, $modelImage);
|
||||
@@ -326,7 +326,7 @@ class FileManagerTest extends \PHPUnit_Framework_TestCase {
|
||||
->method('save')
|
||||
->will($this->returnValue(0));
|
||||
|
||||
$event = new ImageCreateOrUpdateEvent(ImageCreateOrUpdateEvent::TYPE_PRODUCT, 24);
|
||||
$event = new ImagesCreateOrUpdateEvent(ImagesCreateOrUpdateEvent::TYPE_PRODUCT, 24);
|
||||
|
||||
$fileManager->saveImage($event, $stubProductImage);
|
||||
}
|
||||
|
||||
@@ -24,14 +24,27 @@ namespace Thelia\Tools;
|
||||
|
||||
use Symfony\Component\DependencyInjection\ContainerInterface;
|
||||
use Symfony\Component\HttpFoundation\File\UploadedFile;
|
||||
use Thelia\Core\Event\ImageCreateOrUpdateEvent;
|
||||
use Thelia\Core\Event\ImageDeleteEvent;
|
||||
use Thelia\Core\Event\ImagesCreateOrUpdateEvent;
|
||||
use Thelia\Core\HttpFoundation\Request;
|
||||
use Thelia\Core\Translation\Translator;
|
||||
use Thelia\Exception\ImageException;
|
||||
use Thelia\Form\CategoryImageModification;
|
||||
use Thelia\Form\ContentImageModification;
|
||||
use Thelia\Form\FolderImageModification;
|
||||
use Thelia\Form\ProductImageModification;
|
||||
use Thelia\Model\AdminLog;
|
||||
use Thelia\Model\Base\CategoryImage;
|
||||
use Thelia\Model\CategoryImage;
|
||||
use Thelia\Model\CategoryImageQuery;
|
||||
use Thelia\Model\CategoryQuery;
|
||||
use Thelia\Model\ContentImage;
|
||||
use Thelia\Model\ContentImageQuery;
|
||||
use Thelia\Model\ContentQuery;
|
||||
use Thelia\Model\FolderImage;
|
||||
use Thelia\Model\FolderImageQuery;
|
||||
use Thelia\Model\FolderQuery;
|
||||
use Thelia\Model\ProductImage;
|
||||
use Thelia\Model\ProductImageQuery;
|
||||
use Thelia\Model\ProductQuery;
|
||||
|
||||
/**
|
||||
* Created by JetBrains PhpStorm.
|
||||
@@ -46,6 +59,12 @@ use Thelia\Model\ProductImage;
|
||||
*/
|
||||
class FileManager
|
||||
{
|
||||
CONST TYPE_PRODUCT = 'product';
|
||||
CONST TYPE_CATEGORY = 'category';
|
||||
CONST TYPE_CONTENT = 'content';
|
||||
CONST TYPE_FOLDER = 'folder';
|
||||
CONST TYPE_MODULE = 'module';
|
||||
|
||||
/** @var ContainerInterface Service Container */
|
||||
protected $container = null;
|
||||
|
||||
@@ -70,20 +89,15 @@ class FileManager
|
||||
* @param string $imageType Image type
|
||||
* @param FolderImage|ContentImage|CategoryImage|ProductImage $modelImage Image saved
|
||||
* @param UploadedFile $uploadedFile Ready to be uploaded file
|
||||
* @param array $newUploadedFiles UploadedFile array to update
|
||||
*
|
||||
* @throws \Thelia\Exception\ImageException
|
||||
* @return array Updated UploadedFile array
|
||||
* @return UploadedFile
|
||||
*/
|
||||
public function copyUploadedFile($parentId, $imageType, $modelImage, $uploadedFile, $newUploadedFiles)
|
||||
public function copyUploadedFile($parentId, $imageType, $modelImage, $uploadedFile)
|
||||
{
|
||||
if ($uploadedFile !== null) {
|
||||
$directory = $modelImage->getUploadDir();
|
||||
$fileName = $this->sanitizeFileName(
|
||||
$uploadedFile->getClientOriginalName() . "-" . $modelImage->getId() . "." . strtolower(
|
||||
$uploadedFile->getClientOriginalExtension()
|
||||
)
|
||||
);
|
||||
$directory = $this->getUploadDir($imageType);
|
||||
$fileName = $this->renameFile($modelImage->getId(), $uploadedFile);
|
||||
|
||||
$this->adminLogAppend(
|
||||
$this->translator->trans(
|
||||
@@ -98,7 +112,7 @@ class FileManager
|
||||
)
|
||||
);
|
||||
|
||||
$newUploadedFiles[] = array('file' => $uploadedFile->move($directory, $fileName));
|
||||
$newUploadedFile = $uploadedFile->move($directory, $fileName);
|
||||
$modelImage->setFile($fileName);
|
||||
|
||||
if (!$modelImage->save()) {
|
||||
@@ -112,38 +126,38 @@ class FileManager
|
||||
}
|
||||
}
|
||||
|
||||
return $newUploadedFiles;
|
||||
return $newUploadedFile;
|
||||
}
|
||||
|
||||
/**
|
||||
* Save image into the database
|
||||
*
|
||||
* @param ImageCreateOrUpdateEvent $event Image event
|
||||
* @param ImagesCreateOrUpdateEvent $event Image event
|
||||
* @param FolderImage|ContentImage|CategoryImage|ProductImage $modelImage Image to save
|
||||
*
|
||||
* @return int Nb lines modified
|
||||
* @throws \Thelia\Exception\ImageException
|
||||
* @todo refactor make all pictures using propel inheritance and factorise image behaviour into one single clean action
|
||||
*/
|
||||
public function saveImage(ImageCreateOrUpdateEvent $event, $modelImage)
|
||||
public function saveImage(ImagesCreateOrUpdateEvent $event, $modelImage)
|
||||
{
|
||||
$nbModifiedLines = 0;
|
||||
|
||||
if ($modelImage->getFile() !== null) {
|
||||
switch ($event->getImageType()) {
|
||||
case ImageCreateOrUpdateEvent::TYPE_PRODUCT:
|
||||
case ImagesCreateOrUpdateEvent::TYPE_PRODUCT:
|
||||
/** @var ProductImage $modelImage */
|
||||
$modelImage->setProductId($event->getParentId());
|
||||
break;
|
||||
case ImageCreateOrUpdateEvent::TYPE_CATEGORY:
|
||||
case ImagesCreateOrUpdateEvent::TYPE_CATEGORY:
|
||||
/** @var CategoryImage $modelImage */
|
||||
$modelImage->setCategoryId($event->getParentId());
|
||||
break;
|
||||
case ImageCreateOrUpdateEvent::TYPE_CONTENT:
|
||||
case ImagesCreateOrUpdateEvent::TYPE_CONTENT:
|
||||
/** @var ContentImage $modelImage */
|
||||
$modelImage->setContentId($event->getParentId());
|
||||
break;
|
||||
case ImageCreateOrUpdateEvent::TYPE_FOLDER:
|
||||
case ImagesCreateOrUpdateEvent::TYPE_FOLDER:
|
||||
/** @var FolderImage $modelImage */
|
||||
$modelImage->setFolderId($event->getParentId());
|
||||
break;
|
||||
@@ -213,10 +227,227 @@ class FileManager
|
||||
* Delete image from file storage and database
|
||||
*
|
||||
* @param CategoryImage|ProductImage|ContentImage|FolderImage $imageModel Image being deleted
|
||||
* @param string $parentType Parent type
|
||||
*/
|
||||
public function deleteImage($imageModel)
|
||||
public function deleteImage($imageModel, $parentType)
|
||||
{
|
||||
unlink($imageModel->getAbsolutePath());
|
||||
$url = $this->getUploadDir($parentType) . '/' . $imageModel->getFile();
|
||||
unlink(str_replace('..', '', $url));
|
||||
$imageModel->delete();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get image model from type
|
||||
*
|
||||
* @param string $parentType Parent type
|
||||
*
|
||||
* @return null|\Thelia\Model\CategoryImage|\Thelia\Model\ContentImage|\Thelia\Model\FolderImage|\Thelia\Model\ProductImage
|
||||
*
|
||||
* @todo refactor make all pictures using propel inheritance and factorise image behaviour into one single clean action
|
||||
*/
|
||||
public function getImageModel($parentType)
|
||||
{
|
||||
switch ($parentType) {
|
||||
case ImagesCreateOrUpdateEvent::TYPE_PRODUCT:
|
||||
$model = new ProductImage();
|
||||
break;
|
||||
case ImagesCreateOrUpdateEvent::TYPE_CATEGORY:
|
||||
$model = new CategoryImage();
|
||||
break;
|
||||
case ImagesCreateOrUpdateEvent::TYPE_CONTENT:
|
||||
$model = new ContentImage();
|
||||
break;
|
||||
case ImagesCreateOrUpdateEvent::TYPE_FOLDER:
|
||||
$model = new FolderImage();
|
||||
break;
|
||||
default:
|
||||
$model = null;
|
||||
}
|
||||
|
||||
return $model;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get image model query from type
|
||||
*
|
||||
* @param string $parentType
|
||||
*
|
||||
* @return null|\Thelia\Model\CategoryImageQuery|\Thelia\Model\ContentImageQuery|\Thelia\Model\FolderImageQuery|\Thelia\Model\ProductImageQuery
|
||||
*
|
||||
* @todo refactor make all pictures using propel inheritance and factorise image behaviour into one single clean action
|
||||
*/
|
||||
public function getImageModelQuery($parentType)
|
||||
{
|
||||
switch ($parentType) {
|
||||
case ImagesCreateOrUpdateEvent::TYPE_PRODUCT:
|
||||
$model = new ProductImageQuery();
|
||||
break;
|
||||
case ImagesCreateOrUpdateEvent::TYPE_CATEGORY:
|
||||
$model = new CategoryImageQuery();
|
||||
break;
|
||||
case ImagesCreateOrUpdateEvent::TYPE_CONTENT:
|
||||
$model = new ContentImageQuery();
|
||||
break;
|
||||
case ImagesCreateOrUpdateEvent::TYPE_FOLDER:
|
||||
$model = new FolderImageQuery();
|
||||
break;
|
||||
default:
|
||||
$model = null;
|
||||
}
|
||||
|
||||
return $model;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get image parent model from type
|
||||
*
|
||||
* @param string $parentType
|
||||
* @param int $parentId
|
||||
*
|
||||
* @return null|\Thelia\Model\Category|\Thelia\Model\Content|\Thelia\Model\Folder|\Thelia\Model\Product
|
||||
*
|
||||
* @todo refactor make all pictures using propel inheritance and factorise image behaviour into one single clean action
|
||||
*/
|
||||
public function getParentImageModel($parentType, $parentId)
|
||||
{
|
||||
switch ($parentType) {
|
||||
case ImagesCreateOrUpdateEvent::TYPE_PRODUCT:
|
||||
$model = ProductQuery::create()->findPk($parentId);
|
||||
break;
|
||||
case ImagesCreateOrUpdateEvent::TYPE_CATEGORY:
|
||||
$model = CategoryQuery::create()->findPk($parentId);
|
||||
break;
|
||||
case ImagesCreateOrUpdateEvent::TYPE_CONTENT:
|
||||
$model = ContentQuery::create()->findPk($parentId);
|
||||
break;
|
||||
case ImagesCreateOrUpdateEvent::TYPE_FOLDER:
|
||||
$model = FolderQuery::create()->findPk($parentId);
|
||||
break;
|
||||
default:
|
||||
$model = null;
|
||||
}
|
||||
|
||||
return $model;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get image parent model from type
|
||||
*
|
||||
* @param string $parentType Parent type
|
||||
* @param Request $request Request service
|
||||
*
|
||||
* @todo refactor make all pictures using propel inheritance and factorise image behaviour into one single clean action
|
||||
* @return ProductImageModification|CategoryImageModification|ContentImageModification|FolderImageModification
|
||||
*/
|
||||
public function getImageForm($parentType, Request $request)
|
||||
{
|
||||
switch ($parentType) {
|
||||
case ImagesCreateOrUpdateEvent::TYPE_PRODUCT:
|
||||
$form = new ProductImageModification($request);
|
||||
break;
|
||||
case ImagesCreateOrUpdateEvent::TYPE_CATEGORY:
|
||||
$form = new CategoryImageModification($request);
|
||||
break;
|
||||
case ImagesCreateOrUpdateEvent::TYPE_CONTENT:
|
||||
$form = new ContentImageModification($request);
|
||||
break;
|
||||
case ImagesCreateOrUpdateEvent::TYPE_FOLDER:
|
||||
$form = new FolderImageModification($request);
|
||||
break;
|
||||
default:
|
||||
$model = null;
|
||||
}
|
||||
|
||||
return $form;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Get image upload dir
|
||||
*
|
||||
* @param string $parentType Parent type
|
||||
*
|
||||
* @return string Uri
|
||||
*/
|
||||
public function getUploadDir($parentType)
|
||||
{
|
||||
switch ($parentType) {
|
||||
case ImagesCreateOrUpdateEvent::TYPE_PRODUCT:
|
||||
$uri = THELIA_LOCAL_DIR . 'media/images/' . ImagesCreateOrUpdateEvent::TYPE_PRODUCT;
|
||||
break;
|
||||
case ImagesCreateOrUpdateEvent::TYPE_CATEGORY:
|
||||
$uri = THELIA_LOCAL_DIR . 'media/images/' . ImagesCreateOrUpdateEvent::TYPE_CATEGORY;
|
||||
break;
|
||||
case ImagesCreateOrUpdateEvent::TYPE_CONTENT:
|
||||
$uri = THELIA_LOCAL_DIR . 'media/images/' . ImagesCreateOrUpdateEvent::TYPE_CONTENT;
|
||||
break;
|
||||
case ImagesCreateOrUpdateEvent::TYPE_FOLDER:
|
||||
$uri = THELIA_LOCAL_DIR . 'media/images/' . ImagesCreateOrUpdateEvent::TYPE_FOLDER;
|
||||
break;
|
||||
default:
|
||||
$uri = null;
|
||||
}
|
||||
|
||||
return $uri;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Deduce image redirecting URL from parent type
|
||||
*
|
||||
* @param string $parentType Parent type
|
||||
* @param int $parentId Parent id
|
||||
* @return string
|
||||
*/
|
||||
public function getRedirectionUrl($parentType, $parentId)
|
||||
{
|
||||
switch ($parentType) {
|
||||
case ImagesCreateOrUpdateEvent::TYPE_PRODUCT:
|
||||
$uri = '/admin/products/update?product_id=' . $parentId;
|
||||
break;
|
||||
case ImagesCreateOrUpdateEvent::TYPE_CATEGORY:
|
||||
$uri = '/admin/categories/update?category_id=' . $parentId;
|
||||
break;
|
||||
case ImagesCreateOrUpdateEvent::TYPE_CONTENT:
|
||||
$uri = '/admin/content/update/' . $parentId;
|
||||
break;
|
||||
case ImagesCreateOrUpdateEvent::TYPE_FOLDER:
|
||||
$uri = '/admin/folders/update?folder_id=' . $parentId;
|
||||
break;
|
||||
default:
|
||||
$uri = false;
|
||||
}
|
||||
|
||||
return $uri;
|
||||
|
||||
}
|
||||
|
||||
/** @var array Available image parent type */
|
||||
public static $availableType = array(
|
||||
self::TYPE_PRODUCT,
|
||||
self::TYPE_CATEGORY,
|
||||
self::TYPE_CONTENT,
|
||||
self::TYPE_FOLDER,
|
||||
self::TYPE_MODULE
|
||||
);
|
||||
|
||||
/**
|
||||
* Rename file with image model id
|
||||
*
|
||||
* @param int $modelId Model id
|
||||
* @param UploadedFile $uploadedFile File being saved
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function renameFile($modelId, $uploadedFile)
|
||||
{
|
||||
$extension = $uploadedFile->getClientOriginalExtension();
|
||||
$fileName = $this->sanitizeFileName(
|
||||
str_replace('.' . $extension, '', $uploadedFile->getClientOriginalName()) . "-" . $modelId . "." . strtolower(
|
||||
$extension
|
||||
)
|
||||
);
|
||||
return $fileName;
|
||||
}
|
||||
}
|
||||
0
local/modules/Cheque/images/cheque.png
Normal file → Executable file
0
local/modules/Cheque/images/cheque.png
Normal file → Executable file
|
Before Width: | Height: | Size: 4.0 KiB After Width: | Height: | Size: 4.0 KiB |
0
local/modules/FakeCB/images/mastercard.png
Normal file → Executable file
0
local/modules/FakeCB/images/mastercard.png
Normal file → Executable file
|
Before Width: | Height: | Size: 3.6 KiB After Width: | Height: | Size: 3.6 KiB |
0
local/modules/FakeCB/images/visa.png
Normal file → Executable file
0
local/modules/FakeCB/images/visa.png
Normal file → Executable file
|
Before Width: | Height: | Size: 3.1 KiB After Width: | Height: | Size: 3.1 KiB |
1758
templates/admin/default/assets/js/dropzone.js
Normal file
1758
templates/admin/default/assets/js/dropzone.js
Normal file
File diff suppressed because it is too large
Load Diff
@@ -1,28 +1,37 @@
|
||||
// Manage picture upload
|
||||
$(function($){
|
||||
|
||||
// Manage picture upload
|
||||
var pictureUploadManager = {};
|
||||
|
||||
// Set selected image as preview
|
||||
pictureUploadManager.onChangePreviewPicture = function() {
|
||||
$('#images input:file').on('change', function () {
|
||||
var $this = $(this);
|
||||
if ($this.prop("files") && $this.prop("files")[0]) {
|
||||
var reader = new FileReader();
|
||||
var imageDropzone = new Dropzone("#images-dropzone");
|
||||
Dropzone.options.imageDropzone = {
|
||||
uploadMultiple: false
|
||||
};
|
||||
imageDropzone.on("success", function(file) {
|
||||
$(".image-manager .dz-file-preview").remove();
|
||||
imageDropzone.removeFile(file);
|
||||
pictureUploadManager.updateImageListAjax();
|
||||
});
|
||||
|
||||
reader.onload = function (e) {
|
||||
$this.parent()
|
||||
.find('img.preview')
|
||||
.attr('src', e.target.result)
|
||||
.width(150)
|
||||
.height(200);
|
||||
// Update picture list via AJAX call
|
||||
pictureUploadManager.updateImageListAjax = function() {
|
||||
var $imageListArea = $(".image-manager .existing-image");
|
||||
$imageListArea.html('<div class="loading" ></div>');
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: imageListUrl,
|
||||
statusCode: {
|
||||
404: function() {
|
||||
$imageListArea.html(
|
||||
imageListErrorMessage
|
||||
);
|
||||
}
|
||||
|
||||
reader.readAsDataURL($this.prop("files")[0]);
|
||||
}
|
||||
}).done(function(data) {
|
||||
$imageListArea.html(
|
||||
data
|
||||
);
|
||||
});
|
||||
};
|
||||
pictureUploadManager.onChangePreviewPicture();
|
||||
|
||||
// Remove image on click
|
||||
pictureUploadManager.onClickDeleteImage = function() {
|
||||
@@ -52,16 +61,4 @@ $(function($){
|
||||
});
|
||||
};
|
||||
pictureUploadManager.onClickDeleteImage();
|
||||
|
||||
// Remove image on click
|
||||
pictureUploadManager.clonePictureInputs = function() {
|
||||
var $inputs = $(".image-manager .picture-input");
|
||||
if ($inputs.size == 1) {
|
||||
console.log('1');
|
||||
$(".image-manager .picture-input").last().show();
|
||||
} else {
|
||||
console.log('+d1');
|
||||
$(".image-manager .picture-input").last().clone().appendTo(".image-manager .pictures-input");
|
||||
}
|
||||
}
|
||||
});
|
||||
@@ -256,7 +256,7 @@
|
||||
</div>
|
||||
|
||||
<div class="tab-pane fade {if $current_tab == 'images'}active in{/if}" id="images">
|
||||
{include file='includes/image-upload-form.html' formName="thelia.admin.category.image.creation" formSuccessUrl={url path="/admin/categories/update?category_id=$category_id"} imageType='category' parentId=$category_id}
|
||||
{include file='includes/image-upload-form.html' imageType='category' parentId=$category_id}
|
||||
</div>
|
||||
|
||||
<div class="tab-pane fade {if $current_tab == 'documents'}active in{/if}" id="documents">
|
||||
@@ -297,9 +297,14 @@
|
||||
{/block}
|
||||
|
||||
{block name="javascript-initialization"}
|
||||
{javascripts file='assets/js/image-upload.js'}
|
||||
{javascripts file='assets/js/dropzone.js'}
|
||||
<script src="{$asset_url}"></script>
|
||||
{/javascripts}
|
||||
{/javascripts}
|
||||
{javascripts file='assets/js/image-upload.js'}
|
||||
<script src="{$asset_url}"></script>
|
||||
{/javascripts}
|
||||
|
||||
|
||||
|
||||
<script src="{url file='/tinymce/tinymce.min.js'}"></script>
|
||||
<script>
|
||||
|
||||
120
templates/admin/default/image-edit.html
Normal file
120
templates/admin/default/image-edit.html
Normal file
@@ -0,0 +1,120 @@
|
||||
{extends file="admin-layout.tpl"}
|
||||
|
||||
{block name="page-title"}{intl l='Edit an image'}{/block}
|
||||
|
||||
{block name="check-permissions"}admin.image.edit{/block}
|
||||
|
||||
{block name="main-content"}
|
||||
<div class="customers edit-image">
|
||||
|
||||
<div id="wrapper" class="container">
|
||||
|
||||
{loop type="image" name="image_edit" source="{$imageType}" id="{$imageId}" width="200" height="100" resize_mode="borders" backend_context="1" lang="$edit_language_id"}
|
||||
<ul class="breadcrumb">
|
||||
<li><a href="{url path='/admin/home'}">{intl l="Home"}</a></li>
|
||||
<li><a href="{url path="{$redirectUrl}"}">{intl l="Image"}</a></li>
|
||||
<li>{intl l='Editing image "%name"' name="{$TITLE}"}</li>
|
||||
</ul>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-md-12 general-block-decorator">
|
||||
<div class="row">
|
||||
|
||||
<div class="col-md-12 title title-without-tabs">
|
||||
{intl l="Edit image $TITLE"}
|
||||
</div>
|
||||
|
||||
<div class="form-container">
|
||||
<div class="col-md-12">
|
||||
|
||||
{form name="thelia.admin.category.image.modification"}
|
||||
<form method="POST" action="{url path="/admin/image/type/{$imageType}/{$ID}/update"}" enctype="multipart/form-data" class="clearfix">
|
||||
|
||||
<div class="row inner-toolbar clearfix">
|
||||
<div class="col-md-6 inner-actions pull-right">
|
||||
<button type="submit" name="save_mode" value="stay" class="btn btn-default btn-primary" title="{intl l='Save'}">{intl l='Save'} <span class="glyphicon glyphicon-ok"></span></button>
|
||||
<a href="{url path="{$redirectUrl}"}" class="btn btn-default btn-info">{intl l='Close'} <span class="glyphicon glyphicon-remove"></span></a>
|
||||
</div>
|
||||
</div>
|
||||
{form_hidden_fields form=$form}
|
||||
|
||||
{form_field form=$form field='success_url'}
|
||||
<input type="hidden" name="{$name}" value="{url path="/admin/image/type/{$imageType}/{$ID}/update"}" />
|
||||
{/form_field}
|
||||
|
||||
{if $form_error}<div class="alert alert-danger">{$form_error_message}</div>{/if}
|
||||
|
||||
<div class="col-md-6">
|
||||
<p class="title title-without-tabs">{intl l="Image informations"}</p>
|
||||
|
||||
|
||||
|
||||
<img src="{$IMAGE_URL}" alt="{$TITLE}" />
|
||||
{form_field form=$form field='file'}
|
||||
<div class="form-group {if $error}has-error{/if}">
|
||||
<label for="{$label_attr.for}" class="control-label">{intl l="{$label}"} : </label>
|
||||
<input type="file" id="{$label_attr.for}" name="{$name}" class="form-control" value="" title="{intl l="{$label}"}" placeholder="{intl l='File'}">
|
||||
</div>
|
||||
{/form_field}
|
||||
|
||||
{form_field form=$form field='title'}
|
||||
<div class="form-group {if $error}has-error{/if}">
|
||||
<label for="{$label_attr.for}" class="control-label">{intl l="{$label}"} : </label>
|
||||
<input type="text" id="{$label_attr.for}" name="{$name}" class="form-control" value="{$TITLE}" title="{intl l="{$label}"}" placeholder="{intl l='Title'}">
|
||||
</div>
|
||||
{/form_field}
|
||||
|
||||
{form_field form=$form field='chapo'}
|
||||
<div class="form-group {if $error}has-error{/if}">
|
||||
<label for="{$label_attr.for}" class="control-label">{intl l="{$label}"} : </label>
|
||||
<input type="text" id="{$label_attr.for}" name="{$name}" class="form-control" value="{$CHAPO}" title="{intl l="{$label}"}" placeholder="{intl l='Chapo'}">
|
||||
</div>
|
||||
{/form_field}
|
||||
|
||||
{form_field form=$form field='postscriptum'}
|
||||
<div class="form-group {if $error}has-error{/if}">
|
||||
<label for="{$label_attr.for}" class="control-label">{intl l="{$label}"} : </label>
|
||||
<input type="text" id="{$label_attr.for}" name="{$name}" class="form-control" value="{$POSTSCRIPTUM}" title="{intl l="{$label}"}" placeholder="{intl l='Post Scriptum'}">
|
||||
</div>
|
||||
{/form_field}
|
||||
|
||||
{form_field form=$form field='description'}
|
||||
<div class="form-group {if $error}has-error{/if}">
|
||||
<label for="{$label_attr.for}" class="control-label">{intl l="{$label}"} : </label>
|
||||
<input type="text" id="{$label_attr.for}" name="{$name}" class="form-control" value="{$DESCRIPTION}" title="{intl l="{$label}"}" placeholder="{intl l='Description'}">
|
||||
</div>
|
||||
{/form_field}
|
||||
|
||||
</div>
|
||||
</form>
|
||||
{/form}
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
{/loop}
|
||||
|
||||
{elseloop rel="image_edit"}
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
<div class="alert alert-error">
|
||||
{intl l="Sorry, image ID=$imageId was not found."}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{/elseloop}
|
||||
|
||||
</div>
|
||||
</div>
|
||||
{/block}
|
||||
|
||||
{block name="javascript-initialization"}
|
||||
{javascripts file='assets/js/main.js'}
|
||||
<script src="{$asset_url}"></script>
|
||||
{/javascripts}
|
||||
{/block}
|
||||
@@ -1,80 +1,476 @@
|
||||
{*
|
||||
A generic image upload form
|
||||
|
||||
Parameters:
|
||||
imageType = Image type (category, product, folder, content, module)
|
||||
parentId = Image parent id, ex: category id
|
||||
|
||||
*}
|
||||
|
||||
<div class="image-manager" >
|
||||
<div class="message" >{$imageMessage}</div>
|
||||
<div class="existing-image">
|
||||
{loop type="image" name="image_test" source="{$imageType}" source_id="{$parentId}" width="200" height="100" resize_mode="borders"}
|
||||
<div>
|
||||
<img src="{$IMAGE_URL}" alt="{$TITLE}" />
|
||||
<a class="image-delete-btn" href="{url path="/admin/image/type/$imageType/delete/$ID"}" data-error-message="{intl l='Please retry'}">
|
||||
{intl l='Delete'}
|
||||
</a>
|
||||
<form action="{url path="/admin/image/type/$imageType/$parentId/save-ajax"}" class="dropzone" id="images-dropzone" enctype="multipart/form-data">
|
||||
<div class="fallback">
|
||||
<input name="file" type="file" multiple />
|
||||
</div>
|
||||
{/loop}
|
||||
</div>
|
||||
|
||||
{form name=$formName}
|
||||
<form id="related_picture_form" method="POST" enctype="multipart/form-data" action="{url path="/admin/image/type/$imageType/$parentId/save"}" runat="server">
|
||||
|
||||
<div>flashMessage = {flashMessage key="imageMessage"}{$value}{/flashMessage}</div>
|
||||
{form_hidden_fields form=$form}
|
||||
|
||||
{*{form_field form=$form field='locale'}*}
|
||||
{*<input type="hidden" name="{$name}" value="{if $value}{$value}{else}{$edit_language_locale}{/if}" />*}
|
||||
{*{/form_field}*}
|
||||
|
||||
{form_field form=$form field='success_url'}
|
||||
<input type="hidden" name="{$name}" value="{$formSuccessUrl}" />
|
||||
{/form_field}
|
||||
|
||||
{form_field form=$form field='pictures'}
|
||||
<div class="pictures-input form-group {if $error}has-error{/if}">
|
||||
{*$value={$value|var_dump}*}
|
||||
{*$error={$error|var_dump}*}
|
||||
{*$message={$message|var_dump}*}
|
||||
{*img0={$value.0|var_dump}*}
|
||||
{*img0={$value.0->getFile()}*}
|
||||
{*img1={$value[1]->getFile()}*}
|
||||
<div class="picture-input hide">
|
||||
<label for="pictures" class="control-label" >{intl l='Pictures 1 :'}</label>
|
||||
{*{form_field form=$form field='pictures.0.title'}*}
|
||||
{*$name={$name|var_dump}*}
|
||||
<input class="form-control" type="text" name="{$name}[0][title]" value="{$value}" placeholder="{intl l='picture name'}">
|
||||
{*{/form_field}*}
|
||||
{*{form_field form=$form field='pictures.0.file'}*}
|
||||
{*$name={$name|var_dump}*}
|
||||
<input class="form-control" type="file" name="{$name}[0][file]" value="{$value}" >
|
||||
{*{/form_field}*}
|
||||
<img class="preview" src="#" width="200" height="100" alt="Your image"/>
|
||||
</div>
|
||||
{*<div class="picture-input">*}
|
||||
{*<label for="pictures" class="control-label" >{intl l='Pictures 2 :'}</label>*}
|
||||
{*<input class="form-control" type="text" name="{$name}[1][title]" value="{$value}" placeholder="{intl l='picture name'}">*}
|
||||
{*<input class="form-control" type="file" name="{$name}[1][file]" value="{$value}" >*}
|
||||
{*<img class="preview" src="#" width="200" height="100" alt="Your image"/>*}
|
||||
{*</div>*}
|
||||
{*<div class="picture-input">*}
|
||||
{*<label for="pictures" class="control-label" >{intl l='Pictures 3 :'}</label>*}
|
||||
{*<input class="form-control" type="text" name="{$name}[2][title]" value="{$value}" placeholder="{intl l='picture name'}">*}
|
||||
{*<input class="form-control" type="file" name="{$name}[2][file]" value="{$value}" >*}
|
||||
{*<img class="preview" src="#" width="200" height="100" alt="Your image"/>*}
|
||||
{*</div>*}
|
||||
{*<div class="picture-input">*}
|
||||
{*<label for="pictures" class="control-label" >{intl l='Pictures 4 :'}</label>*}
|
||||
{*<input class="form-control" type="text" name="{$name}[3][title]" value="{$value}" placeholder="{intl l='picture name'}">*}
|
||||
{*<input class="form-control" type="file" name="{$name}[3][file]" value="{$value}" >*}
|
||||
{*<img class="preview" src="#" width="200" height="100" alt="Your image"/>*}
|
||||
{*</div>*}
|
||||
{*<div class="picture-input">*}
|
||||
{*<label for="pictures" class="control-label" >{intl l='Pictures 5 :'}</label>*}
|
||||
{*<input class="form-control" type="text" name="{$name}[4][title]" value="{$value}" placeholder="{intl l='picture name'}">*}
|
||||
{*<input class="form-control" type="file" name="{$name}[4][file]" value="{$value}" >*}
|
||||
{*<img class="preview" src="#" width="200" height="100" alt="Your image"/>*}
|
||||
{*</div>*}
|
||||
{if $error}{$message}{/if}
|
||||
</div>
|
||||
{/form_field}
|
||||
|
||||
<input type="submit" value="submit"/>
|
||||
</form>
|
||||
{/form}
|
||||
|
||||
<div class="existing-image">
|
||||
{include file='includes/image-upload-list-ajax.html'}
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
{*{block name="javascript-initialization"}*}
|
||||
{*{$smarty.block.parent}*}
|
||||
|
||||
{*{javascripts file='assets/js/image-upload.js'}*}
|
||||
{*<script src="{$asset_url}"></script>*}
|
||||
{*{/javascripts}*}
|
||||
{*{javascripts file='assets/js/dropzone.js'}*}
|
||||
{*<script src="{$asset_url}"></script>*}
|
||||
{*{/javascripts}*}
|
||||
{*{/block}*}
|
||||
|
||||
<script>
|
||||
var imageDropZoneUrl = "{url path="/admin/image/type/$imageType/$parentId/save-ajax"}";
|
||||
var imageListUrl = "{url path="/admin/image/type/$imageType/$parentId/list-ajax"}";
|
||||
var imageListErrorMessage = "{intl l='Can\'t load images, please refresh this page.'}";
|
||||
</script>
|
||||
{*
|
||||
@todo refactor
|
||||
see http://www.dropzonejs.com/
|
||||
|
||||
*}
|
||||
<style type="text/css">
|
||||
.dropzone,
|
||||
.dropzone *,
|
||||
.dropzone-previews,
|
||||
.dropzone-previews * {
|
||||
-webkit-box-sizing: border-box;
|
||||
-moz-box-sizing: border-box;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
.dropzone {
|
||||
position: relative;
|
||||
border: 1px solid rgba(0,0,0,0.08);
|
||||
background: rgba(0,0,0,0.02);
|
||||
padding: 1em;
|
||||
}
|
||||
.dropzone.dz-clickable {
|
||||
cursor: pointer;
|
||||
}
|
||||
.dropzone.dz-clickable .dz-message,
|
||||
.dropzone.dz-clickable .dz-message span {
|
||||
cursor: pointer;
|
||||
}
|
||||
.dropzone.dz-clickable * {
|
||||
cursor: default;
|
||||
}
|
||||
.dropzone .dz-message {
|
||||
opacity: 1;
|
||||
-ms-filter: none;
|
||||
filter: none;
|
||||
}
|
||||
.dropzone.dz-drag-hover {
|
||||
border-color: rgba(0,0,0,0.15);
|
||||
background: rgba(0,0,0,0.04);
|
||||
}
|
||||
.dropzone.dz-started .dz-message {
|
||||
display: none;
|
||||
}
|
||||
.dropzone .dz-preview,
|
||||
.dropzone-previews .dz-preview {
|
||||
background: rgba(255,255,255,0.8);
|
||||
position: relative;
|
||||
display: inline-block;
|
||||
margin: 17px;
|
||||
vertical-align: top;
|
||||
border: 1px solid #acacac;
|
||||
padding: 6px 6px 6px 6px;
|
||||
}
|
||||
.dropzone .dz-preview.dz-file-preview [data-dz-thumbnail],
|
||||
.dropzone-previews .dz-preview.dz-file-preview [data-dz-thumbnail] {
|
||||
display: none;
|
||||
}
|
||||
.dropzone .dz-preview .dz-details,
|
||||
.dropzone-previews .dz-preview .dz-details {
|
||||
width: 100px;
|
||||
height: 100px;
|
||||
position: relative;
|
||||
background: #ebebeb;
|
||||
padding: 5px;
|
||||
margin-bottom: 22px;
|
||||
}
|
||||
.dropzone .dz-preview .dz-details .dz-filename,
|
||||
.dropzone-previews .dz-preview .dz-details .dz-filename {
|
||||
overflow: hidden;
|
||||
height: 100%;
|
||||
}
|
||||
.dropzone .dz-preview .dz-details img,
|
||||
.dropzone-previews .dz-preview .dz-details img {
|
||||
position: absolute;
|
||||
top: 0;
|
||||
left: 0;
|
||||
width: 100px;
|
||||
height: 100px;
|
||||
}
|
||||
.dropzone .dz-preview .dz-details .dz-size,
|
||||
.dropzone-previews .dz-preview .dz-details .dz-size {
|
||||
position: absolute;
|
||||
bottom: -28px;
|
||||
left: 3px;
|
||||
height: 28px;
|
||||
line-height: 28px;
|
||||
}
|
||||
.dropzone .dz-preview.dz-error .dz-error-mark,
|
||||
.dropzone-previews .dz-preview.dz-error .dz-error-mark {
|
||||
display: block;
|
||||
}
|
||||
.dropzone .dz-preview.dz-success .dz-success-mark,
|
||||
.dropzone-previews .dz-preview.dz-success .dz-success-mark {
|
||||
display: block;
|
||||
}
|
||||
.dropzone .dz-preview:hover .dz-details img,
|
||||
.dropzone-previews .dz-preview:hover .dz-details img {
|
||||
display: none;
|
||||
}
|
||||
.dropzone .dz-preview .dz-success-mark,
|
||||
.dropzone-previews .dz-preview .dz-success-mark,
|
||||
.dropzone .dz-preview .dz-error-mark,
|
||||
.dropzone-previews .dz-preview .dz-error-mark {
|
||||
display: none;
|
||||
position: absolute;
|
||||
width: 40px;
|
||||
height: 40px;
|
||||
font-size: 30px;
|
||||
text-align: center;
|
||||
right: -10px;
|
||||
top: -10px;
|
||||
}
|
||||
.dropzone .dz-preview .dz-success-mark,
|
||||
.dropzone-previews .dz-preview .dz-success-mark {
|
||||
color: #8cc657;
|
||||
}
|
||||
.dropzone .dz-preview .dz-error-mark,
|
||||
.dropzone-previews .dz-preview .dz-error-mark {
|
||||
color: #ee162d;
|
||||
}
|
||||
.dropzone .dz-preview .dz-progress,
|
||||
.dropzone-previews .dz-preview .dz-progress {
|
||||
position: absolute;
|
||||
top: 100px;
|
||||
left: 6px;
|
||||
right: 6px;
|
||||
height: 6px;
|
||||
background: #d7d7d7;
|
||||
display: none;
|
||||
}
|
||||
.dropzone .dz-preview .dz-progress .dz-upload,
|
||||
.dropzone-previews .dz-preview .dz-progress .dz-upload {
|
||||
position: absolute;
|
||||
top: 0;
|
||||
bottom: 0;
|
||||
left: 0;
|
||||
width: 0%;
|
||||
background-color: #8cc657;
|
||||
}
|
||||
.dropzone .dz-preview.dz-processing .dz-progress,
|
||||
.dropzone-previews .dz-preview.dz-processing .dz-progress {
|
||||
display: block;
|
||||
}
|
||||
.dropzone .dz-preview .dz-error-message,
|
||||
.dropzone-previews .dz-preview .dz-error-message {
|
||||
display: none;
|
||||
position: absolute;
|
||||
top: -5px;
|
||||
left: -20px;
|
||||
background: rgba(245,245,245,0.8);
|
||||
padding: 8px 10px;
|
||||
color: #800;
|
||||
min-width: 140px;
|
||||
max-width: 500px;
|
||||
z-index: 500;
|
||||
}
|
||||
.dropzone .dz-preview:hover.dz-error .dz-error-message,
|
||||
.dropzone-previews .dz-preview:hover.dz-error .dz-error-message {
|
||||
display: block;
|
||||
}
|
||||
.dropzone {
|
||||
margin-top: 6px;
|
||||
border: 1px solid rgba(0,0,0,0.03);
|
||||
min-height: 200px;
|
||||
-webkit-border-radius: 3px;
|
||||
border-radius: 3px;
|
||||
background: rgba(0,0,0,0.03);
|
||||
padding: 23px;
|
||||
}
|
||||
.dropzone .dz-default.dz-message {
|
||||
opacity: 1;
|
||||
-ms-filter: none;
|
||||
filter: none;
|
||||
-webkit-transition: opacity 0.3s ease-in-out;
|
||||
-moz-transition: opacity 0.3s ease-in-out;
|
||||
-o-transition: opacity 0.3s ease-in-out;
|
||||
-ms-transition: opacity 0.3s ease-in-out;
|
||||
transition: opacity 0.3s ease-in-out;
|
||||
background-image: url("../images/spritemap.png");
|
||||
background-repeat: no-repeat;
|
||||
background-position: 0 0;
|
||||
position: absolute;
|
||||
width: 428px;
|
||||
height: 123px;
|
||||
margin-left: -214px;
|
||||
margin-top: -61.5px;
|
||||
top: 50%;
|
||||
left: 50%;
|
||||
}
|
||||
@media all and (-webkit-min-device-pixel-ratio: 1.5) {
|
||||
.dropzone .dz-default.dz-message {
|
||||
background-image: url("../images/spritemap@2x.png");
|
||||
-webkit-background-size: 428px 406px;
|
||||
-moz-background-size: 428px 406px;
|
||||
background-size: 428px 406px;
|
||||
}
|
||||
}
|
||||
.dropzone .dz-default.dz-message span {
|
||||
display: none;
|
||||
}
|
||||
.dropzone.dz-square .dz-default.dz-message {
|
||||
background-position: 0 -123px;
|
||||
width: 268px;
|
||||
margin-left: -134px;
|
||||
height: 174px;
|
||||
margin-top: -87px;
|
||||
}
|
||||
.dropzone.dz-drag-hover .dz-message {
|
||||
opacity: 0.15;
|
||||
filter: alpha(opacity=15);
|
||||
-ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=15)";
|
||||
}
|
||||
.dropzone.dz-started .dz-message {
|
||||
display: block;
|
||||
opacity: 0;
|
||||
filter: alpha(opacity=0);
|
||||
-ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=0)";
|
||||
}
|
||||
.dropzone .dz-preview,
|
||||
.dropzone-previews .dz-preview {
|
||||
-webkit-box-shadow: 1px 1px 4px rgba(0,0,0,0.16);
|
||||
box-shadow: 1px 1px 4px rgba(0,0,0,0.16);
|
||||
font-size: 14px;
|
||||
}
|
||||
.dropzone .dz-preview.dz-image-preview:hover .dz-details img,
|
||||
.dropzone-previews .dz-preview.dz-image-preview:hover .dz-details img {
|
||||
display: block;
|
||||
opacity: 0.1;
|
||||
filter: alpha(opacity=10);
|
||||
-ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=10)";
|
||||
}
|
||||
.dropzone .dz-preview.dz-success .dz-success-mark,
|
||||
.dropzone-previews .dz-preview.dz-success .dz-success-mark {
|
||||
opacity: 1;
|
||||
-ms-filter: none;
|
||||
filter: none;
|
||||
}
|
||||
.dropzone .dz-preview.dz-error .dz-error-mark,
|
||||
.dropzone-previews .dz-preview.dz-error .dz-error-mark {
|
||||
opacity: 1;
|
||||
-ms-filter: none;
|
||||
filter: none;
|
||||
}
|
||||
.dropzone .dz-preview.dz-error .dz-progress .dz-upload,
|
||||
.dropzone-previews .dz-preview.dz-error .dz-progress .dz-upload {
|
||||
background: #ee1e2d;
|
||||
}
|
||||
.dropzone .dz-preview .dz-error-mark,
|
||||
.dropzone-previews .dz-preview .dz-error-mark,
|
||||
.dropzone .dz-preview .dz-success-mark,
|
||||
.dropzone-previews .dz-preview .dz-success-mark {
|
||||
display: block;
|
||||
opacity: 0;
|
||||
filter: alpha(opacity=0);
|
||||
-ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=0)";
|
||||
-webkit-transition: opacity 0.4s ease-in-out;
|
||||
-moz-transition: opacity 0.4s ease-in-out;
|
||||
-o-transition: opacity 0.4s ease-in-out;
|
||||
-ms-transition: opacity 0.4s ease-in-out;
|
||||
transition: opacity 0.4s ease-in-out;
|
||||
background-image: url("../images/spritemap.png");
|
||||
background-repeat: no-repeat;
|
||||
}
|
||||
@media all and (-webkit-min-device-pixel-ratio: 1.5) {
|
||||
.dropzone .dz-preview .dz-error-mark,
|
||||
.dropzone-previews .dz-preview .dz-error-mark,
|
||||
.dropzone .dz-preview .dz-success-mark,
|
||||
.dropzone-previews .dz-preview .dz-success-mark {
|
||||
background-image: url("../images/spritemap@2x.png");
|
||||
-webkit-background-size: 428px 406px;
|
||||
-moz-background-size: 428px 406px;
|
||||
background-size: 428px 406px;
|
||||
}
|
||||
}
|
||||
.dropzone .dz-preview .dz-error-mark span,
|
||||
.dropzone-previews .dz-preview .dz-error-mark span,
|
||||
.dropzone .dz-preview .dz-success-mark span,
|
||||
.dropzone-previews .dz-preview .dz-success-mark span {
|
||||
display: none;
|
||||
}
|
||||
.dropzone .dz-preview .dz-error-mark,
|
||||
.dropzone-previews .dz-preview .dz-error-mark {
|
||||
background-position: -268px -123px;
|
||||
}
|
||||
.dropzone .dz-preview .dz-success-mark,
|
||||
.dropzone-previews .dz-preview .dz-success-mark {
|
||||
background-position: -268px -163px;
|
||||
}
|
||||
.dropzone .dz-preview .dz-progress .dz-upload,
|
||||
.dropzone-previews .dz-preview .dz-progress .dz-upload {
|
||||
-webkit-animation: loading 0.4s linear infinite;
|
||||
-moz-animation: loading 0.4s linear infinite;
|
||||
-o-animation: loading 0.4s linear infinite;
|
||||
-ms-animation: loading 0.4s linear infinite;
|
||||
animation: loading 0.4s linear infinite;
|
||||
-webkit-transition: width 0.3s ease-in-out;
|
||||
-moz-transition: width 0.3s ease-in-out;
|
||||
-o-transition: width 0.3s ease-in-out;
|
||||
-ms-transition: width 0.3s ease-in-out;
|
||||
transition: width 0.3s ease-in-out;
|
||||
-webkit-border-radius: 2px;
|
||||
border-radius: 2px;
|
||||
position: absolute;
|
||||
top: 0;
|
||||
left: 0;
|
||||
width: 0%;
|
||||
height: 100%;
|
||||
background-image: url("../images/spritemap.png");
|
||||
background-repeat: repeat-x;
|
||||
background-position: 0px -400px;
|
||||
}
|
||||
@media all and (-webkit-min-device-pixel-ratio: 1.5) {
|
||||
.dropzone .dz-preview .dz-progress .dz-upload,
|
||||
.dropzone-previews .dz-preview .dz-progress .dz-upload {
|
||||
background-image: url("../images/spritemap@2x.png");
|
||||
-webkit-background-size: 428px 406px;
|
||||
-moz-background-size: 428px 406px;
|
||||
background-size: 428px 406px;
|
||||
}
|
||||
}
|
||||
.dropzone .dz-preview.dz-success .dz-progress,
|
||||
.dropzone-previews .dz-preview.dz-success .dz-progress {
|
||||
display: block;
|
||||
opacity: 0;
|
||||
filter: alpha(opacity=0);
|
||||
-ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=0)";
|
||||
-webkit-transition: opacity 0.4s ease-in-out;
|
||||
-moz-transition: opacity 0.4s ease-in-out;
|
||||
-o-transition: opacity 0.4s ease-in-out;
|
||||
-ms-transition: opacity 0.4s ease-in-out;
|
||||
transition: opacity 0.4s ease-in-out;
|
||||
}
|
||||
.dropzone .dz-preview .dz-error-message,
|
||||
.dropzone-previews .dz-preview .dz-error-message {
|
||||
display: block;
|
||||
opacity: 0;
|
||||
filter: alpha(opacity=0);
|
||||
-ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=0)";
|
||||
-webkit-transition: opacity 0.3s ease-in-out;
|
||||
-moz-transition: opacity 0.3s ease-in-out;
|
||||
-o-transition: opacity 0.3s ease-in-out;
|
||||
-ms-transition: opacity 0.3s ease-in-out;
|
||||
transition: opacity 0.3s ease-in-out;
|
||||
}
|
||||
.dropzone .dz-preview:hover.dz-error .dz-error-message,
|
||||
.dropzone-previews .dz-preview:hover.dz-error .dz-error-message {
|
||||
opacity: 1;
|
||||
-ms-filter: none;
|
||||
filter: none;
|
||||
}
|
||||
.dropzone a.dz-remove,
|
||||
.dropzone-previews a.dz-remove {
|
||||
background-image: -webkit-gradient(linear, left top, left bottom, color-stop(0, #fafafa), color-stop(1, #eee));
|
||||
background-image: -webkit-linear-gradient(top, #fafafa 0%, #eee 100%);
|
||||
background-image: -moz-linear-gradient(top, #fafafa 0%, #eee 100%);
|
||||
background-image: -o-linear-gradient(top, #fafafa 0%, #eee 100%);
|
||||
background-image: -ms-linear-gradient(top, #fafafa 0%, #eee 100%);
|
||||
background-image: linear-gradient(top, #fafafa 0%, #eee 100%);
|
||||
-webkit-border-radius: 2px;
|
||||
border-radius: 2px;
|
||||
border: 1px solid #eee;
|
||||
text-decoration: none;
|
||||
display: block;
|
||||
padding: 4px 5px;
|
||||
text-align: center;
|
||||
color: #aaa;
|
||||
margin-top: 26px;
|
||||
}
|
||||
.dropzone a.dz-remove:hover,
|
||||
.dropzone-previews a.dz-remove:hover {
|
||||
color: #666;
|
||||
}
|
||||
@-moz-keyframes loading {
|
||||
0% {
|
||||
background-position: 0 -400px;
|
||||
}
|
||||
|
||||
100% {
|
||||
background-position: -7px -400px;
|
||||
}
|
||||
}
|
||||
@-webkit-keyframes loading {
|
||||
0% {
|
||||
background-position: 0 -400px;
|
||||
}
|
||||
|
||||
100% {
|
||||
background-position: -7px -400px;
|
||||
}
|
||||
}
|
||||
@-o-keyframes loading {
|
||||
0% {
|
||||
background-position: 0 -400px;
|
||||
}
|
||||
|
||||
100% {
|
||||
background-position: -7px -400px;
|
||||
}
|
||||
}
|
||||
@-ms-keyframes loading {
|
||||
0% {
|
||||
background-position: 0 -400px;
|
||||
}
|
||||
|
||||
100% {
|
||||
background-position: -7px -400px;
|
||||
}
|
||||
}
|
||||
@keyframes loading {
|
||||
0% {
|
||||
background-position: 0 -400px;
|
||||
}
|
||||
|
||||
100% {
|
||||
background-position: -7px -400px;
|
||||
}
|
||||
}
|
||||
#dropzone {
|
||||
margin: 30px 0;
|
||||
-webkit-box-shadow: 0 0 50px rgba(0,0,0,0.13);
|
||||
box-shadow: 0 0 50px rgba(0,0,0,0.13);
|
||||
padding: 4px;
|
||||
-webkit-border-radius: 3px;
|
||||
border-radius: 3px;
|
||||
}
|
||||
#dropzone .dropzone {
|
||||
-webkit-box-shadow: none;
|
||||
box-shadow: none;
|
||||
}
|
||||
@media screen and (max-width: 37.5em) {
|
||||
.dropzone .dz-default.dz-message {
|
||||
background-position: 0 -123px;
|
||||
width: 268px;
|
||||
margin-left: -134px;
|
||||
height: 174px;
|
||||
margin-top: -87px;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
23
templates/admin/default/includes/image-upload-list-ajax.html
Normal file
23
templates/admin/default/includes/image-upload-list-ajax.html
Normal file
@@ -0,0 +1,23 @@
|
||||
{*
|
||||
|
||||
A generic image upload form
|
||||
|
||||
Parameters:
|
||||
imageType = Image type (category, product, folder, content, module)
|
||||
parentId = Image parent id, ex: category id
|
||||
|
||||
*}
|
||||
|
||||
{loop type="image" name="image" source="{$imageType}" source_id="{$parentId}" width="200" height="100" resize_mode="borders"}
|
||||
<div>
|
||||
<img src="{$IMAGE_URL}" alt="{$TITLE}" />
|
||||
<a class="image-update-btn" href="{url path="/admin/image/type/$imageType/$ID/update"}" data-error-message="{intl l='Please retry'}">
|
||||
{intl l='Update'}
|
||||
</a>
|
||||
<a class="image-delete-btn" href="{url path="/admin/image/type/$imageType/delete/$ID"}" data-error-message="{intl l='Please retry'}">
|
||||
{intl l='Delete'}
|
||||
</a>
|
||||
</div>
|
||||
{/loop}
|
||||
|
||||
|
||||
0
web/test_to_remove/admin-stats.json
Normal file → Executable file
0
web/test_to_remove/admin-stats.json
Normal file → Executable file
Reference in New Issue
Block a user