Finish export forms
modifié: core/lib/Thelia/Config/Resources/config.xml modifié: core/lib/Thelia/Config/Resources/form.xml modifié: core/lib/Thelia/Controller/Admin/ExportController.php modifié: core/lib/Thelia/Controller/Admin/ImportExportController.php modifié: core/lib/Thelia/Core/Template/Loop/Formatter.php modifié: core/lib/Thelia/Core/Template/Loop/ImportExportType.php modifié: core/lib/Thelia/Form/ExportForm.php modifié: core/lib/Thelia/ImportExport/Both/NewsletterImportExport.php modifié: core/lib/Thelia/ImportExport/Export/MailingExport.php renommé: core/lib/Thelia/ImportExport/ExportHandlerInterface.php -> core/lib/Thelia/ImportExport/ExportHandler.php modifié: core/lib/Thelia/Model/Export.php modifié: core/lib/Thelia/Model/Import.php nouveau fichier: core/lib/Thelia/Tests/ImportExport/Export/MailingExportTest.php nouveau fichier: templates/backOffice/default/ajax/export-modal.html modifié: templates/backOffice/default/export-page.html modifié: templates/backOffice/default/export.html
This commit is contained in:
@@ -146,7 +146,7 @@
|
||||
|
||||
<!-- zip -->
|
||||
<service id="thelia.archive_builder.zip" class="Thelia\Core\FileFormat\Archive\ArchiveBuilder\ZipArchiveBuilder">
|
||||
<tag name="thelia.manager.archive_builder" />
|
||||
<tag name="thelia.archive_builder" />
|
||||
</service>
|
||||
|
||||
<!-- tar -->
|
||||
|
||||
@@ -133,7 +133,7 @@
|
||||
<form name="thelia.assets.flush" class="Thelia\Form\Cache\AssetsFlushForm"/>
|
||||
<form name="thelia.images-and-documents-cache.flush" class="Thelia\Form\Cache\ImagesAndDocumentsCacheFlushForm"/>
|
||||
|
||||
<form name="thelia.admin.export" class="Thelia\Form\ExportForm" />
|
||||
<form name="thelia.export" class="Thelia\Form\ExportForm" />
|
||||
|
||||
</forms>
|
||||
|
||||
|
||||
@@ -108,11 +108,11 @@ class ExportController extends BaseAdminController
|
||||
protected function setOrders($category = null, $export = null)
|
||||
{
|
||||
if ($category === null) {
|
||||
$category = $this->getRequest()->query->get("category_order");
|
||||
$category = $this->getRequest()->query->get("category_order", "manual");
|
||||
}
|
||||
|
||||
if ($export === null) {
|
||||
$export = $this->getRequest()->query->get("export_order");
|
||||
$export = $this->getRequest()->query->get("export_order", "manual");
|
||||
}
|
||||
|
||||
$this->getParserContext()
|
||||
|
||||
@@ -11,7 +11,9 @@
|
||||
/*************************************************************************************/
|
||||
|
||||
namespace Thelia\Controller\Admin;
|
||||
use Thelia\Core\HttpFoundation\Response;
|
||||
use Thelia\Core\Template\Element\LoopResult;
|
||||
use Thelia\Core\Template\Loop\Export as ExportLoop;
|
||||
use Thelia\Core\Template\Loop\Import as ImportLoop;
|
||||
use Thelia\Model\ExportQuery;
|
||||
|
||||
/**
|
||||
@@ -37,7 +39,37 @@ class ImportExportController extends BaseAdminController
|
||||
return $this->render("404");
|
||||
}
|
||||
|
||||
return $this->render("import-page");
|
||||
/**
|
||||
* Use the loop to inject the same vars in Smarty
|
||||
*/
|
||||
$loop = new ImportLoop($this->container);
|
||||
|
||||
$loop->initializeArgs([
|
||||
"export" => $export->getId()
|
||||
]);
|
||||
|
||||
$query = $loop->buildModelCriteria();
|
||||
$result= $query->find();
|
||||
|
||||
$results = $loop->parseResults(
|
||||
new LoopResult($result)
|
||||
);
|
||||
|
||||
$parserContext = $this->getParserContext();
|
||||
|
||||
/** @var \Thelia\Core\Template\Element\LoopResultRow $row */
|
||||
foreach ($results as $row) {
|
||||
foreach ($row->getVarVal() as $name=>$value) {
|
||||
$parserContext->set($name, $value);
|
||||
}
|
||||
}
|
||||
|
||||
/** Then render the form */
|
||||
if ($this->getRequest()->isXmlHttpRequest()) {
|
||||
return $this->render("ajax/import-modal");
|
||||
} else {
|
||||
return $this->render("import-page");
|
||||
}
|
||||
}
|
||||
|
||||
public function exportView($id)
|
||||
@@ -46,12 +78,37 @@ class ImportExportController extends BaseAdminController
|
||||
return $this->render("404");
|
||||
}
|
||||
|
||||
$this->getParserContext()
|
||||
->set("ID", $export->getId())
|
||||
->set("TITLE", $export->getTitle())
|
||||
;
|
||||
/**
|
||||
* Use the loop to inject the same vars in Smarty
|
||||
*/
|
||||
$loop = new ExportLoop($this->container);
|
||||
|
||||
return $this->render("export-page");
|
||||
$loop->initializeArgs([
|
||||
"export" => $export->getId()
|
||||
]);
|
||||
|
||||
$query = $loop->buildModelCriteria();
|
||||
$result= $query->find();
|
||||
|
||||
$results = $loop->parseResults(
|
||||
new LoopResult($result)
|
||||
);
|
||||
|
||||
$parserContext = $this->getParserContext();
|
||||
|
||||
/** @var \Thelia\Core\Template\Element\LoopResultRow $row */
|
||||
foreach ($results as $row) {
|
||||
foreach ($row->getVarVal() as $name=>$value) {
|
||||
$parserContext->set($name, $value);
|
||||
}
|
||||
}
|
||||
|
||||
/** Then render the form */
|
||||
if ($this->getRequest()->isXmlHttpRequest()) {
|
||||
return $this->render("ajax/export-modal");
|
||||
} else {
|
||||
return $this->render("export-page");
|
||||
}
|
||||
}
|
||||
|
||||
protected function getExport($id)
|
||||
|
||||
@@ -42,6 +42,7 @@ class Formatter extends BaseLoop implements ArraySearchLoopInterface
|
||||
|
||||
$exportId = $this->getExport();
|
||||
$formatters = [];
|
||||
|
||||
if ($exportId !== null) {
|
||||
$export = ExportQuery::create()->findPk($exportId);
|
||||
|
||||
|
||||
@@ -12,6 +12,8 @@
|
||||
|
||||
namespace Thelia\Core\Template\Loop;
|
||||
use Propel\Runtime\ActiveQuery\Criteria;
|
||||
use Propel\Runtime\ActiveQuery\ModelCriteria;
|
||||
use Thelia\Core\Template\Element\BaseI18nLoop;
|
||||
use Thelia\Core\Template\Element\BaseLoop;
|
||||
use Thelia\Core\Template\Element\LoopResult;
|
||||
use Thelia\Core\Template\Element\LoopResultRow;
|
||||
@@ -27,7 +29,7 @@ use Thelia\Type\TypeCollection;
|
||||
* @package Thelia\Core\Template\Loop
|
||||
* @author Benjamin Perche <bperche@openstudio.fr>
|
||||
*/
|
||||
abstract class ImportExportType extends BaseLoop implements PropelSearchLoopInterface
|
||||
abstract class ImportExportType extends BaseI18nLoop implements PropelSearchLoopInterface
|
||||
{
|
||||
const DEFAULT_ORDER = "manual";
|
||||
|
||||
@@ -49,8 +51,8 @@ abstract class ImportExportType extends BaseLoop implements PropelSearchLoopInte
|
||||
|
||||
$loopResultRow
|
||||
->set("ID", $type->getId())
|
||||
->set("TITLE", $type->getTitle())
|
||||
->set("DESCRIPTION", $type->getDescription())
|
||||
->set("TITLE", $type->getVirtualColumn("i18n_TITLE"))
|
||||
->set("DESCRIPTION", $type->getVirtualColumn("i18n_DESCRIPTION"))
|
||||
->set("URL", $url)
|
||||
->set("POSITION", $type->getPosition())
|
||||
->set("CATEGORY_ID", $type->getByName($this->getCategoryName()))
|
||||
@@ -69,8 +71,12 @@ abstract class ImportExportType extends BaseLoop implements PropelSearchLoopInte
|
||||
*/
|
||||
public function buildModelCriteria()
|
||||
{
|
||||
/** @var ModelCriteria $query */
|
||||
$query = $this->getQueryModel();
|
||||
|
||||
$this->configureI18nProcessing($query, array('TITLE', 'DESCRIPTION'));
|
||||
|
||||
|
||||
if (null !== $ids = $this->getId()) {
|
||||
$query->filterById($ids);
|
||||
}
|
||||
|
||||
@@ -47,6 +47,11 @@ class ExportForm extends BaseForm
|
||||
"multiple" => false,
|
||||
"choices" => $this->formattersNames,
|
||||
))
|
||||
->add("do_compress", "checkbox", array(
|
||||
"label" => $this->translator->trans("Do compress"),
|
||||
"label_attr" => ["for" => "do_compress"],
|
||||
"required" => false,
|
||||
))
|
||||
->add("archive_builder", "choice", array(
|
||||
"label" => $this->translator->trans("Archive Format"),
|
||||
"label_attr" => ["for" => "archive_builder"],
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
namespace Thelia\ImportExport\Both;
|
||||
use Symfony\Component\DependencyInjection\ContainerInterface;
|
||||
use Thelia\Core\FileFormat\Formatting\FormatterData;
|
||||
use Thelia\ImportExport\ExportHandlerInterface;
|
||||
use Thelia\ImportExport\ExportHandler;
|
||||
use Thelia\ImportExport\ImportHandlerInterface;
|
||||
|
||||
/**
|
||||
@@ -21,7 +21,7 @@ use Thelia\ImportExport\ImportHandlerInterface;
|
||||
* @package Thelia\ImportExport\Both
|
||||
* @author Benjamin Perche <bperche@openstudio.fr>
|
||||
*/
|
||||
class NewsletterImportExport implements ExportHandlerInterface, ImportHandlerInterface
|
||||
class NewsletterImportExport implements ExportHandler, ImportHandlerInterface
|
||||
{
|
||||
protected $container;
|
||||
|
||||
|
||||
@@ -13,27 +13,20 @@
|
||||
namespace Thelia\ImportExport\Export;
|
||||
use Symfony\Component\DependencyInjection\ContainerInterface;
|
||||
use Thelia\Core\FileFormat\Formatting\FormatterData;
|
||||
use Thelia\ImportExport\ExportHandlerInterface;
|
||||
use Thelia\Core\Translation\Translator;
|
||||
use Thelia\ImportExport\ExportHandler;
|
||||
use Thelia\Model\CustomerQuery;
|
||||
use Thelia\Model\Map\CustomerTableMap;
|
||||
use Thelia\Model\Map\NewsletterTableMap;
|
||||
use Thelia\Model\NewsletterQuery;
|
||||
|
||||
/**
|
||||
* Class MailingExport
|
||||
* @package Thelia\ImportExport\Export
|
||||
* @author Benjamin Perche <bperche@openstudio.fr>
|
||||
*/
|
||||
class MailingExport implements ExportHandlerInterface
|
||||
class MailingExport extends ExportHandler
|
||||
{
|
||||
protected $container;
|
||||
|
||||
/**
|
||||
* @param ContainerInterface $container
|
||||
*
|
||||
* Dependency injection: load the container to be able to get parameters and services
|
||||
*/
|
||||
public function __construct(ContainerInterface $container)
|
||||
{
|
||||
$this->container = $container;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Thelia\Core\FileFormat\Formatting\FormatterData
|
||||
*
|
||||
@@ -41,7 +34,49 @@ class MailingExport implements ExportHandlerInterface
|
||||
*/
|
||||
public function buildFormatterData()
|
||||
{
|
||||
$data = new FormatterData();
|
||||
$translator = Translator::getInstance();
|
||||
|
||||
$email = $translator->trans("email");
|
||||
$lastName = $translator->trans("last name");
|
||||
$firstName = $translator->trans("first name");
|
||||
|
||||
|
||||
$aliases = [
|
||||
NewsletterTableMap::EMAIL => $email,
|
||||
CustomerTableMap::EMAIL => $email,
|
||||
|
||||
NewsletterTableMap::LASTNAME => $lastName,
|
||||
CustomerTableMap::LASTNAME => $lastName,
|
||||
|
||||
NewsletterTableMap::FIRSTNAME => $firstName,
|
||||
CustomerTableMap::FIRSTNAME => $firstName,
|
||||
];
|
||||
|
||||
$data = new FormatterData($aliases);
|
||||
|
||||
$newsletter = NewsletterQuery::create()
|
||||
->select([
|
||||
NewsletterTableMap::EMAIL,
|
||||
NewsletterTableMap::LASTNAME,
|
||||
NewsletterTableMap::FIRSTNAME,
|
||||
])
|
||||
->find()
|
||||
->toArray()
|
||||
;
|
||||
|
||||
$customers = CustomerQuery::create()
|
||||
->select([
|
||||
CustomerTableMap::EMAIL,
|
||||
CustomerTableMap::LASTNAME,
|
||||
CustomerTableMap::FIRSTNAME,
|
||||
])
|
||||
->find()
|
||||
->toArray()
|
||||
;
|
||||
|
||||
$both = $newsletter + $customers;
|
||||
|
||||
return $data->setData($both);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -14,25 +14,29 @@ namespace Thelia\ImportExport;
|
||||
use Symfony\Component\DependencyInjection\ContainerInterface;
|
||||
|
||||
/**
|
||||
* Interface ExportHandlerInterface
|
||||
* Interface ExportHandler
|
||||
* @package Thelia\ImportExport
|
||||
* @author Benjamin Perche <bperche@openstudio.fr>
|
||||
*/
|
||||
interface ExportHandlerInterface
|
||||
abstract class ExportHandler
|
||||
{
|
||||
protected $container;
|
||||
|
||||
/**
|
||||
* @param ContainerInterface $container
|
||||
*
|
||||
* Dependency injection: load the container to be able to get parameters and services
|
||||
*/
|
||||
public function __construct(ContainerInterface $container);
|
||||
public function __construct(ContainerInterface $container) {
|
||||
$this->container = $container;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Thelia\Core\FileFormat\Formatting\FormatterData
|
||||
*
|
||||
* The method builds
|
||||
* The method builds the FormatterData for the formatter
|
||||
*/
|
||||
public function buildFormatterData();
|
||||
abstract public function buildFormatterData();
|
||||
|
||||
/**
|
||||
* @return string|array
|
||||
@@ -49,5 +53,5 @@ interface ExportHandlerInterface
|
||||
* ExportType::EXPORT_UNBOUNDED,
|
||||
* );
|
||||
*/
|
||||
public function getHandledType();
|
||||
abstract public function getHandledType();
|
||||
}
|
||||
@@ -5,7 +5,7 @@ namespace Thelia\Model;
|
||||
use Propel\Runtime\ActiveQuery\Criteria;
|
||||
use Symfony\Component\DependencyInjection\ContainerInterface;
|
||||
use Thelia\Core\Translation\Translator;
|
||||
use Thelia\ImportExport\ExportHandlerInterface;
|
||||
use Thelia\ImportExport\ExportHandler;
|
||||
use Thelia\Model\Base\Export as BaseExport;
|
||||
use Thelia\Model\Map\ExportTableMap;
|
||||
|
||||
@@ -77,7 +77,7 @@ class Export extends BaseExport
|
||||
|
||||
/**
|
||||
* @param ContainerInterface $container
|
||||
* @return ExportHandlerInterface
|
||||
* @return ExportHandler
|
||||
* @throws \ErrorException
|
||||
*/
|
||||
public function getHandleClassInstance(ContainerInterface $container)
|
||||
@@ -101,13 +101,13 @@ class Export extends BaseExport
|
||||
|
||||
$instance = new $class($container);
|
||||
|
||||
if (!$instance instanceof ExportHandlerInterface) {
|
||||
if (!$instance instanceof ExportHandler) {
|
||||
throw new \ErrorException(
|
||||
Translator::getInstance()->trans(
|
||||
"The class \"%class\" must implement %interface",
|
||||
[
|
||||
"%class" => $class,
|
||||
"%interface" => "\\Thelia\\ImportExport\\ExportHandlerInterface",
|
||||
"%interface" => "\\Thelia\\ImportExport\\ExportHandler",
|
||||
]
|
||||
)
|
||||
);
|
||||
|
||||
@@ -4,7 +4,7 @@ namespace Thelia\Model;
|
||||
|
||||
use Propel\Runtime\ActiveQuery\Criteria;
|
||||
use Symfony\Component\DependencyInjection\ContainerInterface;
|
||||
use Thelia\ImportExport\ExportHandlerInterface;
|
||||
use Thelia\ImportExport\ExportHandler;
|
||||
use Thelia\Model\Base\Import as BaseImport;
|
||||
use Thelia\Model\Map\ImportTableMap;
|
||||
|
||||
@@ -89,12 +89,12 @@ class Import extends BaseImport
|
||||
|
||||
$instance = new $class($container);
|
||||
|
||||
if (!$class instanceof ExportHandlerInterface) {
|
||||
if (!$class instanceof ExportHandler) {
|
||||
throw new \ErrorException(
|
||||
"The class \"%class\" must implement %interface",
|
||||
[
|
||||
"%class" => $class,
|
||||
"%interface" => "\\Thelia\\ImportExport\\ExportHandlerInterface",
|
||||
"%interface" => "\\Thelia\\ImportExport\\ExportHandler",
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,52 @@
|
||||
<?php
|
||||
/*************************************************************************************/
|
||||
/* This file is part of the Thelia package. */
|
||||
/* */
|
||||
/* Copyright (c) OpenStudio */
|
||||
/* email : dev@thelia.net */
|
||||
/* web : http://www.thelia.net */
|
||||
/* */
|
||||
/* For the full copyright and license information, please view the LICENSE.txt */
|
||||
/* file that was distributed with this source code. */
|
||||
/*************************************************************************************/
|
||||
|
||||
namespace Thelia\Tests\ImportExport\Export;
|
||||
use Symfony\Component\DependencyInjection\Container;
|
||||
use Thelia\Core\Translation\Translator;
|
||||
use Thelia\ImportExport\Export\ExportType;
|
||||
use Thelia\ImportExport\Export\MailingExport;
|
||||
|
||||
/**
|
||||
* Class MailingExportTest
|
||||
* @package Thelia\Tests\ImportExport\Export
|
||||
* @author Benjamin Perche <bperche@openstudio.fr>
|
||||
*/
|
||||
class MailingExportTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
/** @var MailingExport $handler */
|
||||
protected $handler;
|
||||
|
||||
public function setUp()
|
||||
{
|
||||
$container = new Container();
|
||||
|
||||
new Translator($container);
|
||||
|
||||
$this->handler = new MailingExport($container);
|
||||
}
|
||||
|
||||
public function testExport()
|
||||
{
|
||||
$data = $this->handler->buildFormatterData();
|
||||
|
||||
|
||||
}
|
||||
|
||||
public function testType()
|
||||
{
|
||||
$this->assertEquals(
|
||||
[ExportType::EXPORT_TABLE, ExportType::EXPORT_UNBOUNDED],
|
||||
$this->handler->getHandledType()
|
||||
);
|
||||
}
|
||||
}
|
||||
93
templates/backOffice/default/ajax/export-modal.html
Normal file
93
templates/backOffice/default/ajax/export-modal.html
Normal file
@@ -0,0 +1,93 @@
|
||||
{form name="thelia.export"}
|
||||
<form action="{$URL}" method="post" {form_enctype form=$form}>
|
||||
<div class="modal fade" id="real-export-modal" tabindex="-1" role="dialog" aria-labelledby="export-modal-label" aria-hidden="true">
|
||||
<div class="modal-dialog">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">×</span><span class="sr-only">Close</span></button>
|
||||
<h4 class="modal-title" id="export-modal-label">Export: {$TITLE}</h4>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
{ifloop rel="export-formatters"}
|
||||
<div class="row">
|
||||
<div class="col-md-6">
|
||||
{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-6">
|
||||
{form_field form=$form field="do_compress"}
|
||||
<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">
|
||||
<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">
|
||||
{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 class="col-md-4">
|
||||
{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-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>
|
||||
</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 class="modal-footer">
|
||||
<button type="button" class="btn btn-default" data-dismiss="modal">{intl l="Close"}</button>
|
||||
<button type="submit" class="btn btn-primary">{intl l="Export"}</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
{/form}
|
||||
@@ -1,41 +1,41 @@
|
||||
{extends file="admin-layout.tpl"}
|
||||
|
||||
{block name="no-return-functions"}
|
||||
{$admin_current_location = 'tools'}
|
||||
{$admin_current_location = 'modules'}
|
||||
{/block}
|
||||
|
||||
{block name="page-title"}{intl l='Export: %title' title=$TITLE}{/block}
|
||||
{block name="page-title"}{intl l='Export'}: {$TITLE}{/block}
|
||||
|
||||
{block name="check-resource"}admin.export{/block}
|
||||
{block name="check-access"}view{/block}
|
||||
|
||||
{block name="main-content"}
|
||||
{form name="thelia.admin.export"}
|
||||
<form method="post" {form_enctype form=$form}>
|
||||
<div class="configuration">
|
||||
<div id="wrapper" class="container">
|
||||
<div class="container" id="wrapper">
|
||||
|
||||
<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>
|
||||
<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}</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">
|
||||
<div class="row">
|
||||
<div class="col-md-6">
|
||||
<div class="general-block-decorator">
|
||||
|
||||
<div class="title title-without-tabs">
|
||||
{intl l='Export: '}{$TITLE}
|
||||
</div>
|
||||
|
||||
{form name="thelia.export"}
|
||||
<form action="{$URL}" method="post" {form_enctype form=$form}>
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
{ifloop rel="export-formatters"}
|
||||
<div class="row">
|
||||
|
||||
<div class="col-md-12">
|
||||
<div class="col-md-3">
|
||||
<div class="row">
|
||||
<div class="col-md-6">
|
||||
{custom_render_form_field form=$form field="formatter"}
|
||||
<select>
|
||||
{loop name="export-formatters" type="formatter" export=$ID}
|
||||
@@ -46,75 +46,72 @@
|
||||
</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 class="col-md-6">
|
||||
{form_field form=$form field="do_compress"}
|
||||
<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">
|
||||
<input type="checkbox" name="{$name}" id="{$label_attr.for}"/>
|
||||
</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>
|
||||
{/form_field}
|
||||
</div>
|
||||
|
||||
<div class="col-md-3">
|
||||
</div>
|
||||
<div class="row export-compression-selection-row">
|
||||
<div class="col-md-4">
|
||||
{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 class="col-md-4">
|
||||
{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 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">
|
||||
<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 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."}
|
||||
{/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>
|
||||
</div>
|
||||
{/elseloop}
|
||||
{/elseloop}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<button type="submit" class="btn btn-primary">{intl l="Export"}</button>
|
||||
</form>
|
||||
{/form}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
{/form}
|
||||
</div>
|
||||
{/block}
|
||||
|
||||
{block name="javascript-initialization"}
|
||||
@@ -124,19 +121,19 @@
|
||||
{/block}
|
||||
|
||||
{block name="javascript-last-call"}
|
||||
<!-- -->
|
||||
<script>
|
||||
$(document).ready(function() {
|
||||
var compression_switch = $(".export-compression-switch");
|
||||
|
||||
var compression_switch = $("#export-compression-switch");
|
||||
var compression_row = $(".export-compression-selection-row");
|
||||
|
||||
compression_switch.on("switch-change", function(e, data) {
|
||||
var is_checked = data.value;
|
||||
|
||||
if (is_checked) {
|
||||
compression_row.show();
|
||||
compression_row.show("slow");
|
||||
} else {
|
||||
compression_row.hide();
|
||||
compression_row.hide("slow");
|
||||
}
|
||||
});
|
||||
|
||||
@@ -145,6 +142,10 @@
|
||||
} else {
|
||||
compression_row.hide();
|
||||
}
|
||||
|
||||
$(".make-switch", export_modal).bootstrapSwitch();
|
||||
$("#real-export-modal").modal();
|
||||
|
||||
});
|
||||
</script>
|
||||
{module_include location='configuration-js'}
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
{assign url_export "export_order="|cat:$export_order}
|
||||
{/if}
|
||||
|
||||
<div id="export-modal"></div>
|
||||
|
||||
<div class="configuration">
|
||||
|
||||
@@ -33,17 +34,18 @@
|
||||
{module_include location='tools_top'}
|
||||
|
||||
{loop name="export-category" type="export-category" order=$category_order}
|
||||
{assign category_title $TITLE}
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
<div class="general-block-decorator">
|
||||
<div class="table-responsive">
|
||||
<div class="table-responsive" id="category_{$category_title}">
|
||||
<table class="table table-striped table-condensed table-left-aligned">
|
||||
<caption class="clearfix">
|
||||
<a href="{url path="/admin/export/position/category/up/{$ID}{if $url_export}?{$url_export}{/if}"}">
|
||||
<a href="{url path="/admin/export/position/category/up/{$ID}{if $url_export}?{$url_export}{/if}#category_{$category_title}"}">
|
||||
<span class="glyphicon glyphicon-arrow-up"></span>
|
||||
</a>
|
||||
{$POSITION}
|
||||
<a href="{url path="/admin/export/position/category/down/{$ID}{if $url_export}?{$url_export}{/if}"}">
|
||||
<a href="{url path="/admin/export/position/category/down/{$ID}{if $url_export}?{$url_export}{/if}#category_{$category_title}"}">
|
||||
<span class="glyphicon glyphicon-arrow-down"></span>
|
||||
</a>
|
||||
{$TITLE}
|
||||
@@ -51,17 +53,32 @@
|
||||
<thead>
|
||||
<tr>
|
||||
<th class="col-md-1">
|
||||
<a href="{url path="/admin/export"}?{if $url_category}{$url_category}&{/if}export_order=id{if $export_order == "id"}_reverse{/if}">
|
||||
{if $export_order == "id"}
|
||||
<i class="glyphicon glyphicon-chevron-up"></i>
|
||||
{elseif $export_order == "id_reverse"}
|
||||
<i class="glyphicon glyphicon-chevron-down"></i>
|
||||
{/if}
|
||||
<a href="{url path="/admin/export"}?{if $url_category}{$url_category}&{/if}export_order=id{if $export_order == "id"}_reverse{/if}#category_{$category_title}">
|
||||
{intl l="ID"}
|
||||
</a>
|
||||
</th>
|
||||
<th class="col-md-8">
|
||||
<a href="{url path="/admin/export"}?{if $url_category}{$url_category}&{/if}export_order=alpha{if $export_order == "alpha"}_reverse{/if}">
|
||||
{if $export_order == "alpha"}
|
||||
<i class="glyphicon glyphicon-chevron-up"></i>
|
||||
{elseif $export_order == "alpha_reverse"}
|
||||
<i class="glyphicon glyphicon-chevron-down"></i>
|
||||
{/if}
|
||||
<a href="{url path="/admin/export"}?{if $url_category}{$url_category}&{/if}export_order=alpha{if $export_order == "alpha"}_reverse{/if}#category_{$category_title}">
|
||||
{intl l="Name"}
|
||||
</a>
|
||||
</th>
|
||||
<th class="col-md-2">
|
||||
<a href="{url path="/admin/export"}?{if $url_category}{$url_category}&{/if}export_order=manual{if $export_order == "manual"}_reverse{/if}">
|
||||
{if $export_order == "manual"}
|
||||
<i class="glyphicon glyphicon-chevron-up"></i>
|
||||
{elseif $export_order == "manual_reverse"}
|
||||
<i class="glyphicon glyphicon-chevron-down"></i>
|
||||
{/if}
|
||||
<a href="{url path="/admin/export"}?{if $url_category}{$url_category}&{/if}export_order=manual{if $export_order == "manual"}_reverse{/if}#category_{$category_title}">
|
||||
{intl l="Position"}
|
||||
</a>
|
||||
</th>
|
||||
@@ -77,20 +94,20 @@
|
||||
{$ID}
|
||||
</td>
|
||||
<td>
|
||||
<a href="{$URL}">{$TITLE}</a>
|
||||
<a href="#category_{$category_title}" class="btn-show-export-modal" data-id="{$ID}" data-url="{$URL}">{$TITLE}</a>
|
||||
</td>
|
||||
<td>
|
||||
<a href="{url path="/admin/export/position/up/{if $url_category}?{$url_category}{/if}{$ID}"}">
|
||||
<a href="{url path="/admin/export/position/up/{if $url_category}?{$url_category}{/if}{$ID}#category_{$category_title}"}">
|
||||
<span class="glyphicon glyphicon-arrow-up"></span>
|
||||
</a>
|
||||
{$POSITION}
|
||||
<a href="{url path="/admin/export/position/down/{$ID}{if $url_category}?{$url_category}{/if}"}">
|
||||
<a href="{url path="/admin/export/position/down/{$ID}{if $url_category}?{$url_category}{/if}#category_{$category_title}"}">
|
||||
<span class="glyphicon glyphicon-arrow-down"></span>
|
||||
</a>
|
||||
</td>
|
||||
<td>
|
||||
<div class="btn-group">
|
||||
<a class="btn btn-default btn-xs" href="{$URL}" title="{intl l="Do this export"}">
|
||||
<a class="btn btn-default btn-xs btn-show-export-modal" data-id="{$ID}" data-url="{$URL}" title="{intl l="Do this export"}">
|
||||
<span class="glyphicon glyphicon-open"></span>
|
||||
</a>
|
||||
</div>
|
||||
@@ -116,3 +133,58 @@
|
||||
</div>
|
||||
</div>
|
||||
{/block}
|
||||
|
||||
{block name="javascript-initialization"}
|
||||
{javascripts file='assets/js/bootstrap-switch/bootstrap-switch.js'}
|
||||
<script src="{$asset_url}"></script>
|
||||
{/javascripts}
|
||||
{/block}
|
||||
|
||||
{block name="javascript-last-call"}
|
||||
<script>
|
||||
$(document).ready(function() {
|
||||
|
||||
var export_modal = $("#export-modal");
|
||||
|
||||
$(".btn-show-export-modal").click(function() {
|
||||
|
||||
var export_id = $(this).data("id");
|
||||
|
||||
/**
|
||||
* If we can't load the modal form, redirect to a page where the form is too.
|
||||
*/
|
||||
$.ajax(
|
||||
$(this).data("url")
|
||||
).success(function(data) {
|
||||
export_modal.html(data);
|
||||
|
||||
var compression_switch = $("#export-compression-switch", export_modal);
|
||||
var compression_row = $(".export-compression-selection-row", export_modal);
|
||||
|
||||
compression_switch.on("switch-change", function(e, data) {
|
||||
var is_checked = data.value;
|
||||
|
||||
if (is_checked) {
|
||||
compression_row.show("slow");
|
||||
} else {
|
||||
compression_row.hide("slow");
|
||||
}
|
||||
});
|
||||
|
||||
if ($("input[type=checkbox]", compression_switch).is(":checked")) {
|
||||
compression_row.show();
|
||||
} else {
|
||||
compression_row.hide();
|
||||
}
|
||||
|
||||
$(".make-switch", export_modal).bootstrapSwitch();
|
||||
$("#real-export-modal").modal();
|
||||
|
||||
}).fail(function() {
|
||||
window.location.replace("{url path='/admin/export/'}"+export_id);
|
||||
});
|
||||
});
|
||||
});
|
||||
</script>
|
||||
{module_include location='configuration-js'}
|
||||
{/block}
|
||||
Reference in New Issue
Block a user