diff --git a/core/lib/Thelia/Action/Content.php b/core/lib/Thelia/Action/Content.php index 4c8810a40..a76664955 100644 --- a/core/lib/Thelia/Action/Content.php +++ b/core/lib/Thelia/Action/Content.php @@ -26,6 +26,7 @@ use Symfony\Component\EventDispatcher\EventSubscriberInterface; use Thelia\Core\Event\Content\ContentCreateEvent; use Thelia\Core\Event\Content\ContentUpdateEvent; use Thelia\Core\Event\TheliaEvents; +use Thelia\Core\Event\UpdatePositionEvent; use Thelia\Model\ContentQuery; use Thelia\Model\Content as ContentModel; use Thelia\Model\FolderQuery; @@ -77,6 +78,25 @@ class Content extends BaseAction implements EventSubscriberInterface } } + public function updatePosition(UpdatePositionEvent $event) + { + if(null !== $content = ContentQuery::create()->findPk($event->getObjectId())) { + $content->setDispatcher($this->getDispatcher()); + + switch($event->getMode()) + { + case UpdatePositionEvent::POSITION_ABSOLUTE: + $content->changeAbsolutePosition($event->getPosition()); + break; + case UpdatePositionEvent::POSITION_DOWN: + $content->movePositionDown(); + break; + case UpdatePositionEvent::POSITION_UP: + $content->movePositionUp(); + break; + } + } + } /** * Returns an array of event names this subscriber wants to listen to. * diff --git a/core/lib/Thelia/Config/Resources/routing/admin.xml b/core/lib/Thelia/Config/Resources/routing/admin.xml index 838bd6da8..b4beb9799 100755 --- a/core/lib/Thelia/Config/Resources/routing/admin.xml +++ b/core/lib/Thelia/Config/Resources/routing/admin.xml @@ -235,6 +235,10 @@ Thelia\Controller\Admin\ContentController::processUpdateAction + + Thelia\Controller\Admin\ContentController::updatePositionAction + + diff --git a/core/lib/Thelia/Controller/Admin/ContentController.php b/core/lib/Thelia/Controller/Admin/ContentController.php index 9d20830a8..d91596ac0 100644 --- a/core/lib/Thelia/Controller/Admin/ContentController.php +++ b/core/lib/Thelia/Controller/Admin/ContentController.php @@ -25,6 +25,7 @@ namespace Thelia\Controller\Admin; use Thelia\Core\Event\Content\ContentCreateEvent; use Thelia\Core\Event\Content\ContentUpdateEvent; use Thelia\Core\Event\TheliaEvents; +use Thelia\Core\Event\UpdatePositionEvent; use Thelia\Form\ContentCreationForm; use Thelia\Form\ContentModificationForm; use Thelia\Model\ContentQuery; @@ -286,4 +287,31 @@ class ContentController extends AbstractCrudController ); } } + + /** + * @param $event \Thelia\Core\Event\UpdatePositionEvent + * @return null|Response + */ + protected function performAdditionalUpdatePositionAction($event) + { + + if (null !== $content = ContentQuery::create()->findPk($event->getObjectId())) { + // Redirect to parent category list + $this->redirectToRoute( + 'admin.folders.default', + array('parent' => $content->getDefaultFolderId()) + ); + } + + return null; + } + + protected function createUpdatePositionEvent($positionChangeMode, $positionValue) + { + return new UpdatePositionEvent( + $this->getRequest()->get('content_id', null), + $positionChangeMode, + $positionValue + ); + } } \ No newline at end of file diff --git a/templates/admin/default/content-edit.html b/templates/admin/default/content-edit.html index a7b55dfb8..f15718f91 100644 --- a/templates/admin/default/content-edit.html +++ b/templates/admin/default/content-edit.html @@ -57,7 +57,7 @@ {form name="thelia.admin.content.modification"}
- {include file="includes/inner-form-toolbar.html" close_url="{url path='/admin/folders' parent=0}"} + {include file="includes/inner-form-toolbar.html" close_url="{url path='/admin/folders' parent=$DEFAULT_FOLDER}"} {* Be sure to get the folder ID, even if the form could not be validated *} diff --git a/templates/admin/default/folders.html b/templates/admin/default/folders.html index fca34ba21..a4e1c0fc7 100644 --- a/templates/admin/default/folders.html +++ b/templates/admin/default/folders.html @@ -288,7 +288,7 @@ {admin_position_block permission="admin.content.edit" - path={url path='/admin/contents/update-position' content_id=$ID} + path={url path='/admin/content/update-position' content_id=$ID} url_parameter="content_id" in_place_edit_class="contentPositionChange" position=$POSITION