diff --git a/core/lib/Thelia/Action/Export.php b/core/lib/Thelia/Action/Export.php index bdea9f360..de5ee5008 100644 --- a/core/lib/Thelia/Action/Export.php +++ b/core/lib/Thelia/Action/Export.php @@ -11,7 +11,6 @@ /*************************************************************************************/ namespace Thelia\Action; -use Symfony\Component\DependencyInjection\ContainerInterface; use Symfony\Component\EventDispatcher\EventDispatcherInterface; use Symfony\Component\EventDispatcher\EventSubscriberInterface; use Thelia\Core\Event\Cache\CacheEvent; diff --git a/core/lib/Thelia/Action/Import.php b/core/lib/Thelia/Action/Import.php index e0aef97b5..b0a8c4354 100644 --- a/core/lib/Thelia/Action/Import.php +++ b/core/lib/Thelia/Action/Import.php @@ -11,7 +11,6 @@ /*************************************************************************************/ namespace Thelia\Action; -use Symfony\Component\DependencyInjection\ContainerInterface; use Symfony\Component\EventDispatcher\EventDispatcherInterface; use Symfony\Component\EventDispatcher\EventSubscriberInterface; use Thelia\Core\Event\Cache\CacheEvent; diff --git a/core/lib/Thelia/Config/Resources/config.xml b/core/lib/Thelia/Config/Resources/config.xml index f25ef42b7..6e001e18a 100644 --- a/core/lib/Thelia/Config/Resources/config.xml +++ b/core/lib/Thelia/Config/Resources/config.xml @@ -137,7 +137,7 @@ - + diff --git a/core/lib/Thelia/Controller/Admin/FileController.php b/core/lib/Thelia/Controller/Admin/FileController.php index 4c7ae3751..bcd02fe9b 100644 --- a/core/lib/Thelia/Controller/Admin/FileController.php +++ b/core/lib/Thelia/Controller/Admin/FileController.php @@ -26,7 +26,6 @@ use Thelia\Files\FileModelInterface; use Thelia\Form\Exception\FormValidationException; use Thelia\Log\Tlog; use Thelia\Model\Lang; -use Thelia\Tools\MimeTypeTools; use Thelia\Tools\Rest\ResponseRest; use Thelia\Tools\URL; @@ -61,7 +60,7 @@ class FileController extends BaseAdminController * @param string $parentType Parent Type owning files being saved (product, category, content, etc.) * @param string $objectType Object type, e.g. image or document * @param array $validMimeTypes an array of valid mime types. If empty, any mime type is allowed. - * @param array $extBlackList an array of blacklisted extensions. + * @param array $extBlackList an array of blacklisted extensions. * @return Response */ public function saveFileAjaxAction( diff --git a/core/lib/Thelia/Core/FileFormat/Archive/ArchiveBuilder/TarArchiveBuilder.php b/core/lib/Thelia/Core/FileFormat/Archive/ArchiveBuilder/TarArchiveBuilder.php index 00e4fe838..22652904c 100644 --- a/core/lib/Thelia/Core/FileFormat/Archive/ArchiveBuilder/TarArchiveBuilder.php +++ b/core/lib/Thelia/Core/FileFormat/Archive/ArchiveBuilder/TarArchiveBuilder.php @@ -503,4 +503,9 @@ class TarArchiveBuilder extends AbstractArchiveBuilder { return $this->compression; } + + public function isAvailable() + { + return false === (bool) ini_get("phar.readonly") && class_exists("\\PharData"); + } } diff --git a/core/lib/Thelia/Core/FileFormat/Archive/ArchiveBuilder/TarBz2ArchiveBuilder.php b/core/lib/Thelia/Core/FileFormat/Archive/ArchiveBuilder/TarBz2ArchiveBuilder.php index eb6790711..bd8975312 100644 --- a/core/lib/Thelia/Core/FileFormat/Archive/ArchiveBuilder/TarBz2ArchiveBuilder.php +++ b/core/lib/Thelia/Core/FileFormat/Archive/ArchiveBuilder/TarBz2ArchiveBuilder.php @@ -44,4 +44,9 @@ class TarBz2ArchiveBuilder extends TarArchiveBuilder return $this; } + + public function isAvailable() + { + return parent::isAvailable() && extension_loaded("bz2"); + } } diff --git a/core/lib/Thelia/Core/FileFormat/Archive/ArchiveBuilder/TarGzArchiveBuilder.php b/core/lib/Thelia/Core/FileFormat/Archive/ArchiveBuilder/TarGzArchiveBuilder.php index 581e4a3b2..ef188d0b6 100644 --- a/core/lib/Thelia/Core/FileFormat/Archive/ArchiveBuilder/TarGzArchiveBuilder.php +++ b/core/lib/Thelia/Core/FileFormat/Archive/ArchiveBuilder/TarGzArchiveBuilder.php @@ -45,4 +45,8 @@ class TarGzArchiveBuilder extends TarArchiveBuilder return $this; } + public function isAvailable() + { + return parent::isAvailable() && extension_loaded("zlib"); + } } diff --git a/core/lib/Thelia/Core/FileFormat/Archive/ArchiveBuilder/ZipArchiveBuilder.php b/core/lib/Thelia/Core/FileFormat/Archive/ArchiveBuilder/ZipArchiveBuilder.php index dcaac183e..034bad869 100644 --- a/core/lib/Thelia/Core/FileFormat/Archive/ArchiveBuilder/ZipArchiveBuilder.php +++ b/core/lib/Thelia/Core/FileFormat/Archive/ArchiveBuilder/ZipArchiveBuilder.php @@ -610,4 +610,14 @@ class ZipArchiveBuilder extends AbstractArchiveBuilder { return $this->zip; } + + /** + * @return bool + * + * Returns conditions for archive builder to be available ( loaded libraries ) + */ + public function isAvailable() + { + return class_exists('\\ZipArchive'); + } } diff --git a/core/lib/Thelia/Core/FileFormat/Archive/ArchiveBuilderInterface.php b/core/lib/Thelia/Core/FileFormat/Archive/ArchiveBuilderInterface.php index 0ff882ae5..c3fc30621 100644 --- a/core/lib/Thelia/Core/FileFormat/Archive/ArchiveBuilderInterface.php +++ b/core/lib/Thelia/Core/FileFormat/Archive/ArchiveBuilderInterface.php @@ -112,4 +112,10 @@ interface ArchiveBuilderInterface */ public function hasDirectory($directory); + /** + * @return bool + * + * Returns conditions for archive builder to be available ( loaded libraries ) + */ + public function isAvailable(); } diff --git a/core/lib/Thelia/Core/FileFormat/Archive/ArchiveBuilderManager.php b/core/lib/Thelia/Core/FileFormat/Archive/ArchiveBuilderManager.php index 176531670..701f985f7 100644 --- a/core/lib/Thelia/Core/FileFormat/Archive/ArchiveBuilderManager.php +++ b/core/lib/Thelia/Core/FileFormat/Archive/ArchiveBuilderManager.php @@ -35,7 +35,7 @@ class ArchiveBuilderManager */ public function add(AbstractArchiveBuilder $archiveBuilder) { - if (null !== $archiveBuilder) { + if ($archiveBuilder->isAvailable()) { $archiveBuilder->setEnvironment($this->environment); $this->archiveBuilders[$archiveBuilder->getName()] = $archiveBuilder; diff --git a/core/lib/Thelia/Tests/FileFormat/Archive/ArchiveBuilderManagerTest.php b/core/lib/Thelia/Tests/FileFormat/Archive/ArchiveBuilderManagerTest.php index 69fdfdb9a..3cdb600d5 100644 --- a/core/lib/Thelia/Tests/FileFormat/Archive/ArchiveBuilderManagerTest.php +++ b/core/lib/Thelia/Tests/FileFormat/Archive/ArchiveBuilderManagerTest.php @@ -39,7 +39,34 @@ class ArchiveBuilderManagerTest extends \PHPUnit_Framework_TestCase public function testAddArchiveBuilder() { /** @var AbstractArchiveBuilder $instance */ - $instance = $this->getMock("Thelia\\Core\\FileFormat\\Archive\\AbstractArchiveBuilder"); + $instance = $this->getMock( + "Thelia\\Core\\FileFormat\\Archive\\AbstractArchiveBuilder", + [ + "isAvailable", + "getName", + "getExtension", + "getMimeType", + "addFile", + "addFileFromString", + "getFileContent", + "deleteFile", + "addDirectory", + "buildArchiveResponse", + "loadArchive", + "hasFile", + "hasDirectory", + ] + ); + + $instance->expects($this->any()) + ->method("isAvailable") + ->willReturn(true) + ; + + $instance->expects($this->any()) + ->method("getName") + ->willReturn("foo") + ; $this->manager->add($instance); @@ -53,7 +80,34 @@ class ArchiveBuilderManagerTest extends \PHPUnit_Framework_TestCase public function testDeleteArchiveBuilder() { /** @var AbstractArchiveBuilder $instance */ - $instance = $this->getMock("Thelia\\Core\\FileFormat\\Archive\\AbstractArchiveBuilder"); + $instance = $this->getMock( + "Thelia\\Core\\FileFormat\\Archive\\AbstractArchiveBuilder", + [ + "isAvailable", + "getName", + "getExtension", + "getMimeType", + "addFile", + "addFileFromString", + "getFileContent", + "deleteFile", + "addDirectory", + "buildArchiveResponse", + "loadArchive", + "hasFile", + "hasDirectory", + ] + ); + + $instance->expects($this->any()) + ->method("isAvailable") + ->willReturn(true) + ; + + $instance->expects($this->any()) + ->method("getName") + ->willReturn("foo") + ; $this->manager->add($instance); diff --git a/core/lib/Thelia/Tests/ImportExport/Export/ProductPricesExportTest.php b/core/lib/Thelia/Tests/ImportExport/Export/ProductPricesExportTest.php index 689dbcee8..1fa104a75 100644 --- a/core/lib/Thelia/Tests/ImportExport/Export/ProductPricesExportTest.php +++ b/core/lib/Thelia/Tests/ImportExport/Export/ProductPricesExportTest.php @@ -74,7 +74,9 @@ class ProductPricesExportTest extends \PHPUnit_Framework_TestCase $attributes = []; foreach ($attributeCombinations as $attributeCombination) { - $attributes[] = $attributeCombination->getAttributeAv()->getTitle(); + if (!in_array($attributeCombination->getAttributeAv()->getTitle(), $attributes)) { + $attributes[] = $attributeCombination->getAttributeAv()->getTitle(); + } } $rowAttributes = explode(",", $row["attributes"]); diff --git a/templates/backOffice/default/ajax/export-modal.html b/templates/backOffice/default/ajax/export-modal.html index b92abfc7f..990b7055a 100644 --- a/templates/backOffice/default/ajax/export-modal.html +++ b/templates/backOffice/default/ajax/export-modal.html @@ -51,59 +51,61 @@ {/form_field} -
-
- {form_field form=$form field="do_compress"} - -
- + {ifloop rel="export-archive-builder"} +
+
+ {form_field form=$form field="do_compress"} + +
+ +
+ {/form_field}
- {/form_field}
-
-
-
- {form_field form=$form field="archive_builder"} - - - {/form_field} -
- {if $HAS_IMAGES} -
- {form_field form=$form field="images"} - +
+
+ {form_field form=$form field="archive_builder"} + + + {/form_field} +
+ {if $HAS_IMAGES} +
+ {form_field form=$form field="images"} + -
- -
- {/form_field} -
- {/if} - {if $HAS_DOCUMENTS} -
- {form_field form=$form field="documents"} - +
+ +
+ {/form_field} +
+ {/if} + {if $HAS_DOCUMENTS} +
+ {form_field form=$form field="documents"} + -
- -
- {/form_field} -
- {/if} +
+ +
+ {/form_field} +
+ {/if} + {/ifloop}
{/ifloop} {elseloop rel="export-formatters"} diff --git a/templates/backOffice/default/export-page.html b/templates/backOffice/default/export-page.html index 69417131a..9d215fb82 100644 --- a/templates/backOffice/default/export-page.html +++ b/templates/backOffice/default/export-page.html @@ -86,64 +86,66 @@ {/form_field}
-
- {form_field form=$form field="do_compress"} - -
- -
- {/form_field} -
- -
-
- {form_field form=$form field="archive_builder"} -
+ {ifloop rel="export-archive-builder"} +
+ {form_field form=$form field="do_compress"} - - - {if $error} -
{$message}
- {/if} -
- {/form_field} +
+ +
+ {/form_field} +
- {if $HAS_IMAGES} -
- {form_field form=$form field="images"} - +
+
+ {form_field form=$form field="archive_builder"} +
+ + -
- -
- {/form_field} -
- {/if} - {if $HAS_DOCUMENTS} -
- {form_field form=$form field="documents"} - + {if $error} +
{$message}
+ {/if} +
+ {/form_field} +
+ {if $HAS_IMAGES} +
+ {form_field form=$form field="images"} + -
- -
- {/form_field} -
- {/if} +
+ +
+ {/form_field} +
+ {/if} + {if $HAS_DOCUMENTS} +
+ {form_field form=$form field="documents"} + + +
+ +
+ {/form_field} +
+ {/if} + {/ifloop}
{/ifloop} {elseloop rel="export-formatters"}