Export positions
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/Template/Loop/ImportExportType.php modifié: core/lib/Thelia/Model/Export.php nouveau fichier: templates/backOffice/default/export-page.html modifié: templates/backOffice/default/export.html nouveau fichier: templates/backOffice/default/import-page.html
This commit is contained in:
@@ -14,6 +14,9 @@ namespace Thelia\Controller\Admin;
|
||||
|
||||
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\ExportQuery;
|
||||
|
||||
/**
|
||||
* Class ExportController
|
||||
@@ -22,18 +25,78 @@ use Thelia\Core\Security\Resource\AdminResources;
|
||||
*/
|
||||
class ExportController extends BaseAdminController
|
||||
{
|
||||
|
||||
public function indexAction()
|
||||
{
|
||||
if (null !== $response = $this->checkAuth([AdminResources::EXPORT], [], [AccessManager::VIEW])) {
|
||||
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)
|
||||
;
|
||||
|
||||
return $this->render('export');
|
||||
}
|
||||
|
||||
public function export($exportType)
|
||||
public function changePosition($action, $id)
|
||||
{
|
||||
if (null !== $response = $this->checkAuth([AdminResources::EXPORT], [], [AccessManager::UPDATE])) {
|
||||
return $response;
|
||||
}
|
||||
|
||||
$export = $this->getExport($id);
|
||||
|
||||
if ($action === "up") {
|
||||
$export->upPosition();
|
||||
} elseif ($action === "down") {
|
||||
$export->downPosition();
|
||||
}
|
||||
|
||||
$this->getParserContext()
|
||||
->set("export_order", "manual")
|
||||
;
|
||||
|
||||
return $this->render('export');
|
||||
}
|
||||
|
||||
public function updatePosition($id, $value)
|
||||
{
|
||||
if (null !== $response = $this->checkAuth([AdminResources::EXPORT], [], [AccessManager::UPDATE])) {
|
||||
return $response;
|
||||
}
|
||||
|
||||
$export = $this->getExport($id);
|
||||
|
||||
$export->updatePosition($value);
|
||||
|
||||
$this->getParserContext()
|
||||
->set("export_order", "manual")
|
||||
;
|
||||
|
||||
return $this->render('export');
|
||||
}
|
||||
|
||||
|
||||
protected function getExport($id)
|
||||
{
|
||||
$export = ExportQuery::create()->findPk($id);
|
||||
|
||||
if (null === $export) {
|
||||
throw new \ErrorException(
|
||||
Translator::getInstance()->trans(
|
||||
"There is no id \"%id\" in the exports",
|
||||
[
|
||||
"%id" => $id
|
||||
]
|
||||
)
|
||||
);
|
||||
}
|
||||
return $export;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
/*************************************************************************************/
|
||||
|
||||
namespace Thelia\Controller\Admin;
|
||||
use Thelia\Core\HttpFoundation\Response;
|
||||
|
||||
/**
|
||||
* Class ImportExportController
|
||||
@@ -28,4 +29,14 @@ class ImportExportController extends BaseAdminController
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public function importView()
|
||||
{
|
||||
return $this->render("import-page");
|
||||
}
|
||||
|
||||
public function exportView()
|
||||
{
|
||||
return $this->render("export-page");
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user