diff --git a/core/lib/Thelia/Config/Resources/routing/admin.xml b/core/lib/Thelia/Config/Resources/routing/admin.xml index b8796ab16..4b2b6b4df 100755 --- a/core/lib/Thelia/Config/Resources/routing/admin.xml +++ b/core/lib/Thelia/Config/Resources/routing/admin.xml @@ -135,10 +135,19 @@ Thelia\Controller\Admin\CurrencyController::deleteAction - + + Thelia\Controller\Admin\AttributeController::defaultAction + + + + + Thelia\Controller\Admin\CurrencyController::updatePositionAction + + + diff --git a/core/lib/Thelia/Controller/Admin/AttributeController.php b/core/lib/Thelia/Controller/Admin/AttributeController.php new file mode 100644 index 000000000..d2c1ea351 --- /dev/null +++ b/core/lib/Thelia/Controller/Admin/AttributeController.php @@ -0,0 +1,57 @@ +. */ +/* */ +/*************************************************************************************/ + +namespace Thelia\Controller\Admin; + +use Thelia\Core\Event\MessageDeleteEvent; +use Thelia\Core\Event\TheliaEvents; +use Thelia\Tools\URL; +use Thelia\Core\Event\MessageUpdateEvent; +use Thelia\Core\Event\MessageCreateEvent; +use Thelia\Log\Tlog; +use Thelia\Form\Exception\FormValidationException; +use Thelia\Core\Security\Exception\AuthorizationException; +use Thelia\Model\MessageQuery; +use Thelia\Form\MessageModificationForm; +use Thelia\Form\MessageCreationForm; + +/** + * Manages messages sent by mail + * + * @author Franck Allimant + */ +class AttributeController extends BaseAdminController +{ + /** + * The default action is displaying the messages list. + * + * @return Symfony\Component\HttpFoundation\Response the response + */ + public function defaultAction() { + + if (null !== $response = $this->checkAuth("admin.configuration.attributes.view")) return $response; + + return $this->render('product_attributes'); + } + +} \ No newline at end of file diff --git a/core/lib/Thelia/Controller/Admin/BaseAdminController.php b/core/lib/Thelia/Controller/Admin/BaseAdminController.php index 15634214c..101a35d20 100755 --- a/core/lib/Thelia/Controller/Admin/BaseAdminController.php +++ b/core/lib/Thelia/Controller/Admin/BaseAdminController.php @@ -132,7 +132,7 @@ class BaseAdminController extends BaseController * Create the standard message displayed to the user when the form cannot be validated. */ protected function createStandardFormValidationErrorMessage(FormValidationException $exception) { - return Translator::getInstance()->trans( + return $this->getTranslator()->trans( "Please check your input: %error", array( '%error' => $exception->getMessage() @@ -154,7 +154,7 @@ class BaseAdminController extends BaseController // Log the error message Tlog::getInstance()->error( - Translator::getInstance()->trans( + $this->getTranslator()->trans( "Error during %action process : %error. Exception was %exc", array( '%action' => $action, diff --git a/core/lib/Thelia/Controller/Admin/CategoryController.php b/core/lib/Thelia/Controller/Admin/CategoryController.php index 73104349c..27cffd059 100755 --- a/core/lib/Thelia/Controller/Admin/CategoryController.php +++ b/core/lib/Thelia/Controller/Admin/CategoryController.php @@ -34,6 +34,7 @@ use Thelia\Core\Event\CategoryToggleVisibilityEvent; use Thelia\Core\Event\CategoryChangePositionEvent; use Thelia\Form\CategoryDeletionForm; use Thelia\Model\Lang; +use Thelia\Core\Translation\Translator; class CategoryController extends BaseAdminController { @@ -244,31 +245,53 @@ class CategoryController extends BaseAdminController } catch (FormValidationException $ex) { // Invalid data entered - $error_msg = sprintf("Please check your input: %s", $ex->getMessage()); + $error_msg = $this->getTranslator()->trans( + "Please check your input: %message", array("%message" => $ex->getMessage())); } catch (\Exception $ex) { // Any other error $error_msg = $ex; } - if ($error_msg !== false) { - // Log error currency - Tlog::getInstance()->error(sprintf("Error during currency modification process : %s. Exception was %s", $error_msg, $ex->getMessage())); + $this->setupFormErrorContext( + $form, + $error_msg, + "category" - // Mark the form as errored - $changeForm->setErrorMessage($error_msg); - // Pas the form and the error to the parser - $this->getParserContext() - ->addForm($changeForm) - ->setGeneralError($error_msg) - ; - } // 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) + ; + } + + } + /** * Sets the default currency */ @@ -293,25 +316,7 @@ class CategoryController extends BaseAdminController } /** - * Update categories rates - */ - public function updateRatesAction() { - // Check current user authorization - if (null !== $response = $this->checkAuth("admin.categories.update")) return $response; - - try { - $this->dispatch(TheliaEvents::CATEGORY_UPDATE_RATES); - } - catch (\Exception $ex) { - // Any error - return $this->errorPage($ex); - } - - $this->redirectToRoute('admin.categories.default'); - } - - /** - * Update currencyposition + * Update currency position */ public function updatePositionAction() { // Check current user authorization @@ -363,4 +368,4 @@ class CategoryController extends BaseAdminController $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 e7d6674b8..17b24530e 100644 --- a/core/lib/Thelia/Controller/Admin/ConfigController.php +++ b/core/lib/Thelia/Controller/Admin/ConfigController.php @@ -229,7 +229,7 @@ class ConfigController extends BaseAdminController if ($this->getRequest()->get('save_mode') == 'stay') { $this->redirectToRoute( - "admin.configuration.variables.change", + "admin.configuration.variables.update", array('variable_id' => $variable_id) ); } @@ -246,7 +246,7 @@ class ConfigController extends BaseAdminController $message = $ex->getMessage(); } - $this->setupFormErrorContext("variable edition", $message, $creationForm, $ex); + $this->setupFormErrorContext("variable edition", $message, $changeForm, $ex); // At this point, the form has errors, and should be redisplayed. return $this->render('variable-edit', array('variable_id' => $variable_id)); diff --git a/core/lib/Thelia/Controller/Admin/CurrencyController.php b/core/lib/Thelia/Controller/Admin/CurrencyController.php index d5b984cfb..4d0a2cc06 100644 --- a/core/lib/Thelia/Controller/Admin/CurrencyController.php +++ b/core/lib/Thelia/Controller/Admin/CurrencyController.php @@ -121,26 +121,14 @@ class CurrencyController 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 currency 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("currency creation", $error_msg, $creationForm, $ex); // At this point, the form has error, and should be redisplayed. return $this->renderList(); @@ -241,27 +229,15 @@ class CurrencyController extends BaseAdminController $this->redirect($changeForm->getSuccessUrl()); } catch (FormValidationException $ex) { - // Invalid data entered - $error_msg = sprintf("Please check your input: %s", $ex->getMessage()); + // Form cannot be validated + $error_msg = $this->createStandardFormValidationErrorMessage($ex); } catch (\Exception $ex) { // Any other error - $error_msg = $ex; + $error_msg = $ex->getMessage(); } - if ($error_msg !== false) { - // Log error currency - Tlog::getInstance()->error(sprintf("Error during currency modification process : %s. Exception was %s", $error_msg, $ex->getMessage())); - - // Mark the form as errored - $changeForm->setErrorMessage($error_msg); - - // Pas the form and the error to the parser - $this->getParserContext() - ->addForm($changeForm) - ->setGeneralError($error_msg) - ; - } + $this->setupFormErrorContext("currency 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)); diff --git a/core/lib/Thelia/Controller/Admin/MessageController.php b/core/lib/Thelia/Controller/Admin/MessageController.php index c024a5d34..8c042aa0d 100644 --- a/core/lib/Thelia/Controller/Admin/MessageController.php +++ b/core/lib/Thelia/Controller/Admin/MessageController.php @@ -100,26 +100,14 @@ class MessageController extends BaseAdminController } catch (FormValidationException $ex) { // Form cannot be validated - $message = sprintf("Please check your input: %s", $ex->getMessage()); + $message = $this->createStandardFormValidationErrorMessage($ex); } catch (\Exception $ex) { // Any other error - $message = sprintf("Sorry, an error occured: %s", $ex->getMessage()); + $message = $ex->getMessage(); } - if ($message !== false) { - // An error has been detected: log it - Tlog::getInstance()->error(sprintf("Error during message creation process : %s. Exception was %s", $message, $ex->getMessage())); - - // Mark the form as errored - $creationForm->setErrorMessage($message); - - // Pass it to the parser, along with the error message - $this->getParserContext() - ->addForm($creationForm) - ->setGeneralError($message) - ; - } + $this->setupFormErrorContext("message modification", $message, $creationForm, $ex); // At this point, the form has error, and should be redisplayed. return $this->render('messages'); @@ -224,27 +212,15 @@ class MessageController extends BaseAdminController $this->redirect($changeForm->getSuccessUrl()); } catch (FormValidationException $ex) { - // Invalid data entered - $message = sprintf("Please check your input: %s", $ex->getMessage()); + // Form cannot be validated + $message = $this->createStandardFormValidationErrorMessage($ex); } catch (\Exception $ex) { // Any other error - $message = sprintf("Sorry, an error occured: %s", $ex->getMessage()); + $message = $ex->getMessage(); } - if ($message !== false) { - // Log error message - Tlog::getInstance()->error(sprintf("Error during message modification process : %s. Exception was %s", $message, $ex->getMessage())); - - // Mark the form as errored - $changeForm->setErrorMessage($message); - - // Pas the form and the error to the parser - $this->getParserContext() - ->addForm($changeForm) - ->setGeneralError($message) - ; - } + $this->setupFormErrorContext("message modification", $message, $changeForm, $ex); // At this point, the form has errors, and should be redisplayed. return $this->render('message-edit', array('message_id' => $message_id)); diff --git a/core/lib/Thelia/Controller/Admin/SessionController.php b/core/lib/Thelia/Controller/Admin/SessionController.php index a377df208..d7385ad1b 100755 --- a/core/lib/Thelia/Controller/Admin/SessionController.php +++ b/core/lib/Thelia/Controller/Admin/SessionController.php @@ -73,32 +73,34 @@ class SessionController extends BaseAdminController // Redirect to the success URL return Redirect::exec($adminLoginForm->getSuccessUrl()); - } catch (ValidatorException $ex) { + + } + catch (FormValidationException $ex) { // Validation problem - $message = "Missing or invalid information. Please check your input."; - } catch (AuthenticationException $ex) { + $message = $this->createStandardFormValidationErrorMessage($ex); + } + catch (AuthenticationException $ex) { // Log authentication failure AdminLog::append(sprintf("Authentication failure for username '%s'", $authenticator->getUsername()), $request); - $message = "Login failed. Please check your username and password."; - } catch (\Exception $ex) { + $message = $this->getTranslator()->trans("Login failed. Please check your username and password."); + } + catch (\Exception $ex) { // Log authentication failure AdminLog::append(sprintf("Undefined error: %s", $ex->getMessage()), $request); - $message = "Unable to process your request. Please try again.".$ex->getMessage(); + $message = $this->getTranslator()->trans( + "Unable to process your request. Please try again (%err).", + array("%err" => $ex->getMessage()) + ); } - // Store error information in the form - $adminLoginForm->setError(true); - $adminLoginForm->setErrorMessage($message); - - // Store the form name in session (see Form Smarty plugin to find usage of this parameter) - $this->getParserContext()->addForm($adminLoginForm); + $this->setupFormErrorContext("Login process", $message, $adminLoginForm, $ex); // Display the login form again return $this->render("login"); } -} +} \ No newline at end of file diff --git a/core/lib/Thelia/Controller/BaseController.php b/core/lib/Thelia/Controller/BaseController.php index 853776214..5fbcc56d2 100755 --- a/core/lib/Thelia/Controller/BaseController.php +++ b/core/lib/Thelia/Controller/BaseController.php @@ -215,7 +215,7 @@ class BaseController extends ContainerAware $route = $this->container->get($routerName)->getRouteCollection()->get($routeId); if ($route == null) { - throw new InvalidArgumentException(sprintf("Route ID '%s' does not exists.", $routeId)); + throw new \InvalidArgumentException(sprintf("Route ID '%s' does not exists.", $routeId)); } return $route->getPath(); diff --git a/core/lib/Thelia/Core/Event/CategoryToggleVisibilityEvent.php b/core/lib/Thelia/Core/Event/CategoryToggleVisibilityEvent.php index ef921a0de..4b4d6dc88 100644 --- a/core/lib/Thelia/Core/Event/CategoryToggleVisibilityEvent.php +++ b/core/lib/Thelia/Core/Event/CategoryToggleVisibilityEvent.php @@ -24,7 +24,7 @@ namespace Thelia\Core\Event; use Thelia\Model\Category; -class CategoryToggleVisibilityEvent extends ActionEvent +class CategoryToggleVisibilityEvent extends CategoryEvent { protected $category_id; protected $category; diff --git a/core/lib/Thelia/Form/BaseDescForm.php b/core/lib/Thelia/Form/BaseDescForm.php index c4f4f90c3..2b35f3e6e 100644 --- a/core/lib/Thelia/Form/BaseDescForm.php +++ b/core/lib/Thelia/Form/BaseDescForm.php @@ -43,12 +43,31 @@ abstract class BaseDescForm extends BaseForm ->add("title", "text", array( "constraints" => array( new NotBlank() + ), + "label" => "Title", + "label_attr" => array( + "for" => "title" ) ) ) - ->add("chapo", "text", array()) - ->add("description", "text", array()) - ->add("postscriptum", "text", array()) + ->add("chapo", "text", array( + "label" => "Summary", + "label_attr" => array( + "for" => "summary" + ) + )) + ->add("description", "text", array( + "label" => "Detailed description", + "label_attr" => array( + "for" => "detailed_description" + ) + )) + ->add("postscriptum", "text", array( + "label" => "Conclusion", + "label_attr" => array( + "for" => "conclusion" + ) + )) ; } } \ No newline at end of file diff --git a/core/lib/Thelia/Form/BaseForm.php b/core/lib/Thelia/Form/BaseForm.php index 870f94505..0eb6b828b 100755 --- a/core/lib/Thelia/Form/BaseForm.php +++ b/core/lib/Thelia/Form/BaseForm.php @@ -141,6 +141,8 @@ abstract class BaseForm public function createView() { $this->view = $this->form->createView(); + + return $this; } public function getView() @@ -159,6 +161,8 @@ abstract class BaseForm public function setError($has_error = true) { $this->has_error = $has_error; + + return $this; } /** @@ -180,6 +184,8 @@ abstract class BaseForm { $this->setError(true); $this->error_message = $message; + + return $this; } /** diff --git a/core/lib/Thelia/Form/CategoryCreationForm.php b/core/lib/Thelia/Form/CategoryCreationForm.php index 9935eec19..a125ad090 100755 --- a/core/lib/Thelia/Form/CategoryCreationForm.php +++ b/core/lib/Thelia/Form/CategoryCreationForm.php @@ -32,6 +32,10 @@ class CategoryCreationForm extends BaseForm ->add("title", "text", array( "constraints" => array( new NotBlank() + ), + "label" => "Category title *", + "label_attr" => array( + "for" => "title" ) )) ->add("parent", "integer", array( diff --git a/core/lib/Thelia/Form/ConfigCreationForm.php b/core/lib/Thelia/Form/ConfigCreationForm.php index 5594830bc..b2a0c11bb 100644 --- a/core/lib/Thelia/Form/ConfigCreationForm.php +++ b/core/lib/Thelia/Form/ConfigCreationForm.php @@ -40,11 +40,19 @@ class ConfigCreationForm extends BaseForm $this->formBuilder ->add("name", "text", array( - "constraints" => $name_constraints + "constraints" => $name_constraints, + "label" => "Name *", + "label_attr" => array( + "for" => "name" + ) )) ->add("title", "text", array( "constraints" => array( new Constraints\NotBlank() + ), + "label" => "Purpose *", + "label_attr" => array( + "for" => "purpose" ) )) ->add("locale", "hidden", array( @@ -52,9 +60,16 @@ class ConfigCreationForm extends BaseForm new Constraints\NotBlank() ) )) - ->add("value", "text", array()) + ->add("value", "text", array( + "label" => "Value *", + "label_attr" => array( + "for" => "value" + ) + )) ->add("hidden", "hidden", array()) - ->add("secured", "hidden", array()) + ->add("secured", "hidden", array( + "label" => "Prevent variable modification or deletion, except for super-admin" + )) ; } diff --git a/core/lib/Thelia/Form/ConfigModificationForm.php b/core/lib/Thelia/Form/ConfigModificationForm.php index dd0a0e42f..295c0403d 100644 --- a/core/lib/Thelia/Form/ConfigModificationForm.php +++ b/core/lib/Thelia/Form/ConfigModificationForm.php @@ -44,11 +44,22 @@ class ConfigModificationForm extends BaseDescForm ->add("name", "text", array( "constraints" => array( new NotBlank() + ), + "label" => "Name", + "label_attr" => array( + "for" => "name" + ) + )) + ->add("value", "text", array( + "label" => "Value", + "label_attr" => array( + "for" => "value" ) )) - ->add("value", "text", array()) ->add("hidden", "hidden", array()) - ->add("secured", "hidden", array()) + ->add("secured", "hidden", array( + "label" => "Prevent variable modification or deletion, except for super-admin" + )) ; } diff --git a/core/lib/Thelia/Form/MessageCreationForm.php b/core/lib/Thelia/Form/MessageCreationForm.php index a3444c733..6ce84cb06 100644 --- a/core/lib/Thelia/Form/MessageCreationForm.php +++ b/core/lib/Thelia/Form/MessageCreationForm.php @@ -40,11 +40,19 @@ class MessageCreationForm extends BaseForm $this->formBuilder ->add("name", "text", array( - "constraints" => $name_constraints + "constraints" => $name_constraints, + "label" => "Name *", + "label_attr" => array( + "for" => "name" + ) )) ->add("title", "text", array( "constraints" => array( new Constraints\NotBlank() + ), + "label" => "Purpose *", + "label_attr" => array( + "for" => "purpose" ) )) ->add("locale", "hidden", array( diff --git a/core/lib/Thelia/Form/MessageModificationForm.php b/core/lib/Thelia/Form/MessageModificationForm.php index 539a8babc..a23f66e28 100644 --- a/core/lib/Thelia/Form/MessageModificationForm.php +++ b/core/lib/Thelia/Form/MessageModificationForm.php @@ -33,13 +33,43 @@ class MessageModificationForm extends BaseForm { $this->formBuilder ->add("id" , "hidden", array("constraints" => array(new GreaterThan(array('value' => 0))))) - ->add("name" , "text" , array("constraints" => array(new NotBlank()))) - ->add("secured" , "text" , array()) + ->add("name" , "text" , array( + "constraints" => array(new NotBlank()), + "label" => "Name *", + "label_attr" => array( + "for" => "name" + ) + )) + ->add("secured" , "text" , array( + "label" => "Prevent mailing template modification or deletion, except for super-admin" + )) ->add("locale" , "text" , array()) - ->add("title" , "text" , array("constraints" => array(new NotBlank()))) - ->add("subject" , "text" , array("constraints" => array(new NotBlank()))) - ->add("html_message" , "text" , array()) - ->add("text_message" , "text" , array()) + ->add("title" , "text" , array( + "constraints" => array(new NotBlank()), + "label" => "Title *", + "label_attr" => array( + "for" => "title" + ) + )) + ->add("subject" , "text" , array( + "constraints" => array(new NotBlank()), + "label" => "Message subject *", + "label_attr" => array( + "for" => "subject" + ) + )) + ->add("html_message" , "text" , array( + "label" => "HTML Message", + "label_attr" => array( + "for" => "html_message" + ) + )) + ->add("text_message" , "text" , array( + "label" => "Text Message", + "label_attr" => array( + "for" => "text_message" + ) + )) ; } diff --git a/templates/admin/default/assets/less/thelia/variables.less b/templates/admin/default/assets/less/thelia/variables.less index dec523afc..35bc931b5 100755 --- a/templates/admin/default/assets/less/thelia/variables.less +++ b/templates/admin/default/assets/less/thelia/variables.less @@ -44,4 +44,10 @@ // Used for a bird's eye view of components dependent on the z-axis // Try to avoid customizing these :) -@zindex-dropdown: 1005; \ No newline at end of file +@zindex-dropdown: 1005; + +// Forms +// ------------------------- + + +@input-border-focus: @link-color; \ No newline at end of file diff --git a/templates/admin/default/categories.html b/templates/admin/default/categories.html index 5e3e28018..777fd4e4d 100755 --- a/templates/admin/default/categories.html +++ b/templates/admin/default/categories.html @@ -269,6 +269,7 @@ {module_include location='product_list_row'} +<<<<<<< HEAD {loop type="auth" name="can_change" roles="ADMIN" permissions="admin.products.edit"}
@@ -280,6 +281,11 @@
{/elseloop} +======= +
+ +
+>>>>>>> ebb350111a2c65929f8c61f621c9a8a6dd878984 @@ -312,7 +318,7 @@ {elseloop rel="product_list"} -
{intl l="This category doesn't have any products. To add a new product, click the + button above."}
+
{intl l="This category doesn't have any products. To add a new product, click the + button above."}
{/elseloop} @@ -436,6 +442,7 @@ {/javascripts} +<<<<<<< HEAD +======= + +>>>>>>> ebb350111a2c65929f8c61f621c9a8a6dd878984 {/block} \ No newline at end of file diff --git a/templates/admin/default/includes/add-category-dialog.html b/templates/admin/default/includes/add-category-dialog.html new file mode 100755 index 000000000..631d0c06e --- /dev/null +++ b/templates/admin/default/includes/add-category-dialog.html @@ -0,0 +1,70 @@ + +{* Adding a new Category *} + + \ No newline at end of file diff --git a/templates/admin/default/includes/delete-category-dialog.html b/templates/admin/default/includes/delete-category-dialog.html new file mode 100755 index 000000000..38e93a340 --- /dev/null +++ b/templates/admin/default/includes/delete-category-dialog.html @@ -0,0 +1,48 @@ + +{* Adding a new Category *} + + diff --git a/templates/admin/default/includes/standard-description-form-fields.html b/templates/admin/default/includes/standard-description-form-fields.html index e70092316..0030af54f 100644 --- a/templates/admin/default/includes/standard-description-form-fields.html +++ b/templates/admin/default/includes/standard-description-form-fields.html @@ -1,60 +1,41 @@ {* The standard description fields, used by many Thelia objects *} {form_field form=$form field='title'} -
- - -
- - - -
+
+ +
{/form_field} {form_field form=$form field='chapo'} -
-