Merge branch 'master' into tax
This commit is contained in:
@@ -24,8 +24,11 @@
|
|||||||
namespace Thelia\Action;
|
namespace Thelia\Action;
|
||||||
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
|
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
|
||||||
use Thelia\Core\Event\Content\ContentCreateEvent;
|
use Thelia\Core\Event\Content\ContentCreateEvent;
|
||||||
|
use Thelia\Core\Event\Content\ContentDeleteEvent;
|
||||||
|
use Thelia\Core\Event\Content\ContentToggleVisibilityEvent;
|
||||||
use Thelia\Core\Event\Content\ContentUpdateEvent;
|
use Thelia\Core\Event\Content\ContentUpdateEvent;
|
||||||
use Thelia\Core\Event\TheliaEvents;
|
use Thelia\Core\Event\TheliaEvents;
|
||||||
|
use Thelia\Core\Event\UpdatePositionEvent;
|
||||||
use Thelia\Model\ContentQuery;
|
use Thelia\Model\ContentQuery;
|
||||||
use Thelia\Model\Content as ContentModel;
|
use Thelia\Model\Content as ContentModel;
|
||||||
use Thelia\Model\FolderQuery;
|
use Thelia\Model\FolderQuery;
|
||||||
@@ -77,6 +80,51 @@ 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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function toggleVisibility(ContentToggleVisibilityEvent $event)
|
||||||
|
{
|
||||||
|
$content = $event->getContent();
|
||||||
|
|
||||||
|
$content
|
||||||
|
->setDispatcher($this->getDispatcher())
|
||||||
|
->setVisible(!$content->getVisible())
|
||||||
|
->save();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public function delete(ContentDeleteEvent $event)
|
||||||
|
{
|
||||||
|
if (null !== $content = ContentQuery::create()->findPk($event->getContentId())) {
|
||||||
|
$defaultFolderId = $content->getDefaultFolderId();
|
||||||
|
|
||||||
|
$content->setDispatcher($this->getDispatcher())
|
||||||
|
->delete();
|
||||||
|
|
||||||
|
$event->setDefaultFolderId($defaultFolderId);
|
||||||
|
$event->setContent($content);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns an array of event names this subscriber wants to listen to.
|
* Returns an array of event names this subscriber wants to listen to.
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -247,6 +247,18 @@
|
|||||||
<default key="_controller">Thelia\Controller\Admin\ContentController::processUpdateAction</default>
|
<default key="_controller">Thelia\Controller\Admin\ContentController::processUpdateAction</default>
|
||||||
</route>
|
</route>
|
||||||
|
|
||||||
|
<route id="admin.content.update-position" path="/admin/content/update-position">
|
||||||
|
<default key="_controller">Thelia\Controller\Admin\ContentController::updatePositionAction</default>
|
||||||
|
</route>
|
||||||
|
|
||||||
|
<route id="admin.content.toggle-online" path="/admin/content/toggle-online">
|
||||||
|
<default key="_controller">Thelia\Controller\Admin\ContentController::setToggleVisibilityAction</default>
|
||||||
|
</route>
|
||||||
|
|
||||||
|
<route id="admin.content.delete" path="/admin/content/delete">
|
||||||
|
<default key="_controller">Thelia\Controller\Admin\ContentController::deleteAction</default>
|
||||||
|
</route>
|
||||||
|
|
||||||
|
|
||||||
<!-- Route to the Coupon controller (process Coupon browsing) -->
|
<!-- Route to the Coupon controller (process Coupon browsing) -->
|
||||||
|
|
||||||
|
|||||||
@@ -23,8 +23,11 @@
|
|||||||
|
|
||||||
namespace Thelia\Controller\Admin;
|
namespace Thelia\Controller\Admin;
|
||||||
use Thelia\Core\Event\Content\ContentCreateEvent;
|
use Thelia\Core\Event\Content\ContentCreateEvent;
|
||||||
|
use Thelia\Core\Event\Content\ContentDeleteEvent;
|
||||||
|
use Thelia\Core\Event\Content\ContentToggleVisibilityEvent;
|
||||||
use Thelia\Core\Event\Content\ContentUpdateEvent;
|
use Thelia\Core\Event\Content\ContentUpdateEvent;
|
||||||
use Thelia\Core\Event\TheliaEvents;
|
use Thelia\Core\Event\TheliaEvents;
|
||||||
|
use Thelia\Core\Event\UpdatePositionEvent;
|
||||||
use Thelia\Form\ContentCreationForm;
|
use Thelia\Form\ContentCreationForm;
|
||||||
use Thelia\Form\ContentModificationForm;
|
use Thelia\Form\ContentModificationForm;
|
||||||
use Thelia\Model\ContentQuery;
|
use Thelia\Model\ContentQuery;
|
||||||
@@ -143,7 +146,7 @@ class ContentController extends AbstractCrudController
|
|||||||
*/
|
*/
|
||||||
protected function getDeleteEvent()
|
protected function getDeleteEvent()
|
||||||
{
|
{
|
||||||
// TODO: Implement getDeleteEvent() method.
|
return new ContentDeleteEvent($this->getRequest()->get('content_id'));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -286,4 +289,59 @@ class ContentController extends AbstractCrudController
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Put in this method post object delete processing if required.
|
||||||
|
*
|
||||||
|
* @param \Thelia\Core\Event\Content\ContentDeleteEvent $deleteEvent the delete event
|
||||||
|
* @return Response a response, or null to continue normal processing
|
||||||
|
*/
|
||||||
|
protected function performAdditionalDeleteAction($deleteEvent)
|
||||||
|
{
|
||||||
|
// Redirect to parent category list
|
||||||
|
$this->redirectToRoute(
|
||||||
|
'admin.folders.default',
|
||||||
|
array('parent' => $deleteEvent->getDefaultFolderId())
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @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;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param $positionChangeMode
|
||||||
|
* @param $positionValue
|
||||||
|
* @return UpdatePositionEvent|void
|
||||||
|
*/
|
||||||
|
protected function createUpdatePositionEvent($positionChangeMode, $positionValue)
|
||||||
|
{
|
||||||
|
return new UpdatePositionEvent(
|
||||||
|
$this->getRequest()->get('content_id', null),
|
||||||
|
$positionChangeMode,
|
||||||
|
$positionValue
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return ContentToggleVisibilityEvent|void
|
||||||
|
*/
|
||||||
|
protected function createToggleVisibilityEvent()
|
||||||
|
{
|
||||||
|
return new ContentToggleVisibilityEvent($this->getExistingObject());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
74
core/lib/Thelia/Core/Event/Content/ContentDeleteEvent.php
Normal file
74
core/lib/Thelia/Core/Event/Content/ContentDeleteEvent.php
Normal file
@@ -0,0 +1,74 @@
|
|||||||
|
<?php
|
||||||
|
/*************************************************************************************/
|
||||||
|
/* */
|
||||||
|
/* Thelia */
|
||||||
|
/* */
|
||||||
|
/* Copyright (c) OpenStudio */
|
||||||
|
/* email : info@thelia.net */
|
||||||
|
/* web : http://www.thelia.net */
|
||||||
|
/* */
|
||||||
|
/* This program is free software; you can redistribute it and/or modify */
|
||||||
|
/* it under the terms of the GNU General Public License as published by */
|
||||||
|
/* the Free Software Foundation; either version 3 of the License */
|
||||||
|
/* */
|
||||||
|
/* This program is distributed in the hope that it will be useful, */
|
||||||
|
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
|
||||||
|
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
|
||||||
|
/* GNU General Public License for more details. */
|
||||||
|
/* */
|
||||||
|
/* You should have received a copy of the GNU General Public License */
|
||||||
|
/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||||
|
/* */
|
||||||
|
/*************************************************************************************/
|
||||||
|
|
||||||
|
namespace Thelia\Core\Event\Content;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class ContentDeleteEvent
|
||||||
|
* @package Thelia\Core\Event\Content
|
||||||
|
* @author manuel raynaud <mraynaud@openstudio.fr>
|
||||||
|
*/
|
||||||
|
class ContentDeleteEvent extends ContentEvent
|
||||||
|
{
|
||||||
|
protected $content_id;
|
||||||
|
|
||||||
|
protected $folder_id;
|
||||||
|
|
||||||
|
function __construct($content_id)
|
||||||
|
{
|
||||||
|
$this->content_id = $content_id;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param mixed $content_id
|
||||||
|
*
|
||||||
|
* @return $this
|
||||||
|
*/
|
||||||
|
public function setContentId($content_id)
|
||||||
|
{
|
||||||
|
$this->content_id = $content_id;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
|
public function getContentId()
|
||||||
|
{
|
||||||
|
return $this->content_id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setDefaultFolderId($folderid)
|
||||||
|
{
|
||||||
|
$this->folder_id = $folderid;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getDefaultFolderId()
|
||||||
|
{
|
||||||
|
return $this->folder_id;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,35 @@
|
|||||||
|
<?php
|
||||||
|
/*************************************************************************************/
|
||||||
|
/* */
|
||||||
|
/* Thelia */
|
||||||
|
/* */
|
||||||
|
/* Copyright (c) OpenStudio */
|
||||||
|
/* email : info@thelia.net */
|
||||||
|
/* web : http://www.thelia.net */
|
||||||
|
/* */
|
||||||
|
/* This program is free software; you can redistribute it and/or modify */
|
||||||
|
/* it under the terms of the GNU General Public License as published by */
|
||||||
|
/* the Free Software Foundation; either version 3 of the License */
|
||||||
|
/* */
|
||||||
|
/* This program is distributed in the hope that it will be useful, */
|
||||||
|
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
|
||||||
|
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
|
||||||
|
/* GNU General Public License for more details. */
|
||||||
|
/* */
|
||||||
|
/* You should have received a copy of the GNU General Public License */
|
||||||
|
/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||||
|
/* */
|
||||||
|
/*************************************************************************************/
|
||||||
|
|
||||||
|
namespace Thelia\Core\Event\Content;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class ContentToggleVisibilityEvent
|
||||||
|
* @package Thelia\Core\Event\Content
|
||||||
|
* @author manuel raynaud <mraynaud@openstudio.fr>
|
||||||
|
*/
|
||||||
|
class ContentToggleVisibilityEvent extends ContentEvent
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
@@ -236,6 +236,7 @@ class Content extends BaseI18nLoop
|
|||||||
->set("POSITION", $content->getPosition())
|
->set("POSITION", $content->getPosition())
|
||||||
->set("DEFAULT_FOLDER", $content->getDefaultFolderId())
|
->set("DEFAULT_FOLDER", $content->getDefaultFolderId())
|
||||||
->set("URL", $content->getUrl($locale))
|
->set("URL", $content->getUrl($locale))
|
||||||
|
->set("VISIBLE", $content->getVisible())
|
||||||
;
|
;
|
||||||
|
|
||||||
$loopResult->addRow($loopResultRow);
|
$loopResult->addRow($loopResultRow);
|
||||||
|
|||||||
@@ -228,8 +228,16 @@
|
|||||||
{* -- Javascript section ------------------------------------------------ *}
|
{* -- Javascript section ------------------------------------------------ *}
|
||||||
|
|
||||||
{block name="before-javascript-include"}{/block}
|
{block name="before-javascript-include"}{/block}
|
||||||
|
<script src="http://code.jquery.com/jquery-2.0.3.min.js"></script>
|
||||||
|
<script>
|
||||||
|
if (typeof jQuery == 'undefined') {
|
||||||
|
{javascripts file='assets/js/libs/jquery.js'}
|
||||||
|
document.write(unescape("%3Cscript src='{$asset_url}' %3E%3C/script%3E"));
|
||||||
|
{/javascripts}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
|
||||||
<script src="http://code.jquery.com/jquery-2.0.3.min.js"></script>
|
|
||||||
|
|
||||||
{debugbar_renderjs}
|
{debugbar_renderjs}
|
||||||
{debugbar_renderresult}
|
{debugbar_renderresult}
|
||||||
|
|||||||
6
templates/admin/default/assets/js/libs/jquery.js
vendored
Normal file
6
templates/admin/default/assets/js/libs/jquery.js
vendored
Normal file
File diff suppressed because one or more lines are too long
@@ -57,7 +57,7 @@
|
|||||||
{form name="thelia.admin.content.modification"}
|
{form name="thelia.admin.content.modification"}
|
||||||
<form method="POST" action="{url path='/admin/content/save'}" {form_enctype form=$form} class="clearfix">
|
<form method="POST" action="{url path='/admin/content/save'}" {form_enctype form=$form} class="clearfix">
|
||||||
|
|
||||||
{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 *}
|
{* Be sure to get the folder ID, even if the form could not be validated *}
|
||||||
<input type="hidden" name="content_id" value="{$content_id}" />
|
<input type="hidden" name="content_id" value="{$content_id}" />
|
||||||
|
|||||||
@@ -288,7 +288,7 @@
|
|||||||
<td>
|
<td>
|
||||||
{admin_position_block
|
{admin_position_block
|
||||||
permission="admin.content.edit"
|
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"
|
url_parameter="content_id"
|
||||||
in_place_edit_class="contentPositionChange"
|
in_place_edit_class="contentPositionChange"
|
||||||
position=$POSITION
|
position=$POSITION
|
||||||
@@ -511,7 +511,7 @@
|
|||||||
dialog_title = {intl l="Delete content"}
|
dialog_title = {intl l="Delete content"}
|
||||||
dialog_message = {intl l="Do you really want to delete this content ?"}
|
dialog_message = {intl l="Do you really want to delete this content ?"}
|
||||||
|
|
||||||
form_action = {url path='/admin/contents/delete'}
|
form_action = {url path='/admin/content/delete'}
|
||||||
form_content = {$smarty.capture.content_delete_dialog nofilter}
|
form_content = {$smarty.capture.content_delete_dialog nofilter}
|
||||||
}
|
}
|
||||||
{/block}
|
{/block}
|
||||||
@@ -567,7 +567,7 @@
|
|||||||
|
|
||||||
$(".contentVisibleToggle").on('switch-change', function(event, data) {
|
$(".contentVisibleToggle").on('switch-change', function(event, data) {
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url : "{url path='admin/contents/toggle-online'}",
|
url : "{url path='admin/content/toggle-online'}",
|
||||||
data : {
|
data : {
|
||||||
content_id : $(this).data('id'),
|
content_id : $(this).data('id'),
|
||||||
action : 'visibilityToggle'
|
action : 'visibilityToggle'
|
||||||
|
|||||||
Reference in New Issue
Block a user