From a229f555cbd8855623ebfdc7e45f20934efa7122 Mon Sep 17 00:00:00 2001 From: mespeche Date: Mon, 16 Sep 2013 15:32:52 +0200 Subject: [PATCH 01/15] No alert bloc --- templates/admin/default/general_error.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/templates/admin/default/general_error.html b/templates/admin/default/general_error.html index c66f83502..eae6614c9 100755 --- a/templates/admin/default/general_error.html +++ b/templates/admin/default/general_error.html @@ -13,7 +13,7 @@

{intl l="Oops! An Error Occurred"}

- {block name="error-message"}
{$error_message}
{/block} + {block name="error-message"}

{$error_message}

{/block} {intl l="Go to administration home"}
From 785057c0be9fffd32221c6fdff4b0270ab39c535 Mon Sep 17 00:00:00 2001 From: Manuel Raynaud Date: Mon, 16 Sep 2013 15:42:25 +0200 Subject: [PATCH 02/15] add some information for OSX requirements --- Readme.md | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/Readme.md b/Readme.md index 791b61d1e..3481d508c 100755 --- a/Readme.md +++ b/Readme.md @@ -12,13 +12,34 @@ Here is the most recent developed code for the next major version (v2). You can Most part of the code can possibly change, a large part will be refactor soon, graphical setup does not exist yet. +Requirements +------------ + +* php 5.4 +* apache 2 +* mysql 5 + +If you use Mac OSX, they still don't use php 5.4 as default php version... There are many solutions for you : + +* use linux (the better one) +* use last MAMP version and put the php bin directory in your path and : + +```bash +$ vim ~/.bash_profile +then put this line : export PATH=/Applications/MAMP/bin/php/php5.4.x/bin/:$PATH +$ . .bash_profile +``` + +* configure a complete development environment : http://php-osx.liip.ch/ +* use a virtual machine with vagrant and puppet : https://puphpet.com/ + Installation ------------ ``` bash $ git clone --recursive https://github.com/thelia/thelia.git $ cd thelia -$ wget http://getcomposer.org/composer.phar +$ curl -sS https://getcomposer.org/installer | php $ php composer.phar install ``` From 1dcde3ff2ca5925fb0f9b247fbfae1646123ca91 Mon Sep 17 00:00:00 2001 From: Manuel Raynaud Date: Mon, 16 Sep 2013 15:47:32 +0200 Subject: [PATCH 03/15] fix typo --- Readme.md | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/Readme.md b/Readme.md index 3481d508c..c0c3ebef5 100755 --- a/Readme.md +++ b/Readme.md @@ -19,15 +19,13 @@ Requirements * apache 2 * mysql 5 -If you use Mac OSX, they still don't use php 5.4 as default php version... There are many solutions for you : +If you use Mac OSX, it still doesn't use php 5.4 as default php version... There are many solutions for you : -* use linux (the better one) -* use last MAMP version and put the php bin directory in your path and : +* use linux (the best one) +* use last MAMP version and put the php bin directory in your path : ```bash -$ vim ~/.bash_profile -then put this line : export PATH=/Applications/MAMP/bin/php/php5.4.x/bin/:$PATH -$ . .bash_profile +export PATH=/Applications/MAMP/bin/php/php5.4.x/bin/:$PATH ``` * configure a complete development environment : http://php-osx.liip.ch/ From 2309a2e7885a1f763291cc0429f1767ee94a87ac Mon Sep 17 00:00:00 2001 From: Manuel Raynaud Date: Mon, 16 Sep 2013 16:29:09 +0200 Subject: [PATCH 04/15] remove script part of composer.json file --- composer.json | 4 ---- 1 file changed, 4 deletions(-) diff --git a/composer.json b/composer.json index 2d315bd3a..c8291305d 100755 --- a/composer.json +++ b/composer.json @@ -53,9 +53,5 @@ "": "local/modules/", "Thelia" : "core/lib/" } - }, - "scripts" : { - "post-update-cmd": "composer dump-autoload -o", - "post-install-cmd": "composer dump-autoload -o" } } From aa4e0636e8f270d4c3f79cba3d758bb4a9954822 Mon Sep 17 00:00:00 2001 From: Manuel Raynaud Date: Mon, 16 Sep 2013 16:31:13 +0200 Subject: [PATCH 05/15] use dump autoloader in all compser scripts --- Readme.md | 2 +- composer.lock | 2 +- reset_install.sh | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Readme.md b/Readme.md index c0c3ebef5..ac0862dae 100755 --- a/Readme.md +++ b/Readme.md @@ -38,7 +38,7 @@ Installation $ git clone --recursive https://github.com/thelia/thelia.git $ cd thelia $ curl -sS https://getcomposer.org/installer | php -$ php composer.phar install +$ php composer.phar install --optimize-autoloader ``` Finish the installation using cli tools : diff --git a/composer.lock b/composer.lock index 61160ea49..acc232713 100755 --- a/composer.lock +++ b/composer.lock @@ -3,7 +3,7 @@ "This file locks the dependencies of your project to a known state", "Read more about it at http://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file" ], - "hash": "28dfdc7a840f9e70df422581f82a871f", + "hash": "6db52c20c300000aa218e3be92ef978e", "packages": [ { "name": "imagine/imagine", diff --git a/reset_install.sh b/reset_install.sh index 399156b67..380a80a5f 100755 --- a/reset_install.sh +++ b/reset_install.sh @@ -8,7 +8,7 @@ echo -e "\n\e[01;34m[INFO] Clearing caches\e[00m\n" php Thelia cache:clear echo -e "\n\e[01;34m[INFO] Downloading vendors\e[00m\n" -composer install --prefer-dist +composer install --prefer-dist --optimize-autoloader cd local/config/ From 035d9dd0e94fdcb992d72518bb8d7f9dd4da4582 Mon Sep 17 00:00:00 2001 From: Manuel Raynaud Date: Mon, 16 Sep 2013 16:57:08 +0200 Subject: [PATCH 06/15] add swiftmailer in composer --- composer.json | 3 ++- composer.lock | 51 ++++++++++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 52 insertions(+), 2 deletions(-) diff --git a/composer.json b/composer.json index c8291305d..4a3798384 100755 --- a/composer.json +++ b/composer.json @@ -36,7 +36,8 @@ "simplepie/simplepie": "dev-master", "imagine/imagine": "dev-master", - "symfony/icu": "1.0" + "symfony/icu": "1.0", + "swiftmailer/swiftmailer": "5.0.*" }, "require-dev" : { "phpunit/phpunit": "3.7.*", diff --git a/composer.lock b/composer.lock index acc232713..b0310c075 100755 --- a/composer.lock +++ b/composer.lock @@ -3,7 +3,7 @@ "This file locks the dependencies of your project to a known state", "Read more about it at http://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file" ], - "hash": "6db52c20c300000aa218e3be92ef978e", + "hash": "a40be01c82e68ba0c446dc204d2667da", "packages": [ { "name": "imagine/imagine", @@ -445,6 +445,55 @@ ], "time": "2013-07-02 16:38:47" }, + { + "name": "swiftmailer/swiftmailer", + "version": "v5.0.2", + "source": { + "type": "git", + "url": "https://github.com/swiftmailer/swiftmailer.git", + "reference": "f3917ecef35a4e4d98b303eb9fee463bc983f379" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/swiftmailer/swiftmailer/zipball/f3917ecef35a4e4d98b303eb9fee463bc983f379", + "reference": "f3917ecef35a4e4d98b303eb9fee463bc983f379", + "shasum": "" + }, + "require": { + "php": ">=5.2.4" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "5.1-dev" + } + }, + "autoload": { + "files": [ + "lib/swift_required.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + }, + { + "name": "Chris Corbyn" + } + ], + "description": "Swiftmailer, free feature-rich PHP mailer", + "homepage": "http://swiftmailer.org", + "keywords": [ + "mail", + "mailer" + ], + "time": "2013-08-30 12:35:21" + }, { "name": "symfony-cmf/routing", "version": "1.0.0", From 874c5f6cacc6a83e25b710ca4836c22f0d4e32db Mon Sep 17 00:00:00 2001 From: Manuel Raynaud Date: Mon, 16 Sep 2013 18:20:15 +0200 Subject: [PATCH 07/15] integrate swiftMailer as mailer solution --- core/lib/Thelia/Config/Resources/config.xml | 4 + core/lib/Thelia/Controller/BaseController.php | 9 ++ .../Core/Event/MailTransporterEvent.php | 52 +++++++++++ core/lib/Thelia/Core/Event/TheliaEvents.php | 5 + core/lib/Thelia/Mailer/MailerFactory.php | 91 +++++++++++++++++++ 5 files changed, 161 insertions(+) create mode 100644 core/lib/Thelia/Core/Event/MailTransporterEvent.php create mode 100644 core/lib/Thelia/Mailer/MailerFactory.php diff --git a/core/lib/Thelia/Config/Resources/config.xml b/core/lib/Thelia/Config/Resources/config.xml index 691cf2198..bed490b4a 100755 --- a/core/lib/Thelia/Config/Resources/config.xml +++ b/core/lib/Thelia/Config/Resources/config.xml @@ -267,6 +267,10 @@ + + + + diff --git a/core/lib/Thelia/Controller/BaseController.php b/core/lib/Thelia/Controller/BaseController.php index 19e62a400..8bf9aeec3 100755 --- a/core/lib/Thelia/Controller/BaseController.php +++ b/core/lib/Thelia/Controller/BaseController.php @@ -281,4 +281,13 @@ class BaseController extends ContainerAware $this->accessDenied(); } } + + /** + * @return \Swift_Mailer + */ + public function getMailer() + { + $mailer = $this->container->get('mailer'); + return $mailer->getSwiftMailer(); + } } diff --git a/core/lib/Thelia/Core/Event/MailTransporterEvent.php b/core/lib/Thelia/Core/Event/MailTransporterEvent.php new file mode 100644 index 000000000..d47ac693f --- /dev/null +++ b/core/lib/Thelia/Core/Event/MailTransporterEvent.php @@ -0,0 +1,52 @@ +. */ +/* */ +/*************************************************************************************/ + +namespace Thelia\Core\Event; + + +/** + * Class MailTransporterEvent + * @package Thelia\Core\Event + * @author Manuel Raynaud + */ +class MailTransporterEvent extends ActionEvent { + /** + * @var \Swift_Transport + */ + protected $transporter; + + public function setMailerTransporter(\Swift_Transport $transporter) + { + $this->transporter = $transporter; + } + + public function getTransporter() + { + return $this->transporter; + } + + public function hasTransporter() + { + return null !== $this->transporter; + } +} \ No newline at end of file diff --git a/core/lib/Thelia/Core/Event/TheliaEvents.php b/core/lib/Thelia/Core/Event/TheliaEvents.php index 2867762aa..242fde4e4 100755 --- a/core/lib/Thelia/Core/Event/TheliaEvents.php +++ b/core/lib/Thelia/Core/Event/TheliaEvents.php @@ -430,4 +430,9 @@ final class TheliaEvents const BEFORE_DELETEFEATURE_AV = "action.before_deleteFeatureAv"; const AFTER_DELETEFEATURE_AV = "action.after_deleteFeatureAv"; + /** + * sent when system find a mailer transporter. + */ + const MAILTRANSPORTER_CONFIG = 'action.mailertransporter.config'; + } diff --git a/core/lib/Thelia/Mailer/MailerFactory.php b/core/lib/Thelia/Mailer/MailerFactory.php new file mode 100644 index 000000000..5cd952270 --- /dev/null +++ b/core/lib/Thelia/Mailer/MailerFactory.php @@ -0,0 +1,91 @@ +. */ +/* */ +/*************************************************************************************/ + +namespace Thelia\Mailer; +use Symfony\Component\EventDispatcher\EventDispatcherInterface; +use Thelia\Core\Event\MailTransporterEvent; +use Thelia\Core\Event\TheliaEvents; +use Thelia\Model\ConfigQuery; + + +/** + * Class MailerFactory + * @package Thelia\Mailer + * @author Manuel Raynaud + */ +class MailerFactory { + /** + * @var \Swift_Mailer + */ + protected $swiftMailer; + + protected $dispatcher; + + public function _construct(EventDispatcherInterface $dispatcher) + { + + $this->dispatcher = $dispatcher; + + $transporterEvent = new MailTransporterEvent(); + $this->dispatcher->dispatch(TheliaEvents::MAILTRANSPORTER_CONFIG, $transporterEvent); + + if($transporterEvent->hasTransporter()) { + $transporter = $transporterEvent->getTransporter(); + } else { + if (ConfigQuery::read("smtp.enabled")) { + $transporter = $this->configureSmtp(); + } else { + $transporter = \Swift_MailTransport::newInstance(); + } + } + + $this->swiftMailer = new \Swift_Mailer($transporter); + } + + private function configureSmtp() + { + $smtpTransporter = new \Swift_SmtpTransport(); + $smtpTransporter->setHost(Configquery::read('smtp.host', 'localhost')) + ->setPort(ConfigQuery::read('smtp.host')) + ->setEncryption(ConfigQuery::read('smtp.encryption')) + ->setUsername(ConfigQuery::read('smtp.username')) + ->setPassword(ConfigQuery::read('smtp.password')) + ->setAuthMode(ConfigQuery::read('smtp.authmode')) + ->setTimeout(ConfigQuery::read('smtp.timeout', 30)) + ->setSourceIp(ConfigQuery::read('smtp.sourceip')) + ; + return $smtpTransporter; + } + + public function send(\Swift_Mime_Message $message, &$failedRecipients = null) + { + $this->swiftMailer->send($message, $failedRecipients); + } + + public function getSwiftMailer() + { + return $this->swiftMailer; + } + + +} \ No newline at end of file From 67b6e5f07de74cfd019d3b5c32141067fde3c981 Mon Sep 17 00:00:00 2001 From: Manuel Raynaud Date: Mon, 16 Sep 2013 18:21:07 +0200 Subject: [PATCH 08/15] add some php doc --- core/lib/Thelia/Controller/BaseController.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/core/lib/Thelia/Controller/BaseController.php b/core/lib/Thelia/Controller/BaseController.php index 8bf9aeec3..3c4c0a5bc 100755 --- a/core/lib/Thelia/Controller/BaseController.php +++ b/core/lib/Thelia/Controller/BaseController.php @@ -283,6 +283,9 @@ class BaseController extends ContainerAware } /** + * + * return an instance of \Swift_Mailer with good Transporter configured. + * * @return \Swift_Mailer */ public function getMailer() From 2f41d4db6f15f88387638af4c70ff51f1ebf2945 Mon Sep 17 00:00:00 2001 From: franck Date: Mon, 16 Sep 2013 18:58:45 +0200 Subject: [PATCH 09/15] Started category management --- core/lib/Thelia/Action/Category.php | 262 +++---- core/lib/Thelia/Action/Config.php | 70 +- core/lib/Thelia/Action/Currency.php | 6 +- core/lib/Thelia/Action/Message.php | 4 +- core/lib/Thelia/Config/Resources/config.xml | 2 +- .../Thelia/Config/Resources/routing/admin.xml | 2 +- .../Admin/AbstractCrudController.php | 59 +- .../Admin/AttributeAvController.php | 2 +- .../Controller/Admin/AttributeController.php | 2 +- .../Controller/Admin/CategoryController.php | 419 ++++------- .../Controller/Admin/ConfigController.php | 2 +- .../Controller/Admin/CurrencyController.php | 2 +- .../Controller/Admin/FeatureAvController.php | 2 +- .../Controller/Admin/FeatureController.php | 2 +- .../Controller/Admin/TemplateController.php | 2 +- .../Thelia/Core/Event/CategoryCreateEvent.php | 20 +- .../Event/CategoryToggleVisibilityEvent.php | 28 + .../Thelia/Core/Event/CategoryUpdateEvent.php | 13 - core/lib/Thelia/Core/Event/TheliaEvents.php | 43 +- .../Core/Template/Loop/CategoryTree.php | 4 +- core/lib/Thelia/Form/CategoryCreationForm.php | 6 +- .../Thelia/Form/CategoryModificationForm.php | 8 +- core/lib/Thelia/Model/Category.php | 24 +- .../default/assets/less/thelia/thelia.less | 8 +- templates/admin/default/categories.html | 710 +++++++----------- templates/admin/default/category-edit.html | 243 +++--- templates/admin/default/currency-edit.html | 8 +- .../default/includes/catalog-breadcrumb.html | 4 +- templates/admin/default/message-edit.html | 12 +- templates/admin/default/orders.html | 6 +- templates/admin/default/variable-edit.html | 6 +- templates/admin/default/variables.html | 2 +- 32 files changed, 772 insertions(+), 1211 deletions(-) create mode 100644 core/lib/Thelia/Core/Event/CategoryToggleVisibilityEvent.php diff --git a/core/lib/Thelia/Action/Category.php b/core/lib/Thelia/Action/Category.php index 297cd64da..a34f4a85e 100755 --- a/core/lib/Thelia/Action/Category.php +++ b/core/lib/Thelia/Action/Category.php @@ -24,52 +24,88 @@ namespace Thelia\Action; use Symfony\Component\EventDispatcher\EventSubscriberInterface; -use Thelia\Core\Event\TheliaEvents; -use Thelia\Model\Category as CategoryModel; + use Thelia\Model\CategoryQuery; +use Thelia\Model\Category as CategoryModel; -use Propel\Runtime\ActiveQuery\Criteria; -use Propel\Runtime\Propel; -use Thelia\Model\Map\CategoryTableMap; +use Thelia\Core\Event\TheliaEvents; +use Thelia\Core\Event\CategoryUpdateEvent; use Thelia\Core\Event\CategoryCreateEvent; use Thelia\Core\Event\CategoryDeleteEvent; +use Thelia\Model\ConfigQuery; +use Thelia\Core\Event\UpdatePositionEvent; use Thelia\Core\Event\CategoryToggleVisibilityEvent; -use Thelia\Core\Event\CategoryChangePositionEvent; class Category extends BaseAction implements EventSubscriberInterface { + /** + * Create a new category entry + * + * @param CategoryCreateEvent $event + */ public function create(CategoryCreateEvent $event) { $category = new CategoryModel(); $category ->setDispatcher($this->getDispatcher()) - ->create( - $event->getTitle(), - $event->getParent(), - $event->getLocale() - ); + + ->setLocale($event->getLocale()) + ->setTitle($event->getTitle()) + ->setParent($event->getParent()) + ->setVisible($event->getVisible()) + + ->save() + ; $event->setCategory($category); } - public function update(CategoryChangeEvent $event) + /** + * Change a category + * + * @param CategoryUpdateEvent $event + */ + public function update(CategoryUpdateEvent $event) { + $search = CategoryQuery::create(); + + if (null !== $category = CategoryQuery::create()->findPk($event->getCategoryId())) { + + $category + ->setDispatcher($this->getDispatcher()) + + ->setLocale($event->getLocale()) + ->setTitle($event->getTitle()) + ->setDescription($event->getDescription()) + ->setChapo($event->getChapo()) + ->setPostscriptum($event->getPostscriptum()) + + ->setParent($event->getParent()) + ->setVisible($event->getVisible()) + + ->save(); + + $event->setCategory($category); + } } /** - * Delete a category + * Delete a category entry * - * @param ActionEvent $event + * @param CategoryDeleteEvent $event */ public function delete(CategoryDeleteEvent $event) { - $category = CategoryQuery::create()->findPk($event->getCategoryId()); + if (null !== $category = CategoryQuery::create()->findPk($event->getCategoryId())) { - if ($category !== null) { + $category + ->setDispatcher($this->getDispatcher()) + ->delete() + ; - $category->setDispatcher($this->getDispatcher())->delete(); + $event->setCategory($category); } } @@ -80,178 +116,48 @@ class Category extends BaseAction implements EventSubscriberInterface */ public function toggleVisibility(CategoryToggleVisibilityEvent $event) { - $category = CategoryQuery::create()->findPk($event->getCategoryId()); + $category = $event->getCategory(); - if ($category !== null) { - - $category - ->setDispatcher($this->getDispatcher()) - ->setVisible($category->getVisible() ? false : true) - ->save() + $category + ->setDispatcher($this->getDispatcher()) + ->setVisible($category->getVisible() ? false : true) + ->save() ; + } + + /** + * Changes position, selecting absolute ou relative change. + * + * @param CategoryChangePositionEvent $event + */ + public function updatePosition(UpdatePositionEvent $event) + { + if (null !== $category = CategoryQuery::create()->findPk($event->getObjectId())) { + + $category->setDispatcher($this->getDispatcher()); + + $mode = $event->getMode(); + + if ($mode == UpdatePositionEvent::POSITION_ABSOLUTE) + return $category->changeAbsolutePosition($event->getPosition()); + else if ($mode == UpdatePositionEvent::POSITION_UP) + return $category->movePositionUp(); + else if ($mode == UpdatePositionEvent::POSITION_DOWN) + return $category->movePositionDown(); } } /** - * Changes category position, selecting absolute ou relative change. - * - * @param CategoryChangePositionEvent $event - */ - public function changePosition(CategoryChangePositionEvent $event) - { - if ($event->getMode() == CategoryChangePositionEvent::POSITION_ABSOLUTE) - return $this->changeAbsolutePosition($event); - else - return $this->exchangePosition($event); - } - - /** - * Move up or down a category - * - * @param CategoryChangePositionEvent $event - */ - protected function exchangePosition(CategoryChangePositionEvent $event) - { - $category = CategoryQuery::create()->findPk($event->getCategoryId()); - - if ($category !== null) { - - // The current position of the category - $my_position = $category->getPosition(); - - // Find category to exchange position with - $search = CategoryQuery::create() - ->filterByParent($category->getParent()); - - // Up or down ? - if ($event->getMode() == CategoryChangePositionEvent::POSITION_UP) { - // Find the category immediately before me - $search->filterByPosition(array('max' => $my_position-1))->orderByPosition(Criteria::DESC); - } elseif ($event->getMode() == CategoryChangePositionEvent::POSITION_DOWN) { - // Find the category immediately after me - $search->filterByPosition(array('min' => $my_position+1))->orderByPosition(Criteria::ASC); - } else - - return; - - $result = $search->findOne(); - - // If we found the proper category, exchange their positions - if ($result) { - - $cnx = Propel::getWriteConnection(CategoryTableMap::DATABASE_NAME); - - $cnx->beginTransaction(); - - try { - $category - ->setDispatcher($this->getDispatcher()) - ->setPosition($result->getPosition()) - ->save() - ; - - $result->setPosition($my_position)->save(); - - $cnx->commit(); - } catch (Exception $e) { - $cnx->rollback(); - } - } - } - } - - /** - * Changes category position - * - * @param CategoryChangePositionEvent $event - */ - protected function changeAbsolutePosition(CategoryChangePositionEvent $event) - { - $category = CategoryQuery::create()->findPk($event->getCategoryId()); - - if ($category !== null) { - - // The required position - $new_position = $event->getPosition(); - - // The current position - $current_position = $category->getPosition(); - - if ($new_position != null && $new_position > 0 && $new_position != $current_position) { - - // Find categories to offset - $search = CategoryQuery::create()->filterByParent($category->getParent()); - - if ($new_position > $current_position) { - // The new position is after the current position -> we will offset + 1 all categories located between us and the new position - $search->filterByPosition(array('min' => 1+$current_position, 'max' => $new_position)); - - $delta = -1; - } else { - // The new position is brefore the current position -> we will offset - 1 all categories located between us and the new position - $search->filterByPosition(array('min' => $new_position, 'max' => $current_position - 1)); - - $delta = 1; - } - - $results = $search->find(); - - $cnx = Propel::getWriteConnection(CategoryTableMap::DATABASE_NAME); - - $cnx->beginTransaction(); - - try { - foreach ($results as $result) { - $result->setPosition($result->getPosition() + $delta)->save($cnx); - } - - $category - ->setDispatcher($this->getDispatcher()) - ->setPosition($new_position) - ->save($cnx) - ; - - $cnx->commit(); - } catch (Exception $e) { - $cnx->rollback(); - } - } - } - } - - /** - * Returns an array of event names this subscriber listens to. - * - * The array keys are event names and the value can be: - * - * * The method name to call (priority defaults to 0) - * * An array composed of the method name to call and the priority - * * An array of arrays composed of the method names to call and respective - * priorities, or 0 if unset - * - * For instance: - * - * * array('eventName' => 'methodName') - * * array('eventName' => array('methodName', $priority)) - * * array('eventName' => array(array('methodName1', $priority), array('methodName2')) - * - * @return array The event names to listen to - * - * @api + * {@inheritDoc} */ public static function getSubscribedEvents() { return array( - TheliaEvents::CATEGORY_CREATE => array("create", 128), - TheliaEvents::CATEGORY_UPDATE => array("update", 128), - TheliaEvents::CATEGORY_DELETE => array("delete", 128), - + TheliaEvents::CATEGORY_CREATE => array("create", 128), + TheliaEvents::CATEGORY_UPDATE => array("update", 128), + TheliaEvents::CATEGORY_DELETE => array("delete", 128), TheliaEvents::CATEGORY_TOGGLE_VISIBILITY => array("toggleVisibility", 128), - TheliaEvents::CATEGORY_CHANGE_POSITION => array("changePosition", 128), - - "action.updateCategoryPositionU" => array("changePositionUp", 128), - "action.updateCategoryPositionDown" => array("changePositionDown", 128), - "action.updateCategoryPosition" => array("changePosition", 128), + TheliaEvents::CATEGORY_UPDATE_POSITION => array("updatePosition", 128) ); } } diff --git a/core/lib/Thelia/Action/Config.php b/core/lib/Thelia/Action/Config.php index 83df28524..f8a7c027c 100644 --- a/core/lib/Thelia/Action/Config.php +++ b/core/lib/Thelia/Action/Config.php @@ -22,7 +22,6 @@ /*************************************************************************************/ namespace Thelia\Action; - use Symfony\Component\EventDispatcher\EventSubscriberInterface; use Thelia\Model\ConfigQuery; @@ -45,18 +44,9 @@ class Config extends BaseAction implements EventSubscriberInterface { $config = new ConfigModel(); - $config - ->setDispatcher($this->getDispatcher()) - - ->setName($event->getEventName()) - ->setValue($event->getValue()) - ->setLocale($event->getLocale()) - ->setTitle($event->getTitle()) - ->setHidden($event->getHidden()) - ->setSecured($event->getSecured()) - - ->save() - ; + $config->setDispatcher($this->getDispatcher())->setName($event->getEventName())->setValue($event->getValue()) + ->setLocale($event->getLocale())->setTitle($event->getTitle())->setHidden($event->getHidden()) + ->setSecured($event->getSecured())->save(); $event->setConfig($config); } @@ -70,18 +60,13 @@ class Config extends BaseAction implements EventSubscriberInterface { $search = ConfigQuery::create(); - if (null !== $config = $search->findOneById($event->getConfigId())) { + if (null !== $config = $search->findPk($event->getConfigId())) { if ($event->getValue() !== $config->getValue()) { - $config - ->setDispatcher($this->getDispatcher()) + $config->setDispatcher($this->getDispatcher())->setValue($event->getValue())->save(); - ->setValue($event->getValue()) - ->save() - ; - - $event->setConfig($config); + $event->setConfig($config); } } } @@ -95,23 +80,12 @@ class Config extends BaseAction implements EventSubscriberInterface { $search = ConfigQuery::create(); - if (null !== $config = ConfigQuery::create()->findOneById($event->getConfigId())) { + if (null !== $config = ConfigQuery::create()->findPk($event->getConfigId())) { - $config - ->setDispatcher($this->getDispatcher()) - - ->setName($event->getEventName()) - ->setValue($event->getValue()) - ->setHidden($event->getHidden()) - ->setSecured($event->getSecured()) - - ->setLocale($event->getLocale()) - ->setTitle($event->getTitle()) - ->setDescription($event->getDescription()) - ->setChapo($event->getChapo()) - ->setPostscriptum($event->getPostscriptum()) - - ->save(); + $config->setDispatcher($this->getDispatcher())->setName($event->getEventName())->setValue($event->getValue()) + ->setHidden($event->getHidden())->setSecured($event->getSecured())->setLocale($event->getLocale()) + ->setTitle($event->getTitle())->setDescription($event->getDescription())->setChapo($event->getChapo()) + ->setPostscriptum($event->getPostscriptum())->save(); $event->setConfig($config); } @@ -125,14 +99,11 @@ class Config extends BaseAction implements EventSubscriberInterface public function delete(ConfigDeleteEvent $event) { - if (null !== ($config = ConfigQuery::create()->findOneById($event->getConfigId()))) { + if (null !== ($config = ConfigQuery::create()->findPk($event->getConfigId()))) { - if (! $config->getSecured()) { + if (!$config->getSecured()) { - $config - ->setDispatcher($this->getDispatcher()) - ->delete() - ; + $config->setDispatcher($this->getDispatcher())->delete(); $event->setConfig($config); } @@ -145,10 +116,15 @@ class Config extends BaseAction implements EventSubscriberInterface public static function getSubscribedEvents() { return array( - TheliaEvents::CONFIG_CREATE => array("create", 128), - TheliaEvents::CONFIG_SETVALUE => array("setValue", 128), - TheliaEvents::CONFIG_UPDATE => array("modify", 128), - TheliaEvents::CONFIG_DELETE => array("delete", 128), + TheliaEvents::CONFIG_CREATE => array( + "create", 128 + ), TheliaEvents::CONFIG_SETVALUE => array( + "setValue", 128 + ), TheliaEvents::CONFIG_UPDATE => array( + "modify", 128 + ), TheliaEvents::CONFIG_DELETE => array( + "delete", 128 + ), ); } } diff --git a/core/lib/Thelia/Action/Currency.php b/core/lib/Thelia/Action/Currency.php index 7908d1f0d..946fee375 100644 --- a/core/lib/Thelia/Action/Currency.php +++ b/core/lib/Thelia/Action/Currency.php @@ -71,7 +71,7 @@ class Currency extends BaseAction implements EventSubscriberInterface { $search = CurrencyQuery::create(); - if (null !== $currency = CurrencyQuery::create()->findOneById($event->getCurrencyId())) { + if (null !== $currency = CurrencyQuery::create()->findPk($event->getCurrencyId())) { $currency ->setDispatcher($this->getDispatcher()) @@ -97,7 +97,7 @@ class Currency extends BaseAction implements EventSubscriberInterface { $search = CurrencyQuery::create(); - if (null !== $currency = CurrencyQuery::create()->findOneById($event->getCurrencyId())) { + if (null !== $currency = CurrencyQuery::create()->findPk($event->getCurrencyId())) { if ($currency->getByDefault() != $event->getIsDefault()) { @@ -123,7 +123,7 @@ class Currency extends BaseAction implements EventSubscriberInterface public function delete(CurrencyDeleteEvent $event) { - if (null !== ($currency = CurrencyQuery::create()->findOneById($event->getCurrencyId()))) { + if (null !== ($currency = CurrencyQuery::create()->findPk($event->getCurrencyId()))) { $currency ->setDispatcher($this->getDispatcher()) diff --git a/core/lib/Thelia/Action/Message.php b/core/lib/Thelia/Action/Message.php index faac35bf2..8918913fe 100644 --- a/core/lib/Thelia/Action/Message.php +++ b/core/lib/Thelia/Action/Message.php @@ -70,7 +70,7 @@ class Message extends BaseAction implements EventSubscriberInterface { $search = MessageQuery::create(); - if (null !== $message = MessageQuery::create()->findOneById($event->getMessageId())) { + if (null !== $message = MessageQuery::create()->findPk($event->getMessageId())) { $message ->setDispatcher($this->getDispatcher()) @@ -99,7 +99,7 @@ class Message extends BaseAction implements EventSubscriberInterface public function delete(MessageDeleteEvent $event) { - if (null !== ($message = MessageQuery::create()->findOneById($event->getMessageId()))) { + if (null !== ($message = MessageQuery::create()->findPk($event->getMessageId()))) { $message ->setDispatcher($this->getDispatcher()) diff --git a/core/lib/Thelia/Config/Resources/config.xml b/core/lib/Thelia/Config/Resources/config.xml index 691cf2198..0c0973db9 100755 --- a/core/lib/Thelia/Config/Resources/config.xml +++ b/core/lib/Thelia/Config/Resources/config.xml @@ -51,7 +51,7 @@
- + diff --git a/core/lib/Thelia/Config/Resources/routing/admin.xml b/core/lib/Thelia/Config/Resources/routing/admin.xml index dc650d8d6..53c137988 100755 --- a/core/lib/Thelia/Config/Resources/routing/admin.xml +++ b/core/lib/Thelia/Config/Resources/routing/admin.xml @@ -85,7 +85,7 @@ - Thelia\Controller\Admin\CategoryController::toggleOnlineAction + Thelia\Controller\Admin\CategoryController::setToggleVisibilityAction diff --git a/core/lib/Thelia/Controller/Admin/AbstractCrudController.php b/core/lib/Thelia/Controller/Admin/AbstractCrudController.php index fad774023..5b7f8b60a 100644 --- a/core/lib/Thelia/Controller/Admin/AbstractCrudController.php +++ b/core/lib/Thelia/Controller/Admin/AbstractCrudController.php @@ -240,6 +240,17 @@ abstract class AbstractCrudController extends BaseAdminController return null; } + /** + * Put in this method post object position change processing if required. + * + * @param unknown $deleteEvent the delete event + * @return Response a response, or null to continue normal processing + */ + protected function performAdditionalUpdatePositionAction($positionChangeEvent) + { + return null; + } + /** * Return the current list order identifier, updating it in the same time. */ @@ -309,14 +320,18 @@ abstract class AbstractCrudController extends BaseAdminController $this->adminLogAppend(sprintf("%s %s (ID %s) created", ucfirst($this->objectName), $this->getObjectLabel($createdObject), $this->getObjectId($createdObject))); } - $this->performAdditionalCreateAction($createEvent); + $response = $this->performAdditionalCreateAction($createEvent); - // Substitute _ID_ in the URL with the ID of the created object - $successUrl = str_replace('_ID_', $this->getObjectId($createdObject), $creationForm->getSuccessUrl()); - - // Redirect to the success URL - $this->redirect($successUrl); + if ($response == null) { + // Substitute _ID_ in the URL with the ID of the created object + $successUrl = str_replace('_ID_', $this->getObjectId($createdObject), $creationForm->getSuccessUrl()); + // Redirect to the success URL + $this->redirect($successUrl); + } + else { + return $response; + } } catch (FormValidationException $ex) { // Form cannot be validated @@ -396,16 +411,21 @@ abstract class AbstractCrudController extends BaseAdminController $this->adminLogAppend(sprintf("%s %s (ID %s) modified", ucfirst($this->objectName), $this->getObjectLabel($changedObject), $this->getObjectId($changedObject))); } - $this->performAdditionalUpdateAction($changeEvent); + $response = $this->performAdditionalUpdateAction($changeEvent); - // If we have to stay on the same page, do not redirect to the succesUrl, - // just redirect to the edit page again. - if ($this->getRequest()->get('save_mode') == 'stay') { - $this->redirectToEditionTemplate($this->getRequest()); + if ($response == null) { + // If we have to stay on the same page, do not redirect to the succesUrl, + // just redirect to the edit page again. + if ($this->getRequest()->get('save_mode') == 'stay') { + $this->redirectToEditionTemplate($this->getRequest()); + } + + // Redirect to the success URL + $this->redirect($changeForm->getSuccessUrl()); + } + else { + return $response; } - - // Redirect to the success URL - $this->redirect($changeForm->getSuccessUrl()); } catch (FormValidationException $ex) { // Form cannot be validated @@ -452,7 +472,14 @@ abstract class AbstractCrudController extends BaseAdminController return $this->errorPage($ex); } - $this->redirectToListTemplate(); + $response = $this->performAdditionalUpdatePositionAction($event); + + if ($response == null) { + $this->redirectToListTemplate(); + } + else { + return $response; + } } /** @@ -475,7 +502,7 @@ abstract class AbstractCrudController extends BaseAdminController return $this->errorPage($ex); } - $this->redirectToRoute('admin.categories.default'); + $this->redirectToListTemplate(); } /** diff --git a/core/lib/Thelia/Controller/Admin/AttributeAvController.php b/core/lib/Thelia/Controller/Admin/AttributeAvController.php index b3afa687d..1ab12a081 100644 --- a/core/lib/Thelia/Controller/Admin/AttributeAvController.php +++ b/core/lib/Thelia/Controller/Admin/AttributeAvController.php @@ -33,7 +33,7 @@ use Thelia\Form\AttributeAvCreationForm; use Thelia\Core\Event\UpdatePositionEvent; /** - * Manages attributes-av sent by mail + * Manages attributes-av * * @author Franck Allimant */ diff --git a/core/lib/Thelia/Controller/Admin/AttributeController.php b/core/lib/Thelia/Controller/Admin/AttributeController.php index 247b89632..48a65baa7 100644 --- a/core/lib/Thelia/Controller/Admin/AttributeController.php +++ b/core/lib/Thelia/Controller/Admin/AttributeController.php @@ -37,7 +37,7 @@ use Thelia\Core\Event\AttributeAvUpdateEvent; use Thelia\Core\Event\AttributeEvent; /** - * Manages attributes sent by mail + * Manages attributes * * @author Franck Allimant */ diff --git a/core/lib/Thelia/Controller/Admin/CategoryController.php b/core/lib/Thelia/Controller/Admin/CategoryController.php index fba832ec8..15f620736 100755 --- a/core/lib/Thelia/Controller/Admin/CategoryController.php +++ b/core/lib/Thelia/Controller/Admin/CategoryController.php @@ -23,226 +23,160 @@ namespace Thelia\Controller\Admin; -use Thelia\Core\Event\TheliaEvents; -use Thelia\Core\Event\CategoryCreateEvent; -use Thelia\Form\CategoryCreationForm; use Thelia\Core\Event\CategoryDeleteEvent; -use Thelia\Core\Event\CategoryUpdatePositionEvent; +use Thelia\Core\Event\TheliaEvents; +use Thelia\Core\Event\CategoryUpdateEvent; +use Thelia\Core\Event\CategoryCreateEvent; use Thelia\Model\CategoryQuery; use Thelia\Form\CategoryModificationForm; +use Thelia\Form\CategoryCreationForm; +use Thelia\Core\Event\UpdatePositionEvent; +use Thelia\Core\Event\CategoryToggleVisibilityEvent; -class CategoryController extends BaseAdminController +/** + * Manages categories + * + * @author Franck Allimant + */ +class CategoryController extends AbstractCrudController { - /** - * Render the categories list, ensuring the sort order is set. - * - * @return Symfony\Component\HttpFoundation\Response the response - */ - protected function renderList() - { - return $this->render('categories', $this->getTemplateArgs()); + public function __construct() { + parent::__construct( + 'category', + 'manual', + 'category_order', + + 'admin.categories.default', + 'admin.categories.create', + 'admin.categories.update', + 'admin.categories.delete', + + TheliaEvents::CATEGORY_CREATE, + TheliaEvents::CATEGORY_UPDATE, + TheliaEvents::CATEGORY_DELETE, + TheliaEvents::CATEGORY_TOGGLE_VISIBILITY, + TheliaEvents::CATEGORY_UPDATE_POSITION + ); } - protected function getTemplateArgs() - { - // Get the category ID - $category_id = $this->getRequest()->get('category_id', 0); + protected function getCreationForm() { + return new CategoryCreationForm($this->getRequest()); + } - // Find the current category order - $category_order = $this->getRequest()->get( - 'order', - $this->getSession()->get('admin.category_order', 'manual') + protected function getUpdateForm() { + return new CategoryModificationForm($this->getRequest()); + } + + protected function getCreationEvent($formData) { + $createEvent = new CategoryCreateEvent(); + + $createEvent + ->setTitle($formData['title']) + ->setLocale($formData["locale"]) + ->setParent($formData['parent']) + ->setVisible($formData['visible']) + ; + + return $createEvent; + } + + protected function getUpdateEvent($formData) { + $changeEvent = new CategoryUpdateEvent($formData['id']); + + // Create and dispatch the change event + $changeEvent + ->setLocale($formData['locale']) + ->setTitle($formData['title']) + ->setChapo($formData['chapo']) + ->setDescription($formData['description']) + ->setPostscriptum($formData['postscriptum']) + ->setVisible($formData['visible']) + ->setUrl($formData['url']) + ->setParent($formData['parent']) + ; + + return $changeEvent; + } + + protected function createUpdatePositionEvent($positionChangeMode, $positionValue) { + + return new UpdatePositionEvent( + $this->getRequest()->get('category_id', null), + $positionChangeMode, + $positionValue + ); + } + + protected function getDeleteEvent() { + return new CategoryDeleteEvent($this->getRequest()->get('category_id', 0)); + } + + protected function eventContainsObject($event) { + return $event->hasCategory(); + } + + protected function hydrateObjectForm($object) { + + // Prepare the data that will hydrate the form + $data = array( + 'id' => $object->getId(), + 'locale' => $object->getLocale(), + 'title' => $object->getTitle(), + 'chapo' => $object->getChapo(), + 'description' => $object->getDescription(), + 'postscriptum' => $object->getPostscriptum(), + 'visible' => $object->getVisible(), + 'url' => $object->getUrl($this->getCurrentEditionLocale()), + 'parent' => $object->getParent() ); - $args = array( - 'current_category_id' => $category_id, - 'category_order' => $category_order, + // Setup the object form + return new CategoryModificationForm($this->getRequest(), "form", $data); + } + + protected function getObjectFromEvent($event) { + return $event->hasCategory() ? $event->getCategory() : null; + } + + protected function getExistingObject() { + return CategoryQuery::create() + ->joinWithI18n($this->getCurrentEditionLocale()) + ->findOneById($this->getRequest()->get('category_id', 0)); + } + + protected function getObjectLabel($object) { + return $object->getTitle(); + } + + protected function getObjectId($object) { + return $object->getId(); + } + + protected function renderListTemplate($currentOrder) { + return $this->render('categories', + array( + 'category_order' => $currentOrder, + 'category_id' => $this->getRequest()->get('category_id', 0) + ) + ); + } + + protected function renderEditionTemplate() { + return $this->render('category-edit', array('category_id' => $this->getRequest()->get('category_id', 0))); + } + + protected function redirectToEditionTemplate() { + $this->redirectToRoute( + "admin.categories.update", + array('category_id' => $this->getRequest()->get('category_id', 0)) ); - - // Store the current sort order in session - $this->getSession()->set('admin.category_order', $category_order); - - return $args; } - /** - * The default action is displaying the categories list. - * - * @return Symfony\Component\HttpFoundation\Response the response - */ - public function defaultAction() - { - if (null !== $response = $this->checkAuth("admin.categories.view")) return $response; - return $this->renderList(); - } - - /** - * Create a new category object - * - * @return Symfony\Component\HttpFoundation\Response the response - */ - public function createAction() - { - // Check current user authorization - if (null !== $response = $this->checkAuth("admin.categories.create")) return $response; - - $error_msg = false; - - // Create the Creation Form - $creationForm = new CategoryCreationForm($this->getRequest()); - - try { - - // Validate the form, create the CategoryCreation event and dispatch it. - $form = $this->validateForm($creationForm, "POST"); - - $data = $form->getData(); - - $createEvent = new CategoryCreateEvent( - $data["title"], - $data["parent"], - $data["locale"] - ); - - $this->dispatch(TheliaEvents::CATEGORY_CREATE, $createEvent); - - if (! $createEvent->hasCategory()) throw new \LogicException($this->getTranslator()->trans("No category was created.")); - - $createdObject = $createEvent->getCategory(); - - // Log category creation - $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()); - - // Redirect to the success URL - $this->redirect($successUrl); - } catch (FormValidationException $ex) { - // Form cannot be validated - $error_msg = $this->createStandardFormValidationErrorMessage($ex); - } catch (\Exception $ex) { - // Any other error - $error_msg = $ex->getMessage(); - } - - $this->setupFormErrorContext("category creation", $error_msg, $creationForm, $ex); - - // At this point, the form has error, and should be redisplayed. - return $this->renderList(); - } - - /** - * Load a category object for modification, and display the edit template. - * - * @return Symfony\Component\HttpFoundation\Response the response - */ - public function changeAction() - { - // Check current user authorization - if (null !== $response = $this->checkAuth("admin.categories.update")) return $response; - - // Load the category object - $category = CategoryQuery::create() - ->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(), - 'locale' => $category->getLocale(), - 'title' => $category->getTitle(), - 'chapo' => $category->getChapo(), - 'description' => $category->getDescription(), - 'postscriptum' => $category->getPostscriptum(), - 'parent' => $category->getParent(), - 'visible' => $category->getVisible() ? true : false, - 'url' => $category->getUrl($this->getCurrentEditionLocale()) - // tbc !!! - ); - - // Setup the object form - $changeForm = new CategoryModificationForm($this->getRequest(), "form", $data); - - // Pass it to the parser - $this->getParserContext()->addForm($changeForm); - } - - // Render the edition template. - return $this->render('category-edit', $this->getTemplateArgs()); - } - - /** - * Save changes on a modified category object, and either go back to the category list, or stay on the edition page. - * - * @return Symfony\Component\HttpFoundation\Response the response - */ - public function saveChangeAction() - { - // Check current user authorization - if (null !== $response = $this->checkAuth("admin.categories.update")) return $response; - - $error_msg = false; - - // Create the form from the request - $changeForm = new CategoryModificationForm($this->getRequest()); - - // Get the category ID - $category_id = $this->getRequest()->get('category_id'); - - try { - - // Check the form against constraints violations - $form = $this->validateForm($changeForm, "POST"); - - // Get the form field values - $data = $form->getData(); - - $changeEvent = new CategoryUpdateEvent($data['id']); - - // Create and dispatch the change event - $changeEvent - ->setCategoryName($data['name']) - ->setLocale($data["locale"]) - ->setSymbol($data['symbol']) - ->setCode($data['code']) - ->setRate($data['rate']) - ; - - $this->dispatch(TheliaEvents::CATEGORY_UPDATE, $changeEvent); - - if (! $createEvent->hasCategory()) throw new \LogicException($this->getTranslator()->trans("No category was updated.")); - - // Log category modification - $changedObject = $changeEvent->getCategory(); - - $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. - if ($this->getRequest()->get('save_mode') == 'stay') { - $this->redirectToRoute( - "admin.categories.update", - array('category_id' => $category_id) + protected function redirectToListTemplate() { + $this->redirectToRoute( + 'admin.categories.default', + array('category_id' => $this->getRequest()->get('category_id', 0)) ); - } - - // Redirect to the success URL - $this->redirect($changeForm->getSuccessUrl()); - } catch (FormValidationException $ex) { - // Form cannot be validated - $error_msg = $this->createStandardFormValidationErrorMessage($ex); - } catch (\Exception $ex) { - // Any other error - $error_msg = $ex->getMessage(); - } - - $this->setupFormErrorContext("category modification", $error_msg, $changeForm, $ex); - - // At this point, the form has errors, and should be redisplayed. - return $this->render('category-edit', array('category_id' => $category_id)); } /** @@ -253,74 +187,41 @@ class CategoryController extends BaseAdminController // Check current user authorization if (null !== $response = $this->checkAuth("admin.categories.update")) return $response; - $changeEvent = new CategoryUpdateEvent($this->getRequest()->get('category_id', 0)); - - // Create and dispatch the change event - $changeEvent->setIsDefault(true); + $event = new CategoryToggleVisibilityEvent($this->getExistingObject()); try { - $this->dispatch(TheliaEvents::CATEGORY_SET_DEFAULT, $changeEvent); + $this->dispatch(TheliaEvents::CATEGORY_TOGGLE_VISIBILITY, $event); } catch (\Exception $ex) { // Any error return $this->errorPage($ex); } - $this->redirectToRoute('admin.categories.default'); + // Ajax response -> no action + return $this->nullResponse(); } - /** - * Update categoryposition - */ - public function updatePositionAction() + protected function performAdditionalDeleteAction($deleteEvent) { - // Check current user authorization - if (null !== $response = $this->checkAuth("admin.categories.update")) return $response; + // Redirect to parent category list + $this->redirectToRoute( + 'admin.categories.default', + array('category_id' => $deleteEvent->getCategory()->getParent()) + ); + } - try { - $mode = $this->getRequest()->get('mode', null); + protected function performAdditionalUpdatePositionAction($event) + { - if ($mode == 'up') - $mode = CategoryUpdatePositionEvent::POSITION_UP; - else if ($mode == 'down') - $mode = CategoryUpdatePositionEvent::POSITION_DOWN; - else - $mode = CategoryUpdatePositionEvent::POSITION_ABSOLUTE; + $category = CategoryQuery::create()->findPk($event->getObjectId()); - $position = $this->getRequest()->get('position', null); - - $event = new CategoryUpdatePositionEvent( - $this->getRequest()->get('category_id', null), - $mode, - $this->getRequest()->get('position', null) + if ($category != null) { + // Redirect to parent category list + $this->redirectToRoute( + 'admin.categories.default', + array('category_id' => $category->getParent()) ); - - $this->dispatch(TheliaEvents::CATEGORY_UPDATE_POSITION, $event); - } catch (\Exception $ex) { - // Any error - return $this->errorPage($ex); } - $this->redirectToRoute('admin.categories.default'); - } - - /** - * Delete a category object - * - * @return Symfony\Component\HttpFoundation\Response the response - */ - public function deleteAction() - { - // Check current user authorization - if (null !== $response = $this->checkAuth("admin.categories.delete")) return $response; - - // Get the category id, and dispatch the deleted request - $event = new CategoryDeleteEvent($this->getRequest()->get('category_id')); - - $this->dispatch(TheliaEvents::CATEGORY_DELETE, $event); - - if ($event->hasCategory()) - $this->adminLogAppend(sprintf("Category %s (ID %s) deleted", $event->getCategory()->getTitle(), $event->getCategory()->getId())); - - $this->redirectToRoute('admin.categories.default'); + return null; } } diff --git a/core/lib/Thelia/Controller/Admin/ConfigController.php b/core/lib/Thelia/Controller/Admin/ConfigController.php index ff0e4bb39..8701710b0 100644 --- a/core/lib/Thelia/Controller/Admin/ConfigController.php +++ b/core/lib/Thelia/Controller/Admin/ConfigController.php @@ -33,7 +33,7 @@ use Thelia\Form\ConfigCreationForm; use Thelia\Core\Event\UpdatePositionEvent; /** - * Manages variables sent by mail + * Manages variables * * @author Franck Allimant */ diff --git a/core/lib/Thelia/Controller/Admin/CurrencyController.php b/core/lib/Thelia/Controller/Admin/CurrencyController.php index 4f3fdaaea..f0081d698 100644 --- a/core/lib/Thelia/Controller/Admin/CurrencyController.php +++ b/core/lib/Thelia/Controller/Admin/CurrencyController.php @@ -33,7 +33,7 @@ use Thelia\Form\CurrencyCreationForm; use Thelia\Core\Event\UpdatePositionEvent; /** - * Manages currencies sent by mail + * Manages currencies * * @author Franck Allimant */ diff --git a/core/lib/Thelia/Controller/Admin/FeatureAvController.php b/core/lib/Thelia/Controller/Admin/FeatureAvController.php index 25c7a5495..fc6571ccc 100644 --- a/core/lib/Thelia/Controller/Admin/FeatureAvController.php +++ b/core/lib/Thelia/Controller/Admin/FeatureAvController.php @@ -33,7 +33,7 @@ use Thelia\Form\FeatureAvCreationForm; use Thelia\Core\Event\UpdatePositionEvent; /** - * Manages features-av sent by mail + * Manages features-av * * @author Franck Allimant */ diff --git a/core/lib/Thelia/Controller/Admin/FeatureController.php b/core/lib/Thelia/Controller/Admin/FeatureController.php index 92cb89d33..f81f55919 100644 --- a/core/lib/Thelia/Controller/Admin/FeatureController.php +++ b/core/lib/Thelia/Controller/Admin/FeatureController.php @@ -37,7 +37,7 @@ use Thelia\Core\Event\FeatureAvUpdateEvent; use Thelia\Core\Event\FeatureEvent; /** - * Manages features sent by mail + * Manages features * * @author Franck Allimant */ diff --git a/core/lib/Thelia/Controller/Admin/TemplateController.php b/core/lib/Thelia/Controller/Admin/TemplateController.php index 3685a359a..c9e30612c 100644 --- a/core/lib/Thelia/Controller/Admin/TemplateController.php +++ b/core/lib/Thelia/Controller/Admin/TemplateController.php @@ -41,7 +41,7 @@ use Thelia\Core\Event\TemplateAddFeatureEvent; use Thelia\Core\Event\TemplateDeleteFeatureEvent; /** - * Manages templates sent by mail + * Manages product templates * * @author Franck Allimant */ diff --git a/core/lib/Thelia/Core/Event/CategoryCreateEvent.php b/core/lib/Thelia/Core/Event/CategoryCreateEvent.php index 5a687217c..41529019c 100644 --- a/core/lib/Thelia/Core/Event/CategoryCreateEvent.php +++ b/core/lib/Thelia/Core/Event/CategoryCreateEvent.php @@ -28,13 +28,7 @@ class CategoryCreateEvent extends CategoryEvent protected $title; protected $parent; protected $locale; - - public function __construct($title, $parent, $locale) - { - $this->title = $title; - $this->parent = $parent; - $this->locale = $locale; - } + protected $visible; public function getTitle() { @@ -71,4 +65,16 @@ class CategoryCreateEvent extends CategoryEvent return $this; } + + public function getVisible() + { + return $this->visible; + } + + public function setVisible($visible) + { + $this->visible = $visible; + + return $this; + } } diff --git a/core/lib/Thelia/Core/Event/CategoryToggleVisibilityEvent.php b/core/lib/Thelia/Core/Event/CategoryToggleVisibilityEvent.php new file mode 100644 index 000000000..f90378e38 --- /dev/null +++ b/core/lib/Thelia/Core/Event/CategoryToggleVisibilityEvent.php @@ -0,0 +1,28 @@ +. */ +/* */ +/*************************************************************************************/ + +namespace Thelia\Core\Event; + +class CategoryToggleVisibilityEvent extends CategoryEvent +{ +} diff --git a/core/lib/Thelia/Core/Event/CategoryUpdateEvent.php b/core/lib/Thelia/Core/Event/CategoryUpdateEvent.php index 44e760549..f5f775a22 100644 --- a/core/lib/Thelia/Core/Event/CategoryUpdateEvent.php +++ b/core/lib/Thelia/Core/Event/CategoryUpdateEvent.php @@ -32,7 +32,6 @@ class CategoryUpdateEvent extends CategoryCreateEvent protected $postscriptum; protected $url; - protected $visibility; protected $parent; public function __construct($category_id) @@ -100,18 +99,6 @@ class CategoryUpdateEvent extends CategoryCreateEvent return $this; } - public function getVisibility() - { - return $this->visibility; - } - - public function setVisibility($visibility) - { - $this->visibility = $visibility; - - return $this; - } - public function getParent() { return $this->parent; diff --git a/core/lib/Thelia/Core/Event/TheliaEvents.php b/core/lib/Thelia/Core/Event/TheliaEvents.php index 2867762aa..a305f134a 100755 --- a/core/lib/Thelia/Core/Event/TheliaEvents.php +++ b/core/lib/Thelia/Core/Event/TheliaEvents.php @@ -145,50 +145,21 @@ final class TheliaEvents // -- END ADDRESS MANAGEMENT --------------------------------------------------------- - /** - * Sent once the category creation form has been successfully validated, and before category insertion in the database. - */ - const BEFORE_CREATECATEGORY = "action.before_createcategory"; + // -- Categories management ----------------------------------------------- - /** - * Create, change or delete a category - */ - const CATEGORY_CREATE = "action.createCategory"; - const CATEGORY_UPDATE = "action.updateCategory"; - const CATEGORY_DELETE = "action.deleteCategory"; - - /** - * Toggle category visibility - */ + const CATEGORY_CREATE = "action.createCategory"; + const CATEGORY_UPDATE = "action.updateCategory"; + const CATEGORY_DELETE = "action.deleteCategory"; const CATEGORY_TOGGLE_VISIBILITY = "action.toggleCategoryVisibility"; + const CATEGORY_UPDATE_POSITION = "action.updateCategoryPosition"; - /** - * Change category position - */ - const CATEGORY_CHANGE_POSITION = "action.updateCategoryPosition"; - - /** - * Sent just after a successful insert of a new category in the database. - */ + const BEFORE_CREATECATEGORY = "action.before_createcategory"; const AFTER_CREATECATEGORY = "action.after_createcategory"; - /** - * Sent befonre deleting a category - */ - const BEFORE_DELETECATEGORY = "action.before_deletecategory"; - /** - * Sent just after a successful delete of a category from the database. - */ + const BEFORE_DELETECATEGORY = "action.before_deletecategory"; const AFTER_DELETECATEGORY = "action.after_deletecategory"; - /** - * Sent just before a successful change of a category in the database. - */ const BEFORE_UPDATECATEGORY = "action.before_updateCategory"; - - /** - * Sent just after a successful change of a category in the database. - */ const AFTER_UPDATECATEGORY = "action.after_updateCategory"; /** diff --git a/core/lib/Thelia/Core/Template/Loop/CategoryTree.php b/core/lib/Thelia/Core/Template/Loop/CategoryTree.php index afcd0410e..712767954 100755 --- a/core/lib/Thelia/Core/Template/Loop/CategoryTree.php +++ b/core/lib/Thelia/Core/Template/Loop/CategoryTree.php @@ -59,7 +59,7 @@ class CategoryTree extends BaseI18nLoop } // changement de rubrique - protected function buildCategoryTree($parent, $visible, $level, $max_level, array $exclude, LoopResult &$loopResult) + protected function buildCategoryTree($parent, $visible, $level, $max_level, $exclude, LoopResult &$loopResult) { if ($level > $max_level) return; @@ -73,7 +73,7 @@ class CategoryTree extends BaseI18nLoop if ($visible != BooleanOrBothType::ANY) $search->filterByVisible($visible); - $search->filterById($exclude, Criteria::NOT_IN); + if ($exclude != null) $search->filterById($exclude, Criteria::NOT_IN); $search->orderByPosition(Criteria::ASC); diff --git a/core/lib/Thelia/Form/CategoryCreationForm.php b/core/lib/Thelia/Form/CategoryCreationForm.php index 5dce6a049..172b09ee6 100755 --- a/core/lib/Thelia/Form/CategoryCreationForm.php +++ b/core/lib/Thelia/Form/CategoryCreationForm.php @@ -39,7 +39,8 @@ class CategoryCreationForm extends BaseForm "for" => "title" ) )) - ->add("parent", "integer", array( + ->add("parent", "text", array( + "label" => Translator::getInstance()->trans("Parent category *"), "constraints" => array( new NotBlank() ) @@ -49,6 +50,9 @@ class CategoryCreationForm extends BaseForm new NotBlank() ) )) + ->add("visible", "integer", array( + "label" => Translator::getInstance()->trans("This category is online on the front office.") + )) ; } diff --git a/core/lib/Thelia/Form/CategoryModificationForm.php b/core/lib/Thelia/Form/CategoryModificationForm.php index d9de36d16..42b5893c1 100644 --- a/core/lib/Thelia/Form/CategoryModificationForm.php +++ b/core/lib/Thelia/Form/CategoryModificationForm.php @@ -24,6 +24,7 @@ namespace Thelia\Form; use Symfony\Component\Validator\Constraints\GreaterThan; use Thelia\Core\Translation\Translator; +use Symfony\Component\Validator\Constraints\NotBlank; class CategoryModificationForm extends CategoryCreationForm { @@ -36,12 +37,13 @@ class CategoryModificationForm extends CategoryCreationForm $this->formBuilder ->add("id", "hidden", array("constraints" => array(new GreaterThan(array('value' => 0))))) - ->add("visible", "checkbox", array( - "label" => Translator::getInstance()->trans("This category is online on the front office.") + ->add("url", "text", array( + "label" => Translator::getInstance()->trans("Rewriten URL *"), + "constraints" => array(new NotBlank()) )) ; - // Add standard description fields + // Add standard description fields, excluding title and locale, which a re defined in parent class $this->addStandardDescFields(array('title', 'locale')); } diff --git a/core/lib/Thelia/Model/Category.php b/core/lib/Thelia/Model/Category.php index ced10c94b..5533eaf42 100755 --- a/core/lib/Thelia/Model/Category.php +++ b/core/lib/Thelia/Model/Category.php @@ -28,26 +28,6 @@ class Category extends BaseCategory return URL::getInstance()->retrieve('category', $this->getId(), $locale)->toString(); } - /** - * Create a new category. - * - * @param string $title the category title - * @param int $parent the ID of the parent category - * @param string $locale the locale of the title - */ - public function create($title, $parent, $locale) - { - $this - ->setLocale($locale) - ->setTitle($title) - ->setParent($parent) - ->setVisible(1) - ->setPosition($this->getNextPosition($parent)) - ; - - $this->save(); - } - /** * * count all products for current category and sub categories @@ -73,6 +53,8 @@ class Category extends BaseCategory public function preInsert(ConnectionInterface $con = null) { + $this->setPosition($this->getNextPosition($this->parent)); + $this->dispatchEvent(TheliaEvents::BEFORE_CREATECATEGORY, new CategoryEvent($this)); return true; @@ -98,6 +80,8 @@ class Category extends BaseCategory public function preDelete(ConnectionInterface $con = null) { $this->dispatchEvent(TheliaEvents::BEFORE_DELETECATEGORY, new CategoryEvent($this)); + + return true; } public function postDelete(ConnectionInterface $con = null) diff --git a/templates/admin/default/assets/less/thelia/thelia.less b/templates/admin/default/assets/less/thelia/thelia.less index 50cd9bde6..6dc130918 100644 --- a/templates/admin/default/assets/less/thelia/thelia.less +++ b/templates/admin/default/assets/less/thelia/thelia.less @@ -34,7 +34,7 @@ .topbar { - background: url("@{imgDir}/top.jpg") repeat-x; + background: url("@{imgDir}/top.jpg") repeat-x; font-weight: bold; .version-info { @@ -202,7 +202,7 @@ border-bottom: 2px solid #A5CED8; margin-bottom: 0.5em; } - + // The action bar on the right .actions { text-align: right; @@ -217,6 +217,10 @@ text-transform: none; } } + + .inner-actions { + margin-top: 0.5em; + } } // The overall form container diff --git a/templates/admin/default/categories.html b/templates/admin/default/categories.html index 6fe06f8bc..32b9e6cba 100755 --- a/templates/admin/default/categories.html +++ b/templates/admin/default/categories.html @@ -1,396 +1,260 @@ {extends file="admin-layout.tpl"} -{block name="page-title"}{intl l='Catalog'}{/block} +{block name="page-title"}{intl l='Categories'}{/block} -{block name="check-permissions"}admin.catalog.view{/block} +{block name="check-permissions"}admin.categories.view{/block} {block name="main-content"} -
-
+
- {include file="includes/catalog-breadcrumb.html"} +
- {module_include location='catalog_top'} + {include file="includes/catalog-breadcrumb.html"} -
-
-
- - - {module_include location='catalog_bottom'} - - + {module_include location='category_list_row'} - {* Adding a new Category *} + + + + + + + {/loop} + + {/ifloop} + + {elseloop rel="category_list"} + + + + + + {/elseloop} +
- {* display parent category name, and get current cat ID *} - {loop name="category_title" type="category" visible="*" id=$current_category_id} - {intl l="Categories in %cat" cat=$TITLE} - {$cat_id = $ID} - {/loop} - {elseloop rel="category_title"} - {intl l="Top level categories"} - {/elseloop} + {module_include location='categories_top'} - {module_include location='category_list_caption'} +
+
+
+ + + {module_include location='category_list_caption'} - {ifloop rel="category_list"} - - - + {loop type="auth" name="can_create" roles="ADMIN" permissions="admin.categories.create"} + + + + {/loop} + - + {ifloop rel="category_list"} + + + - + - {module_include location='category_list_header'} + - + {module_include location='category_list_header'} - + - - - + - - {loop name="category_list" type="category" visible="*" parent=$current_category_id order=$category_order backend_context="1" lang=$lang_id} - - + + + - + + {loop name="category_list" type="category" visible="*" parent=$category_id order=$category_order backend_context="1" lang=$lang_id} + + - - - {module_include location='category_list_row'} - - - - - - - - {/loop} - - {/ifloop} - - {elseloop rel="category_list"} - - - - - - {/elseloop} -
+ {* display parent category name, and get current cat ID *} + {loop name="category_title" type="category" visible="*" id=$category_id} + {intl l="Categories in %cat" cat=$TITLE} + {$cat_id = $ID} + {/loop} + {elseloop rel="category_title"} + {intl l="Top level categories"} + {/elseloop} - {loop type="auth" name="can_create" roles="ADMIN" permissions="admin.categories.create"} - - - - {/loop} -
- {admin_sortable_header - current_order=$category_order - order='id' - reverse_order='id_reverse' - path={url path='/admin/catalog' id_category=$current_category_id} - label="{intl l='ID'}" - } -  
+ {admin_sortable_header + current_order=$category_order + order='id' + reverse_order='id_reverse' + path={url path='/admin/categories' id_category=$category_id} + request_parameter_name='category_order' + label="{intl l='ID'}" + } + - {admin_sortable_header - current_order=$category_order - order='alpha' - reverse_order='alpha_reverse' - path={url path='/admin/catalog' id_category=$current_category_id} - label="{intl l='Category title'}" - } -   + {admin_sortable_header + current_order=$category_order + order='alpha' + reverse_order='alpha_reverse' + path={url path='/admin/categories' id_category=$category_id} + request_parameter_name='category_order' + label="{intl l='Category title'}" + } + - {admin_sortable_header - current_order=$category_order - order='visible' - reverse_order='visible_reverse' - path={url path='/admin/catalog' id_category=$current_category_id} - label="{intl l='Online'}" - } - - {admin_sortable_header - current_order=$category_order - order='manual' - reverse_order='manual_reverse' - path={url path='/admin/catalog' id_category=$current_category_id} - label="{intl l='Position'}" - } - + {admin_sortable_header + current_order=$category_order + order='visible' + reverse_order='visible_reverse' + path={url path='/admin/categories' id_category=$category_id} + request_parameter_name='category_order' + label="{intl l='Online'}" + } + {intl l='Actions'}
+ {admin_sortable_header + current_order=$category_order + order='manual' + reverse_order='manual_reverse' + path={url path='/admin/categories' id_category=$category_id} + request_parameter_name='category_order' + label="{intl l='Position'}" + } +
{$ID}{intl l='Actions'}
- {loop type="image" name="cat_image" source="category" source_id="$ID" limit="1" width="50" height="50" resize_mode="crop" backend_context="1"} - {$TITLE} - {/loop} -
{$ID} - - {$TITLE} - - - {loop type="auth" name="can_change" roles="ADMIN" permissions="admin.categories.edit"} -
- -
- {/loop} - - {elseloop rel="can_change"} -
- -
- {/elseloop} -
- {admin_position_block - permission="admin.categories.edit" - path={url path='admin/category/update-position' category_id=$ID} - url_parameter="category_id" - in_place_edit_class="categoryPositionChange" - position=$POSITION - id=$ID - } - -
- - - {loop type="auth" name="can_change" roles="ADMIN" permissions="admin.categories.edit"} - - {/loop} - - {loop type="auth" name="can_delete" roles="ADMIN" permissions="admin.categories.delete"} - - {/loop} -
-
-
- {loop type="auth" name="can_create" roles="ADMIN" permissions="admin.categories.create"} - {intl l="This category has no sub-categories. To create a new one, click the + button above."} - {/loop} - - {elseloop rel="can_create"} - {intl l="This category has no sub-categories."} - {/elseloop} -
-
-
-
-
- -
-
-
- - - - {ifloop rel="product_list"} - - - - - - - - - - - - - - - - {loop name="product_list" type="product" category=$current_category_id order="manual"} - - - - - - - - {module_include location='product_list_row'} - - - - - - - - {/loop} - - {/ifloop} + - {elseloop rel="product_list"} - - - - - - {/elseloop} -
- {* display parent category name *} - {loop name="category_title" type="category" visible="*" id=$current_category_id} - {intl l="Products in %cat" cat=$TITLE} - {/loop} - - {elseloop rel="category_title"} - {intl l="Top level Products"} - {/elseloop} - - {module_include location='product_list_caption'} - - - - -
- {admin_sortable_header - current_order=$product_order - order='id' - reverse_order='id_reverse' - path={url path='/admin/product' category_id=$current_category_id} - label="{intl l='ID'}" - } - -   - {admin_sortable_header - current_order=$product_order - order='ref' - reverse_order='ref_reverse' - path={url path='/admin/product' category_id=$current_category_id} - label="{intl l='Reference'}" - } - - {admin_sortable_header - current_order=$product_order - order='alpha' - reverse_order='alpha_reverse' - path={url path='/admin/product' category_id=$current_category_id} - label="{intl l='Product title'}" - } - - {module_include location='product_list_header'} - - - {admin_sortable_header - current_order=$product_order - order='visible' - reverse_order='visible_reverse' - path={url path='/admin/product' category_id=$current_category_id} - label="{intl l='Online'}" - } - - {admin_sortable_header - current_order=$product_order - order='manual' - reverse_order='manual_reverse' - path={url path='/admin/product' category_id=$current_category_id} - label="{intl l='Position'}" - } -  
{$ID} - {loop type="image" name="cat_image" source="product" source_id="$ID" limit="1" width="50" height="50" resize_mode="crop" backend_context="1"} - - {$TITLE} - - {/loop} - - {$REF}{$TITLE} - {loop type="auth" name="can_change" roles="ADMIN" permissions="admin.products.edit"} -
- -
- {/loop} - - {elseloop rel="can_change"} -
- -
- {/elseloop} -
- {admin_position_block - permission="admin.product.edit" - path={url path='admin/product' category_id=$ID} - url_parameter="product_id" - in_place_edit_class="productPositionChange" - position=$POSITION - id=$ID - } - -
- {loop type="auth" name="can_change" roles="ADMIN" permissions="admin.product.edit"} - - {/loop} - - {loop type="auth" name="can_change" roles="ADMIN" permissions="admin.product.delete"} - +
+ {loop type="image" name="cat_image" source="category" source_id="$ID" limit="1" width="50" height="50" resize_mode="crop" backend_context="1"} + {$TITLE} {/loop} - -
{intl l="This category doesn't have any products. To add a new product, click the + button above."}
-
-
-
+
+ + {$TITLE} + + + {loop type="auth" name="can_change" roles="ADMIN" permissions="admin.categories.edit"} +
+ +
+ {/loop} - {form name="thelia.admin.category.creation"} + {elseloop rel="can_change"} +
+ +
+ {/elseloop} +
+ {admin_position_block + permission="admin.categories.edit" + path={url path='admin/categories/update-position' category_id=$ID} + url_parameter="category_id" + in_place_edit_class="categoryPositionChange" + position=$POSITION + id=$ID + } + +
+ + + {loop type="auth" name="can_change" roles="ADMIN" permissions="admin.categories.edit"} + + {/loop} + + {loop type="auth" name="can_delete" roles="ADMIN" permissions="admin.categories.delete"} + + {/loop} +
+
+
+ {loop type="auth" name="can_create" roles="ADMIN" permissions="admin.categories.create"} + {intl l="This category has no sub-categories. To create a new one, click the + button above."} + {/loop} + + {elseloop rel="can_create"} + {intl l="This category has no sub-categories."} + {/elseloop} +
+
+
+
+
+ + {module_include location='categories_bottom'} + +
+
+ + + {* Adding a new category *} + + {form name="thelia.admin.category.creation"} {* Capture the dialog body, to pass it to the generic dialog *} {capture "category_creation_dialog"} {form_hidden_fields form=$form} - {form_field form=$form field='success_url'} - {* on success, redirect to the edition page, _ID_ is replaced with the created object ID, see controller *} - - {/form_field} + {form_field form=$form field='success_url'} + {* on success, redirect to the edition page, _ID_ is replaced with the created object ID, see controller *} + + {/form_field} - {form_field form=$form field='parent'} - - {/form_field} + {form_field form=$form field='parent'} + + {/form_field} - {form_field form=$form field='title'} -
- + {form_field form=$form field='title'} +
+ + {loop type="lang" name="default-lang" default_only="1"} +
+ + $TITLE +
- {loop type="lang" name="default-lang" default_only="1"} +
{intl l='Enter here the category name in the default language (%title)' title="$TITLE"}
-
- - $TITLE -
+ {* Switch edition to the current locale *} + -
{intl l='Enter here the category name in the default language (%title)' title="$TITLE"}
+ {form_field form=$form field='locale'} + + {/form_field} + {/loop} +
+ {/form_field} - {* Switch edition to the current locale *} - - - {form_field form=$form field='locale'} - - {/form_field} - {/loop} -
- {/form_field} + {form_field form=$form field='visible'} +
+
+ +
+
+ {/form_field} {module_include location='category_create_form'} - {/capture} + {/capture} - {include - file = "includes/generic-create-dialog.html" + {include + file = "includes/generic-create-dialog.html" - dialog_id = "add_category_dialog" - dialog_title = {intl l="Create a new category"} - dialog_body = {$smarty.capture.category_creation_dialog nofilter} + dialog_id = "category_creation_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"} + dialog_ok_label = {intl l="Create this category"} - form_action = {url path='/admin/categories/create'} - form_enctype = {form_enctype form=$form} - form_error_message = $form_error_message - } + form_action = {url path='/admin/categories/create'} + form_enctype = {form_enctype form=$form} + form_error_message = $form_error_message + } {/form} - {* Delete category confirmation dialog *} + + {* Delete confirmation dialog *} {capture "category_delete_dialog"} - - + {module_include location='category_delete_form'} @@ -399,9 +263,9 @@ {include file = "includes/generic-confirm-dialog.html" - 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 ?"} + dialog_id = "category_delete_dialog" + dialog_title = {intl l="Delete category"} + dialog_message = {intl l="Do you really want to delete this category and all its content ?"} form_action = {url path='/admin/categories/delete'} form_content = {$smarty.capture.category_delete_dialog nofilter} @@ -410,108 +274,76 @@ {block name="javascript-initialization"} - {javascripts file='assets/js/bootstrap-switch/bootstrap-switch.js'} - - {/javascripts} + {javascripts file='assets/js/bootstrap-switch/bootstrap-switch.js'} + + {/javascripts} - {javascripts file='assets/js/bootstrap-editable/bootstrap-editable.js'} - - {/javascripts} + {javascripts file='assets/js/bootstrap-editable/bootstrap-editable.js'} + + {/javascripts} - + {/block} \ No newline at end of file diff --git a/templates/admin/default/category-edit.html b/templates/admin/default/category-edit.html index e01849475..9fa9e18e4 100755 --- a/templates/admin/default/category-edit.html +++ b/templates/admin/default/category-edit.html @@ -11,7 +11,7 @@ {include file="includes/catalog-breadcrumb.html"}
- {loop name="category_edit" type="category" visible="*" id="{$current_category_id}" backend_context="1" lang="$edit_language_id"} + {loop name="category_edit" type="category" visible="*" id="{$category_id}" backend_context="1" lang="$edit_language_id"}
@@ -25,189 +25,126 @@
- +
+
-
- -
+
-
-
-
+
- {include file="includes/inner-form-toolbar.html" close_url="{url path='admin/catalog/category/edit' category_id=$current_category_id}"} +
-
-
-
- + {form name="thelia.admin.category.modification"} + -
- -
-
+ {include file="includes/inner-form-toolbar.html" close_url="{url path='/admin/categories' category_id=$category_id}"} -
- + {* Be sure to get the category ID, even if the form could not be validated *} + -
- -
-
+ {form_hidden_fields form=$form} -
- + {form_field form=$form field='success_url'} + + {/form_field} -
- + {form_field form=$form field='locale'} + + {/form_field} -
-
+ {if $form_error}
{$form_error_message}
{/if} -
- + {include file="includes/standard-description-form-fields.html"} -
- -
-
+ {form_field form=$form field='url'} +
+ -
- + +
+ {/form_field} -
- -
{intl l="The rewritten URL to the category page. Click \"Use Default\" button to use the default URL. Use only digits, letters, - and _ characters."}
-
-
+
+
+ {form_field form=$form field='parent'} +
-
-
+ -
-
-
-   -
-

{intl l='Category created on %date_create. Last modification: %date_change' date_create="{format_date date=$CREATE_DATE}" date_change="{format_date date=$UPDATE_DATE}"}}

-
-
-
-
+ +
+ {/form_field} +
+ +
+ {form_field form=$form field='visible'} +
+ +
+ +
+
+ {/form_field} +
+
-
-
- - -
- -
-
-
- -
-
- - -
- -
-
-
-
- -
- - -
- +   +
+

{intl l='Category created on %date_create. Last modification: %date_change' date_create="{format_date date=$CREATE_DATE}" date_change="{format_date date=$UPDATE_DATE}"}

-
+
-
-
-
+ + {/form} +
+
-
-

Images

-
+
+ klljkmk +
-
-

Documents

-
+
+
-
-

Modules

-
+
+
-
-
- - {/loop} +
+
+
+
+
+ {/loop}
@@ -217,10 +154,6 @@