Continuing categories administration...
This commit is contained in:
@@ -51,6 +51,8 @@ class Category extends BaseAction implements EventSubscriberInterface
|
|||||||
$event->getParent(),
|
$event->getParent(),
|
||||||
$event->getLocale()
|
$event->getLocale()
|
||||||
);
|
);
|
||||||
|
|
||||||
|
$event->setCategory($category);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function update(CategoryChangeEvent $event)
|
public function update(CategoryChangeEvent $event)
|
||||||
|
|||||||
@@ -47,7 +47,10 @@
|
|||||||
<form name="thelia.address.update" class="Thelia\Form\AddressUpdateForm" />
|
<form name="thelia.address.update" class="Thelia\Form\AddressUpdateForm" />
|
||||||
|
|
||||||
<form name="thelia.admin.category.creation" class="Thelia\Form\CategoryCreationForm"/>
|
<form name="thelia.admin.category.creation" class="Thelia\Form\CategoryCreationForm"/>
|
||||||
<form name="thelia.admin.category.deletion" class="Thelia\Form\CategoryDeletionForm"/>
|
<form name="thelia.admin.category.deletion" class="Thelia\Form\CategoryModificationForm"/>
|
||||||
|
|
||||||
|
<form name="thelia.admin.product.creation" class="Thelia\Form\ProductCreationForm"/>
|
||||||
|
<form name="thelia.admin.product.deletion" class="Thelia\Form\ProductModificationForm"/>
|
||||||
|
|
||||||
<form name="thelia.cart.add" class="Thelia\Form\CartAdd"/>
|
<form name="thelia.cart.add" class="Thelia\Form\CartAdd"/>
|
||||||
|
|
||||||
|
|||||||
@@ -33,27 +33,31 @@
|
|||||||
|
|
||||||
<!-- Categories management -->
|
<!-- Categories management -->
|
||||||
|
|
||||||
<route id="admin.configuration.categories.create" path="/admin/categories/create">
|
<route id="admin.categories.default" path="/admin/categories">
|
||||||
|
<default key="_controller">Thelia\Controller\Admin\CategoryController::defaultAction</default>
|
||||||
|
</route>
|
||||||
|
|
||||||
|
<route id="admin.categories.create" path="/admin/categories/create">
|
||||||
<default key="_controller">Thelia\Controller\Admin\CategoryController::createAction</default>
|
<default key="_controller">Thelia\Controller\Admin\CategoryController::createAction</default>
|
||||||
</route>
|
</route>
|
||||||
|
|
||||||
<route id="admin.configuration.categories.update" path="/admin/categories/update">
|
<route id="admin.categories.update" path="/admin/categories/update">
|
||||||
<default key="_controller">Thelia\Controller\Admin\CategoryController::changeAction</default>
|
<default key="_controller">Thelia\Controller\Admin\CategoryController::changeAction</default>
|
||||||
</route>
|
</route>
|
||||||
|
|
||||||
<route id="admin.configuration.categories.save" path="/admin/categories/save">
|
<route id="admin.categories.save" path="/admin/categories/save">
|
||||||
<default key="_controller">Thelia\Controller\Admin\CategoryController::saveChangeAction</default>
|
<default key="_controller">Thelia\Controller\Admin\CategoryController::saveChangeAction</default>
|
||||||
</route>
|
</route>
|
||||||
|
|
||||||
<route id="admin.configuration.categories.set-default" path="/admin/categories/toggle-online">
|
<route id="admin.categories.set-default" path="/admin/categories/toggle-online">
|
||||||
<default key="_controller">Thelia\Controller\Admin\CategoryController::toggleOnlineAction</default>
|
<default key="_controller">Thelia\Controller\Admin\CategoryController::toggleOnlineAction</default>
|
||||||
</route>
|
</route>
|
||||||
|
|
||||||
<route id="admin.configuration.categories.delete" path="/admin/categories/delete">
|
<route id="admin.categories.delete" path="/admin/categories/delete">
|
||||||
<default key="_controller">Thelia\Controller\Admin\CategoryController::deleteAction</default>
|
<default key="_controller">Thelia\Controller\Admin\CategoryController::deleteAction</default>
|
||||||
</route>
|
</route>
|
||||||
|
|
||||||
<route id="admin.configuration.categories.update-position" path="/admin/categories/update-position">
|
<route id="admin.categories.update-position" path="/admin/categories/update-position">
|
||||||
<default key="_controller">Thelia\Controller\Admin\CategoryController::updatePositionAction</default>
|
<default key="_controller">Thelia\Controller\Admin\CategoryController::updatePositionAction</default>
|
||||||
</route>
|
</route>
|
||||||
|
|
||||||
@@ -127,6 +131,10 @@
|
|||||||
<default key="_controller">Thelia\Controller\Admin\CurrencyController::setDefaultAction</default>
|
<default key="_controller">Thelia\Controller\Admin\CurrencyController::setDefaultAction</default>
|
||||||
</route>
|
</route>
|
||||||
|
|
||||||
|
<route id="admin.configuration.currencies.update-position" path="/admin/configuration/currencies/update-position">
|
||||||
|
<default key="_controller">Thelia\Controller\Admin\CurrencyController::updatePositionAction</default>
|
||||||
|
</route>
|
||||||
|
|
||||||
<route id="admin.configuration.currencies.update-rates" path="/admin/configuration/currencies/update-rates">
|
<route id="admin.configuration.currencies.update-rates" path="/admin/configuration/currencies/update-rates">
|
||||||
<default key="_controller">Thelia\Controller\Admin\CurrencyController::updateRatesAction</default>
|
<default key="_controller">Thelia\Controller\Admin\CurrencyController::updateRatesAction</default>
|
||||||
</route>
|
</route>
|
||||||
@@ -140,8 +148,8 @@
|
|||||||
</route>
|
</route>
|
||||||
|
|
||||||
<!-- attribute and feature routes management -->
|
<!-- attribute and feature routes management -->
|
||||||
|
|
||||||
<route id="admin.configuration.currencies.update-position" path="/admin/configuration/product_attributes">
|
<route id="admin.configuration.product-attributes" path="/admin/configuration/product-attributes">
|
||||||
<default key="_controller">Thelia\Controller\Admin\CurrencyController::updatePositionAction</default>
|
<default key="_controller">Thelia\Controller\Admin\CurrencyController::updatePositionAction</default>
|
||||||
</route>
|
</route>
|
||||||
|
|
||||||
|
|||||||
@@ -68,7 +68,7 @@ class BaseAdminController extends BaseController
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (\Exception $ex) {
|
catch (\Exception $ex) {
|
||||||
return new Response($this->errorPage($ex->getMessage()));
|
return $this->errorPage($ex->getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->pageNotFound();
|
return $this->pageNotFound();
|
||||||
|
|||||||
@@ -35,6 +35,7 @@ use Thelia\Core\Event\CategoryChangePositionEvent;
|
|||||||
use Thelia\Form\CategoryDeletionForm;
|
use Thelia\Form\CategoryDeletionForm;
|
||||||
use Thelia\Model\Lang;
|
use Thelia\Model\Lang;
|
||||||
use Thelia\Core\Translation\Translator;
|
use Thelia\Core\Translation\Translator;
|
||||||
|
use Thelia\Core\Event\CategoryUpdatePositionEvent;
|
||||||
|
|
||||||
class CategoryController extends BaseAdminController
|
class CategoryController extends BaseAdminController
|
||||||
{
|
{
|
||||||
@@ -53,7 +54,7 @@ class CategoryController extends BaseAdminController
|
|||||||
protected function setupArgs() {
|
protected function setupArgs() {
|
||||||
|
|
||||||
// Get the category ID
|
// Get the category ID
|
||||||
$id = $this->getRequest()->get('category_id', 0);
|
$category_id = $this->getRequest()->get('category_id', 0);
|
||||||
|
|
||||||
// Find the current category order
|
// Find the current category order
|
||||||
$category_order = $this->getRequest()->get(
|
$category_order = $this->getRequest()->get(
|
||||||
@@ -62,7 +63,7 @@ class CategoryController extends BaseAdminController
|
|||||||
);
|
);
|
||||||
|
|
||||||
$args = array(
|
$args = array(
|
||||||
'current_category_id' => $id,
|
'current_category_id' => $category_id,
|
||||||
'category_order' => $category_order,
|
'category_order' => $category_order,
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -84,8 +85,13 @@ class CategoryController extends BaseAdminController
|
|||||||
return $this->renderList();
|
return $this->renderList();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function createAction($args)
|
/**
|
||||||
{
|
* Create a new category object
|
||||||
|
*
|
||||||
|
* @return Symfony\Component\HttpFoundation\Response the response
|
||||||
|
*/
|
||||||
|
public function createAction() {
|
||||||
|
|
||||||
// Check current user authorization
|
// Check current user authorization
|
||||||
if (null !== $response = $this->checkAuth("admin.categories.create")) return $response;
|
if (null !== $response = $this->checkAuth("admin.categories.create")) return $response;
|
||||||
|
|
||||||
@@ -103,7 +109,7 @@ class CategoryController extends BaseAdminController
|
|||||||
|
|
||||||
$createEvent = new CategoryCreateEvent();
|
$createEvent = new CategoryCreateEvent();
|
||||||
|
|
||||||
$categoryCreateEvent = new CategoryCreateEvent(
|
$createEvent = new CategoryCreateEvent(
|
||||||
$data["title"],
|
$data["title"],
|
||||||
$data["parent"],
|
$data["parent"],
|
||||||
$data["locale"]
|
$data["locale"]
|
||||||
@@ -111,9 +117,11 @@ class CategoryController extends BaseAdminController
|
|||||||
|
|
||||||
$this->dispatch(TheliaEvents::CATEGORY_CREATE, $createEvent);
|
$this->dispatch(TheliaEvents::CATEGORY_CREATE, $createEvent);
|
||||||
|
|
||||||
|
if (! $createEvent->hasCategory()) throw new \LogicException($this->getTranslator()->trans("No category was created."));
|
||||||
|
|
||||||
$createdObject = $createEvent->getCategory();
|
$createdObject = $createEvent->getCategory();
|
||||||
|
|
||||||
// Log currency creation
|
// Log category creation
|
||||||
$this->adminLogAppend(sprintf("Category %s (ID %s) created", $createdObject->getName(), $createdObject->getId()));
|
$this->adminLogAppend(sprintf("Category %s (ID %s) created", $createdObject->getName(), $createdObject->getId()));
|
||||||
|
|
||||||
// Substitute _ID_ in the URL with the ID of the created object
|
// Substitute _ID_ in the URL with the ID of the created object
|
||||||
@@ -124,33 +132,21 @@ class CategoryController extends BaseAdminController
|
|||||||
}
|
}
|
||||||
catch (FormValidationException $ex) {
|
catch (FormValidationException $ex) {
|
||||||
// Form cannot be validated
|
// Form cannot be validated
|
||||||
$error_msg = sprintf("Please check your input: %s", $ex->getMessage());
|
$error_msg = $this->createStandardFormValidationErrorMessage($ex);
|
||||||
}
|
}
|
||||||
catch (\Exception $ex) {
|
catch (\Exception $ex) {
|
||||||
// Any other error
|
// Any other error
|
||||||
$error_msg = $ex;
|
$error_msg = $ex->getMessage();
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($error_msg !== false) {
|
$this->setupFormErrorContext("category creation", $error_msg, $creationForm, $ex);
|
||||||
// An error has been detected: log it
|
|
||||||
Tlog::getInstance()->error(sprintf("Error during category creation process : %s. Exception was %s", $error_msg, $ex->getMessage()));
|
|
||||||
|
|
||||||
// Mark the form as errored
|
|
||||||
$creationForm->setErrorMessage($error_msg);
|
|
||||||
|
|
||||||
// Pass it to the parser, along with the error currency
|
|
||||||
$this->getParserContext()
|
|
||||||
->addForm($creationForm)
|
|
||||||
->setGeneralError($error_msg)
|
|
||||||
;
|
|
||||||
}
|
|
||||||
|
|
||||||
// At this point, the form has error, and should be redisplayed.
|
// At this point, the form has error, and should be redisplayed.
|
||||||
return $this->renderList();
|
return $this->renderList();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Load a currency object for modification, and display the edit template.
|
* Load a category object for modification, and display the edit template.
|
||||||
*
|
*
|
||||||
* @return Symfony\Component\HttpFoundation\Response the response
|
* @return Symfony\Component\HttpFoundation\Response the response
|
||||||
*/
|
*/
|
||||||
@@ -159,21 +155,21 @@ class CategoryController extends BaseAdminController
|
|||||||
// Check current user authorization
|
// Check current user authorization
|
||||||
if (null !== $response = $this->checkAuth("admin.categories.update")) return $response;
|
if (null !== $response = $this->checkAuth("admin.categories.update")) return $response;
|
||||||
|
|
||||||
// Load the currency object
|
// Load the category object
|
||||||
$currency = CategoryQuery::create()
|
$category = CategoryQuery::create()
|
||||||
->joinWithI18n($this->getCurrentEditionLocale())
|
->joinWithI18n($this->getCurrentEditionLocale())
|
||||||
->findOneById($this->getRequest()->get('currency_id'));
|
->findOneById($this->getRequest()->get('category_id'));
|
||||||
|
|
||||||
if ($currency != null) {
|
if ($category != null) {
|
||||||
|
|
||||||
// Prepare the data that will hydrate the form
|
// Prepare the data that will hydrate the form
|
||||||
$data = array(
|
$data = array(
|
||||||
'id' => $currency->getId(),
|
'id' => $category->getId(),
|
||||||
'name' => $currency->getName(),
|
'name' => $category->getName(),
|
||||||
'locale' => $currency->getLocale(),
|
'locale' => $category->getLocale(),
|
||||||
'code' => $currency->getCode(),
|
'code' => $category->getCode(),
|
||||||
'symbol' => $currency->getSymbol(),
|
'symbol' => $category->getSymbol(),
|
||||||
'rate' => $currency->getRate()
|
'rate' => $category->getRate()
|
||||||
);
|
);
|
||||||
|
|
||||||
// Setup the object form
|
// Setup the object form
|
||||||
@@ -184,11 +180,11 @@ class CategoryController extends BaseAdminController
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Render the edition template.
|
// Render the edition template.
|
||||||
return $this->render('currency-edit', array('currency_id' => $this->getRequest()->get('currency_id')));
|
return $this->render('category-edit', array('category_id' => $this->getRequest()->get('category_id')));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Save changes on a modified currency object, and either go back to the currency list, or stay on the edition page.
|
* Save changes on a modified category object, and either go back to the category list, or stay on the edition page.
|
||||||
*
|
*
|
||||||
* @return Symfony\Component\HttpFoundation\Response the response
|
* @return Symfony\Component\HttpFoundation\Response the response
|
||||||
*/
|
*/
|
||||||
@@ -202,8 +198,8 @@ class CategoryController extends BaseAdminController
|
|||||||
// Create the form from the request
|
// Create the form from the request
|
||||||
$changeForm = new CategoryModificationForm($this->getRequest());
|
$changeForm = new CategoryModificationForm($this->getRequest());
|
||||||
|
|
||||||
// Get the currency ID
|
// Get the category ID
|
||||||
$currency_id = $this->getRequest()->get('currency_id');
|
$category_id = $this->getRequest()->get('category_id');
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
||||||
@@ -226,7 +222,9 @@ class CategoryController extends BaseAdminController
|
|||||||
|
|
||||||
$this->dispatch(TheliaEvents::CATEGORY_UPDATE, $changeEvent);
|
$this->dispatch(TheliaEvents::CATEGORY_UPDATE, $changeEvent);
|
||||||
|
|
||||||
// Log currency modification
|
if (! $createEvent->hasCategory()) throw new \LogicException($this->getTranslator()->trans("No category was updated."));
|
||||||
|
|
||||||
|
// Log category modification
|
||||||
$changedObject = $changeEvent->getCategory();
|
$changedObject = $changeEvent->getCategory();
|
||||||
|
|
||||||
$this->adminLogAppend(sprintf("Category %s (ID %s) modified", $changedObject->getName(), $changedObject->getId()));
|
$this->adminLogAppend(sprintf("Category %s (ID %s) modified", $changedObject->getName(), $changedObject->getId()));
|
||||||
@@ -236,7 +234,7 @@ class CategoryController extends BaseAdminController
|
|||||||
if ($this->getRequest()->get('save_mode') == 'stay') {
|
if ($this->getRequest()->get('save_mode') == 'stay') {
|
||||||
$this->redirectToRoute(
|
$this->redirectToRoute(
|
||||||
"admin.categories.update",
|
"admin.categories.update",
|
||||||
array('currency_id' => $currency_id)
|
array('category_id' => $category_id)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -244,62 +242,28 @@ class CategoryController extends BaseAdminController
|
|||||||
$this->redirect($changeForm->getSuccessUrl());
|
$this->redirect($changeForm->getSuccessUrl());
|
||||||
}
|
}
|
||||||
catch (FormValidationException $ex) {
|
catch (FormValidationException $ex) {
|
||||||
// Invalid data entered
|
// Form cannot be validated
|
||||||
$error_msg = $this->getTranslator()->trans(
|
$error_msg = $this->createStandardFormValidationErrorMessage($ex);
|
||||||
"Please check your input: %message", array("%message" => $ex->getMessage()));
|
|
||||||
}
|
}
|
||||||
catch (\Exception $ex) {
|
catch (\Exception $ex) {
|
||||||
// Any other error
|
// Any other error
|
||||||
$error_msg = $ex;
|
$error_msg = $ex->getMessage();
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->setupFormErrorContext(
|
$this->setupFormErrorContext("category modification", $error_msg, $changeForm, $ex);
|
||||||
$form,
|
|
||||||
$error_msg,
|
|
||||||
"category"
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// At this point, the form has errors, and should be redisplayed.
|
// At this point, the form has errors, and should be redisplayed.
|
||||||
return $this->render('currency-edit', array('currency_id' => $currency_id));
|
return $this->render('category-edit', array('category_id' => $category_id));
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
protected function setupFormErrorContext($object_type, $form, $error_message, $exception) {
|
|
||||||
|
|
||||||
if ($error_message !== false) {
|
|
||||||
// Lot the error message
|
|
||||||
Tlog::getInstance()->error(
|
|
||||||
$this->getTranslator()->trans(
|
|
||||||
"Error during %type modification process : %error. Exception was %exc",
|
|
||||||
array(
|
|
||||||
"%type" => "category",
|
|
||||||
"%error" => $error_message,
|
|
||||||
"%exc" => $exception->getMessage()
|
|
||||||
)
|
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
// Mark the form as errored
|
|
||||||
$form->setErrorMessage($error_message);
|
|
||||||
|
|
||||||
// Pas the form and the error to the parser
|
|
||||||
$this->getParserContext()
|
|
||||||
->addForm($form)
|
|
||||||
->setGeneralError($error_message)
|
|
||||||
;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the default currency
|
* Online status toggle category
|
||||||
*/
|
*/
|
||||||
public function setDefaultAction() {
|
public function setToggleVisibilityAction() {
|
||||||
// Check current user authorization
|
// Check current user authorization
|
||||||
if (null !== $response = $this->checkAuth("admin.categories.update")) return $response;
|
if (null !== $response = $this->checkAuth("admin.categories.update")) return $response;
|
||||||
|
|
||||||
$changeEvent = new CategoryUpdateEvent($this->getRequest()->get('currency_id', 0));
|
$changeEvent = new CategoryUpdateEvent($this->getRequest()->get('category_id', 0));
|
||||||
|
|
||||||
// Create and dispatch the change event
|
// Create and dispatch the change event
|
||||||
$changeEvent->setIsDefault(true);
|
$changeEvent->setIsDefault(true);
|
||||||
@@ -316,7 +280,7 @@ class CategoryController extends BaseAdminController
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Update currency position
|
* Update categoryposition
|
||||||
*/
|
*/
|
||||||
public function updatePositionAction() {
|
public function updatePositionAction() {
|
||||||
// Check current user authorization
|
// Check current user authorization
|
||||||
@@ -335,7 +299,7 @@ class CategoryController extends BaseAdminController
|
|||||||
$position = $this->getRequest()->get('position', null);
|
$position = $this->getRequest()->get('position', null);
|
||||||
|
|
||||||
$event = new CategoryUpdatePositionEvent(
|
$event = new CategoryUpdatePositionEvent(
|
||||||
$this->getRequest()->get('currency_id', null),
|
$this->getRequest()->get('category_id', null),
|
||||||
$mode,
|
$mode,
|
||||||
$this->getRequest()->get('position', null)
|
$this->getRequest()->get('position', null)
|
||||||
);
|
);
|
||||||
@@ -350,9 +314,8 @@ class CategoryController extends BaseAdminController
|
|||||||
$this->redirectToRoute('admin.categories.default');
|
$this->redirectToRoute('admin.categories.default');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Delete a currency object
|
* Delete a category object
|
||||||
*
|
*
|
||||||
* @return Symfony\Component\HttpFoundation\Response the response
|
* @return Symfony\Component\HttpFoundation\Response the response
|
||||||
*/
|
*/
|
||||||
@@ -361,11 +324,14 @@ class CategoryController extends BaseAdminController
|
|||||||
// Check current user authorization
|
// Check current user authorization
|
||||||
if (null !== $response = $this->checkAuth("admin.categories.delete")) return $response;
|
if (null !== $response = $this->checkAuth("admin.categories.delete")) return $response;
|
||||||
|
|
||||||
// Get the currency id, and dispatch the delet request
|
// Get the category id, and dispatch the deleted request
|
||||||
$event = new CategoryDeleteEvent($this->getRequest()->get('currency_id'));
|
$event = new CategoryDeleteEvent($this->getRequest()->get('category_id'));
|
||||||
|
|
||||||
$this->dispatch(TheliaEvents::CATEGORY_DELETE, $event);
|
$this->dispatch(TheliaEvents::CATEGORY_DELETE, $event);
|
||||||
|
|
||||||
|
if ($event->hasCategory())
|
||||||
|
$this->adminLogAppend(sprintf("Category %s (ID %s) deleted", $event->getCategory()->getTitle(), $event->getCategory()->getId()));
|
||||||
|
|
||||||
$this->redirectToRoute('admin.categories.default');
|
$this->redirectToRoute('admin.categories.default');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -108,6 +108,8 @@ class ConfigController extends BaseAdminController
|
|||||||
|
|
||||||
$this->dispatch(TheliaEvents::CONFIG_CREATE, $createEvent);
|
$this->dispatch(TheliaEvents::CONFIG_CREATE, $createEvent);
|
||||||
|
|
||||||
|
if (! $createEvent->hasConfig()) throw new \LogicException($this->getTranslator()->trans("No variable was created."));
|
||||||
|
|
||||||
$createdObject = $createEvent->getConfig();
|
$createdObject = $createEvent->getConfig();
|
||||||
|
|
||||||
// Log config creation
|
// Log config creation
|
||||||
@@ -219,6 +221,8 @@ class ConfigController extends BaseAdminController
|
|||||||
|
|
||||||
$this->dispatch(TheliaEvents::CONFIG_UPDATE, $changeEvent);
|
$this->dispatch(TheliaEvents::CONFIG_UPDATE, $changeEvent);
|
||||||
|
|
||||||
|
if (! $changeEvent->hasConfig()) throw new \LogicException($this->getTranslator()->trans("No variable was updated."));
|
||||||
|
|
||||||
// Log config modification
|
// Log config modification
|
||||||
$changedObject = $changeEvent->getConfig();
|
$changedObject = $changeEvent->getConfig();
|
||||||
|
|
||||||
@@ -290,6 +294,9 @@ class ConfigController extends BaseAdminController
|
|||||||
|
|
||||||
$this->dispatch(TheliaEvents::CONFIG_DELETE, $event);
|
$this->dispatch(TheliaEvents::CONFIG_DELETE, $event);
|
||||||
|
|
||||||
|
if ($event->hasConfig())
|
||||||
|
$this->adminLogAppend(sprintf("Variable %s (ID %s) modified", $event->getConfig()->getName(), $event->getConfig()->getId()));
|
||||||
|
|
||||||
$this->redirectToRoute('admin.configuration.variables.default');
|
$this->redirectToRoute('admin.configuration.variables.default');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -108,6 +108,8 @@ class CurrencyController extends BaseAdminController
|
|||||||
|
|
||||||
$this->dispatch(TheliaEvents::CURRENCY_CREATE, $createEvent);
|
$this->dispatch(TheliaEvents::CURRENCY_CREATE, $createEvent);
|
||||||
|
|
||||||
|
if (! $createEvent->hasCurrency()) throw new \LogicException($this->getTranslator()->trans("No currency was created."));
|
||||||
|
|
||||||
$createdObject = $createEvent->getCurrency();
|
$createdObject = $createEvent->getCurrency();
|
||||||
|
|
||||||
// Log currency creation
|
// Log currency creation
|
||||||
@@ -211,6 +213,8 @@ class CurrencyController extends BaseAdminController
|
|||||||
|
|
||||||
$this->dispatch(TheliaEvents::CURRENCY_UPDATE, $changeEvent);
|
$this->dispatch(TheliaEvents::CURRENCY_UPDATE, $changeEvent);
|
||||||
|
|
||||||
|
if (! $changeEvent->hasCurrency()) throw new \LogicException($this->getTranslator()->trans("No currency was updated."));
|
||||||
|
|
||||||
// Log currency modification
|
// Log currency modification
|
||||||
$changedObject = $changeEvent->getCurrency();
|
$changedObject = $changeEvent->getCurrency();
|
||||||
|
|
||||||
@@ -335,6 +339,9 @@ class CurrencyController extends BaseAdminController
|
|||||||
|
|
||||||
$this->dispatch(TheliaEvents::CURRENCY_DELETE, $event);
|
$this->dispatch(TheliaEvents::CURRENCY_DELETE, $event);
|
||||||
|
|
||||||
|
if ($event->hasCurrency())
|
||||||
|
$this->adminLogAppend(sprintf("Currency %s (ID %s) modified", $event->getCurrency()->getName(), $event->getCurrency()->getId()));
|
||||||
|
|
||||||
$this->redirectToRoute('admin.configuration.currencies.default');
|
$this->redirectToRoute('admin.configuration.currencies.default');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -42,6 +42,15 @@ use Thelia\Form\MessageCreationForm;
|
|||||||
*/
|
*/
|
||||||
class MessageController extends BaseAdminController
|
class MessageController extends BaseAdminController
|
||||||
{
|
{
|
||||||
|
/**
|
||||||
|
* Render the messages list
|
||||||
|
*
|
||||||
|
* @return Symfony\Component\HttpFoundation\Response the response
|
||||||
|
*/
|
||||||
|
protected function renderList() {
|
||||||
|
return $this->render('messages');
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The default action is displaying the messages list.
|
* The default action is displaying the messages list.
|
||||||
*
|
*
|
||||||
@@ -51,7 +60,7 @@ class MessageController extends BaseAdminController
|
|||||||
|
|
||||||
if (null !== $response = $this->checkAuth("admin.configuration.messages.view")) return $response;
|
if (null !== $response = $this->checkAuth("admin.configuration.messages.view")) return $response;
|
||||||
|
|
||||||
return $this->render('messages');
|
return $this->renderList();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -66,7 +75,7 @@ class MessageController extends BaseAdminController
|
|||||||
|
|
||||||
$message = false;
|
$message = false;
|
||||||
|
|
||||||
// Create the Creation Form
|
// Create the creation Form
|
||||||
$creationForm = new MessageCreationForm($this->getRequest());
|
$creationForm = new MessageCreationForm($this->getRequest());
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@@ -87,10 +96,11 @@ class MessageController extends BaseAdminController
|
|||||||
|
|
||||||
$this->dispatch(TheliaEvents::MESSAGE_CREATE, $createEvent);
|
$this->dispatch(TheliaEvents::MESSAGE_CREATE, $createEvent);
|
||||||
|
|
||||||
|
if (! $createEvent->hasMessage()) throw new \LogicException($this->getTranslator()->trans("No message was created."));
|
||||||
|
|
||||||
$createdObject = $createEvent->getMessage();
|
$createdObject = $createEvent->getMessage();
|
||||||
|
|
||||||
// Log message creation
|
$this->adminLogAppend(sprintf("Message %s (ID %s) created", $createdObject->getName(), $createdObject->getId()));
|
||||||
$this->adminLogAppend(sprintf("Variable %s (ID %s) created", $createdObject->getName(), $createdObject->getId()));
|
|
||||||
|
|
||||||
// Substitute _ID_ in the URL with the ID of the created object
|
// Substitute _ID_ in the URL with the ID of the created object
|
||||||
$successUrl = str_replace('_ID_', $createdObject->getId(), $creationForm->getSuccessUrl());
|
$successUrl = str_replace('_ID_', $createdObject->getId(), $creationForm->getSuccessUrl());
|
||||||
@@ -194,7 +204,8 @@ class MessageController extends BaseAdminController
|
|||||||
|
|
||||||
$this->dispatch(TheliaEvents::MESSAGE_UPDATE, $changeEvent);
|
$this->dispatch(TheliaEvents::MESSAGE_UPDATE, $changeEvent);
|
||||||
|
|
||||||
// Log message modification
|
if (! $changeEvent->hasMessage()) throw new \LogicException($this->getTranslator()->trans("No message was updated."));
|
||||||
|
|
||||||
$changedObject = $changeEvent->getMessage();
|
$changedObject = $changeEvent->getMessage();
|
||||||
|
|
||||||
$this->adminLogAppend(sprintf("Variable %s (ID %s) modified", $changedObject->getName(), $changedObject->getId()));
|
$this->adminLogAppend(sprintf("Variable %s (ID %s) modified", $changedObject->getName(), $changedObject->getId()));
|
||||||
@@ -241,6 +252,9 @@ class MessageController extends BaseAdminController
|
|||||||
|
|
||||||
$this->dispatch(TheliaEvents::MESSAGE_DELETE, $event);
|
$this->dispatch(TheliaEvents::MESSAGE_DELETE, $event);
|
||||||
|
|
||||||
$this->redirect(URL::getInstance()->adminViewUrl('messages'));
|
if ($event->hasMessage())
|
||||||
|
$this->adminLogAppend(sprintf("Message %s (ID %s) modified", $event->getMessage()->getName(), $event->getMessage()->getId()));
|
||||||
|
|
||||||
|
$this->redirectToRoute('admin.configuration.messages.default');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -46,6 +46,7 @@ class CategoryCreateEvent extends CategoryEvent
|
|||||||
public function setTitle($title)
|
public function setTitle($title)
|
||||||
{
|
{
|
||||||
$this->title = $title;
|
$this->title = $title;
|
||||||
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getParent()
|
public function getParent()
|
||||||
@@ -56,6 +57,7 @@ class CategoryCreateEvent extends CategoryEvent
|
|||||||
public function setParent($parent)
|
public function setParent($parent)
|
||||||
{
|
{
|
||||||
$this->parent = $parent;
|
$this->parent = $parent;
|
||||||
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getLocale()
|
public function getLocale()
|
||||||
@@ -66,5 +68,6 @@ class CategoryCreateEvent extends CategoryEvent
|
|||||||
public function setLocale($locale)
|
public function setLocale($locale)
|
||||||
{
|
{
|
||||||
$this->locale = $locale;
|
$this->locale = $locale;
|
||||||
|
return $this;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -40,5 +40,6 @@ class CategoryDeleteEvent extends CategoryEvent
|
|||||||
public function setCategoryId($category_id)
|
public function setCategoryId($category_id)
|
||||||
{
|
{
|
||||||
$this->category_id = $category_id;
|
$this->category_id = $category_id;
|
||||||
|
return $this;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -28,13 +28,17 @@ use Thelia\Core\Event\ActionEvent;
|
|||||||
|
|
||||||
class CategoryEvent extends ActionEvent
|
class CategoryEvent extends ActionEvent
|
||||||
{
|
{
|
||||||
public $category;
|
public $category = null;
|
||||||
|
|
||||||
public function __construct(Category $category)
|
public function __construct(Category $category = null)
|
||||||
{
|
{
|
||||||
$this->category = $category;
|
$this->category = $category;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function hasCategory() {
|
||||||
|
return ! is_null($this->category);
|
||||||
|
}
|
||||||
|
|
||||||
public function getCategory()
|
public function getCategory()
|
||||||
{
|
{
|
||||||
return $this->category;
|
return $this->category;
|
||||||
|
|||||||
@@ -22,35 +22,7 @@
|
|||||||
/*************************************************************************************/
|
/*************************************************************************************/
|
||||||
|
|
||||||
namespace Thelia\Core\Event;
|
namespace Thelia\Core\Event;
|
||||||
use Thelia\Model\Category;
|
|
||||||
|
|
||||||
class CategoryToggleVisibilityEvent extends CategoryEvent
|
class CategoryToggleVisibilityEvent extends BaseToggleVisibilityEvent
|
||||||
{
|
{
|
||||||
protected $category_id;
|
|
||||||
protected $category;
|
|
||||||
|
|
||||||
public function __construct($category_id)
|
|
||||||
{
|
|
||||||
$this->category_id = $category_id;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getCategoryId()
|
|
||||||
{
|
|
||||||
return $this->category_id;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function setCategoryId($category_id)
|
|
||||||
{
|
|
||||||
$this->category_id = $category_id;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getCategory()
|
|
||||||
{
|
|
||||||
return $this->category;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function setCategory(Category $category)
|
|
||||||
{
|
|
||||||
$this->category = $category;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@@ -22,17 +22,16 @@
|
|||||||
/*************************************************************************************/
|
/*************************************************************************************/
|
||||||
|
|
||||||
namespace Thelia\Core\Event;
|
namespace Thelia\Core\Event;
|
||||||
|
|
||||||
use Thelia\Model\Category;
|
use Thelia\Model\Category;
|
||||||
|
|
||||||
class CategoryUpdateEvent extends ActionEvent
|
class CategoryUpdateEvent extends CategoryCreateEvent
|
||||||
{
|
{
|
||||||
protected $category_id;
|
protected $category_id;
|
||||||
protected $locale;
|
|
||||||
protected $title;
|
|
||||||
protected $chapo;
|
protected $chapo;
|
||||||
protected $description;
|
protected $description;
|
||||||
protected $postscriptum;
|
protected $postscriptum;
|
||||||
|
|
||||||
protected $url;
|
protected $url;
|
||||||
protected $visibility;
|
protected $visibility;
|
||||||
protected $parent;
|
protected $parent;
|
||||||
@@ -41,4 +40,81 @@ class CategoryUpdateEvent extends ActionEvent
|
|||||||
{
|
{
|
||||||
$this->category_id = $category_id;
|
$this->category_id = $category_id;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getCategoryId()
|
||||||
|
{
|
||||||
|
return $this->category_id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setCategoryId($category_id)
|
||||||
|
{
|
||||||
|
$this->category_id = $category_id;
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getChapo()
|
||||||
|
{
|
||||||
|
return $this->chapo;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setChapo($chapo)
|
||||||
|
{
|
||||||
|
$this->chapo = $chapo;
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getDescription()
|
||||||
|
{
|
||||||
|
return $this->description;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setDescription($description)
|
||||||
|
{
|
||||||
|
$this->description = $description;
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getPostscriptum()
|
||||||
|
{
|
||||||
|
return $this->postscriptum;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setPostscriptum($postscriptum)
|
||||||
|
{
|
||||||
|
$this->postscriptum = $postscriptum;
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getUrl()
|
||||||
|
{
|
||||||
|
return $this->url;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setUrl($url)
|
||||||
|
{
|
||||||
|
$this->url = $url;
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getVisibility()
|
||||||
|
{
|
||||||
|
return $this->visibility;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setVisibility($visibility)
|
||||||
|
{
|
||||||
|
$this->visibility = $visibility;
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getParent()
|
||||||
|
{
|
||||||
|
return $this->parent;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setParent($parent)
|
||||||
|
{
|
||||||
|
$this->parent = $parent;
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,13 +26,17 @@ use Thelia\Model\Config;
|
|||||||
|
|
||||||
class ConfigEvent extends ActionEvent
|
class ConfigEvent extends ActionEvent
|
||||||
{
|
{
|
||||||
protected $config;
|
protected $config = null;
|
||||||
|
|
||||||
public function __construct(Config $config = null)
|
public function __construct(Config $config = null)
|
||||||
{
|
{
|
||||||
$this->config = $config;
|
$this->config = $config;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function hasConfig() {
|
||||||
|
return ! is_null($this->config);
|
||||||
|
}
|
||||||
|
|
||||||
public function getConfig()
|
public function getConfig()
|
||||||
{
|
{
|
||||||
return $this->config;
|
return $this->config;
|
||||||
|
|||||||
@@ -26,13 +26,17 @@ use Thelia\Model\Currency;
|
|||||||
|
|
||||||
class CurrencyEvent extends ActionEvent
|
class CurrencyEvent extends ActionEvent
|
||||||
{
|
{
|
||||||
protected $currency;
|
protected $currency = null;
|
||||||
|
|
||||||
public function __construct(Currency $currency = null)
|
public function __construct(Currency $currency = null)
|
||||||
{
|
{
|
||||||
$this->currency = $currency;
|
$this->currency = $currency;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function hasCurrency() {
|
||||||
|
return ! is_null($this->currency);
|
||||||
|
}
|
||||||
|
|
||||||
public function getCurrency()
|
public function getCurrency()
|
||||||
{
|
{
|
||||||
return $this->currency;
|
return $this->currency;
|
||||||
|
|||||||
@@ -26,13 +26,17 @@ use Thelia\Model\Message;
|
|||||||
|
|
||||||
class MessageEvent extends ActionEvent
|
class MessageEvent extends ActionEvent
|
||||||
{
|
{
|
||||||
protected $message;
|
protected $message = null;
|
||||||
|
|
||||||
public function __construct(Message $message = null)
|
public function __construct(Message $message = null)
|
||||||
{
|
{
|
||||||
$this->message = $message;
|
$this->message = $message;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function hasMessage() {
|
||||||
|
return ! is_null($this->message);
|
||||||
|
}
|
||||||
|
|
||||||
public function getMessage()
|
public function getMessage()
|
||||||
{
|
{
|
||||||
return $this->message;
|
return $this->message;
|
||||||
|
|||||||
@@ -126,7 +126,7 @@ class AsseticHelper
|
|||||||
//
|
//
|
||||||
// before generating 3bc974a-ad3ef47.css, delete 3bc974a-* files.
|
// before generating 3bc974a-ad3ef47.css, delete 3bc974a-* files.
|
||||||
//
|
//
|
||||||
if ($dev_mode == true || ! file_exists($target_file)) {
|
if (/*$dev_mode == true || */! file_exists($target_file)) {
|
||||||
|
|
||||||
// Delete previous version of the file
|
// Delete previous version of the file
|
||||||
list($commonPart, $dummy) = explode('-', $asset_target_path);
|
list($commonPart, $dummy) = explode('-', $asset_target_path);
|
||||||
|
|||||||
@@ -23,6 +23,7 @@
|
|||||||
namespace Thelia\Form;
|
namespace Thelia\Form;
|
||||||
|
|
||||||
use Symfony\Component\Validator\Constraints\NotBlank;
|
use Symfony\Component\Validator\Constraints\NotBlank;
|
||||||
|
use Thelia\Core\Translation\Translator;
|
||||||
|
|
||||||
class CategoryCreationForm extends BaseForm
|
class CategoryCreationForm extends BaseForm
|
||||||
{
|
{
|
||||||
@@ -33,7 +34,7 @@ class CategoryCreationForm extends BaseForm
|
|||||||
"constraints" => array(
|
"constraints" => array(
|
||||||
new NotBlank()
|
new NotBlank()
|
||||||
),
|
),
|
||||||
"label" => "Category title *",
|
"label" => Translator::getInstance()->trans("Category title *"),
|
||||||
"label_attr" => array(
|
"label_attr" => array(
|
||||||
"for" => "title"
|
"for" => "title"
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -1,44 +0,0 @@
|
|||||||
<?php
|
|
||||||
/*************************************************************************************/
|
|
||||||
/* */
|
|
||||||
/* Thelia */
|
|
||||||
/* */
|
|
||||||
/* Copyright (c) OpenStudio */
|
|
||||||
/* email : info@thelia.net */
|
|
||||||
/* web : http://www.thelia.net */
|
|
||||||
/* */
|
|
||||||
/* This program is free software; you can redistribute it and/or modify */
|
|
||||||
/* it under the terms of the GNU General Public License as published by */
|
|
||||||
/* the Free Software Foundation; either version 3 of the License */
|
|
||||||
/* */
|
|
||||||
/* This program is distributed in the hope that it will be useful, */
|
|
||||||
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
|
|
||||||
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
|
|
||||||
/* GNU General Public License for more details. */
|
|
||||||
/* */
|
|
||||||
/* You should have received a copy of the GNU General Public License */
|
|
||||||
/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
|
||||||
/* */
|
|
||||||
/*************************************************************************************/
|
|
||||||
namespace Thelia\Form;
|
|
||||||
|
|
||||||
use Symfony\Component\Validator\Constraints\NotBlank;
|
|
||||||
|
|
||||||
class CategoryDeletionForm extends BaseForm
|
|
||||||
{
|
|
||||||
protected function buildForm()
|
|
||||||
{
|
|
||||||
$this->formBuilder
|
|
||||||
->add("category_id", "integer", array(
|
|
||||||
"constraints" => array(
|
|
||||||
new NotBlank()
|
|
||||||
)
|
|
||||||
))
|
|
||||||
;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getName()
|
|
||||||
{
|
|
||||||
return "thelia_category_deletion";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -269,7 +269,6 @@
|
|||||||
{module_include location='product_list_row'}
|
{module_include location='product_list_row'}
|
||||||
|
|
||||||
<td>
|
<td>
|
||||||
<<<<<<< HEAD
|
|
||||||
{loop type="auth" name="can_change" roles="ADMIN" permissions="admin.products.edit"}
|
{loop type="auth" name="can_change" roles="ADMIN" permissions="admin.products.edit"}
|
||||||
<div class="make-switch switch-small" data-on="success" data-off="danger" data-on-label="<i class='glyphicon glyphicon-ok'></i>" data-off-label="<i class='glyphicon glyphicon-remove'></i>">
|
<div class="make-switch switch-small" data-on="success" data-off="danger" data-on-label="<i class='glyphicon glyphicon-ok'></i>" data-off-label="<i class='glyphicon glyphicon-remove'></i>">
|
||||||
<input type="checkbox" data-id="{$ID}" class="productVisibleToggle" {if $VISIBLE == 1}checked="checked"{/if}>
|
<input type="checkbox" data-id="{$ID}" class="productVisibleToggle" {if $VISIBLE == 1}checked="checked"{/if}>
|
||||||
@@ -277,15 +276,10 @@
|
|||||||
{/loop}
|
{/loop}
|
||||||
|
|
||||||
{elseloop rel="can_change"}
|
{elseloop rel="can_change"}
|
||||||
<div class="make-switch switch-small" data-on="success" data-off="danger" data-on-label="<i class='glyphicon glyphicon-ok'></i>" data-off-label="<i class='glyphicon glyphicon-remove'></i>">
|
|
||||||
<input type="checkbox" class="disabled" disabled="disabled" {if $VISIBLE == 1}checked="checked"{/if}>
|
|
||||||
</div>
|
|
||||||
{/elseloop}
|
|
||||||
=======
|
|
||||||
<div class="make-switch switch-small" data-on="success" data-off="danger" data-on-label="<i class='glyphicon glyphicon-ok'></i>" data-off-label="<i class='glyphicon glyphicon-remove'></i>">
|
<div class="make-switch switch-small" data-on="success" data-off="danger" data-on-label="<i class='glyphicon glyphicon-ok'></i>" data-off-label="<i class='glyphicon glyphicon-remove'></i>">
|
||||||
<input type="checkbox" data-id="{$ID}" class="displayToggle" {if $VISIBLE == 1}checked="checked"{/if}>
|
<input type="checkbox" data-id="{$ID}" class="displayToggle" {if $VISIBLE == 1}checked="checked"{/if}>
|
||||||
</div>
|
</div>
|
||||||
>>>>>>> ebb350111a2c65929f8c61f621c9a8a6dd878984
|
{/elseloop}
|
||||||
</td>
|
</td>
|
||||||
|
|
||||||
<td>
|
<td>
|
||||||
@@ -333,72 +327,63 @@
|
|||||||
|
|
||||||
{* Adding a new Category *}
|
{* Adding a new Category *}
|
||||||
|
|
||||||
<div class="modal fade" id="add_category_dialog" tabindex="-1" role="dialog" aria-hidden="true">
|
<div class="modal fade" id="add_category_dialog" tabindex="-1" role="dialog" aria-hidden="true">
|
||||||
<div class="modal-dialog">
|
|
||||||
<div class="modal-content">
|
|
||||||
|
|
||||||
<div class="modal-header">
|
<div class="modal-dialog">
|
||||||
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
|
<div class="modal-content">
|
||||||
<h3>{intl l="Create a new category"}</h3>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
{form name="thelia.admin.category.creation"}
|
<div class="modal-header">
|
||||||
<form method="POST" action="{url path='/admin/catalog/category'}" {form_enctype form=$form}>
|
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
|
||||||
|
<h3>{intl l="Create a new categiry"}</h3>
|
||||||
|
</div>
|
||||||
|
|
||||||
{* the action processed by the controller *}
|
{form name="thelia.admin.category.creation"}
|
||||||
<input type="hidden" name="action" value="create" />
|
<form method="POST" action="{url path='/admin/configuration/categories/create'}" {form_enctype form=$form}>
|
||||||
|
|
||||||
{form_hidden_fields form=$form}
|
{form_hidden_fields form=$form}
|
||||||
|
|
||||||
{form_field form=$form field='parent'}
|
{form_field form=$form field='success_url'}
|
||||||
<input type="hidden" name="{$name}" value="{$current_category_id}" />
|
{* on success, redirect to the edition page, _ID_ is replaced with the created object ID, see controller *}
|
||||||
{/form_field}
|
<input type="hidden" name="{$name}" value="{url path='/admin/configuration/categories/update' category_id='_ID_'}" />
|
||||||
|
{/form_field}
|
||||||
|
|
||||||
{form_field form=$form field='success_url'}
|
<div class="modal-body">
|
||||||
{* on success, redirect to category change page. _ID_ is replaced with the ID of the created category (see Thelia\Action\Category.php) *}
|
|
||||||
<input type="hidden" name="{$name}" value="{url path='admin/catalog/category' id="_ID_" action='edit'}" />
|
|
||||||
{/form_field}
|
|
||||||
|
|
||||||
<div class="modal-body">
|
{if $form_error}<div class="alert alert-block alert-error" id="add_category_dialog_error">{$form_error_message}</div>{/if}
|
||||||
|
|
||||||
{if #form_error}<div class="alert alert-block alert-error" id="add_category_dialog_error">#form_error_message</div>{/if}
|
{form_field form=$form field='title'}
|
||||||
|
<div class="form-group {if $error}has-error{/if}">
|
||||||
|
<label for="{$label_attr.for}" class="control-label">{$label} : </label>
|
||||||
|
|
||||||
<div class="form-group">
|
{loop type="lang" name="default-lang" default_only="1"}
|
||||||
<label class="control-label">
|
<div class="input-group">
|
||||||
{intl l='Category Title *'}
|
<input type="text" id="{$label_attr.for}" required="required" name="{$name}" class="form-control" value="{$value}" title="{intl l='Currency name'}" placeholder="{intl l='Name'}">
|
||||||
</label>
|
<span class="input-group-addon"><img src="{image file="assets/img/flags/{$CODE}.gif"}" alt="{intl l=$TITLE}" /></span>
|
||||||
|
</div>
|
||||||
|
|
||||||
{loop type="lang" name="default-lang" default_only="1"}
|
<div class="help-block">{intl l="Enter here the category name in the default language ($TITLE)"}</div>
|
||||||
{form_field form=$form field='locale'}
|
|
||||||
<input type="hidden" name="{$name}" value="{$LOCALE}" />
|
|
||||||
{/form_field}
|
|
||||||
|
|
||||||
<div class="input-group input-block-level">
|
{* Switch edition to the current locale *}
|
||||||
{form_field form=$form field='title'}
|
<input type="hidden" name="edit_language_id" value="{$ID}" />
|
||||||
<span {if $error}class="error"{/if}>
|
|
||||||
<input type="text" required="required" name="{$name}" value="{$value}" title="{intl l='Category title'}" placeholder="{intl l='Category title'}" class="form-control input-block-level">
|
|
||||||
</span>
|
|
||||||
{/form_field}
|
|
||||||
<span class="input-group-addon"><img src="{image file="assets/img/flags/{$CODE}.gif"}" alt="{intl l=$TITLE}" /></span>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="help-block">{intl l="Enter here the category title in the default language ($TITLE)"}</div>
|
{form_field form=$form field='locale'}
|
||||||
{/loop}
|
<input type="hidden" name="{$name}" value="{$LOCALE}" />
|
||||||
|
{/form_field}
|
||||||
|
{/loop}
|
||||||
|
</div>
|
||||||
|
{/form_field}
|
||||||
|
</div>
|
||||||
|
|
||||||
</div>
|
<div class="modal-footer">
|
||||||
</div>
|
<button type="submit" class="btn btn-default btn-primary"><span class="glyphicon glyphicon-check"></span> {intl l="Create this category"}</button>
|
||||||
|
<button type="button" class="btn btn-default" data-dismiss="modal" aria-hidden="true"><span class="glyphicon glyphicon-remove"></span> {intl l="Cancel"}</button>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div class="modal-footer">
|
</form>
|
||||||
<button type="button" class="btn btn-default" data-dismiss="modal" aria-hidden="true">{intl l="Cancel"}</button>
|
{/form}
|
||||||
<button type="submit" class="btn btn-default btn-primary">{intl l="Create this category"}</button>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
</form>
|
|
||||||
{/form}
|
|
||||||
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
{* Delete category confirmation dialog *}
|
{* Delete category confirmation dialog *}
|
||||||
|
|
||||||
@@ -442,7 +427,6 @@
|
|||||||
<script src="{$asset_url}"></script>
|
<script src="{$asset_url}"></script>
|
||||||
{/javascripts}
|
{/javascripts}
|
||||||
|
|
||||||
<<<<<<< HEAD
|
|
||||||
<script>
|
<script>
|
||||||
$(function() {
|
$(function() {
|
||||||
|
|
||||||
@@ -454,6 +438,12 @@ $(function() {
|
|||||||
{/if}
|
{/if}
|
||||||
{/form}
|
{/form}
|
||||||
|
|
||||||
|
{form name="thelia.admin.product.creation"}
|
||||||
|
{if #form_error}
|
||||||
|
$('#add_category_dialog').modal();
|
||||||
|
{/if}
|
||||||
|
{/form}
|
||||||
|
|
||||||
{* Always reset create dialog on close *}
|
{* Always reset create dialog on close *}
|
||||||
|
|
||||||
$('#add_category_dialog').on('hidden',function() {
|
$('#add_category_dialog').on('hidden',function() {
|
||||||
@@ -467,13 +457,30 @@ $(function() {
|
|||||||
$("#add_category_dialog input[type=text]").val('');
|
$("#add_category_dialog input[type=text]").val('');
|
||||||
});
|
});
|
||||||
|
|
||||||
{* Set the proper category ID in the delete confirmation dialog *}
|
$('#add_product_dialog').on('hidden',function() {
|
||||||
|
// Hide error message
|
||||||
|
$('#add_product_dialog_error').remove();
|
||||||
|
|
||||||
|
// Clear error status
|
||||||
|
$("#add_product_dialog .error").removeClass('error');
|
||||||
|
|
||||||
|
// Empty field values
|
||||||
|
$("#add_product_dialog input[type=text]").val('');
|
||||||
|
});
|
||||||
|
|
||||||
|
{* Set the proper ID in the delete confirmation dialog *}
|
||||||
|
|
||||||
$('a.category-delete').click(function(ev) {
|
$('a.category-delete').click(function(ev) {
|
||||||
$('#delete_category_id').val($(this).data('id'));
|
$('#delete_category_id').val($(this).data('id'));
|
||||||
});
|
});
|
||||||
|
|
||||||
// Toggle category visibility
|
$('a.product-delete').click(function(ev) {
|
||||||
|
$('#delete_product_id').val($(this).data('id'));
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
{* Toggle object visibility *}
|
||||||
|
|
||||||
$(".categoryVisibleToggle").click(function() {
|
$(".categoryVisibleToggle").click(function() {
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url : "{url path='admin/categories/toggle-online'}",
|
url : "{url path='admin/categories/toggle-online'}",
|
||||||
@@ -484,7 +491,6 @@ $(function() {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
// Toggle product visibility
|
|
||||||
$(".productVisibleToggle").click(function() {
|
$(".productVisibleToggle").click(function() {
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url : "{url path='admin/products/toggle-online'}",
|
url : "{url path='admin/products/toggle-online'}",
|
||||||
@@ -495,6 +501,7 @@ $(function() {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
{* Inline editing of object position using bootstrap-editable *}
|
{* Inline editing of object position using bootstrap-editable *}
|
||||||
|
|
||||||
$('.categoryPositionChange').editable({
|
$('.categoryPositionChange').editable({
|
||||||
@@ -537,70 +544,4 @@ $(function() {
|
|||||||
|
|
||||||
})
|
})
|
||||||
</script>
|
</script>
|
||||||
=======
|
|
||||||
<script>
|
|
||||||
$(function() {
|
|
||||||
|
|
||||||
{* display the form creation dialog if it contains errors *}
|
|
||||||
|
|
||||||
{form name="thelia.admin.category.creation"}
|
|
||||||
{if #form_error}
|
|
||||||
$('#add_category_dialog').modal();
|
|
||||||
{/if}
|
|
||||||
{/form}
|
|
||||||
|
|
||||||
{* Always reset create dialog on close *}
|
|
||||||
|
|
||||||
$('#add_category_dialog').on('hidden',function() {
|
|
||||||
// Hide error message
|
|
||||||
$('#add_category_dialog_error').remove();
|
|
||||||
|
|
||||||
// Clear error status
|
|
||||||
$("#add_category_dialog .error").removeClass('error');
|
|
||||||
|
|
||||||
// Empty field values
|
|
||||||
$("#add_category_dialog input[type=text]").val('');
|
|
||||||
});
|
|
||||||
|
|
||||||
{* Set the proper category ID in the delete confirmation dialog *}
|
|
||||||
|
|
||||||
$(document).on("click", ".category-delete", function () {
|
|
||||||
$('#'+'delete-category-id').val($(this).data('id'));
|
|
||||||
});
|
|
||||||
|
|
||||||
// Toggle category visibility
|
|
||||||
$(".categoryVisibleToggle").change(function() {
|
|
||||||
$.ajax({
|
|
||||||
url : "{url path='admin/catalog/category'}",
|
|
||||||
data : {
|
|
||||||
category_id : $(this).data('id'),
|
|
||||||
action : 'visibilityToggle'
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
{* Inline editing of object position using bootstrap-editable *}
|
|
||||||
|
|
||||||
$('.categoryPositionChange').editable({
|
|
||||||
type : 'text',
|
|
||||||
title : '{intl l="Enter new category position"}',
|
|
||||||
mode : 'popup',
|
|
||||||
inputclass : 'input-mini',
|
|
||||||
placement : 'left',
|
|
||||||
success : function(response, newValue) {
|
|
||||||
// The URL template
|
|
||||||
var url = "{url path='admin/catalog/category' action='changePosition' category_id='__ID__' position='__POS__'}";
|
|
||||||
|
|
||||||
// Perform subtitutions
|
|
||||||
url = url.replace('__ID__', $(this).data('id'))
|
|
||||||
.replace('__POS__', newValue);
|
|
||||||
|
|
||||||
// Reload the page
|
|
||||||
location.href = url;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
});
|
|
||||||
</script>
|
|
||||||
>>>>>>> ebb350111a2c65929f8c61f621c9a8a6dd878984
|
|
||||||
{/block}
|
{/block}
|
||||||
Reference in New Issue
Block a user