diff --git a/core/lib/Thelia/Controller/Admin/BaseAdminController.php b/core/lib/Thelia/Controller/Admin/BaseAdminController.php index 87aff7dd9..298cd0182 100755 --- a/core/lib/Thelia/Controller/Admin/BaseAdminController.php +++ b/core/lib/Thelia/Controller/Admin/BaseAdminController.php @@ -36,6 +36,7 @@ use Thelia\Model\Lang; use Thelia\Model\LangQuery; use Thelia\Form\BaseForm; use Thelia\Form\Exception\FormValidationException; +use Thelia\Log\Tlog; class BaseAdminController extends BaseController { @@ -94,7 +95,7 @@ class BaseAdminController extends BaseController protected function errorPage($message) { if ($message instanceof \Exception) { - $message = sprintf("Sorry, an error occured: %s", $message->getMessage()); + $message = sprintf($this->getTranslator()->trans("Sorry, an error occured: %msg"), array('msg' => $message->getMessage())); } return $this->render('general_error', array( @@ -125,7 +126,7 @@ class BaseAdminController extends BaseController // Generate the proper response $response = new Response(); - return $response->setContent($this->errorPage("Sorry, you're not allowed to perform this action")); + return $this->errorPage($this->getTranslator()->trans("Sorry, you're not allowed to perform this action")); } /* @@ -164,7 +165,7 @@ class BaseAdminController extends BaseController ) ); - if ($fom != null) { + if ($form != null) { // Mark the form as errored $form->setErrorMessage($error_message); @@ -312,7 +313,7 @@ class BaseAdminController extends BaseController } catch (AuthorizationException $ex) { // User is not allowed to perform the required action. Return the error page instead of the requested page. - return $this->errorPage("Sorry, you are not allowed to perform this action."); + return $this->errorPage($this->getTranslator()->trans("Sorry, you are not allowed to perform this action.")); } } } diff --git a/core/lib/Thelia/Controller/Admin/CategoryController.php b/core/lib/Thelia/Controller/Admin/CategoryController.php index 81769cd29..6acbbd707 100755 --- a/core/lib/Thelia/Controller/Admin/CategoryController.php +++ b/core/lib/Thelia/Controller/Admin/CategoryController.php @@ -36,6 +36,7 @@ use Thelia\Form\CategoryDeletionForm; use Thelia\Model\Lang; use Thelia\Core\Translation\Translator; use Thelia\Core\Event\CategoryUpdatePositionEvent; +use Thelia\Model\CategoryQuery; class CategoryController extends BaseAdminController { @@ -107,8 +108,6 @@ class CategoryController extends BaseAdminController $data = $form->getData(); - $createEvent = new CategoryCreateEvent(); - $createEvent = new CategoryCreateEvent( $data["title"], $data["parent"], @@ -122,7 +121,7 @@ class CategoryController extends BaseAdminController $createdObject = $createEvent->getCategory(); // Log category creation - $this->adminLogAppend(sprintf("Category %s (ID %s) created", $createdObject->getName(), $createdObject->getId())); + $this->adminLogAppend(sprintf("Category %s (ID %s) created", $createdObject->getTitle(), $createdObject->getId())); // Substitute _ID_ in the URL with the ID of the created object $successUrl = str_replace('_ID_', $createdObject->getId(), $creationForm->getSuccessUrl()); @@ -157,19 +156,17 @@ class CategoryController extends BaseAdminController // Load the category object $category = CategoryQuery::create() - ->joinWithI18n($this->getCurrentEditionLocale()) - ->findOneById($this->getRequest()->get('category_id')); + ->joinWithI18n($this->getCurrentEditionLocale()) + ->findOneById($this->getRequest()->get('category_id')); if ($category != null) { // Prepare the data that will hydrate the form $data = array( 'id' => $category->getId(), - 'name' => $category->getName(), + 'name' => $category->getTitle(), 'locale' => $category->getLocale(), - 'code' => $category->getCode(), - 'symbol' => $category->getSymbol(), - 'rate' => $category->getRate() + // tbc !!! ); // Setup the object form @@ -227,7 +224,7 @@ class CategoryController extends BaseAdminController // Log category modification $changedObject = $changeEvent->getCategory(); - $this->adminLogAppend(sprintf("Category %s (ID %s) modified", $changedObject->getName(), $changedObject->getId())); + $this->adminLogAppend(sprintf("Category %s (ID %s) modified", $changedObject->getTitle(), $changedObject->getId())); // If we have to stay on the same page, do not redirect to the succesUrl, // just redirect to the edit page again. diff --git a/core/lib/Thelia/Core/Event/BaseToggleVisibilityEvent.php b/core/lib/Thelia/Core/Event/BaseToggleVisibilityEvent.php new file mode 100644 index 000000000..2dbd54374 --- /dev/null +++ b/core/lib/Thelia/Core/Event/BaseToggleVisibilityEvent.php @@ -0,0 +1,48 @@ +. */ +/* */ +/*************************************************************************************/ + +namespace Thelia\Core\Event; + + +class BaseToggleVisibilityEvent extends ActionEvent +{ + protected $object_id; + + protected $object; + + public function __construct($object_id) + { + $this->object_id = $object_id; + } + + public function getObjectId() + { + return $this->object_id; + } + + public function setObjectId($object_id) + { + $this->object_id = $object_id; + return $this; + } +} \ No newline at end of file diff --git a/core/lib/Thelia/Core/Template/Assets/AsseticHelper.php b/core/lib/Thelia/Core/Template/Assets/AsseticHelper.php index bf0b7450e..cd7f06ac8 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/ProductCreationForm.php b/core/lib/Thelia/Form/ProductCreationForm.php new file mode 100644 index 000000000..396f6d0d5 --- /dev/null +++ b/core/lib/Thelia/Form/ProductCreationForm.php @@ -0,0 +1,67 @@ +. */ +/* */ +/*************************************************************************************/ +namespace Thelia\Form; + +use Symfony\Component\Validator\Constraints\NotBlank; + +class ProductCreationForm extends BaseForm +{ + protected function buildForm() + { + $this->formBuilder + ->add("ref", "text", array( + "constraints" => array( + new NotBlank() + ), + "label" => "Product reference *", + "label_attr" => array( + "for" => "ref" + ) + )) + ->add("title", "text", array( + "constraints" => array( + new NotBlank() + ), + "label" => "Product title *", + "label_attr" => array( + "for" => "title" + ) + )) + ->add("parent", "integer", array( + "constraints" => array( + new NotBlank() + ) + )) + ->add("locale", "text", array( + "constraints" => array( + new NotBlank() + ) + )) + ; + } + + public function getName() + { + return "thelia_product_creation"; + } +} diff --git a/core/lib/Thelia/Form/StandardDescriptionFieldsTrait.php b/core/lib/Thelia/Form/StandardDescriptionFieldsTrait.php new file mode 100644 index 000000000..98bc53b08 --- /dev/null +++ b/core/lib/Thelia/Form/StandardDescriptionFieldsTrait.php @@ -0,0 +1,58 @@ +. */ +/* */ +/*************************************************************************************/ +namespace Thelia\Form; + +use Symfony\Component\Validator\Constraints\NotBlank; + +/** + * This form defines all standard description fields: + * - title + * - chapo + * - description + * - postscriptum + * + * @author Franck Allimant + */ +Trait StandardDescriptionFieldsTrait +{ + protected function addStandardDescriptionFields() + { + $this->formBuilder + ->add("locale", "hidden", array( + "constraints" => array( + new NotBlank() + ) + ) + ) + ->add("title", "text", array( + "constraints" => array( + new NotBlank() + ) + ) + ) + ->add("chapo", "text", array()) + ->add("description", "text", array()) + ->add("postscriptum", "text", array()) + ; + } +} \ No newline at end of file diff --git a/core/lib/Thelia/Model/Tools/PositionManagementTrait.php b/core/lib/Thelia/Model/Tools/PositionManagementTrait.php index 9e0b1f35c..eb71564eb 100644 --- a/core/lib/Thelia/Model/Tools/PositionManagementTrait.php +++ b/core/lib/Thelia/Model/Tools/PositionManagementTrait.php @@ -55,7 +55,7 @@ trait PositionManagementTrait { ->orderByPosition(Criteria::DESC) ->limit(1); - if ($parent !== null) $last->filterByParent($parent); + if ($parent !== null) $query->filterByParent($parent); $last = $query->findOne() ; diff --git a/templates/admin/default/categories.html b/templates/admin/default/categories.html index 0788a87d2..a0367bad5 100755 --- a/templates/admin/default/categories.html +++ b/templates/admin/default/categories.html @@ -327,94 +327,87 @@ {* Adding a new Category *} - + dialog_id = "add_category_dialog" + dialog_title = {intl l="Create a new category"} + dialog_body = {$smarty.capture.category_creation_dialog nofilter} + + dialog_ok_label = {intl l="Create this category"} + dialog_cancel_label = {intl l="Cancel"} + + form_action = {url path='/admin/categories/create'} + form_enctype = $creation_form_enctype + form_error_message = {$creation_form_error|default:''} + } {* Delete category confirmation dialog *} - + dialog_id = "delete_category_dialog" + dialog_title = {intl l="Delete a category"} + dialog_message = {intl l="Do you really want to delete this category, and all its contents ?"} + form_action = {url path='/admin/categories/delete'} + form_content = {$smarty.capture.category_delete_dialog nofilter} + } {/block} {block name="javascript-initialization"} diff --git a/templates/admin/default/includes/add-category-dialog.html b/templates/admin/default/includes/add-category-dialog.html deleted file mode 100755 index 631d0c06e..000000000 --- a/templates/admin/default/includes/add-category-dialog.html +++ /dev/null @@ -1,70 +0,0 @@ - -{* Adding a new Category *} - - \ No newline at end of file diff --git a/templates/admin/default/includes/catalog-breadcrumb.html b/templates/admin/default/includes/catalog-breadcrumb.html new file mode 100644 index 000000000..b9312f0dd --- /dev/null +++ b/templates/admin/default/includes/catalog-breadcrumb.html @@ -0,0 +1,26 @@ +{* Breadcrumb for categories browsing and editing *} + + \ 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 deleted file mode 100755 index 38e93a340..000000000 --- a/templates/admin/default/includes/delete-category-dialog.html +++ /dev/null @@ -1,48 +0,0 @@ - -{* Adding a new Category *} - - diff --git a/templates/admin/default/includes/generic-confirm-dialog.html b/templates/admin/default/includes/generic-confirm-dialog.html new file mode 100644 index 000000000..b5f3ad700 --- /dev/null +++ b/templates/admin/default/includes/generic-confirm-dialog.html @@ -0,0 +1,43 @@ +{* + +A generic modal confirmation dialog template. + +Parameters: + + dialog_id = the dialog id attribute + dialog_title = the dialog title + dialog_message = the dialog confirmation message + + dialog_ok_label = The OK button label (default: yes) + dialog_cancel_label = The Cancel button label (default: no) + + form_action = the form action URL, subtitted by a click on OK button + form_method = the form method, default "POST" + form_content = the form content + +*} + \ No newline at end of file diff --git a/templates/admin/default/includes/generic-create-dialog.html b/templates/admin/default/includes/generic-create-dialog.html new file mode 100755 index 000000000..c6a00a01b --- /dev/null +++ b/templates/admin/default/includes/generic-create-dialog.html @@ -0,0 +1,43 @@ +{* + +A generic modal creation dialog template. Parameters + + dialog_id = the dialog id attribute + dialog_title = the dialog title + dialog_body = the dialog body. In most cases, this is a creation form + + dialog_ok_label = The OK button label. Default create + dialog_cancel_label = The cancel button label. Default create + + form_action = The form action URL. Form is submitted when OK button is clicked + form_enctype = The form encoding + form_error_message = The form error message (optional) +*} +