From c68f282fe84c55cf14eb1509c95bbfaabeb133ef Mon Sep 17 00:00:00 2001 From: franck Date: Fri, 6 Sep 2013 17:46:40 +0200 Subject: [PATCH] Continuing categories administration... --- core/lib/Thelia/Action/Category.php | 2 + core/lib/Thelia/Config/Resources/config.xml | 5 +- .../Thelia/Config/Resources/routing/admin.xml | 24 ++- .../Controller/Admin/BaseAdminController.php | 2 +- .../Controller/Admin/CategoryController.php | 138 +++++------- .../Controller/Admin/ConfigController.php | 7 + .../Controller/Admin/CurrencyController.php | 7 + .../Controller/Admin/MessageController.php | 26 ++- .../Thelia/Core/Event/CategoryCreateEvent.php | 5 +- .../Thelia/Core/Event/CategoryDeleteEvent.php | 1 + core/lib/Thelia/Core/Event/CategoryEvent.php | 8 +- .../Event/CategoryToggleVisibilityEvent.php | 30 +-- .../Thelia/Core/Event/CategoryUpdateEvent.php | 84 +++++++- core/lib/Thelia/Core/Event/ConfigEvent.php | 6 +- core/lib/Thelia/Core/Event/CurrencyEvent.php | 6 +- core/lib/Thelia/Core/Event/MessageEvent.php | 6 +- .../Core/Template/Assets/AsseticHelper.php | 2 +- core/lib/Thelia/Form/CategoryCreationForm.php | 3 +- core/lib/Thelia/Form/CategoryDeletionForm.php | 44 ---- templates/admin/default/categories.html | 199 ++++++------------ 20 files changed, 289 insertions(+), 316 deletions(-) delete mode 100755 core/lib/Thelia/Form/CategoryDeletionForm.php diff --git a/core/lib/Thelia/Action/Category.php b/core/lib/Thelia/Action/Category.php index 1b0568cbe..7b7608dc9 100755 --- a/core/lib/Thelia/Action/Category.php +++ b/core/lib/Thelia/Action/Category.php @@ -51,6 +51,8 @@ class Category extends BaseAction implements EventSubscriberInterface $event->getParent(), $event->getLocale() ); + + $event->setCategory($category); } public function update(CategoryChangeEvent $event) diff --git a/core/lib/Thelia/Config/Resources/config.xml b/core/lib/Thelia/Config/Resources/config.xml index c5c91a10e..e9e43d186 100755 --- a/core/lib/Thelia/Config/Resources/config.xml +++ b/core/lib/Thelia/Config/Resources/config.xml @@ -47,7 +47,10 @@
- + + + + diff --git a/core/lib/Thelia/Config/Resources/routing/admin.xml b/core/lib/Thelia/Config/Resources/routing/admin.xml index 4b2b6b4df..9fec5eb2e 100755 --- a/core/lib/Thelia/Config/Resources/routing/admin.xml +++ b/core/lib/Thelia/Config/Resources/routing/admin.xml @@ -33,27 +33,31 @@ - + + Thelia\Controller\Admin\CategoryController::defaultAction + + + Thelia\Controller\Admin\CategoryController::createAction - + Thelia\Controller\Admin\CategoryController::changeAction - + Thelia\Controller\Admin\CategoryController::saveChangeAction - + Thelia\Controller\Admin\CategoryController::toggleOnlineAction - + Thelia\Controller\Admin\CategoryController::deleteAction - + Thelia\Controller\Admin\CategoryController::updatePositionAction @@ -127,6 +131,10 @@ Thelia\Controller\Admin\CurrencyController::setDefaultAction + + Thelia\Controller\Admin\CurrencyController::updatePositionAction + + Thelia\Controller\Admin\CurrencyController::updateRatesAction @@ -140,8 +148,8 @@ - - + + Thelia\Controller\Admin\CurrencyController::updatePositionAction diff --git a/core/lib/Thelia/Controller/Admin/BaseAdminController.php b/core/lib/Thelia/Controller/Admin/BaseAdminController.php index 101a35d20..87aff7dd9 100755 --- a/core/lib/Thelia/Controller/Admin/BaseAdminController.php +++ b/core/lib/Thelia/Controller/Admin/BaseAdminController.php @@ -68,7 +68,7 @@ class BaseAdminController extends BaseController } } catch (\Exception $ex) { - return new Response($this->errorPage($ex->getMessage())); + return $this->errorPage($ex->getMessage()); } return $this->pageNotFound(); diff --git a/core/lib/Thelia/Controller/Admin/CategoryController.php b/core/lib/Thelia/Controller/Admin/CategoryController.php index 27cffd059..81769cd29 100755 --- a/core/lib/Thelia/Controller/Admin/CategoryController.php +++ b/core/lib/Thelia/Controller/Admin/CategoryController.php @@ -35,6 +35,7 @@ use Thelia\Core\Event\CategoryChangePositionEvent; use Thelia\Form\CategoryDeletionForm; use Thelia\Model\Lang; use Thelia\Core\Translation\Translator; +use Thelia\Core\Event\CategoryUpdatePositionEvent; class CategoryController extends BaseAdminController { @@ -53,7 +54,7 @@ class CategoryController extends BaseAdminController protected function setupArgs() { // Get the category ID - $id = $this->getRequest()->get('category_id', 0); + $category_id = $this->getRequest()->get('category_id', 0); // Find the current category order $category_order = $this->getRequest()->get( @@ -62,7 +63,7 @@ class CategoryController extends BaseAdminController ); $args = array( - 'current_category_id' => $id, + 'current_category_id' => $category_id, 'category_order' => $category_order, ); @@ -84,8 +85,13 @@ class CategoryController extends BaseAdminController 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 if (null !== $response = $this->checkAuth("admin.categories.create")) return $response; @@ -103,7 +109,7 @@ class CategoryController extends BaseAdminController $createEvent = new CategoryCreateEvent(); - $categoryCreateEvent = new CategoryCreateEvent( + $createEvent = new CategoryCreateEvent( $data["title"], $data["parent"], $data["locale"] @@ -111,9 +117,11 @@ class CategoryController extends BaseAdminController $this->dispatch(TheliaEvents::CATEGORY_CREATE, $createEvent); + if (! $createEvent->hasCategory()) throw new \LogicException($this->getTranslator()->trans("No category was created.")); + $createdObject = $createEvent->getCategory(); - // Log currency creation + // Log category creation $this->adminLogAppend(sprintf("Category %s (ID %s) created", $createdObject->getName(), $createdObject->getId())); // Substitute _ID_ in the URL with the ID of the created object @@ -124,33 +132,21 @@ class CategoryController extends BaseAdminController } catch (FormValidationException $ex) { // Form cannot be validated - $error_msg = sprintf("Please check your input: %s", $ex->getMessage()); + $error_msg = $this->createStandardFormValidationErrorMessage($ex); } catch (\Exception $ex) { // Any other error - $error_msg = $ex; + $error_msg = $ex->getMessage(); } - if ($error_msg !== false) { - // 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) - ; - } + $this->setupFormErrorContext("category creation", $error_msg, $creationForm, $ex); // At this point, the form has error, and should be redisplayed. 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 */ @@ -159,21 +155,21 @@ class CategoryController extends BaseAdminController // Check current user authorization if (null !== $response = $this->checkAuth("admin.categories.update")) return $response; - // Load the currency object - $currency = CategoryQuery::create() + // Load the category object + $category = CategoryQuery::create() ->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 $data = array( - 'id' => $currency->getId(), - 'name' => $currency->getName(), - 'locale' => $currency->getLocale(), - 'code' => $currency->getCode(), - 'symbol' => $currency->getSymbol(), - 'rate' => $currency->getRate() + 'id' => $category->getId(), + 'name' => $category->getName(), + 'locale' => $category->getLocale(), + 'code' => $category->getCode(), + 'symbol' => $category->getSymbol(), + 'rate' => $category->getRate() ); // Setup the object form @@ -184,11 +180,11 @@ class CategoryController extends BaseAdminController } // 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 */ @@ -202,8 +198,8 @@ class CategoryController extends BaseAdminController // Create the form from the request $changeForm = new CategoryModificationForm($this->getRequest()); - // Get the currency ID - $currency_id = $this->getRequest()->get('currency_id'); + // Get the category ID + $category_id = $this->getRequest()->get('category_id'); try { @@ -226,7 +222,9 @@ class CategoryController extends BaseAdminController $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(); $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') { $this->redirectToRoute( "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()); } catch (FormValidationException $ex) { - // Invalid data entered - $error_msg = $this->getTranslator()->trans( - "Please check your input: %message", array("%message" => $ex->getMessage())); + // Form cannot be validated + $error_msg = $this->createStandardFormValidationErrorMessage($ex); } catch (\Exception $ex) { // Any other error - $error_msg = $ex; + $error_msg = $ex->getMessage(); } - $this->setupFormErrorContext( - $form, - $error_msg, - "category" - - + $this->setupFormErrorContext("category modification", $error_msg, $changeForm, $ex); // At this point, the form has errors, and should be redisplayed. - return $this->render('currency-edit', array('currency_id' => $currency_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) - ; - } - + return $this->render('category-edit', array('category_id' => $category_id)); } /** - * Sets the default currency + * Online status toggle category */ - public function setDefaultAction() { + public function setToggleVisibilityAction() { // Check current user authorization 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 $changeEvent->setIsDefault(true); @@ -316,7 +280,7 @@ class CategoryController extends BaseAdminController } /** - * Update currency position + * Update categoryposition */ public function updatePositionAction() { // Check current user authorization @@ -335,7 +299,7 @@ class CategoryController extends BaseAdminController $position = $this->getRequest()->get('position', null); $event = new CategoryUpdatePositionEvent( - $this->getRequest()->get('currency_id', null), + $this->getRequest()->get('category_id', null), $mode, $this->getRequest()->get('position', null) ); @@ -350,9 +314,8 @@ class CategoryController extends BaseAdminController $this->redirectToRoute('admin.categories.default'); } - /** - * Delete a currency object + * Delete a category object * * @return Symfony\Component\HttpFoundation\Response the response */ @@ -361,11 +324,14 @@ class CategoryController extends BaseAdminController // Check current user authorization if (null !== $response = $this->checkAuth("admin.categories.delete")) return $response; - // Get the currency id, and dispatch the delet request - $event = new CategoryDeleteEvent($this->getRequest()->get('currency_id')); + // Get the category id, and dispatch the deleted request + $event = new CategoryDeleteEvent($this->getRequest()->get('category_id')); $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'); } } \ No newline at end of file diff --git a/core/lib/Thelia/Controller/Admin/ConfigController.php b/core/lib/Thelia/Controller/Admin/ConfigController.php index 17b24530e..6d1a04b05 100644 --- a/core/lib/Thelia/Controller/Admin/ConfigController.php +++ b/core/lib/Thelia/Controller/Admin/ConfigController.php @@ -108,6 +108,8 @@ class ConfigController extends BaseAdminController $this->dispatch(TheliaEvents::CONFIG_CREATE, $createEvent); + if (! $createEvent->hasConfig()) throw new \LogicException($this->getTranslator()->trans("No variable was created.")); + $createdObject = $createEvent->getConfig(); // Log config creation @@ -219,6 +221,8 @@ class ConfigController extends BaseAdminController $this->dispatch(TheliaEvents::CONFIG_UPDATE, $changeEvent); + if (! $changeEvent->hasConfig()) throw new \LogicException($this->getTranslator()->trans("No variable was updated.")); + // Log config modification $changedObject = $changeEvent->getConfig(); @@ -290,6 +294,9 @@ class ConfigController extends BaseAdminController $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'); } } \ No newline at end of file diff --git a/core/lib/Thelia/Controller/Admin/CurrencyController.php b/core/lib/Thelia/Controller/Admin/CurrencyController.php index 4d0a2cc06..c6f5afdc3 100644 --- a/core/lib/Thelia/Controller/Admin/CurrencyController.php +++ b/core/lib/Thelia/Controller/Admin/CurrencyController.php @@ -108,6 +108,8 @@ class CurrencyController extends BaseAdminController $this->dispatch(TheliaEvents::CURRENCY_CREATE, $createEvent); + if (! $createEvent->hasCurrency()) throw new \LogicException($this->getTranslator()->trans("No currency was created.")); + $createdObject = $createEvent->getCurrency(); // Log currency creation @@ -211,6 +213,8 @@ class CurrencyController extends BaseAdminController $this->dispatch(TheliaEvents::CURRENCY_UPDATE, $changeEvent); + if (! $changeEvent->hasCurrency()) throw new \LogicException($this->getTranslator()->trans("No currency was updated.")); + // Log currency modification $changedObject = $changeEvent->getCurrency(); @@ -335,6 +339,9 @@ class CurrencyController extends BaseAdminController $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'); } } \ No newline at end of file diff --git a/core/lib/Thelia/Controller/Admin/MessageController.php b/core/lib/Thelia/Controller/Admin/MessageController.php index 8c042aa0d..00fcb17bd 100644 --- a/core/lib/Thelia/Controller/Admin/MessageController.php +++ b/core/lib/Thelia/Controller/Admin/MessageController.php @@ -42,6 +42,15 @@ use Thelia\Form\MessageCreationForm; */ 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. * @@ -51,7 +60,7 @@ class MessageController extends BaseAdminController 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; - // Create the Creation Form + // Create the creation Form $creationForm = new MessageCreationForm($this->getRequest()); try { @@ -87,10 +96,11 @@ class MessageController extends BaseAdminController $this->dispatch(TheliaEvents::MESSAGE_CREATE, $createEvent); + if (! $createEvent->hasMessage()) throw new \LogicException($this->getTranslator()->trans("No message was created.")); + $createdObject = $createEvent->getMessage(); - // Log message creation - $this->adminLogAppend(sprintf("Variable %s (ID %s) created", $createdObject->getName(), $createdObject->getId())); + $this->adminLogAppend(sprintf("Message %s (ID %s) created", $createdObject->getName(), $createdObject->getId())); // Substitute _ID_ in the URL with the ID of the created object $successUrl = str_replace('_ID_', $createdObject->getId(), $creationForm->getSuccessUrl()); @@ -194,7 +204,8 @@ class MessageController extends BaseAdminController $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(); $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->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'); } } \ No newline at end of file diff --git a/core/lib/Thelia/Core/Event/CategoryCreateEvent.php b/core/lib/Thelia/Core/Event/CategoryCreateEvent.php index 1bcfe5f56..0a6b79269 100644 --- a/core/lib/Thelia/Core/Event/CategoryCreateEvent.php +++ b/core/lib/Thelia/Core/Event/CategoryCreateEvent.php @@ -46,6 +46,7 @@ class CategoryCreateEvent extends CategoryEvent public function setTitle($title) { $this->title = $title; + return $this; } public function getParent() @@ -56,6 +57,7 @@ class CategoryCreateEvent extends CategoryEvent public function setParent($parent) { $this->parent = $parent; + return $this; } public function getLocale() @@ -66,5 +68,6 @@ class CategoryCreateEvent extends CategoryEvent public function setLocale($locale) { $this->locale = $locale; + return $this; } -} +} \ No newline at end of file diff --git a/core/lib/Thelia/Core/Event/CategoryDeleteEvent.php b/core/lib/Thelia/Core/Event/CategoryDeleteEvent.php index 05253d435..ad686563d 100644 --- a/core/lib/Thelia/Core/Event/CategoryDeleteEvent.php +++ b/core/lib/Thelia/Core/Event/CategoryDeleteEvent.php @@ -40,5 +40,6 @@ class CategoryDeleteEvent extends CategoryEvent public function setCategoryId($category_id) { $this->category_id = $category_id; + return $this; } } \ No newline at end of file diff --git a/core/lib/Thelia/Core/Event/CategoryEvent.php b/core/lib/Thelia/Core/Event/CategoryEvent.php index 90fbd1e1f..ac04f15c9 100644 --- a/core/lib/Thelia/Core/Event/CategoryEvent.php +++ b/core/lib/Thelia/Core/Event/CategoryEvent.php @@ -28,13 +28,17 @@ use Thelia\Core\Event\ActionEvent; class CategoryEvent extends ActionEvent { - public $category; + public $category = null; - public function __construct(Category $category) + public function __construct(Category $category = null) { $this->category = $category; } + public function hasCategory() { + return ! is_null($this->category); + } + public function getCategory() { return $this->category; diff --git a/core/lib/Thelia/Core/Event/CategoryToggleVisibilityEvent.php b/core/lib/Thelia/Core/Event/CategoryToggleVisibilityEvent.php index 4b4d6dc88..103c5207e 100644 --- a/core/lib/Thelia/Core/Event/CategoryToggleVisibilityEvent.php +++ b/core/lib/Thelia/Core/Event/CategoryToggleVisibilityEvent.php @@ -22,35 +22,7 @@ /*************************************************************************************/ 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; - } } \ No newline at end of file diff --git a/core/lib/Thelia/Core/Event/CategoryUpdateEvent.php b/core/lib/Thelia/Core/Event/CategoryUpdateEvent.php index 8103864c5..305cf9369 100644 --- a/core/lib/Thelia/Core/Event/CategoryUpdateEvent.php +++ b/core/lib/Thelia/Core/Event/CategoryUpdateEvent.php @@ -22,17 +22,16 @@ /*************************************************************************************/ namespace Thelia\Core\Event; - use Thelia\Model\Category; -class CategoryUpdateEvent extends ActionEvent +class CategoryUpdateEvent extends CategoryCreateEvent { protected $category_id; - protected $locale; - protected $title; + protected $chapo; protected $description; protected $postscriptum; + protected $url; protected $visibility; protected $parent; @@ -41,4 +40,81 @@ class CategoryUpdateEvent extends ActionEvent { $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; + } } diff --git a/core/lib/Thelia/Core/Event/ConfigEvent.php b/core/lib/Thelia/Core/Event/ConfigEvent.php index eb5ec57c7..5e1c673cf 100644 --- a/core/lib/Thelia/Core/Event/ConfigEvent.php +++ b/core/lib/Thelia/Core/Event/ConfigEvent.php @@ -26,13 +26,17 @@ use Thelia\Model\Config; class ConfigEvent extends ActionEvent { - protected $config; + protected $config = null; public function __construct(Config $config = null) { $this->config = $config; } + public function hasConfig() { + return ! is_null($this->config); + } + public function getConfig() { return $this->config; diff --git a/core/lib/Thelia/Core/Event/CurrencyEvent.php b/core/lib/Thelia/Core/Event/CurrencyEvent.php index e0716da0c..65ac60513 100644 --- a/core/lib/Thelia/Core/Event/CurrencyEvent.php +++ b/core/lib/Thelia/Core/Event/CurrencyEvent.php @@ -26,13 +26,17 @@ use Thelia\Model\Currency; class CurrencyEvent extends ActionEvent { - protected $currency; + protected $currency = null; public function __construct(Currency $currency = null) { $this->currency = $currency; } + public function hasCurrency() { + return ! is_null($this->currency); + } + public function getCurrency() { return $this->currency; diff --git a/core/lib/Thelia/Core/Event/MessageEvent.php b/core/lib/Thelia/Core/Event/MessageEvent.php index 18433a36b..0f46ae590 100644 --- a/core/lib/Thelia/Core/Event/MessageEvent.php +++ b/core/lib/Thelia/Core/Event/MessageEvent.php @@ -26,13 +26,17 @@ use Thelia\Model\Message; class MessageEvent extends ActionEvent { - protected $message; + protected $message = null; public function __construct(Message $message = null) { $this->message = $message; } + public function hasMessage() { + return ! is_null($this->message); + } + public function getMessage() { return $this->message; diff --git a/core/lib/Thelia/Core/Template/Assets/AsseticHelper.php b/core/lib/Thelia/Core/Template/Assets/AsseticHelper.php index cd7f06ac8..bf0b7450e 100755 --- a/core/lib/Thelia/Core/Template/Assets/AsseticHelper.php +++ b/core/lib/Thelia/Core/Template/Assets/AsseticHelper.php @@ -126,7 +126,7 @@ class AsseticHelper // // 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 list($commonPart, $dummy) = explode('-', $asset_target_path); diff --git a/core/lib/Thelia/Form/CategoryCreationForm.php b/core/lib/Thelia/Form/CategoryCreationForm.php index a125ad090..5dce6a049 100755 --- a/core/lib/Thelia/Form/CategoryCreationForm.php +++ b/core/lib/Thelia/Form/CategoryCreationForm.php @@ -23,6 +23,7 @@ namespace Thelia\Form; use Symfony\Component\Validator\Constraints\NotBlank; +use Thelia\Core\Translation\Translator; class CategoryCreationForm extends BaseForm { @@ -33,7 +34,7 @@ class CategoryCreationForm extends BaseForm "constraints" => array( new NotBlank() ), - "label" => "Category title *", + "label" => Translator::getInstance()->trans("Category title *"), "label_attr" => array( "for" => "title" ) diff --git a/core/lib/Thelia/Form/CategoryDeletionForm.php b/core/lib/Thelia/Form/CategoryDeletionForm.php deleted file mode 100755 index 47c130fdd..000000000 --- a/core/lib/Thelia/Form/CategoryDeletionForm.php +++ /dev/null @@ -1,44 +0,0 @@ -. */ -/* */ -/*************************************************************************************/ -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"; - } -} diff --git a/templates/admin/default/categories.html b/templates/admin/default/categories.html index 777fd4e4d..0788a87d2 100755 --- a/templates/admin/default/categories.html +++ b/templates/admin/default/categories.html @@ -269,7 +269,6 @@ {module_include location='product_list_row'} -<<<<<<< HEAD {loop type="auth" name="can_change" roles="ADMIN" permissions="admin.products.edit"}
@@ -277,15 +276,10 @@ {/loop} {elseloop rel="can_change"} -
- -
- {/elseloop} -=======
->>>>>>> ebb350111a2c65929f8c61f621c9a8a6dd878984 + {/elseloop} @@ -333,72 +327,63 @@ {* Adding a new Category *} - {* Delete category confirmation dialog *} @@ -442,7 +427,6 @@ {/javascripts} -<<<<<<< HEAD -======= - ->>>>>>> ebb350111a2c65929f8c61f621c9a8a6dd878984 {/block} \ No newline at end of file