Implement export types
modifié: core/lib/Thelia/Controller/Admin/ImportExportController.php modifié: core/lib/Thelia/Core/FileFormat/Formatting/Formatter/JsonFormatter.php modifié: core/lib/Thelia/Core/FileFormat/Formatting/Formatter/XMLFormatter.php modifié: core/lib/Thelia/Core/Template/Loop/Formatter.php modifié: core/lib/Thelia/ImportExport/Export/MailingExport.php modifié: core/lib/Thelia/Model/Export.php modifié: templates/backOffice/default/export-page.html modifié: templates/backOffice/default/includes/export-form-definition.html
This commit is contained in:
@@ -46,6 +46,11 @@ class ImportExportController extends BaseAdminController
|
|||||||
return $this->render("404");
|
return $this->render("404");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$this->getParserContext()
|
||||||
|
->set("ID", $export->getId())
|
||||||
|
->set("TITLE", $export->getTitle())
|
||||||
|
;
|
||||||
|
|
||||||
return $this->render("export-page");
|
return $this->render("export-page");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -90,9 +90,6 @@ class JsonFormatter extends AbstractFormatter
|
|||||||
|
|
||||||
public function getExportType()
|
public function getExportType()
|
||||||
{
|
{
|
||||||
return array(
|
return ExportType::EXPORT_UNBOUNDED;
|
||||||
ExportType::EXPORT_TABLE,
|
|
||||||
ExportType::EXPORT_UNBOUNDED,
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -145,9 +145,6 @@ class XMLFormatter extends AbstractFormatter
|
|||||||
|
|
||||||
public function getExportType()
|
public function getExportType()
|
||||||
{
|
{
|
||||||
return array(
|
return ExportType::EXPORT_UNBOUNDED;
|
||||||
ExportType::EXPORT_TABLE,
|
|
||||||
ExportType::EXPORT_UNBOUNDED,
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -46,8 +46,9 @@ class Formatter extends BaseLoop implements ArraySearchLoopInterface
|
|||||||
$export = ExportQuery::create()->findPk($exportId);
|
$export = ExportQuery::create()->findPk($exportId);
|
||||||
|
|
||||||
if (null !== $export) {
|
if (null !== $export) {
|
||||||
$types = $export->getHandleClassInstance($this->container)
|
$handlerInstance = $export->getHandleClassInstance($this->container);
|
||||||
->getHandledType();
|
|
||||||
|
$types = $handlerInstance->getHandledType();
|
||||||
|
|
||||||
if (is_scalar($types)) {
|
if (is_scalar($types)) {
|
||||||
$types = [$types];
|
$types = [$types];
|
||||||
|
|||||||
@@ -44,4 +44,26 @@ class MailingExport implements ExportHandlerInterface
|
|||||||
$data = new FormatterData();
|
$data = new FormatterData();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return string|array
|
||||||
|
*
|
||||||
|
* Define all the type of export/formatters that this can handle
|
||||||
|
* return a string if it handle a single type ( specific exports ),
|
||||||
|
* or an array if multiple.
|
||||||
|
*
|
||||||
|
* Thelia types are defined in \Thelia\ImportExport\Export\ExportType
|
||||||
|
*
|
||||||
|
* example:
|
||||||
|
* return array(
|
||||||
|
* ExportType::EXPORT_TABLE,
|
||||||
|
* ExportType::EXPORT_UNBOUNDED,
|
||||||
|
* );
|
||||||
|
*/
|
||||||
|
public function getHandledType()
|
||||||
|
{
|
||||||
|
return array(
|
||||||
|
ExportType::EXPORT_TABLE,
|
||||||
|
ExportType::EXPORT_UNBOUNDED,
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -4,6 +4,7 @@ namespace Thelia\Model;
|
|||||||
|
|
||||||
use Propel\Runtime\ActiveQuery\Criteria;
|
use Propel\Runtime\ActiveQuery\Criteria;
|
||||||
use Symfony\Component\DependencyInjection\ContainerInterface;
|
use Symfony\Component\DependencyInjection\ContainerInterface;
|
||||||
|
use Thelia\Core\Translation\Translator;
|
||||||
use Thelia\ImportExport\ExportHandlerInterface;
|
use Thelia\ImportExport\ExportHandlerInterface;
|
||||||
use Thelia\Model\Base\Export as BaseExport;
|
use Thelia\Model\Base\Export as BaseExport;
|
||||||
use Thelia\Model\Map\ExportTableMap;
|
use Thelia\Model\Map\ExportTableMap;
|
||||||
@@ -83,24 +84,32 @@ class Export extends BaseExport
|
|||||||
{
|
{
|
||||||
$class = $this->getHandleClass();
|
$class = $this->getHandleClass();
|
||||||
|
|
||||||
|
if ($class[0] !== "\\") {
|
||||||
|
$class = "\\" . $class;
|
||||||
|
}
|
||||||
|
|
||||||
if (!class_exists($class)) {
|
if (!class_exists($class)) {
|
||||||
throw new \ErrorException(
|
throw new \ErrorException(
|
||||||
"The class \"%class\" doesn't exist",
|
Translator::getInstance()->trans(
|
||||||
[
|
"The class \"%class\" doesn't exist",
|
||||||
"%class" => $class
|
[
|
||||||
]
|
"%class" => $class
|
||||||
|
]
|
||||||
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
$instance = new $class($container);
|
$instance = new $class($container);
|
||||||
|
|
||||||
if (!$class instanceof ExportHandlerInterface) {
|
if (!$instance instanceof ExportHandlerInterface) {
|
||||||
throw new \ErrorException(
|
throw new \ErrorException(
|
||||||
"The class \"%class\" must implement %interface",
|
Translator::getInstance()->trans(
|
||||||
[
|
"The class \"%class\" must implement %interface",
|
||||||
"%class" => $class,
|
[
|
||||||
"%interface" => "\\Thelia\\ImportExport\\ExportHandlerInterface",
|
"%class" => $class,
|
||||||
]
|
"%interface" => "\\Thelia\\ImportExport\\ExportHandlerInterface",
|
||||||
|
]
|
||||||
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -4,12 +4,117 @@
|
|||||||
{$admin_current_location = 'tools'}
|
{$admin_current_location = 'tools'}
|
||||||
{/block}
|
{/block}
|
||||||
|
|
||||||
{block name="page-title"}{intl l='Export: %name' name=$NAME}{/block}
|
{block name="page-title"}{intl l='Export: %title' title=$TITLE}{/block}
|
||||||
|
|
||||||
{block name="check-resource"}admin.export{/block}
|
{block name="check-resource"}admin.export{/block}
|
||||||
{block name="check-access"}view{/block}
|
{block name="check-access"}view{/block}
|
||||||
|
|
||||||
{block name="main-content"}
|
{block name="main-content"}
|
||||||
|
{form name="thelia.admin.export"}
|
||||||
|
<form method="post" {form_enctype form=$form}>
|
||||||
|
<div class="configuration">
|
||||||
|
<div id="wrapper" class="container">
|
||||||
|
|
||||||
|
<nav>
|
||||||
|
<ul class="breadcrumb">
|
||||||
|
<li><a href="{url path='admin/home'}">{intl l='Home'}</a></li>
|
||||||
|
<li><a href="{url path='admin/tools'}">{intl l='Tools'}</a></li>
|
||||||
|
<li><a href="{url path='admin/export'}">{intl l="Exports"}</a></li>
|
||||||
|
<li>{intl l='Export: %title' title=$TITLE}</li>
|
||||||
|
</ul>
|
||||||
|
</nav>
|
||||||
|
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-md-12">
|
||||||
|
<div class="general-block-decorator">
|
||||||
|
<div class="title block-title">
|
||||||
|
{intl l="Export"}
|
||||||
|
</div>
|
||||||
|
<div class="block-content">
|
||||||
|
{ifloop rel="export-formatters"}
|
||||||
|
<div class="row">
|
||||||
|
|
||||||
|
<div class="col-md-12">
|
||||||
|
<div class="col-md-3">
|
||||||
|
{custom_render_form_field form=$form field="formatter"}
|
||||||
|
<select>
|
||||||
|
{loop name="export-formatters" type="formatter" export=$ID}
|
||||||
|
<option value="{$NAME}" {if $value == $NAME}selected{/if}>
|
||||||
|
{$NAME} (.{$EXTENSION})
|
||||||
|
</option>
|
||||||
|
{/loop}
|
||||||
|
</select>
|
||||||
|
{/custom_render_form_field}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="col-md-3">
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-md-12">
|
||||||
|
<label>
|
||||||
|
{intl l="Do compress"}
|
||||||
|
</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 export-compression-switch">
|
||||||
|
<input type="checkbox" />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="row export-compression-selection-row">
|
||||||
|
<div class="col-md-12">
|
||||||
|
{custom_render_form_field form=$form field="archive_builder"}
|
||||||
|
<select name="{$name}">
|
||||||
|
{loop name="export-archive-builder" type="archive-builder"}
|
||||||
|
<option value="{$NAME}" {if $value == $NAME}selected{/if}>
|
||||||
|
{$NAME} (.{$EXTENSION})
|
||||||
|
</option>
|
||||||
|
{/loop}
|
||||||
|
</select>
|
||||||
|
{/custom_render_form_field}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="col-md-3">
|
||||||
|
{form_field form=$form field="images"}
|
||||||
|
<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>
|
||||||
|
<div class="col-md-3">
|
||||||
|
{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>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{/ifloop}
|
||||||
|
{elseloop rel="export-formatters"}
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-md-12">
|
||||||
|
<div class="alert alert-warning">
|
||||||
|
{intl l="You can't do exports, you don't have any formatter that handles this."}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{/elseloop}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
{/form}
|
||||||
{/block}
|
{/block}
|
||||||
|
|
||||||
{block name="javascript-initialization"}
|
{block name="javascript-initialization"}
|
||||||
|
|||||||
@@ -1,96 +0,0 @@
|
|||||||
{*
|
|
||||||
|
|
||||||
This file defines the fields used for export configuration:
|
|
||||||
- Export format
|
|
||||||
- With images ? documents ?
|
|
||||||
- archive format ?
|
|
||||||
|
|
||||||
*}
|
|
||||||
|
|
||||||
<div class="row">
|
|
||||||
<div class="col-md-12">
|
|
||||||
<div class="general-block-decorator">
|
|
||||||
<div class="title block-title">
|
|
||||||
{intl l="Export options"}
|
|
||||||
</div>
|
|
||||||
<div class="block-content">
|
|
||||||
{ifloop rel="export-formatters"}
|
|
||||||
<div class="row">
|
|
||||||
|
|
||||||
<div class="col-md-12">
|
|
||||||
<div class="col-md-3">
|
|
||||||
{custom_render_form_field form=$form field="formatter"}
|
|
||||||
<select>
|
|
||||||
{loop name="export-formatters" type="formatter" export=$ID}
|
|
||||||
<option value="{$NAME}" {if $value == $NAME}selected{/if}>
|
|
||||||
{$NAME} (.{$EXTENSION})
|
|
||||||
</option>
|
|
||||||
{/loop}
|
|
||||||
</select>
|
|
||||||
{/custom_render_form_field}
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="col-md-3">
|
|
||||||
<div class="row">
|
|
||||||
<div class="col-md-12">
|
|
||||||
<label>
|
|
||||||
{intl l="Do compress"}
|
|
||||||
</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 export-compression-switch">
|
|
||||||
<input type="checkbox" />
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="row export-compression-selection-row">
|
|
||||||
<div class="col-md-12">
|
|
||||||
{custom_render_form_field form=$form field="archive_builder"}
|
|
||||||
<select name="{$name}">
|
|
||||||
{loop name="export-archive-builder" type="archive-builder"}
|
|
||||||
<option value="{$NAME}" {if $value == $NAME}selected{/if}>
|
|
||||||
{$NAME} (.{$EXTENSION})
|
|
||||||
</option>
|
|
||||||
{/loop}
|
|
||||||
</select>
|
|
||||||
{/custom_render_form_field}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="col-md-3">
|
|
||||||
{form_field form=$form field="images"}
|
|
||||||
<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>
|
|
||||||
<div class="col-md-3">
|
|
||||||
{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>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
{/ifloop}
|
|
||||||
{elseloop rel="export-formatters"}
|
|
||||||
<div class="row">
|
|
||||||
<div class="col-md-12">
|
|
||||||
<div class="alert alert-warning">
|
|
||||||
{intl l="You can't do exports, you don't have any formatter"}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
{/elseloop}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
Reference in New Issue
Block a user