diff --git a/core/lib/Thelia/Action/Attribute.php b/core/lib/Thelia/Action/Attribute.php index a2e956d8e..44c5968a4 100644 --- a/core/lib/Thelia/Action/Attribute.php +++ b/core/lib/Thelia/Action/Attribute.php @@ -41,6 +41,7 @@ use Thelia\Core\Event\CategoryEvent; use Thelia\Core\Event\AttributeEvent; use Thelia\Model\AttributeTemplate; use Thelia\Model\AttributeTemplateQuery; +use Thelia\Model\TemplateQuery; class Attribute extends BaseAction implements EventSubscriberInterface { @@ -137,23 +138,33 @@ class Attribute extends BaseAction implements EventSubscriberInterface } } - public function addToAllTemplates(AttributeEvent $event) + protected function doAddToAllTemplates(AttributeModel $attribute) { - $templates = AttributeTemplateQuery::create()->find(); + $templates = TemplateQuery::create()->find(); foreach($templates as $template) { - $pat = new AttributeTemplate(); - $pat->setTemplate($template->getId()) - ->setAttributeId($event->getAttribute()->getId()) - ->save(); + $attribute_template = new AttributeTemplate(); + + if (null === AttributeTemplateQuery::create()->filterByAttribute($attribute)->filterByTemplate($template)->findOne()) { + $attribute_template + ->setAttribute($attribute) + ->setTemplate($template) + ->save() + ; + } } } + public function addToAllTemplates(AttributeEvent $event) + { + $this->doAddToAllTemplates($event->getAttribute()); + } + public function removeFromAllTemplates(AttributeEvent $event) { // Delete this attribute from all product templates - AttributeTemplateQuery::create()->filterByAttributeId($event->getAttribute()->getId())->delete(); + AttributeTemplateQuery::create()->filterByAttribute($event->getAttribute())->delete(); } /** diff --git a/core/lib/Thelia/Action/Feature.php b/core/lib/Thelia/Action/Feature.php new file mode 100644 index 000000000..a746ce4e2 --- /dev/null +++ b/core/lib/Thelia/Action/Feature.php @@ -0,0 +1,186 @@ +. */ +/* */ +/*************************************************************************************/ + +namespace Thelia\Action; + +use Symfony\Component\EventDispatcher\EventSubscriberInterface; + +use Thelia\Model\FeatureQuery; +use Thelia\Model\Feature as FeatureModel; + +use Thelia\Core\Event\TheliaEvents; + +use Thelia\Core\Event\FeatureUpdateEvent; +use Thelia\Core\Event\FeatureCreateEvent; +use Thelia\Core\Event\FeatureDeleteEvent; +use Thelia\Model\ConfigQuery; +use Thelia\Model\FeatureAv; +use Thelia\Model\FeatureAvQuery; +use Thelia\Core\Event\UpdatePositionEvent; +use Thelia\Core\Event\CategoryEvent; +use Thelia\Core\Event\FeatureEvent; +use Thelia\Model\FeatureTemplate; +use Thelia\Model\FeatureTemplateQuery; +use Thelia\Model\TemplateQuery; + +class Feature extends BaseAction implements EventSubscriberInterface +{ + /** + * Create a new feature entry + * + * @param FeatureCreateEvent $event + */ + public function create(FeatureCreateEvent $event) + { + $feature = new FeatureModel(); + + $feature + ->setDispatcher($this->getDispatcher()) + + ->setLocale($event->getLocale()) + ->setTitle($event->getTitle()) + + ->save() + ; + + $event->setFeature($feature); + + // Add atribute to all product templates if required + if ($event->getAddToAllTemplates() != 0) { + // TODO: add to all product template + } + } + + /** + * Change a product feature + * + * @param FeatureUpdateEvent $event + */ + public function update(FeatureUpdateEvent $event) + { + $search = FeatureQuery::create(); + + if (null !== $feature = FeatureQuery::create()->findPk($event->getFeatureId())) { + + $feature + ->setDispatcher($this->getDispatcher()) + + ->setLocale($event->getLocale()) + ->setTitle($event->getTitle()) + ->setDescription($event->getDescription()) + ->setChapo($event->getChapo()) + ->setPostscriptum($event->getPostscriptum()) + + ->save(); + + $event->setFeature($feature); + } + } + + /** + * Delete a product feature entry + * + * @param FeatureDeleteEvent $event + */ + public function delete(FeatureDeleteEvent $event) + { + + if (null !== ($feature = FeatureQuery::create()->findPk($event->getFeatureId()))) { + + $feature + ->setDispatcher($this->getDispatcher()) + ->delete() + ; + + $event->setFeature($feature); + } + } + + /** + * Changes position, selecting absolute ou relative change. + * + * @param CategoryChangePositionEvent $event + */ + public function updatePosition(UpdatePositionEvent $event) + { + if (null !== $feature = FeatureQuery::create()->findPk($event->getObjectId())) { + + $feature->setDispatcher($this->getDispatcher()); + + $mode = $event->getMode(); + + if ($mode == UpdatePositionEvent::POSITION_ABSOLUTE) + return $feature->changeAbsolutePosition($event->getPosition()); + else if ($mode == UpdatePositionEvent::POSITION_UP) + return $feature->movePositionUp(); + else if ($mode == UpdatePositionEvent::POSITION_DOWN) + return $feature->movePositionDown(); + } + } + + protected function doAddToAllTemplates(FeatureModel $feature) + { + $templates = TemplateQuery::create()->find(); + + foreach($templates as $template) { + + $feature_template = new FeatureTemplate(); + + if (null === FeatureTemplateQuery::create()->filterByFeature($feature)->filterByTemplate($template)->findOne()) { + $feature_template + ->setFeature($feature) + ->setTemplate($template) + ->save() + ; + } + } + } + + public function addToAllTemplates(FeatureEvent $event) + { + $this->doAddToAllTemplates($event->getFeature()); + } + + public function removeFromAllTemplates(FeatureEvent $event) + { + // Delete this feature from all product templates + FeatureTemplateQuery::create()->filterByFeature($event->getFeature())->delete(); + } + + /** + * {@inheritDoc} + */ + public static function getSubscribedEvents() + { + return array( + TheliaEvents::FEATURE_CREATE => array("create", 128), + TheliaEvents::FEATURE_UPDATE => array("update", 128), + TheliaEvents::FEATURE_DELETE => array("delete", 128), + TheliaEvents::FEATURE_UPDATE_POSITION => array("updatePosition", 128), + + TheliaEvents::FEATURE_REMOVE_FROM_ALL_TEMPLATES => array("removeFromAllTemplates", 128), + TheliaEvents::FEATURE_ADD_TO_ALL_TEMPLATES => array("addToAllTemplates", 128), + + ); + } +} \ No newline at end of file diff --git a/core/lib/Thelia/Action/FeatureAv.php b/core/lib/Thelia/Action/FeatureAv.php new file mode 100644 index 000000000..2bd117b4b --- /dev/null +++ b/core/lib/Thelia/Action/FeatureAv.php @@ -0,0 +1,143 @@ +. */ +/* */ +/*************************************************************************************/ + +namespace Thelia\Action; + +use Symfony\Component\EventDispatcher\EventSubscriberInterface; + +use Thelia\Model\FeatureAvQuery; +use Thelia\Model\FeatureAv as FeatureAvModel; + +use Thelia\Core\Event\TheliaEvents; + +use Thelia\Core\Event\FeatureAvUpdateEvent; +use Thelia\Core\Event\FeatureAvCreateEvent; +use Thelia\Core\Event\FeatureAvDeleteEvent; +use Thelia\Model\ConfigQuery; +use Thelia\Core\Event\UpdatePositionEvent; + +class FeatureAv extends BaseAction implements EventSubscriberInterface +{ + /** + * Create a new feature entry + * + * @param FeatureAvCreateEvent $event + */ + public function create(FeatureAvCreateEvent $event) + { + $feature = new FeatureAvModel(); + + $feature + ->setDispatcher($this->getDispatcher()) + + ->setFeatureId($event->getFeatureId()) + ->setLocale($event->getLocale()) + ->setTitle($event->getTitle()) + + ->save() + ; + + $event->setFeatureAv($feature); + } + + /** + * Change a product feature + * + * @param FeatureAvUpdateEvent $event + */ + public function update(FeatureAvUpdateEvent $event) + { + $search = FeatureAvQuery::create(); + + if (null !== $feature = FeatureAvQuery::create()->findPk($event->getFeatureAvId())) { + + $feature + ->setDispatcher($this->getDispatcher()) + + ->setLocale($event->getLocale()) + ->setTitle($event->getTitle()) + ->setDescription($event->getDescription()) + ->setChapo($event->getChapo()) + ->setPostscriptum($event->getPostscriptum()) + + ->save(); + + $event->setFeatureAv($feature); + } + } + + /** + * Delete a product feature entry + * + * @param FeatureAvDeleteEvent $event + */ + public function delete(FeatureAvDeleteEvent $event) + { + + if (null !== ($feature = FeatureAvQuery::create()->findPk($event->getFeatureAvId()))) { + + $feature + ->setDispatcher($this->getDispatcher()) + ->delete() + ; + + $event->setFeatureAv($feature); + } + } + + /** + * Changes position, selecting absolute ou relative change. + * + * @param CategoryChangePositionEvent $event + */ + public function updatePosition(UpdatePositionEvent $event) + { + if (null !== $feature = FeatureAvQuery::create()->findPk($event->getObjectId())) { + + $feature->setDispatcher($this->getDispatcher()); + + $mode = $event->getMode(); + + if ($mode == UpdatePositionEvent::POSITION_ABSOLUTE) + return $feature->changeAbsolutePosition($event->getPosition()); + else if ($mode == UpdatePositionEvent::POSITION_UP) + return $feature->movePositionUp(); + else if ($mode == UpdatePositionEvent::POSITION_DOWN) + return $feature->movePositionDown(); + } + } + + + /** + * {@inheritDoc} + */ + public static function getSubscribedEvents() + { + return array( + TheliaEvents::FEATURE_AV_CREATE => array("create", 128), + TheliaEvents::FEATURE_AV_UPDATE => array("update", 128), + TheliaEvents::FEATURE_AV_DELETE => array("delete", 128), + TheliaEvents::FEATURE_AV_UPDATE_POSITION => array("updatePosition", 128), + ); + } +} \ No newline at end of file diff --git a/core/lib/Thelia/Config/Resources/action.xml b/core/lib/Thelia/Config/Resources/action.xml index f2fa776c3..a586667d1 100755 --- a/core/lib/Thelia/Config/Resources/action.xml +++ b/core/lib/Thelia/Config/Resources/action.xml @@ -67,11 +67,21 @@ + + + + + + + + + + diff --git a/core/lib/Thelia/Config/Resources/config.xml b/core/lib/Thelia/Config/Resources/config.xml index 9735aca36..d8211c6cc 100755 --- a/core/lib/Thelia/Config/Resources/config.xml +++ b/core/lib/Thelia/Config/Resources/config.xml @@ -72,8 +72,13 @@
+ + + + + diff --git a/core/lib/Thelia/Config/Resources/routing/admin.xml b/core/lib/Thelia/Config/Resources/routing/admin.xml index 8812d8ad4..14ab8d4de 100755 --- a/core/lib/Thelia/Config/Resources/routing/admin.xml +++ b/core/lib/Thelia/Config/Resources/routing/admin.xml @@ -292,6 +292,63 @@ + + + + Thelia\Controller\Admin\FeatureController::defaultAction + + + + Thelia\Controller\Admin\FeatureController::createAction + + + + Thelia\Controller\Admin\FeatureController::updateAction + + + + Thelia\Controller\Admin\FeatureController::processUpdateAction + + + + Thelia\Controller\Admin\FeatureController::deleteAction + + + + Thelia\Controller\Admin\FeatureController::updatePositionAction + + + + Thelia\Controller\Admin\FeatureController::removeFromAllTemplates + + + + Thelia\Controller\Admin\FeatureController::addToAllTemplates + + + + + Thelia\Controller\Admin\FeatureAvController::createAction + + + + Thelia\Controller\Admin\FeatureAvController::updateAction + + + + Thelia\Controller\Admin\FeatureAvController::processUpdateAction + + + + Thelia\Controller\Admin\FeatureAvController::deleteAction + + + + Thelia\Controller\Admin\FeatureAvController::updatePositionAction + + + + diff --git a/core/lib/Thelia/Controller/Admin/FeatureAvController.php b/core/lib/Thelia/Controller/Admin/FeatureAvController.php new file mode 100644 index 000000000..25c7a5495 --- /dev/null +++ b/core/lib/Thelia/Controller/Admin/FeatureAvController.php @@ -0,0 +1,196 @@ +. */ +/* */ +/*************************************************************************************/ + +namespace Thelia\Controller\Admin; + +use Thelia\Core\Event\FeatureAvDeleteEvent; +use Thelia\Core\Event\TheliaEvents; +use Thelia\Core\Event\FeatureAvUpdateEvent; +use Thelia\Core\Event\FeatureAvCreateEvent; +use Thelia\Model\FeatureAvQuery; +use Thelia\Form\FeatureAvModificationForm; +use Thelia\Form\FeatureAvCreationForm; +use Thelia\Core\Event\UpdatePositionEvent; + +/** + * Manages features-av sent by mail + * + * @author Franck Allimant + */ +class FeatureAvController extends AbstractCrudController +{ + public function __construct() + { + parent::__construct( + 'featureav', + 'manual', + 'order', + + 'admin.configuration.features-av.view', + 'admin.configuration.features-av.create', + 'admin.configuration.features-av.update', + 'admin.configuration.features-av.delete', + + TheliaEvents::FEATURE_AV_CREATE, + TheliaEvents::FEATURE_AV_UPDATE, + TheliaEvents::FEATURE_AV_DELETE, + null, // No visibility toggle + TheliaEvents::FEATURE_AV_UPDATE_POSITION + ); + } + + protected function getCreationForm() + { + return new FeatureAvCreationForm($this->getRequest()); + } + + protected function getUpdateForm() + { + return new FeatureAvModificationForm($this->getRequest()); + } + + protected function getCreationEvent($formData) + { + $createEvent = new FeatureAvCreateEvent(); + + $createEvent + ->setFeatureId($formData['feature_id']) + ->setTitle($formData['title']) + ->setLocale($formData["locale"]) + ; + + return $createEvent; + } + + protected function getUpdateEvent($formData) + { + $changeEvent = new FeatureAvUpdateEvent($formData['id']); + + // Create and dispatch the change event + $changeEvent + ->setLocale($formData["locale"]) + ->setTitle($formData['title']) + ->setChapo($formData['chapo']) + ->setDescription($formData['description']) + ->setPostscriptum($formData['postscriptum']) + ; + + return $changeEvent; + } + + protected function createUpdatePositionEvent($positionChangeMode, $positionValue) + { + return new UpdatePositionEvent( + $this->getRequest()->get('featureav_id', null), + $positionChangeMode, + $positionValue + ); + } + + protected function getDeleteEvent() + { + return new FeatureAvDeleteEvent($this->getRequest()->get('featureav_id')); + } + + protected function eventContainsObject($event) + { + return $event->hasFeatureAv(); + } + + protected function hydrateObjectForm($object) + { + $data = array( + 'id' => $object->getId(), + 'locale' => $object->getLocale(), + 'title' => $object->getTitle(), + 'chapo' => $object->getChapo(), + 'description' => $object->getDescription(), + 'postscriptum' => $object->getPostscriptum() + ); + + // Setup the object form + return new FeatureAvModificationForm($this->getRequest(), "form", $data); + } + + protected function getObjectFromEvent($event) + { + return $event->hasFeatureAv() ? $event->getFeatureAv() : null; + } + + protected function getExistingObject() + { + return FeatureAvQuery::create() + ->joinWithI18n($this->getCurrentEditionLocale()) + ->findOneById($this->getRequest()->get('featureav_id')); + } + + protected function getObjectLabel($object) + { + return $object->getTitle(); + } + + protected function getObjectId($object) + { + return $object->getId(); + } + + protected function getViewArguments() + { + return array( + 'feature_id' => $this->getRequest()->get('feature_id'), + 'order' => $this->getCurrentListOrder() + ); + } + + protected function renderListTemplate($currentOrder) + { + // We always return to the feature edition form + return $this->render( + 'feature-edit', + $this->getViewArguments() + ); + } + + protected function renderEditionTemplate() + { + // We always return to the feature edition form + return $this->render('feature-edit', $this->getViewArguments()); + } + + protected function redirectToEditionTemplate() + { + // We always return to the feature edition form + $this->redirectToRoute( + "admin.configuration.features.update", + $this->getViewArguments() + ); + } + + protected function redirectToListTemplate() + { + $this->redirectToRoute( + "admin.configuration.features.update", + $this->getViewArguments() + ); + } +} \ No newline at end of file diff --git a/core/lib/Thelia/Controller/Admin/FeatureController.php b/core/lib/Thelia/Controller/Admin/FeatureController.php new file mode 100644 index 000000000..92cb89d33 --- /dev/null +++ b/core/lib/Thelia/Controller/Admin/FeatureController.php @@ -0,0 +1,289 @@ +. */ +/* */ +/*************************************************************************************/ + +namespace Thelia\Controller\Admin; + +use Thelia\Core\Event\FeatureDeleteEvent; +use Thelia\Core\Event\TheliaEvents; +use Thelia\Core\Event\FeatureUpdateEvent; +use Thelia\Core\Event\FeatureCreateEvent; +use Thelia\Model\FeatureQuery; +use Thelia\Form\FeatureModificationForm; +use Thelia\Form\FeatureCreationForm; +use Thelia\Core\Event\UpdatePositionEvent; +use Thelia\Model\FeatureAv; +use Thelia\Model\FeatureAvQuery; +use Thelia\Core\Event\FeatureAvUpdateEvent; +use Thelia\Core\Event\FeatureEvent; + +/** + * Manages features sent by mail + * + * @author Franck Allimant + */ +class FeatureController extends AbstractCrudController +{ + public function __construct() + { + parent::__construct( + 'feature', + 'manual', + 'order', + + 'admin.configuration.features.view', + 'admin.configuration.features.create', + 'admin.configuration.features.update', + 'admin.configuration.features.delete', + + TheliaEvents::FEATURE_CREATE, + TheliaEvents::FEATURE_UPDATE, + TheliaEvents::FEATURE_DELETE, + null, // No visibility toggle + TheliaEvents::FEATURE_UPDATE_POSITION + ); + } + + protected function getCreationForm() + { + return new FeatureCreationForm($this->getRequest()); + } + + protected function getUpdateForm() + { + return new FeatureModificationForm($this->getRequest()); + } + + protected function getCreationEvent($formData) + { + $createEvent = new FeatureCreateEvent(); + + $createEvent + ->setTitle($formData['title']) + ->setLocale($formData["locale"]) + ->setAddToAllTemplates($formData['add_to_all']) + ; + + return $createEvent; + } + + protected function getUpdateEvent($formData) + { + $changeEvent = new FeatureUpdateEvent($formData['id']); + + // Create and dispatch the change event + $changeEvent + ->setLocale($formData["locale"]) + ->setTitle($formData['title']) + ->setChapo($formData['chapo']) + ->setDescription($formData['description']) + ->setPostscriptum($formData['postscriptum']) + ; + + return $changeEvent; + } + + /** + * Process the features values (fix it in future version to integrate it in the feature form as a collection) + * + * @see \Thelia\Controller\Admin\AbstractCrudController::performAdditionalUpdateAction() + */ + protected function performAdditionalUpdateAction($updateEvent) + { + $attr_values = $this->getRequest()->get('feature_values', null); + + if ($attr_values !== null) { + + foreach($attr_values as $id => $value) { + + $event = new FeatureAvUpdateEvent($id); + + $event->setTitle($value); + $event->setLocale($this->getCurrentEditionLocale()); + + $this->dispatch(TheliaEvents::FEATURE_AV_UPDATE, $event); + } + } + + return null; + } + + protected function createUpdatePositionEvent($positionChangeMode, $positionValue) + { + return new UpdatePositionEvent( + $this->getRequest()->get('feature_id', null), + $positionChangeMode, + $positionValue + ); + } + + protected function getDeleteEvent() + { + return new FeatureDeleteEvent($this->getRequest()->get('feature_id')); + } + + protected function eventContainsObject($event) + { + return $event->hasFeature(); + } + + protected function hydrateObjectForm($object) + { + + $data = array( + 'id' => $object->getId(), + 'locale' => $object->getLocale(), + 'title' => $object->getTitle(), + 'chapo' => $object->getChapo(), + 'description' => $object->getDescription(), + 'postscriptum' => $object->getPostscriptum() + ); + + // Setup features values + /* + * FIXME : doesn't work. "We get a This form should not contain extra fields." error + $attr_av_list = FeatureAvQuery::create() + ->joinWithI18n($this->getCurrentEditionLocale()) + ->filterByFeatureId($object->getId()) + ->find(); + + $attr_array = array(); + + foreach($attr_av_list as $attr_av) { + $attr_array[$attr_av->getId()] = $attr_av->getTitle(); + } + + $data['feature_values'] = $attr_array; + */ + + // Setup the object form + return new FeatureModificationForm($this->getRequest(), "form", $data); + } + + protected function getObjectFromEvent($event) + { + return $event->hasFeature() ? $event->getFeature() : null; + } + + protected function getExistingObject() + { + return FeatureQuery::create() + ->joinWithI18n($this->getCurrentEditionLocale()) + ->findOneById($this->getRequest()->get('feature_id')); + } + + protected function getObjectLabel($object) + { + return $object->getTitle(); + } + + protected function getObjectId($object) + { + return $object->getId(); + } + + protected function renderListTemplate($currentOrder) + { + return $this->render('features', array('order' => $currentOrder)); + } + + protected function renderEditionTemplate() + { + return $this->render( + 'feature-edit', + array( + 'feature_id' => $this->getRequest()->get('feature_id'), + 'featureav_order' => $this->getFeatureAvListOrder() + ) + ); + } + + protected function redirectToEditionTemplate() + { + $this->redirectToRoute( + "admin.configuration.features.update", + array( + 'feature_id' => $this->getRequest()->get('feature_id'), + 'featureav_order' => $this->getFeatureAvListOrder() + ) + ); + } + + protected function redirectToListTemplate() + { + $this->redirectToRoute('admin.configuration.features.default'); + } + + /** + * Get the Feature value list order. + * + * @return string the current list order + */ + protected function getFeatureAvListOrder() + { + return $this->getListOrderFromSession( + 'featureav', + 'featureav_order', + 'manual' + ); + } + + /** + * Add or Remove from all product templates + */ + protected function addRemoveFromAllTemplates($eventType) + { + // Check current user authorization + if (null !== $response = $this->checkAuth("admin.configuration.features.update")) return $response; + + try { + if (null !== $object = $this->getExistingObject()) { + + $event = new FeatureEvent($object); + + $this->dispatch($eventType, $event); + } + } + catch (\Exception $ex) { + // Any error + return $this->errorPage($ex); + } + + $this->redirectToListTemplate(); + } + + /** + * Remove from all product templates + */ + public function removeFromAllTemplates() + { + return $this->addRemoveFromAllTemplates(TheliaEvents::FEATURE_REMOVE_FROM_ALL_TEMPLATES); + } + + /** + * Add to all product templates + */ + public function addToAllTemplates() + { + return $this->addRemoveFromAllTemplates(TheliaEvents::FEATURE_ADD_TO_ALL_TEMPLATES); + } +} \ No newline at end of file diff --git a/core/lib/Thelia/Core/Event/FeatureAvCreateEvent.php b/core/lib/Thelia/Core/Event/FeatureAvCreateEvent.php new file mode 100644 index 000000000..2c8fb228e --- /dev/null +++ b/core/lib/Thelia/Core/Event/FeatureAvCreateEvent.php @@ -0,0 +1,68 @@ +. */ +/* */ +/*************************************************************************************/ + +namespace Thelia\Core\Event; + +class FeatureAvCreateEvent extends FeatureAvEvent +{ + protected $title; + protected $locale; + protected $feature_id; + + public function getLocale() + { + return $this->locale; + } + + public function setLocale($locale) + { + $this->locale = $locale; + + return $this; + } + + public function getTitle() + { + return $this->title; + } + + public function setTitle($title) + { + $this->title = $title; + + return $this; + } + + public function getFeatureId() + { + return $this->feature_id; + } + + public function setFeatureId($feature_id) + { + $this->feature_id = $feature_id; + + return $this; + } + +} diff --git a/core/lib/Thelia/Core/Event/FeatureAvDeleteEvent.php b/core/lib/Thelia/Core/Event/FeatureAvDeleteEvent.php new file mode 100644 index 000000000..aa0a3c729 --- /dev/null +++ b/core/lib/Thelia/Core/Event/FeatureAvDeleteEvent.php @@ -0,0 +1,46 @@ +. */ +/* */ +/*************************************************************************************/ + +namespace Thelia\Core\Event; + +class FeatureAvDeleteEvent extends FeatureAvEvent +{ + protected $featureAv_id; + + public function __construct($featureAv_id) + { + $this->setFeatureAvId($featureAv_id); + } + + public function getFeatureAvId() + { + return $this->featureAv_id; + } + + public function setFeatureAvId($featureAv_id) + { + $this->featureAv_id = $featureAv_id; + + return $this; + } +} diff --git a/core/lib/Thelia/Core/Event/FeatureAvEvent.php b/core/lib/Thelia/Core/Event/FeatureAvEvent.php new file mode 100644 index 000000000..225acaf11 --- /dev/null +++ b/core/lib/Thelia/Core/Event/FeatureAvEvent.php @@ -0,0 +1,52 @@ +. */ +/* */ +/*************************************************************************************/ + +namespace Thelia\Core\Event; +use Thelia\Model\FeatureAv; + +class FeatureAvEvent extends ActionEvent +{ + protected $featureAv = null; + + public function __construct(FeatureAv $featureAv = null) + { + $this->featureAv = $featureAv; + } + + public function hasFeatureAv() + { + return ! is_null($this->featureAv); + } + + public function getFeatureAv() + { + return $this->featureAv; + } + + public function setFeatureAv($featureAv) + { + $this->featureAv = $featureAv; + + return $this; + } +} diff --git a/core/lib/Thelia/Core/Event/FeatureAvUpdateEvent.php b/core/lib/Thelia/Core/Event/FeatureAvUpdateEvent.php new file mode 100644 index 000000000..5db9604c2 --- /dev/null +++ b/core/lib/Thelia/Core/Event/FeatureAvUpdateEvent.php @@ -0,0 +1,86 @@ +. */ +/* */ +/*************************************************************************************/ + +namespace Thelia\Core\Event; + +class FeatureAvUpdateEvent extends FeatureAvCreateEvent +{ + protected $featureAv_id; + + protected $description; + protected $chapo; + protected $postscriptum; + + public function __construct($featureAv_id) + { + $this->setFeatureAvId($featureAv_id); + } + + public function getFeatureAvId() + { + return $this->featureAv_id; + } + + public function setFeatureAvId($featureAv_id) + { + $this->featureAv_id = $featureAv_id; + + return $this; + } + + public function getDescription() + { + return $this->description; + } + + public function setDescription($description) + { + $this->description = $description; + + return $this; + } + + public function getChapo() + { + return $this->chapo; + } + + public function setChapo($chapo) + { + $this->chapo = $chapo; + + return $this; + } + + public function getPostscriptum() + { + return $this->postscriptum; + } + + public function setPostscriptum($postscriptum) + { + $this->postscriptum = $postscriptum; + + return $this; + } +} diff --git a/core/lib/Thelia/Core/Event/FeatureCreateEvent.php b/core/lib/Thelia/Core/Event/FeatureCreateEvent.php new file mode 100644 index 000000000..574433084 --- /dev/null +++ b/core/lib/Thelia/Core/Event/FeatureCreateEvent.php @@ -0,0 +1,68 @@ +. */ +/* */ +/*************************************************************************************/ + +namespace Thelia\Core\Event; + +class FeatureCreateEvent extends FeatureEvent +{ + protected $title; + protected $locale; + protected $add_to_all_templates; + + public function getLocale() + { + return $this->locale; + } + + public function setLocale($locale) + { + $this->locale = $locale; + + return $this; + } + + public function getTitle() + { + return $this->title; + } + + public function setTitle($title) + { + $this->title = $title; + + return $this; + } + + public function getAddToAllTemplates() + { + return $this->add_to_all_templates; + } + + public function setAddToAllTemplates($add_to_all_templates) + { + $this->add_to_all_templates = $add_to_all_templates; + + return $this; + } + +} diff --git a/core/lib/Thelia/Core/Event/FeatureDeleteEvent.php b/core/lib/Thelia/Core/Event/FeatureDeleteEvent.php new file mode 100644 index 000000000..1eca57982 --- /dev/null +++ b/core/lib/Thelia/Core/Event/FeatureDeleteEvent.php @@ -0,0 +1,46 @@ +. */ +/* */ +/*************************************************************************************/ + +namespace Thelia\Core\Event; + +class FeatureDeleteEvent extends FeatureEvent +{ + protected $feature_id; + + public function __construct($feature_id) + { + $this->setFeatureId($feature_id); + } + + public function getFeatureId() + { + return $this->feature_id; + } + + public function setFeatureId($feature_id) + { + $this->feature_id = $feature_id; + + return $this; + } +} diff --git a/core/lib/Thelia/Core/Event/FeatureEvent.php b/core/lib/Thelia/Core/Event/FeatureEvent.php new file mode 100644 index 000000000..f1510ac63 --- /dev/null +++ b/core/lib/Thelia/Core/Event/FeatureEvent.php @@ -0,0 +1,52 @@ +. */ +/* */ +/*************************************************************************************/ + +namespace Thelia\Core\Event; +use Thelia\Model\Feature; + +class FeatureEvent extends ActionEvent +{ + protected $feature = null; + + public function __construct(Feature $feature = null) + { + $this->feature = $feature; + } + + public function hasFeature() + { + return ! is_null($this->feature); + } + + public function getFeature() + { + return $this->feature; + } + + public function setFeature($feature) + { + $this->feature = $feature; + + return $this; + } +} diff --git a/core/lib/Thelia/Core/Event/FeatureUpdateEvent.php b/core/lib/Thelia/Core/Event/FeatureUpdateEvent.php new file mode 100644 index 000000000..6bee33ebb --- /dev/null +++ b/core/lib/Thelia/Core/Event/FeatureUpdateEvent.php @@ -0,0 +1,86 @@ +. */ +/* */ +/*************************************************************************************/ + +namespace Thelia\Core\Event; + +class FeatureUpdateEvent extends FeatureCreateEvent +{ + protected $feature_id; + + protected $description; + protected $chapo; + protected $postscriptum; + + public function __construct($feature_id) + { + $this->setFeatureId($feature_id); + } + + public function getFeatureId() + { + return $this->feature_id; + } + + public function setFeatureId($feature_id) + { + $this->feature_id = $feature_id; + + return $this; + } + + public function getDescription() + { + return $this->description; + } + + public function setDescription($description) + { + $this->description = $description; + + return $this; + } + + public function getChapo() + { + return $this->chapo; + } + + public function setChapo($chapo) + { + $this->chapo = $chapo; + + return $this; + } + + public function getPostscriptum() + { + return $this->postscriptum; + } + + public function setPostscriptum($postscriptum) + { + $this->postscriptum = $postscriptum; + + return $this; + } +} diff --git a/core/lib/Thelia/Core/Event/TheliaEvents.php b/core/lib/Thelia/Core/Event/TheliaEvents.php index cc1bcad2a..566395a20 100755 --- a/core/lib/Thelia/Core/Event/TheliaEvents.php +++ b/core/lib/Thelia/Core/Event/TheliaEvents.php @@ -372,6 +372,25 @@ final class TheliaEvents const BEFORE_DELETEATTRIBUTE = "action.before_deleteAttribute"; const AFTER_DELETEATTRIBUTE = "action.after_deleteAttribute"; + // -- Features management --------------------------------------------- + + const FEATURE_CREATE = "action.createFeature"; + const FEATURE_UPDATE = "action.updateFeature"; + const FEATURE_DELETE = "action.deleteFeature"; + const FEATURE_UPDATE_POSITION = "action.updateFeaturePosition"; + + const FEATURE_REMOVE_FROM_ALL_TEMPLATES = "action.addFeatureToAllTemplate"; + const FEATURE_ADD_TO_ALL_TEMPLATES = "action.removeFeatureFromAllTemplate"; + + const BEFORE_CREATEFEATURE = "action.before_createFeature"; + const AFTER_CREATEFEATURE = "action.after_createFeature"; + + const BEFORE_UPDATEFEATURE = "action.before_updateFeature"; + const AFTER_UPDATEFEATURE = "action.after_updateFeature"; + + const BEFORE_DELETEFEATURE = "action.before_deleteFeature"; + const AFTER_DELETEFEATURE = "action.after_deleteFeature"; + // -- Attributes values management ---------------------------------------- const ATTRIBUTE_AV_CREATE = "action.createAttributeAv"; @@ -387,4 +406,22 @@ final class TheliaEvents const BEFORE_DELETEATTRIBUTE_AV = "action.before_deleteAttributeAv"; const AFTER_DELETEATTRIBUTE_AV = "action.after_deleteAttributeAv"; + + + // -- Features values management ---------------------------------------- + + const FEATURE_AV_CREATE = "action.createFeatureAv"; + const FEATURE_AV_UPDATE = "action.updateFeatureAv"; + const FEATURE_AV_DELETE = "action.deleteFeatureAv"; + const FEATURE_AV_UPDATE_POSITION = "action.updateFeatureAvPosition"; + + const BEFORE_CREATEFEATURE_AV = "action.before_createFeatureAv"; + const AFTER_CREATEFEATURE_AV = "action.after_createFeatureAv"; + + const BEFORE_UPDATEFEATURE_AV = "action.before_updateFeatureAv"; + const AFTER_UPDATEFEATURE_AV = "action.after_updateFeatureAv"; + + const BEFORE_DELETEFEATURE_AV = "action.before_deleteFeatureAv"; + const AFTER_DELETEFEATURE_AV = "action.after_deleteFeatureAv"; + } diff --git a/core/lib/Thelia/Form/FeatureAvCreationForm.php b/core/lib/Thelia/Form/FeatureAvCreationForm.php new file mode 100644 index 000000000..504cc9338 --- /dev/null +++ b/core/lib/Thelia/Form/FeatureAvCreationForm.php @@ -0,0 +1,62 @@ +. */ +/* */ +/*************************************************************************************/ +namespace Thelia\Form; + +use Symfony\Component\Validator\Constraints; +use Thelia\Model\CurrencyQuery; +use Symfony\Component\Validator\ExecutionContextInterface; +use Symfony\Component\Validator\Constraints\NotBlank; +use Thelia\Core\Translation\Translator; + +class FeatureAvCreationForm extends BaseForm +{ + protected function buildForm() + { + $this->formBuilder + ->add("title" , "text" , array( + "constraints" => array( + new NotBlank() + ), + "label" => Translator::getInstance()->trans("Title *"), + "label_attr" => array( + "for" => "title" + )) + ) + ->add("locale" , "text" , array( + "constraints" => array( + new NotBlank() + )) + ) + ->add("feature_id", "hidden", array( + "constraints" => array( + new NotBlank() + )) + ) + ; + } + + public function getName() + { + return "thelia_featureav_creation"; + } +} \ No newline at end of file diff --git a/core/lib/Thelia/Form/FeatureCreationForm.php b/core/lib/Thelia/Form/FeatureCreationForm.php new file mode 100644 index 000000000..1977bd78b --- /dev/null +++ b/core/lib/Thelia/Form/FeatureCreationForm.php @@ -0,0 +1,66 @@ +. */ +/* */ +/*************************************************************************************/ +namespace Thelia\Form; + +use Symfony\Component\Validator\Constraints; +use Thelia\Model\CurrencyQuery; +use Symfony\Component\Validator\ExecutionContextInterface; +use Symfony\Component\Validator\Constraints\NotBlank; +use Thelia\Core\Translation\Translator; + +class FeatureCreationForm extends BaseForm +{ + protected function buildForm() + { + $this->formBuilder + ->add("title" , "text" , array( + "constraints" => array( + new NotBlank() + ), + "label" => Translator::getInstance()->trans("Title *"), + "label_attr" => array( + "for" => "title" + )) + ) + ->add("locale" , "text" , array( + "constraints" => array( + new NotBlank() + )) + ) + ->add("add_to_all" , "checkbox" , array( + "constraints" => array( + new NotBlank() + ), + "label" => Translator::getInstance()->trans("Add to all product templates"), + "label_attr" => array( + "for" => "add_to_all" + )) + ) + ; + } + + public function getName() + { + return "thelia_feature_creation"; + } +} diff --git a/core/lib/Thelia/Form/FeatureModificationForm.php b/core/lib/Thelia/Form/FeatureModificationForm.php new file mode 100644 index 000000000..1702f299e --- /dev/null +++ b/core/lib/Thelia/Form/FeatureModificationForm.php @@ -0,0 +1,62 @@ +. */ +/* */ +/*************************************************************************************/ +namespace Thelia\Form; + +use Symfony\Component\Validator\Constraints; +use Thelia\Model\CurrencyQuery; +use Symfony\Component\Validator\ExecutionContextInterface; +use Symfony\Component\Validator\Constraints\NotBlank; +use Thelia\Core\Translation\Translator; +use Symfony\Component\Validator\Constraints\GreaterThan; + +class FeatureModificationForm extends FeatureCreationForm +{ + use StandardDescriptionFieldsTrait; + + protected function buildForm() + { + $this->formBuilder + ->add("id", "hidden", array( + "constraints" => array( + new GreaterThan( + array('value' => 0) + ) + ) + )) +/* FIXME: doesn't work + ->add('feature_values', 'collection', array( + 'type' => 'text', + 'options' => array('required' => false) + )) +*/ + ; + + // Add standard description fields + $this->addStandardDescFields(); + } + + public function getName() + { + return "thelia_feature_modification"; + } +} diff --git a/core/lib/Thelia/Model/Feature.php b/core/lib/Thelia/Model/Feature.php index ce7c57b1d..cf0284d2b 100755 --- a/core/lib/Thelia/Model/Feature.php +++ b/core/lib/Thelia/Model/Feature.php @@ -3,7 +3,70 @@ namespace Thelia\Model; use Thelia\Model\Base\Feature as BaseFeature; +use Propel\Runtime\Connection\ConnectionInterface; +use Thelia\Core\Event\TheliaEvents; +use Thelia\Core\Event\FeatureEvent; class Feature extends BaseFeature { + use \Thelia\Model\Tools\ModelEventDispatcherTrait; + use \Thelia\Model\Tools\PositionManagementTrait; + + /** + * {@inheritDoc} + */ + public function preInsert(ConnectionInterface $con = null) + { + $this->dispatchEvent(TheliaEvents::BEFORE_CREATEFEATURE, new FeatureEvent($this)); + + // Set the current position for the new object + $this->setPosition($this->getNextPosition()); + + return true; + } + + /** + * {@inheritDoc} + */ + public function postInsert(ConnectionInterface $con = null) + { + $this->dispatchEvent(TheliaEvents::AFTER_CREATEFEATURE, new FeatureEvent($this)); + } + + /** + * {@inheritDoc} + */ + public function preUpdate(ConnectionInterface $con = null) + { + $this->dispatchEvent(TheliaEvents::BEFORE_UPDATEFEATURE, new FeatureEvent($this)); + + return true; + } + + /** + * {@inheritDoc} + */ + public function postUpdate(ConnectionInterface $con = null) + { + $this->dispatchEvent(TheliaEvents::AFTER_UPDATEFEATURE, new FeatureEvent($this)); + } + + /** + * {@inheritDoc} + */ + public function preDelete(ConnectionInterface $con = null) + { + $this->dispatchEvent(TheliaEvents::BEFORE_DELETEFEATURE, new FeatureEvent($this)); + + return true; + } + + /** + * {@inheritDoc} + */ + public function postDelete(ConnectionInterface $con = null) + { + $this->dispatchEvent(TheliaEvents::AFTER_DELETEFEATURE, new FeatureEvent($this)); + } + } diff --git a/core/lib/Thelia/Model/FeatureAv.php b/core/lib/Thelia/Model/FeatureAv.php index 68b6fa92a..ae6e35087 100755 --- a/core/lib/Thelia/Model/FeatureAv.php +++ b/core/lib/Thelia/Model/FeatureAv.php @@ -3,7 +3,78 @@ namespace Thelia\Model; use Thelia\Model\Base\FeatureAv as BaseFeatureAv; +use Thelia\Core\Event\TheliaEvents; +use Propel\Runtime\Connection\ConnectionInterface; +use Thelia\Core\Event\FeatureAvEvent; class FeatureAv extends BaseFeatureAv { + use \Thelia\Model\Tools\ModelEventDispatcherTrait; + + use \Thelia\Model\Tools\PositionManagementTrait; + + /** + * when dealing with position, be sure to work insite the current feature. + */ + protected function addCriteriaToPositionQuery($query) { + $query->filterByFeatureId($this->getFeatureId()); + } + + /** + * {@inheritDoc} + */ + public function preInsert(ConnectionInterface $con = null) + { + // Set the current position for the new object + $this->setPosition($this->getNextPosition()); + + $this->dispatchEvent(TheliaEvents::BEFORE_CREATEFEATURE_AV, new FeatureAvEvent($this)); + + return true; + } + + /** + * {@inheritDoc} + */ + public function postInsert(ConnectionInterface $con = null) + { + $this->dispatchEvent(TheliaEvents::AFTER_CREATEFEATURE_AV, new FeatureAvEvent($this)); + } + + /** + * {@inheritDoc} + */ + public function preUpdate(ConnectionInterface $con = null) + { + $this->dispatchEvent(TheliaEvents::BEFORE_UPDATEFEATURE_AV, new FeatureAvEvent($this)); + + return true; + } + + /** + * {@inheritDoc} + */ + public function postUpdate(ConnectionInterface $con = null) + { + $this->dispatchEvent(TheliaEvents::AFTER_UPDATEFEATURE_AV, new FeatureAvEvent($this)); + } + + /** + * {@inheritDoc} + */ + public function preDelete(ConnectionInterface $con = null) + { + $this->dispatchEvent(TheliaEvents::BEFORE_DELETEFEATURE_AV, new FeatureAvEvent($this)); + + return true; + } + + /** + * {@inheritDoc} + */ + public function postDelete(ConnectionInterface $con = null) + { + $this->dispatchEvent(TheliaEvents::AFTER_DELETEFEATURE_AV, new FeatureAvEvent($this)); + } + } diff --git a/templates/admin/default/feature-edit.html b/templates/admin/default/feature-edit.html new file mode 100644 index 000000000..7bbed5965 --- /dev/null +++ b/templates/admin/default/feature-edit.html @@ -0,0 +1,316 @@ +{extends file="admin-layout.tpl"} + +{block name="page-title"}{intl l='Edit an feature'}{/block} + +{block name="check-permissions"}admin.configuration.features.edit{/block} + +{block name="main-content"} +
+ +
+ + {loop name="feature_edit" type="feature" id=$feature_id backend_context="1" lang=$edit_language_id} + + + +
+
+
+ +
+ {intl l="Edit feature $TITLE"} +
+ +
+
+ {form name="thelia.admin.feature.modification"} + + + {include file="includes/inner-form-toolbar.html" close_url="{url path='/admin/configuration/features'}"} + +
+ +

{intl l='Feature information'}

+ + {form_field form=$form field='id'} + + {/form_field} + + {* Be sure to get the feature 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=$form} +
+ +
+ +

+ + {intl l='Feature values'} + + {loop type="auth" name="can_create" roles="ADMIN" permissions="admin.configuration.feature-av.create"} + + + + + + {/loop} +

+ +
+ {intl l="Enter here all possible feature values."} +
+ + + + + + + + + + + {module_include location='features_value_table_header'} + + + + + + + {loop name="list" type="feature_availability" feature=$feature_id backend_context="1" lang=$edit_language_id order=$featureav_order} + + + + + + + + {module_include location='features_value_table_row'} + + + + {/loop} + + {elseloop rel="list"} + + + + {/elseloop} + +
+ {admin_sortable_header + current_order=$featureav_order + order='id' + reverse_order='id_reverse' + request_parameter_name='featureav_order' + path={url path='/admin/configuration/features/update' feature_id=$feature_id} + label="{intl l='ID'}" + } + + {admin_sortable_header + current_order=$featureav_order + order='alpha' + reverse_order='alpha_reverse' + request_parameter_name='featureav_order' + path={url path='/admin/configuration/features/update' feature_id=$feature_id} + label="{intl l='Value'}" + } + + {admin_sortable_header + current_order=$featureav_order + order='manual' + reverse_order='manual_reverse' + request_parameter_name='featureav_order' + path={url path='/admin/configuration/features/update' feature_id=$feature_id} + label="{intl l="Position"}" + } + {intl l="Actions"}
{$ID} + {* FIXME : integrate this in the encolsing form to provide standard form processing *} + + + {admin_position_block + permission="admin.features.edit" + path={url path='/admin/configuration/features-av/update-position' feature_id=$feature_id} + url_parameter="featureav_id" + in_place_edit_class="positionChange" + position="$POSITION" + id="$ID" + } + +
+ {loop type="auth" name="can_create" roles="ADMIN" permissions="admin.configuration.feature-av.delete"} + + + + {/loop} +
+
+
+ {intl l="No value has been created yet. Click the + button to create one."} +
+
+
+ + {/form} +
+
+
+
+ +
+ + {/loop} + + {elseloop rel="feature_edit"} +
+
+
+ {intl l="Sorry, feature ID=$feature_id was not found."} +
+
+
+ {/elseloop} + +
+
+ +{* Adding a new feature *} + +{form name="thelia.admin.featureav.creation"} + + {* Capture the dialog body, to pass it to the generic dialog *} + + {capture "creation_dialog"} + {form_hidden_fields form=$form} + + {* Be sure to get the feature ID, even if the form could not be validated *} + + + {form_field form=$form field='success_url'} + {* on success, redirect to this page *} + + {/form_field} + + {form_field form=$form field='feature_id'} + + {/form_field} + + {form_field form=$form field='title'} +
+ + + {loop type="lang" name="current-edit-lang" id="$edit_language_id"} +
+ + {intl l=$TITLE} +
+ +
{intl l="Enter here the value in the current edit language ($TITLE)"}
+ + {form_field form=$form field='locale'} + + {/form_field} + {/loop} +
+ {/form_field} + + {module_include location='feature_value_create_form'} + + {/capture} + + {include + file = "includes/generic-create-dialog.html" + + dialog_id = "creation_dialog" + dialog_title = {intl l="Create a new feature value"} + dialog_body = {$smarty.capture.creation_dialog nofilter} + + dialog_ok_label = {intl l="Create this value"} + + form_action = {url path='/admin/configuration/features-av/create'} + form_enctype = {form_enctype form=$form} + form_error_message = $form_error_message + } +{/form} + +{* Delete value confirmation dialog *} + +{capture "delete_dialog"} + + +{/capture} + +{include + file = "includes/generic-confirm-dialog.html" + + dialog_id = "delete_dialog" + dialog_title = {intl l="Delete feature value"} + dialog_message = {intl l="Do you really want to delete this feature value ?"} + + form_action = {url path='/admin/configuration/features-av/delete'} + form_content = {$smarty.capture.delete_dialog nofilter} +} + +{/block} + +{block name="javascript-initialization"} + + {javascripts file='assets/js/bootstrap-editable/bootstrap-editable.js'} + + {/javascripts} + + +{/block} \ No newline at end of file diff --git a/templates/admin/default/features.html b/templates/admin/default/features.html new file mode 100644 index 000000000..69ed1d5d4 --- /dev/null +++ b/templates/admin/default/features.html @@ -0,0 +1,326 @@ +{extends file="admin-layout.tpl"} + +{block name="page-title"}{intl l='Thelia Product Features'}{/block} + +{block name="check-permissions"}admin.configuration.features.view{/block} + +{block name="main-content"} +
+ +
+ + + + {module_include location='features_top'} + +
+
+
+
+ + + + + + + + + + + {module_include location='features_table_header'} + + + + + + + {loop name="list" type="feature" backend_context="1" lang=$lang_id order=$order} + + + + + + + + {module_include location='features_table_row'} + + + + {/loop} + + {elseloop rel="list"} + + + + {/elseloop} + +
+ {intl l='Thelia product features'} + + {loop type="auth" name="can_create" roles="ADMIN" permissions="admin.configuration.features.create"} + + + + {/loop} +
+ {admin_sortable_header + current_order=$order + order='id' + reverse_order='id_reverse' + path='/admin/configuration/features' + label="{intl l='ID'}" + } + + {admin_sortable_header + current_order=$order + order='alpha' + reverse_order='alpha_reverse' + path='/admin/configuration/features' + label="{intl l='Title'}" + } + + {admin_sortable_header + current_order=$order + order='manual' + reverse_order='manual_reverse' + path='/admin/configuration/features' + label="{intl l="Position"}" + } + {intl l="Actions"}
{$ID} + {loop type="auth" name="can_change" roles="ADMIN" permissions="admin.configuration.features.change"} + {$TITLE} + {/loop} + {elseloop rel="can_change"} + {$TITLE} + {/elseloop} + + {admin_position_block + permission="admin.features.edit" + path="/admin/configuration/features/update-position" + url_parameter="feature_id" + in_place_edit_class="positionChange" + position="$POSITION" + id="$ID" + } + + {loop type="auth" name="can_change" roles="ADMIN" permissions="admin.configuration.features.change"} + + {/loop} + +
+ {loop type="auth" name="can_change" roles="ADMIN" permissions="admin.configuration.features.change"} + + {/loop} + + {loop type="auth" name="can_change" roles="ADMIN" permissions="admin.configuration.features.delete"} + + {/loop} +
+
+
+ {intl l="No product feature has been created yet. Click the + button to create one."} +
+
+
+
+
+
+ + {module_include location='features_bottom'} + +
+
+ +{* Adding a new feature *} + +{form name="thelia.admin.feature.creation"} + + {* Capture the dialog body, to pass it to the generic dialog *} + {capture "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 feature ID, see controller *} + + {/form_field} + + {form_field form=$form field='title'} +
+ + + {loop type="lang" name="default-lang" default_only="1"} +
+ + {intl l=$TITLE} +
+ +
{intl l="Enter here the feature name in the default language ($TITLE)"}
+ + {* Switch edition to the current locale *} + + + {form_field form=$form field='locale'} + + {/form_field} + {/loop} +
+ {/form_field} + + {form_field form=$form field='add_to_all'} +
+
+ + {intl l='Check this box if you want to add this features to all product templates'} +
+
+ {/form_field} + + {module_include location='feature_create_form'} + + {/capture} + + {include + file = "includes/generic-create-dialog.html" + + dialog_id = "creation_dialog" + dialog_title = {intl l="Create a new feature"} + dialog_body = {$smarty.capture.creation_dialog nofilter} + + dialog_ok_label = {intl l="Create this feature"} + + form_action = {url path='/admin/configuration/features/create'} + form_enctype = {form_enctype form=$form} + form_error_message = $form_error_message + } +{/form} + +{* Delete confirmation dialog *} + +{capture "delete_dialog"} + + + {module_include location='feature_delete_form'} + +{/capture} + +{include + file = "includes/generic-confirm-dialog.html" + + dialog_id = "delete_dialog" + dialog_title = {intl l="Delete feature"} + dialog_message = {intl l="Do you really want to delete this feature ? It will be removed from all product templates."} + + form_action = {url path='/admin/configuration/features/delete'} + form_content = {$smarty.capture.delete_dialog nofilter} +} + + +{* Add to all dialog *} + +{capture "add_to_all_dialog"} + + + {module_include location='feature_add_to_all_form'} + +{/capture} + +{include + file = "includes/generic-confirm-dialog.html" + + dialog_id = "add_to_all_dialog" + dialog_title = {intl l="Add to all product templates"} + dialog_message = {intl l="Do you really want to add this feature to all product templates ?"} + + form_action = {url path='/admin/configuration/features/add-to-all-templates'} + form_content = {$smarty.capture.add_to_all_dialog nofilter} +} + +{* Remove from all dialog *} + +{capture "remove_from_all_dialog"} + + + {module_include location='feature_add_to_all_form'} + +{/capture} + +{include + file = "includes/generic-confirm-dialog.html" + + dialog_id = "remove_from_all_dialog" + dialog_title = {intl l="Remove from all product templates"} + dialog_message = {intl l="Do you really want to remove this feature from all product templates ? You'll loose all product related data for this feature."} + + form_action = {url path='/admin/configuration/features/remove-from-all-templates'} + form_content = {$smarty.capture.remove_from_all_dialog nofilter} +} + +{/block} + +{block name="javascript-initialization"} + + {javascripts file='assets/js/bootstrap-editable/bootstrap-editable.js'} + + {/javascripts} + + +{/block} \ No newline at end of file