Finish Import / Export categories management

modifié:         core/lib/Thelia/Config/Resources/routing/admin.xml
	modifié:         core/lib/Thelia/Controller/Admin/ExportController.php
	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/FileFormat/Formatting/FormatterInterface.php
	modifié:         core/lib/Thelia/Core/Template/Loop/Export.php
	modifié:         core/lib/Thelia/Core/Template/Loop/Formatter.php
	nouveau fichier: core/lib/Thelia/ImportExport/Both/NewsletterImportExport.php
	nouveau fichier: core/lib/Thelia/ImportExport/Export/ExportType.php
	nouveau fichier: core/lib/Thelia/ImportExport/Export/MailingExport.php
	modifié:         core/lib/Thelia/ImportExport/ExportHandlerInterface.php
	modifié:         core/lib/Thelia/Model/Export.php
	modifié:         core/lib/Thelia/Model/ExportCategory.php
	modifié:         core/lib/Thelia/Model/ImportCategory.php
	modifié:         templates/backOffice/default/export-page.html
	modifié:         templates/backOffice/default/export.html
	modifié:         templates/backOffice/default/import.html
	modifié:         templates/backOffice/default/includes/export-form-definition.html
This commit is contained in:
Benjamin Perche
2014-07-11 09:56:06 +02:00
parent 4e5bbd7f60
commit 6bc3ed214b
19 changed files with 610 additions and 135 deletions

View File

@@ -16,6 +16,7 @@ use Thelia\Core\Security\AccessManager;
use Thelia\Core\Security\Resource\AdminResources;
use Thelia\Core\Template\Loop\ImportExportType;
use Thelia\Core\Translation\Translator;
use Thelia\Model\ExportCategoryQuery;
use Thelia\Model\ExportQuery;
/**
@@ -31,15 +32,7 @@ class ExportController extends BaseAdminController
return $response;
}
$export_order = $this->getRequest()->query->get("export_order");
if (!in_array($export_order, ImportExportType::getAllowedOrders())) {
$export_order = ImportExportType::DEFAULT_ORDER;
}
$this->getParserContext()
->set("export_order", $export_order)
;
$this->setOrders();
return $this->render('export');
}
@@ -58,9 +51,7 @@ class ExportController extends BaseAdminController
$export->downPosition();
}
$this->getParserContext()
->set("export_order", "manual")
;
$this->setOrders(null, "manual");
return $this->render('export');
}
@@ -75,13 +66,63 @@ class ExportController extends BaseAdminController
$export->updatePosition($value);
$this->getParserContext()
->set("export_order", "manual")
;
$this->setOrders(null, "manual");
return $this->render('export');
}
public function changeCategoryPosition($action, $id)
{
if (null !== $response = $this->checkAuth([AdminResources::EXPORT], [], [AccessManager::UPDATE])) {
return $response;
}
$category = $this->getCategory($id);
if ($action === "up") {
$category->upPosition();
} elseif ($action === "down") {
$category->downPosition();
}
$this->setOrders("manual");
return $this->render('export');
}
public function updateCategoryPosition($id, $value)
{
if (null !== $response = $this->checkAuth([AdminResources::EXPORT], [], [AccessManager::UPDATE])) {
return $response;
}
$category = $this->getCategory($id);
$category->updatePosition($value);
$this->setOrders("manual");
return $this->render('export');
}
protected function setOrders($category = null, $export = null)
{
if ($category === null) {
$category = $this->getRequest()->query->get("category_order");
}
if ($export === null) {
$export = $this->getRequest()->query->get("export_order");
}
$this->getParserContext()
->set("category_order", $category)
;
$this->getParserContext()
->set("export_order", $export)
;
}
protected function getExport($id)
{
@@ -99,4 +140,21 @@ class ExportController extends BaseAdminController
}
return $export;
}
protected function getCategory($id)
{
$category = ExportCategoryQuery::create()->findPk($id);
if (null === $category) {
throw new \ErrorException(
Translator::getInstance()->trans(
"There is no id \"%id\" in the export categories",
[
"%id" => $id
]
)
);
}
return $category;
}
}

View File

@@ -12,6 +12,7 @@
namespace Thelia\Controller\Admin;
use Thelia\Core\HttpFoundation\Response;
use Thelia\Model\ExportQuery;
/**
* Class ImportExportController
@@ -20,23 +21,40 @@ use Thelia\Core\HttpFoundation\Response;
*/
class ImportExportController extends BaseAdminController
{
public function import()
public function import($id)
{
}
public function export()
public function export($id)
{
}
public function importView()
public function importView($id)
{
if (null === $export = $this->getExport($id)) {
return $this->render("404");
}
return $this->render("import-page");
}
public function exportView()
public function exportView($id)
{
if (null === $export = $this->getExport($id)) {
return $this->render("404");
}
return $this->render("export-page");
}
protected function getExport($id)
{
$export = ExportQuery::create()
->findPk($id)
;
return $export;
}
}