@@ -11,7 +11,6 @@
|
|||||||
/*************************************************************************************/
|
/*************************************************************************************/
|
||||||
|
|
||||||
namespace Thelia\Action;
|
namespace Thelia\Action;
|
||||||
use Symfony\Component\DependencyInjection\ContainerInterface;
|
|
||||||
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
|
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
|
||||||
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
|
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
|
||||||
use Thelia\Core\Event\Cache\CacheEvent;
|
use Thelia\Core\Event\Cache\CacheEvent;
|
||||||
|
|||||||
@@ -11,7 +11,6 @@
|
|||||||
/*************************************************************************************/
|
/*************************************************************************************/
|
||||||
|
|
||||||
namespace Thelia\Action;
|
namespace Thelia\Action;
|
||||||
use Symfony\Component\DependencyInjection\ContainerInterface;
|
|
||||||
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
|
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
|
||||||
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
|
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
|
||||||
use Thelia\Core\Event\Cache\CacheEvent;
|
use Thelia\Core\Event\Cache\CacheEvent;
|
||||||
|
|||||||
@@ -137,7 +137,7 @@
|
|||||||
<service id="session.listener" class="Thelia\Core\EventListener\SessionListener">
|
<service id="session.listener" class="Thelia\Core\EventListener\SessionListener">
|
||||||
<tag name="kernel.event_subscriber"/>
|
<tag name="kernel.event_subscriber"/>
|
||||||
</service>
|
</service>
|
||||||
|
|
||||||
<!-- Archive builders -->
|
<!-- Archive builders -->
|
||||||
|
|
||||||
<service id="thelia.manager.archive_builder_manager" class="Thelia\Core\FileFormat\Archive\ArchiveBuilderManager">
|
<service id="thelia.manager.archive_builder_manager" class="Thelia\Core\FileFormat\Archive\ArchiveBuilderManager">
|
||||||
|
|||||||
@@ -26,7 +26,6 @@ use Thelia\Files\FileModelInterface;
|
|||||||
use Thelia\Form\Exception\FormValidationException;
|
use Thelia\Form\Exception\FormValidationException;
|
||||||
use Thelia\Log\Tlog;
|
use Thelia\Log\Tlog;
|
||||||
use Thelia\Model\Lang;
|
use Thelia\Model\Lang;
|
||||||
use Thelia\Tools\MimeTypeTools;
|
|
||||||
use Thelia\Tools\Rest\ResponseRest;
|
use Thelia\Tools\Rest\ResponseRest;
|
||||||
use Thelia\Tools\URL;
|
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 $parentType Parent Type owning files being saved (product, category, content, etc.)
|
||||||
* @param string $objectType Object type, e.g. image or document
|
* @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 $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
|
* @return Response
|
||||||
*/
|
*/
|
||||||
public function saveFileAjaxAction(
|
public function saveFileAjaxAction(
|
||||||
|
|||||||
@@ -503,4 +503,9 @@ class TarArchiveBuilder extends AbstractArchiveBuilder
|
|||||||
{
|
{
|
||||||
return $this->compression;
|
return $this->compression;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function isAvailable()
|
||||||
|
{
|
||||||
|
return false === (bool) ini_get("phar.readonly") && class_exists("\\PharData");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -44,4 +44,9 @@ class TarBz2ArchiveBuilder extends TarArchiveBuilder
|
|||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function isAvailable()
|
||||||
|
{
|
||||||
|
return parent::isAvailable() && extension_loaded("bz2");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -45,4 +45,8 @@ class TarGzArchiveBuilder extends TarArchiveBuilder
|
|||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function isAvailable()
|
||||||
|
{
|
||||||
|
return parent::isAvailable() && extension_loaded("zlib");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -610,4 +610,14 @@ class ZipArchiveBuilder extends AbstractArchiveBuilder
|
|||||||
{
|
{
|
||||||
return $this->zip;
|
return $this->zip;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return bool
|
||||||
|
*
|
||||||
|
* Returns conditions for archive builder to be available ( loaded libraries )
|
||||||
|
*/
|
||||||
|
public function isAvailable()
|
||||||
|
{
|
||||||
|
return class_exists('\\ZipArchive');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -112,4 +112,10 @@ interface ArchiveBuilderInterface
|
|||||||
*/
|
*/
|
||||||
public function hasDirectory($directory);
|
public function hasDirectory($directory);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return bool
|
||||||
|
*
|
||||||
|
* Returns conditions for archive builder to be available ( loaded libraries )
|
||||||
|
*/
|
||||||
|
public function isAvailable();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ class ArchiveBuilderManager
|
|||||||
*/
|
*/
|
||||||
public function add(AbstractArchiveBuilder $archiveBuilder)
|
public function add(AbstractArchiveBuilder $archiveBuilder)
|
||||||
{
|
{
|
||||||
if (null !== $archiveBuilder) {
|
if ($archiveBuilder->isAvailable()) {
|
||||||
$archiveBuilder->setEnvironment($this->environment);
|
$archiveBuilder->setEnvironment($this->environment);
|
||||||
|
|
||||||
$this->archiveBuilders[$archiveBuilder->getName()] = $archiveBuilder;
|
$this->archiveBuilders[$archiveBuilder->getName()] = $archiveBuilder;
|
||||||
|
|||||||
@@ -39,7 +39,34 @@ class ArchiveBuilderManagerTest extends \PHPUnit_Framework_TestCase
|
|||||||
public function testAddArchiveBuilder()
|
public function testAddArchiveBuilder()
|
||||||
{
|
{
|
||||||
/** @var AbstractArchiveBuilder $instance */
|
/** @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);
|
$this->manager->add($instance);
|
||||||
|
|
||||||
@@ -53,7 +80,34 @@ class ArchiveBuilderManagerTest extends \PHPUnit_Framework_TestCase
|
|||||||
public function testDeleteArchiveBuilder()
|
public function testDeleteArchiveBuilder()
|
||||||
{
|
{
|
||||||
/** @var AbstractArchiveBuilder $instance */
|
/** @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);
|
$this->manager->add($instance);
|
||||||
|
|
||||||
|
|||||||
@@ -74,7 +74,9 @@ class ProductPricesExportTest extends \PHPUnit_Framework_TestCase
|
|||||||
$attributes = [];
|
$attributes = [];
|
||||||
|
|
||||||
foreach ($attributeCombinations as $attributeCombination) {
|
foreach ($attributeCombinations as $attributeCombination) {
|
||||||
$attributes[] = $attributeCombination->getAttributeAv()->getTitle();
|
if (!in_array($attributeCombination->getAttributeAv()->getTitle(), $attributes)) {
|
||||||
|
$attributes[] = $attributeCombination->getAttributeAv()->getTitle();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$rowAttributes = explode(",", $row["attributes"]);
|
$rowAttributes = explode(",", $row["attributes"]);
|
||||||
|
|||||||
@@ -51,59 +51,61 @@
|
|||||||
</select>
|
</select>
|
||||||
{/form_field}
|
{/form_field}
|
||||||
</div>
|
</div>
|
||||||
<div class="col-md-1"></div>
|
{ifloop rel="export-archive-builder"}
|
||||||
<div class="col-md-4">
|
<div class="col-md-1"></div>
|
||||||
{form_field form=$form field="do_compress"}
|
<div class="col-md-4">
|
||||||
<label for="{$label_attr.for}">
|
{form_field form=$form field="do_compress"}
|
||||||
{$label}
|
<label for="{$label_attr.for}">
|
||||||
</label>
|
{$label}
|
||||||
<div data-off-label="<i class='glyphicon glyphicon-remove-circle'></i>" data-on-label="<i class='glyphicon glyphicon-ok-circle'></i>" data-on="success" class="make-switch switch-small" id="export-compression-switch">
|
</label>
|
||||||
<input type="checkbox" name="{$name}" id="{$label_attr.for}"/>
|
<div data-off-label="<i class='glyphicon glyphicon-remove-circle'></i>" data-on-label="<i class='glyphicon glyphicon-ok-circle'></i>" data-on="success" class="make-switch switch-small" id="export-compression-switch">
|
||||||
|
<input type="checkbox" name="{$name}" id="{$label_attr.for}"/>
|
||||||
|
</div>
|
||||||
|
{/form_field}
|
||||||
</div>
|
</div>
|
||||||
{/form_field}
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
<div class="row export-compression-selection-row">
|
||||||
<div class="row export-compression-selection-row">
|
<div class="col-md-4">
|
||||||
<div class="col-md-4">
|
{form_field form=$form field="archive_builder"}
|
||||||
{form_field form=$form field="archive_builder"}
|
<label for="{$label_attr.for}">
|
||||||
<label for="{$label_attr.for}">
|
{$label}
|
||||||
{$label}
|
</label>
|
||||||
</label>
|
<select name="{$name}" id="{$label_attr.for}">
|
||||||
<select name="{$name}" id="{$label_attr.for}">
|
{loop name="export-archive-builder" type="archive-builder"}
|
||||||
{loop name="export-archive-builder" type="archive-builder"}
|
<option value="{$NAME}" {if $value == $NAME}selected{/if}>
|
||||||
<option value="{$NAME}" {if $value == $NAME}selected{/if}>
|
{$NAME} (.{$EXTENSION})
|
||||||
{$NAME} (.{$EXTENSION})
|
</option>
|
||||||
</option>
|
{/loop}
|
||||||
{/loop}
|
</select>
|
||||||
</select>
|
{/form_field}
|
||||||
{/form_field}
|
</div>
|
||||||
</div>
|
{if $HAS_IMAGES}
|
||||||
{if $HAS_IMAGES}
|
<div class="col-md-4">
|
||||||
<div class="col-md-4">
|
{form_field form=$form field="images"}
|
||||||
{form_field form=$form field="images"}
|
<label for="{$label_attr.for}">
|
||||||
<label for="{$label_attr.for}">
|
{$label}
|
||||||
{$label}
|
</label>
|
||||||
</label>
|
|
||||||
|
|
||||||
<div data-off-label="<i class='glyphicon glyphicon-remove-circle'></i>" data-on-label="<i class='glyphicon glyphicon-ok-circle'></i>" data-on="success" class="make-switch switch-small">
|
<div data-off-label="<i class='glyphicon glyphicon-remove-circle'></i>" data-on-label="<i class='glyphicon glyphicon-ok-circle'></i>" data-on="success" class="make-switch switch-small">
|
||||||
<input type="checkbox" name="{$name}" id="{$label_attr.for}" />
|
<input type="checkbox" name="{$name}" id="{$label_attr.for}" />
|
||||||
</div>
|
</div>
|
||||||
{/form_field}
|
{/form_field}
|
||||||
</div>
|
</div>
|
||||||
{/if}
|
{/if}
|
||||||
{if $HAS_DOCUMENTS}
|
{if $HAS_DOCUMENTS}
|
||||||
<div class="col-md-4">
|
<div class="col-md-4">
|
||||||
{form_field form=$form field="documents"}
|
{form_field form=$form field="documents"}
|
||||||
<label for="{$label_attr.for}">
|
<label for="{$label_attr.for}">
|
||||||
{$label}
|
{$label}
|
||||||
</label>
|
</label>
|
||||||
|
|
||||||
<div data-off-label="<i class='glyphicon glyphicon-remove-circle'></i>" data-on-label="<i class='glyphicon glyphicon-ok-circle'></i>" data-on="success" class="make-switch switch-small">
|
<div data-off-label="<i class='glyphicon glyphicon-remove-circle'></i>" data-on-label="<i class='glyphicon glyphicon-ok-circle'></i>" data-on="success" class="make-switch switch-small">
|
||||||
<input type="checkbox" name="{$name}" id="{$label_attr.for}" />
|
<input type="checkbox" name="{$name}" id="{$label_attr.for}" />
|
||||||
</div>
|
</div>
|
||||||
{/form_field}
|
{/form_field}
|
||||||
</div>
|
</div>
|
||||||
{/if}
|
{/if}
|
||||||
|
{/ifloop}
|
||||||
</div>
|
</div>
|
||||||
{/ifloop}
|
{/ifloop}
|
||||||
{elseloop rel="export-formatters"}
|
{elseloop rel="export-formatters"}
|
||||||
|
|||||||
@@ -86,64 +86,66 @@
|
|||||||
</select>
|
</select>
|
||||||
{/form_field}
|
{/form_field}
|
||||||
</div>
|
</div>
|
||||||
<div class="col-md-4">
|
{ifloop rel="export-archive-builder"}
|
||||||
{form_field form=$form field="do_compress"}
|
<div class="col-md-4">
|
||||||
<label for="{$label_attr.for}">
|
{form_field form=$form field="do_compress"}
|
||||||
{$label}
|
|
||||||
</label>
|
|
||||||
<div data-off-label="<i class='glyphicon glyphicon-remove-circle'></i>" data-on-label="<i class='glyphicon glyphicon-ok-circle'></i>" data-on="success" class="make-switch switch-small" id="export-compression-switch">
|
|
||||||
<input type="checkbox" name="{$name}" id="{$label_attr.for}"/>
|
|
||||||
</div>
|
|
||||||
{/form_field}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="row export-compression-selection-row">
|
|
||||||
<div class="col-md-4">
|
|
||||||
{form_field form=$form field="archive_builder"}
|
|
||||||
<div class="form-group {if $error}has-error{/if}">
|
|
||||||
<label for="{$label_attr.for}">
|
<label for="{$label_attr.for}">
|
||||||
{$label}
|
{$label}
|
||||||
</label>
|
</label>
|
||||||
<select name="{$name}" id="{$label_attr.for}">
|
<div data-off-label="<i class='glyphicon glyphicon-remove-circle'></i>" data-on-label="<i class='glyphicon glyphicon-ok-circle'></i>" data-on="success" class="make-switch switch-small" id="export-compression-switch">
|
||||||
{loop name="export-archive-builder" type="archive-builder"}
|
<input type="checkbox" name="{$name}" id="{$label_attr.for}"/>
|
||||||
<option value="{$NAME}" {if $value == $NAME}selected{/if}>
|
</div>
|
||||||
{$NAME} (.{$EXTENSION})
|
{/form_field}
|
||||||
</option>
|
</div>
|
||||||
{/loop}
|
|
||||||
</select>
|
|
||||||
|
|
||||||
{if $error}
|
|
||||||
<div class="error-field">{$message}</div>
|
|
||||||
{/if}
|
|
||||||
</div>
|
|
||||||
{/form_field}
|
|
||||||
</div>
|
</div>
|
||||||
{if $HAS_IMAGES}
|
<div class="row export-compression-selection-row">
|
||||||
<div class="col-md-4">
|
<div class="col-md-4">
|
||||||
{form_field form=$form field="images"}
|
{form_field form=$form field="archive_builder"}
|
||||||
<label for="{$label_attr.for}">
|
<div class="form-group {if $error}has-error{/if}">
|
||||||
{$label}
|
<label for="{$label_attr.for}">
|
||||||
</label>
|
{$label}
|
||||||
|
</label>
|
||||||
|
<select name="{$name}" id="{$label_attr.for}">
|
||||||
|
{loop name="export-archive-builder" type="archive-builder"}
|
||||||
|
<option value="{$NAME}" {if $value == $NAME}selected{/if}>
|
||||||
|
{$NAME} (.{$EXTENSION})
|
||||||
|
</option>
|
||||||
|
{/loop}
|
||||||
|
</select>
|
||||||
|
|
||||||
<div data-off-label="<i class='glyphicon glyphicon-remove-circle'></i>" data-on-label="<i class='glyphicon glyphicon-ok-circle'></i>" data-on="success" class="make-switch switch-small">
|
{if $error}
|
||||||
<input type="checkbox" name="{$name}" id="{$label_attr.for}" />
|
<div class="error-field">{$message}</div>
|
||||||
</div>
|
{/if}
|
||||||
{/form_field}
|
</div>
|
||||||
</div>
|
{/form_field}
|
||||||
{/if}
|
</div>
|
||||||
{if $HAS_DOCUMENTS}
|
{if $HAS_IMAGES}
|
||||||
<div class="col-md-4">
|
<div class="col-md-4">
|
||||||
{form_field form=$form field="documents"}
|
{form_field form=$form field="images"}
|
||||||
<label for="{$label_attr.for}">
|
<label for="{$label_attr.for}">
|
||||||
{$label}
|
{$label}
|
||||||
</label>
|
</label>
|
||||||
|
|
||||||
<div data-off-label="<i class='glyphicon glyphicon-remove-circle'></i>" data-on-label="<i class='glyphicon glyphicon-ok-circle'></i>" data-on="success" class="make-switch switch-small">
|
<div data-off-label="<i class='glyphicon glyphicon-remove-circle'></i>" data-on-label="<i class='glyphicon glyphicon-ok-circle'></i>" data-on="success" class="make-switch switch-small">
|
||||||
<input type="checkbox" name="{$name}" id="{$label_attr.for}" />
|
<input type="checkbox" name="{$name}" id="{$label_attr.for}" />
|
||||||
</div>
|
</div>
|
||||||
{/form_field}
|
{/form_field}
|
||||||
</div>
|
</div>
|
||||||
{/if}
|
{/if}
|
||||||
|
{if $HAS_DOCUMENTS}
|
||||||
|
<div class="col-md-4">
|
||||||
|
{form_field form=$form field="documents"}
|
||||||
|
<label for="{$label_attr.for}">
|
||||||
|
{$label}
|
||||||
|
</label>
|
||||||
|
|
||||||
|
<div data-off-label="<i class='glyphicon glyphicon-remove-circle'></i>" data-on-label="<i class='glyphicon glyphicon-ok-circle'></i>" data-on="success" class="make-switch switch-small">
|
||||||
|
<input type="checkbox" name="{$name}" id="{$label_attr.for}" />
|
||||||
|
</div>
|
||||||
|
{/form_field}
|
||||||
|
</div>
|
||||||
|
{/if}
|
||||||
|
{/ifloop}
|
||||||
</div>
|
</div>
|
||||||
{/ifloop}
|
{/ifloop}
|
||||||
{elseloop rel="export-formatters"}
|
{elseloop rel="export-formatters"}
|
||||||
|
|||||||
Reference in New Issue
Block a user