diff --git a/core/lib/Thelia/Action/AttributeValue.php b/core/lib/Thelia/Action/AttributeAv.php similarity index 73% rename from core/lib/Thelia/Action/AttributeValue.php rename to core/lib/Thelia/Action/AttributeAv.php index 8524f6054..53df7aa72 100644 --- a/core/lib/Thelia/Action/AttributeValue.php +++ b/core/lib/Thelia/Action/AttributeAv.php @@ -25,29 +25,27 @@ namespace Thelia\Action; use Symfony\Component\EventDispatcher\EventSubscriberInterface; -use Thelia\Model\AttributeQuery; -use Thelia\Model\Attribute as AttributeModel; +use Thelia\Model\AttributeAvQuery; +use Thelia\Model\AttributeAv as AttributeAvModel; use Thelia\Core\Event\TheliaEvents; -use Thelia\Core\Event\AttributeUpdateEvent; -use Thelia\Core\Event\AttributeCreateEvent; -use Thelia\Core\Event\AttributeDeleteEvent; +use Thelia\Core\Event\AttributeAvUpdateEvent; +use Thelia\Core\Event\AttributeAvCreateEvent; +use Thelia\Core\Event\AttributeAvDeleteEvent; use Thelia\Model\ConfigQuery; -use Thelia\Model\AttributeAv; -use Thelia\Model\AttributeAvQuery; use Thelia\Core\Event\UpdatePositionEvent; -class Attribute extends BaseAction implements EventSubscriberInterface +class AttributeAv extends BaseAction implements EventSubscriberInterface { /** * Create a new attribute entry * - * @param AttributeCreateEvent $event + * @param AttributeAvCreateEvent $event */ - public function create(AttributeCreateEvent $event) + public function create(AttributeAvCreateEvent $event) { - $attribute = new AttributeModel(); + $attribute = new AttributeAvModel(); $attribute ->setDispatcher($this->getDispatcher()) @@ -58,7 +56,7 @@ class Attribute extends BaseAction implements EventSubscriberInterface ->save() ; - $event->setAttribute($attribute); + $event->setAttributeAv($attribute); // Add atribute to all product templates if required if ($event->getAddToAllTemplates() != 0) { @@ -69,13 +67,13 @@ class Attribute extends BaseAction implements EventSubscriberInterface /** * Change a product attribute * - * @param AttributeUpdateEvent $event + * @param AttributeAvUpdateEvent $event */ - public function update(AttributeUpdateEvent $event) + public function update(AttributeAvUpdateEvent $event) { - $search = AttributeQuery::create(); + $search = AttributeAvQuery::create(); - if (null !== $attribute = AttributeQuery::create()->findPk($event->getAttributeId())) { + if (null !== $attribute = AttributeAvQuery::create()->findPk($event->getAttributeAvId())) { $attribute ->setDispatcher($this->getDispatcher()) @@ -88,26 +86,26 @@ class Attribute extends BaseAction implements EventSubscriberInterface ->save(); - $event->setAttribute($attribute); + $event->setAttributeAv($attribute); } } /** * Delete a product attribute entry * - * @param AttributeDeleteEvent $event + * @param AttributeAvDeleteEvent $event */ - public function delete(AttributeDeleteEvent $event) + public function delete(AttributeAvDeleteEvent $event) { - if (null !== ($attribute = AttributeQuery::create()->findPk($event->getAttributeId()))) { + if (null !== ($attribute = AttributeAvQuery::create()->findPk($event->getAttributeAvId()))) { $attribute ->setDispatcher($this->getDispatcher()) ->delete() ; - $event->setAttribute($attribute); + $event->setAttributeAv($attribute); } } @@ -118,7 +116,7 @@ class Attribute extends BaseAction implements EventSubscriberInterface */ public function updatePosition(UpdatePositionEvent $event) { - if (null !== $attribute = AttributeQuery::create()->findPk($event->getObjectId())) { + if (null !== $attribute = AttributeAvQuery::create()->findPk($event->getObjectId())) { $attribute->setDispatcher($this->getDispatcher()); @@ -140,10 +138,10 @@ class Attribute extends BaseAction implements EventSubscriberInterface public static function getSubscribedEvents() { return array( - TheliaEvents::ATTRIBUTE_CREATE => array("create", 128), - TheliaEvents::ATTRIBUTE_UPDATE => array("update", 128), - TheliaEvents::ATTRIBUTE_DELETE => array("delete", 128), - TheliaEvents::ATTRIBUTE_UPDATE_POSITION => array("updatePosition", 128), + TheliaEvents::ATTRIBUTE_AV_CREATE => array("create", 128), + TheliaEvents::ATTRIBUTE_AV_UPDATE => array("update", 128), + TheliaEvents::ATTRIBUTE_AV_DELETE => array("delete", 128), + TheliaEvents::ATTRIBUTE_AV_UPDATE_POSITION => array("updatePosition", 128), ); } } \ No newline at end of file diff --git a/core/lib/Thelia/Config/Resources/action.xml b/core/lib/Thelia/Config/Resources/action.xml index 07e4637ee..842acdc6f 100755 --- a/core/lib/Thelia/Config/Resources/action.xml +++ b/core/lib/Thelia/Config/Resources/action.xml @@ -62,6 +62,11 @@ + + + + + diff --git a/core/lib/Thelia/Config/Resources/routing/admin.xml b/core/lib/Thelia/Config/Resources/routing/admin.xml index 75d9b0984..69958f115 100755 --- a/core/lib/Thelia/Config/Resources/routing/admin.xml +++ b/core/lib/Thelia/Config/Resources/routing/admin.xml @@ -48,7 +48,7 @@ Thelia\Controller\Admin\OrderController::indexAction - + Thelia\Controller\Admin\OrderController::viewAction @@ -68,11 +68,11 @@ - Thelia\Controller\Admin\CategoryController::changeAction + Thelia\Controller\Admin\CategoryController::updateAction - Thelia\Controller\Admin\CategoryController::saveChangeAction + Thelia\Controller\Admin\CategoryController::processUpdateAction @@ -129,11 +129,11 @@ - Thelia\Controller\Admin\ConfigController::changeAction + Thelia\Controller\Admin\ConfigController::updateAction - Thelia\Controller\Admin\ConfigController::saveChangeAction + Thelia\Controller\Admin\ConfigController::processUpdateAction @@ -151,11 +151,11 @@ - Thelia\Controller\Admin\MessageController::changeAction + Thelia\Controller\Admin\MessageController::updateAction - Thelia\Controller\Admin\MessageController::saveChangeAction + Thelia\Controller\Admin\MessageController::processUpdateAction @@ -173,11 +173,11 @@ - Thelia\Controller\Admin\CurrencyController::changeAction + Thelia\Controller\Admin\CurrencyController::updateAction - Thelia\Controller\Admin\CurrencyController::saveChangeAction + Thelia\Controller\Admin\CurrencyController::processUpdateAction @@ -200,7 +200,8 @@ Thelia\Controller\Admin\CurrencyController::updatePositionAction - + + Thelia\Controller\Admin\AttributeController::defaultAction @@ -210,30 +211,43 @@ Thelia\Controller\Admin\AttributeController::createAction - - Thelia\Controller\Admin\AttributeController::createValueAction - - - Thelia\Controller\Admin\AttributeController::changeAction + Thelia\Controller\Admin\AttributeController::updateAction - Thelia\Controller\Admin\AttributeController::saveChangeAction + Thelia\Controller\Admin\AttributeController::processUpdateAction Thelia\Controller\Admin\AttributeController::deleteAction - - Thelia\Controller\Admin\AttributeController::deleteValueAction - - Thelia\Controller\Admin\AttributeController::updatePositionAction + + + Thelia\Controller\Admin\AttributeAvController::createAction + + + + Thelia\Controller\Admin\AttributeAvController::updateAction + + + + Thelia\Controller\Admin\AttributeAvController::processUpdateAction + + + + Thelia\Controller\Admin\AttributeAvController::deleteAction + + + + Thelia\Controller\Admin\AttributeAvController::updatePositionAction + + diff --git a/core/lib/Thelia/Controller/Admin/AbstractCrudController.php b/core/lib/Thelia/Controller/Admin/AbstractCrudController.php index 6d32220b7..1dcbca01f 100644 --- a/core/lib/Thelia/Controller/Admin/AbstractCrudController.php +++ b/core/lib/Thelia/Controller/Admin/AbstractCrudController.php @@ -28,7 +28,7 @@ use Thelia\Core\Event\UpdatePositionEvent; use Thelia\Core\Event\ToggleVisibilityEvent; /** - * Manages currencies sent by mail + * An abstract CRUD controller for Thelia ADMIN, to manage basic CRUD operations on a givent object. * * @author Franck Allimant */ @@ -53,6 +53,23 @@ abstract class AbstractCrudController extends BaseAdminController protected $changePositionEventIdentifier; + /** + * @param string $objectName the lower case object name. Example. "message" + * + * @param string $defaultListOrder the default object list order, or null if list is not sortable. Example: manual + * + * @param string $viewPermissionIdentifier the 'view' permission identifier. Example: "admin.configuration.message.view" + * @param string $createPermissionIdentifier the 'create' permission identifier. Example: "admin.configuration.message.create" + * @param string $updatePermissionIdentifier the 'update' permission identifier. Example: "admin.configuration.message.update" + * @param string $deletePermissionIdentifier the 'delete' permission identifier. Example: "admin.configuration.message.delete" + * + * @param string $createEventIdentifier the dispatched create TheliaEvent identifier. Example: TheliaEvents::MESSAGE_CREATE + * @param string $updateEventIdentifier the dispatched update TheliaEvent identifier. Example: TheliaEvents::MESSAGE_UPDATE + * @param string $deleteEventIdentifier the dispatched delete TheliaEvent identifier. Example: TheliaEvents::MESSAGE_DELETE + * + * @param string $visibilityToggleEventIdentifier the dispatched visibility toggle TheliaEvent identifier, or null if the object has no visible options. Example: TheliaEvents::MESSAGE_TOGGLE_VISIBILITY + * @param string $changePositionEventIdentifier the dispatched position change TheliaEvent identifier, or null if the object has no position. Example: TheliaEvents::MESSAGE_UPDATE_POSITION + */ public function __construct( $objectName, @@ -187,15 +204,14 @@ abstract class AbstractCrudController extends BaseAdminController } /** - * Render the object list, ensuring the sort order is set. - * - * @return Symfony\Component\HttpFoundation\Response the response + * Return the current list order identifier, updating it in the same time. */ - protected function renderList() - { + protected function getCurrentListOrder($update_session = true) { + $order = null; - if ($this->defaultListOrder != null) { + if ($this->defaultListOrder) { + $orderSessionIdentifier = sprintf("admin.%s.currentListOrder", $this->objectName); // Find the current order @@ -204,11 +220,20 @@ abstract class AbstractCrudController extends BaseAdminController $this->getSession()->get($orderSessionIdentifier, $this->defaultListOrder) ); - // Store the current sort order in session - $this->getSession()->set($orderSessionIdentifier, $order); + if ($update_session) $this->getSession()->set($orderSessionIdentifier, $order); } - return $this->renderListTemplate($order); + return $order; + } + + /** + * Render the object list, ensuring the sort order is set. + * + * @return Symfony\Component\HttpFoundation\Response the response + */ + protected function renderList() + { + return $this->renderListTemplate($this->getCurrentListOrder()); } /** @@ -286,7 +311,7 @@ abstract class AbstractCrudController extends BaseAdminController * * @return Symfony\Component\HttpFoundation\Response the response */ - public function changeAction() + public function updateAction() { // Check current user authorization if (null !== $response = $this->checkAuth($this->updatePermissionIdentifier)) return $response; @@ -312,7 +337,7 @@ abstract class AbstractCrudController extends BaseAdminController * * @return Symfony\Component\HttpFoundation\Response the response */ - public function saveChangeAction() + public function processUpdateAction() { // Check current user authorization if (null !== $response = $this->checkAuth($this->updatePermissionIdentifier)) return $response; diff --git a/core/lib/Thelia/Controller/Admin/AttributeController.php b/core/lib/Thelia/Controller/Admin/AttributeController.php index d775c97c6..f6b76c0df 100644 --- a/core/lib/Thelia/Controller/Admin/AttributeController.php +++ b/core/lib/Thelia/Controller/Admin/AttributeController.php @@ -122,7 +122,7 @@ class AttributeController extends AbstractCrudController ); // Setup the object form - $changeForm = new AttributeModificationForm($this->getRequest(), "form", $data); + return new AttributeModificationForm($this->getRequest(), "form", $data); } protected function getObjectFromEvent($event) { @@ -136,7 +136,7 @@ class AttributeController extends AbstractCrudController } protected function getObjectLabel($object) { - return $object->getName(); + return $object->getTitle(); } protected function getObjectId($object) { diff --git a/core/lib/Thelia/Core/Event/AttributeValueCreateEvent.php b/core/lib/Thelia/Core/Event/AttributeAvCreateEvent.php similarity index 97% rename from core/lib/Thelia/Core/Event/AttributeValueCreateEvent.php rename to core/lib/Thelia/Core/Event/AttributeAvCreateEvent.php index 6f02257b6..81d22cfb9 100644 --- a/core/lib/Thelia/Core/Event/AttributeValueCreateEvent.php +++ b/core/lib/Thelia/Core/Event/AttributeAvCreateEvent.php @@ -23,7 +23,7 @@ namespace Thelia\Core\Event; -class AttributeValueCreateEvent extends AttributeValueEvent +class AttributeAvCreateEvent extends AttributeAvEvent { protected $title; protected $locale; diff --git a/core/lib/Thelia/Core/Event/AttributeValueDeleteEvent.php b/core/lib/Thelia/Core/Event/AttributeAvDeleteEvent.php similarity index 82% rename from core/lib/Thelia/Core/Event/AttributeValueDeleteEvent.php rename to core/lib/Thelia/Core/Event/AttributeAvDeleteEvent.php index c69218bd1..d710dc23f 100644 --- a/core/lib/Thelia/Core/Event/AttributeValueDeleteEvent.php +++ b/core/lib/Thelia/Core/Event/AttributeAvDeleteEvent.php @@ -23,23 +23,23 @@ namespace Thelia\Core\Event; -class AttributeValueDeleteEvent extends AttributeValueEvent +class AttributeAvDeleteEvent extends AttributeAvEvent { - protected $attributeValue_id; + protected $attributeAv_id; - public function __construct($attributeValue_id) + public function __construct($attributeAv_id) { - $this->setAttributeValueId($attributeValue_id); + $this->setAttributeAvId($attributeAv_id); } - public function getAttributeValueId() + public function getAttributeAvId() { - return $this->attributeValue_id; + return $this->attributeAv_id; } - public function setAttributeValueId($attributeValue_id) + public function setAttributeAvId($attributeAv_id) { - $this->attributeValue_id = $attributeValue_id; + $this->attributeAv_id = $attributeAv_id; return $this; } diff --git a/core/lib/Thelia/Core/Event/AttributeValueEvent.php b/core/lib/Thelia/Core/Event/AttributeAvEvent.php similarity index 80% rename from core/lib/Thelia/Core/Event/AttributeValueEvent.php rename to core/lib/Thelia/Core/Event/AttributeAvEvent.php index 5b783ebe9..c6c1726bd 100644 --- a/core/lib/Thelia/Core/Event/AttributeValueEvent.php +++ b/core/lib/Thelia/Core/Event/AttributeAvEvent.php @@ -24,28 +24,28 @@ namespace Thelia\Core\Event; use Thelia\Model\AttributeAv; -class AttributeValueEvent extends ActionEvent +class AttributeAvEvent extends ActionEvent { - protected $attributeValue = null; + protected $attributeAv = null; - public function __construct(AttributeAv $attributeValue = null) + public function __construct(AttributeAv $attributeAv = null) { - $this->attributeValue = $attributeValue; + $this->attributeAv = $attributeAv; } - public function hasAttributeValue() + public function hasAttributeAv() { - return ! is_null($this->attributeValue); + return ! is_null($this->attributeAv); } - public function getAttributeValue() + public function getAttributeAv() { - return $this->attributeValue; + return $this->attributeAv; } - public function setAttributeValue($attributeValue) + public function setAttributeAv($attributeAv) { - $this->attributeValue = $attributeValue; + $this->attributeAv = $attributeAv; return $this; } diff --git a/core/lib/Thelia/Core/Event/AttributeValueUpdateEvent.php b/core/lib/Thelia/Core/Event/AttributeAvUpdateEvent.php similarity index 86% rename from core/lib/Thelia/Core/Event/AttributeValueUpdateEvent.php rename to core/lib/Thelia/Core/Event/AttributeAvUpdateEvent.php index f81082dc5..c76198954 100644 --- a/core/lib/Thelia/Core/Event/AttributeValueUpdateEvent.php +++ b/core/lib/Thelia/Core/Event/AttributeAvUpdateEvent.php @@ -23,27 +23,27 @@ namespace Thelia\Core\Event; -class AttributeValueUpdateEvent extends AttributeValueCreateEvent +class AttributeAvUpdateEvent extends AttributeAvCreateEvent { - protected $attributeValue_id; + protected $attributeAv_id; protected $description; protected $chapo; protected $postscriptum; - public function __construct($attributeValue_id) + public function __construct($attributeAv_id) { - $this->setAttributeValueId($attributeValue_id); + $this->setAttributeAvId($attributeAv_id); } - public function getAttributeValueId() + public function getAttributeAvId() { - return $this->attributeValue_id; + return $this->attributeAv_id; } - public function setAttributeValueId($attributeValue_id) + public function setAttributeAvId($attributeAv_id) { - $this->attributeValue_id = $attributeValue_id; + $this->attributeAv_id = $attributeAv_id; return $this; } diff --git a/core/lib/Thelia/Core/Event/TheliaEvents.php b/core/lib/Thelia/Core/Event/TheliaEvents.php index 507b32bb8..178226188 100755 --- a/core/lib/Thelia/Core/Event/TheliaEvents.php +++ b/core/lib/Thelia/Core/Event/TheliaEvents.php @@ -365,17 +365,17 @@ final class TheliaEvents // -- Attributes values management ---------------------------------------- - const ATTRIBUTE_VALUE_CREATE = "action.createAttributeValue"; - const ATTRIBUTE_VALUE_UPDATE = "action.updateAttributeValue"; - const ATTRIBUTE_VALUE_DELETE = "action.deleteAttributeValue"; - const ATTRIBUTE_VALUE_UPDATE_POSITION = "action.updateAttributeValuePosition"; + const ATTRIBUTE_AV_CREATE = "action.createAttributeAv"; + const ATTRIBUTE_AV_UPDATE = "action.updateAttributeAv"; + const ATTRIBUTE_AV_DELETE = "action.deleteAttributeAv"; + const ATTRIBUTE_AV_UPDATE_POSITION = "action.updateAttributeAvPosition"; - const BEFORE_CREATEATTRIBUTE_VALUE = "action.before_createAttributeValue"; - const AFTER_CREATEATTRIBUTE_VALUE = "action.after_createAttributeValue"; + const BEFORE_CREATEATTRIBUTE_AV = "action.before_createAttributeAv"; + const AFTER_CREATEATTRIBUTE_AV = "action.after_createAttributeAv"; - const BEFORE_UPDATEATTRIBUTE_VALUE = "action.before_updateAttributeValue"; - const AFTER_UPDATEATTRIBUTE_VALUE = "action.after_updateAttributeValue"; + const BEFORE_UPDATEATTRIBUTE_AV = "action.before_updateAttributeAv"; + const AFTER_UPDATEATTRIBUTE_AV = "action.after_updateAttributeAv"; - const BEFORE_DELETEATTRIBUTE_VALUE = "action.before_deleteAttributeValue"; - const AFTER_DELETEATTRIBUTE_VALUE = "action.after_deleteAttributeValue"; + const BEFORE_DELETEATTRIBUTE_AV = "action.before_deleteAttributeAv"; + const AFTER_DELETEATTRIBUTE_AV = "action.after_deleteAttributeAv"; } diff --git a/templates/admin/default/attribute-edit.html b/templates/admin/default/attribute-edit.html index 900045fc7..58933cc9a 100644 --- a/templates/admin/default/attribute-edit.html +++ b/templates/admin/default/attribute-edit.html @@ -27,16 +27,15 @@
-
+
+ {form name="thelia.admin.attribute.modification"} +
- {include file="includes/inner-form-toolbar.html" close_url="{url path='/admin/configuration/attributes'}"} + {include file="includes/inner-form-toolbar.html" close_url="{url path='/admin/configuration/attributes'}"} -
+
-

{intl l='Attribute information'}

- - {form name="thelia.admin.attribute.modification"} - +

{intl l='Attribute information'}

{* Be sure to get the attribute ID, even if the form could not be validated *} @@ -53,114 +52,112 @@ {if $form_error}
{$form_error_message}
{/if} - {include file="includes/standard-description-form-fields.html"} + {include file="includes/standard-description-form-fields.html"} +
- - {/form} +
-
+

-

+ {intl l='Attribute values'} -

+ {loop type="auth" name="can_create" roles="ADMIN" permissions="admin.configuration.attribute-values.create"} + + + + + + {/loop} +

- {intl l='Attribute values'} +
+ {intl l="Enter here all possible attribute values."} +
- {loop type="auth" name="can_create" roles="ADMIN" permissions="admin.configuration.attribute-values.create"} - - - - - - {/loop} -

+ + + + -
- {intl l="Enter here all possible attribute values. If you don't enter any value, you will be able to set a free value to this attribute on the product form."} -
+ -
+ {admin_sortable_header + current_order=$order + order='id' + reverse_order='id_reverse' + path={url path='/admin/configuration/attributes/update' attribute_id=$attribute_id} + label="{intl l='ID'}" + } + + {admin_sortable_header + current_order=$order + order='alpha' + reverse_order='alpha_reverse' + path={url path='/admin/configuration/attributes/update' attribute_id=$attribute_id} + label="{intl l='Value'}" + } +
- - - + - + {module_include location='attributes_value_table_header'} - + + + - {module_include location='attributes_value_table_header'} + + {loop name="list" type="attribute_availability" attribute=$attribute_id backend_context="1" lang=$edit_language_id order=$order} + + - - - + - - {loop name="list" type="attribute_availability" attribute=$attribute_id backend_context="1" lang=$edit_language_id order=$order} - - + - + {module_include location='attributes_value_table_row'} - + + + {/loop} - {module_include location='attributes_value_table_row'} - - - - {/loop} - - {elseloop rel="list"} - - - - {/elseloop} - -
- {admin_sortable_header - current_order=$order - order='id' - reverse_order='id_reverse' - path={url path='/admin/configuration/attributes/update' attribute_id=$attribute_id} - label="{intl l='ID'}" - } - + {admin_sortable_header + current_order=$order + order='manual' + reverse_order='manual_reverse' + path={url path='/admin/configuration/attributes/update' attribute_id=$attribute_id} + label="{intl l="Position"}" + } + - {admin_sortable_header - current_order=$order - order='alpha' - reverse_order='alpha_reverse' - path={url path='/admin/configuration/attributes/update' attribute_id=$attribute_id} - label="{intl l='Value'}" - } - - {admin_sortable_header - current_order=$order - order='manual' - reverse_order='manual_reverse' - path={url path='/admin/configuration/attributes/update' attribute_id=$attribute_id} - label="{intl l="Position"}" - } - {intl l="Actions"}
{$ID}{intl l="Actions"}
+ +
{$ID} + {admin_position_block + permission="admin.attributes.edit" + path="/admin/configuration/attributes/update-value-position" + url_parameter="attribute_id" + in_place_edit_class="positionChange" + position="$POSITION" + id="$ID" + } + - - - {admin_position_block - permission="admin.attributes.edit" - path="/admin/configuration/attributes/update-value-position" - url_parameter="attribute_id" - in_place_edit_class="positionChange" - position="$POSITION" - id="$ID" - } - +
+ +
+
-
- -
-
-
- {intl l="No product attribute has been created yet. Click the + button to create one."} -
-
-
-
+ {elseloop rel="list"} + + +
+ {intl l="No product attribute has been created yet. Click the + button to create one."} +
+ + + {/elseloop} + + +
+ + {/form} +
@@ -235,7 +232,7 @@ dialog_ok_label = {intl l="Create this value"} - form_action = {url path='/admin/configuration/attributes/create-value'} + form_action = {url path='/admin/configuration/attributes-av'} form_enctype = {form_enctype form=$form} form_error_message = $form_error_message } @@ -254,7 +251,7 @@ dialog_title = {intl l="Delete attribute value"} dialog_message = {intl l="Do you really want to delete this attribute value ?"} - form_action = {url path='/admin/configuration/attributes/delete-value'} + form_action = {url path='/admin/configuration/attributes-av/delete'} form_content = {$smarty.capture.delete_dialog nofilter} }