Completed template management
This commit is contained in:
@@ -42,6 +42,14 @@ use Thelia\Core\Event\TemplateEvent;
|
|||||||
use Thelia\Model\TemplateTemplate;
|
use Thelia\Model\TemplateTemplate;
|
||||||
use Thelia\Model\TemplateTemplateQuery;
|
use Thelia\Model\TemplateTemplateQuery;
|
||||||
use Thelia\Model\ProductQuery;
|
use Thelia\Model\ProductQuery;
|
||||||
|
use Thelia\Core\Event\TemplateAddAttributeEvent;
|
||||||
|
use Thelia\Core\Event\TemplateDeleteAttributeEvent;
|
||||||
|
use Thelia\Model\AttributeTemplateQuery;
|
||||||
|
use Thelia\Model\AttributeTemplate;
|
||||||
|
use Thelia\Core\Event\TemplateDeleteFeatureEvent;
|
||||||
|
use Thelia\Core\Event\TemplateAddFeatureEvent;
|
||||||
|
use Thelia\Model\FeatureTemplateQuery;
|
||||||
|
use Thelia\Model\FeatureTemplate;
|
||||||
|
|
||||||
class Template extends BaseAction implements EventSubscriberInterface
|
class Template extends BaseAction implements EventSubscriberInterface
|
||||||
{
|
{
|
||||||
@@ -113,6 +121,54 @@ class Template extends BaseAction implements EventSubscriberInterface
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function addAttribute(TemplateAddAttributeEvent $event) {
|
||||||
|
|
||||||
|
if (null === AttributeTemplateQuery::create()->filterByAttributeId($event->getAttributeId())->filterByTemplate($event->getTemplate())->findOne()) {
|
||||||
|
|
||||||
|
$attribute_template = new AttributeTemplate();
|
||||||
|
|
||||||
|
$attribute_template
|
||||||
|
->setAttributeId($event->getAttributeId())
|
||||||
|
->setTemplate($event->getTemplate())
|
||||||
|
->save()
|
||||||
|
;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function deleteAttribute(TemplateDeleteAttributeEvent $event) {
|
||||||
|
|
||||||
|
$attribute_template = AttributeTemplateQuery::create()
|
||||||
|
->filterByAttributeId($event->getAttributeId())
|
||||||
|
->filterByTemplate($event->getTemplate())->findOne()
|
||||||
|
;
|
||||||
|
|
||||||
|
if ($attribute_template !== null) $attribute_template->delete();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function addFeature(TemplateAddFeatureEvent $event) {
|
||||||
|
|
||||||
|
if (null === FeatureTemplateQuery::create()->filterByFeatureId($event->getFeatureId())->filterByTemplate($event->getTemplate())->findOne()) {
|
||||||
|
|
||||||
|
$feature_template = new FeatureTemplate();
|
||||||
|
|
||||||
|
$feature_template
|
||||||
|
->setFeatureId($event->getFeatureId())
|
||||||
|
->setTemplate($event->getTemplate())
|
||||||
|
->save()
|
||||||
|
;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function deleteFeature(TemplateDeleteFeatureEvent $event) {
|
||||||
|
|
||||||
|
$feature_template = FeatureTemplateQuery::create()
|
||||||
|
->filterByFeatureId($event->getFeatureId())
|
||||||
|
->filterByTemplate($event->getTemplate())->findOne()
|
||||||
|
;
|
||||||
|
|
||||||
|
if ($feature_template !== null) $feature_template->delete();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
@@ -122,6 +178,13 @@ class Template extends BaseAction implements EventSubscriberInterface
|
|||||||
TheliaEvents::TEMPLATE_CREATE => array("create", 128),
|
TheliaEvents::TEMPLATE_CREATE => array("create", 128),
|
||||||
TheliaEvents::TEMPLATE_UPDATE => array("update", 128),
|
TheliaEvents::TEMPLATE_UPDATE => array("update", 128),
|
||||||
TheliaEvents::TEMPLATE_DELETE => array("delete", 128),
|
TheliaEvents::TEMPLATE_DELETE => array("delete", 128),
|
||||||
|
|
||||||
|
TheliaEvents::TEMPLATE_ADD_ATTRIBUTE => array("addAttribute", 128),
|
||||||
|
TheliaEvents::TEMPLATE_DELETE_ATTRIBUTE => array("deleteAttribute", 128),
|
||||||
|
|
||||||
|
TheliaEvents::TEMPLATE_ADD_FEATURE => array("addFeature", 128),
|
||||||
|
TheliaEvents::TEMPLATE_DELETE_FEATURE => array("deleteFeature", 128),
|
||||||
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -234,6 +234,30 @@
|
|||||||
<default key="_controller">Thelia\Controller\Admin\TemplateController::deleteAction</default>
|
<default key="_controller">Thelia\Controller\Admin\TemplateController::deleteAction</default>
|
||||||
</route>
|
</route>
|
||||||
|
|
||||||
|
<route id="admin.configuration.templates.features.list" path="/admin/configuration/templates/features/list">
|
||||||
|
<default key="_controller">Thelia\Controller\Admin\TemplateController::getAjaxFeaturesAction</default>
|
||||||
|
</route>
|
||||||
|
|
||||||
|
<route id="admin.configuration.templates.features.add" path="/admin/configuration/templates/features/add">
|
||||||
|
<default key="_controller">Thelia\Controller\Admin\TemplateController::addFeatureAction</default>
|
||||||
|
</route>
|
||||||
|
|
||||||
|
<route id="admin.configuration.templates.features.delete" path="/admin/configuration/templates/features/delete">
|
||||||
|
<default key="_controller">Thelia\Controller\Admin\TemplateController::deleteFeatureAction</default>
|
||||||
|
</route>
|
||||||
|
|
||||||
|
<route id="admin.configuration.templates.attributes.list" path="/admin/configuration/templates/attributes/list">
|
||||||
|
<default key="_controller">Thelia\Controller\Admin\TemplateController::getAjaxAttributesAction</default>
|
||||||
|
</route>
|
||||||
|
|
||||||
|
<route id="admin.configuration.templates.attributes.add" path="/admin/configuration/templates/attributes/add">
|
||||||
|
<default key="_controller">Thelia\Controller\Admin\TemplateController::addAttributeAction</default>
|
||||||
|
</route>
|
||||||
|
|
||||||
|
<route id="admin.configuration.templates.attributes.delete" path="/admin/configuration/templates/attributes/delete">
|
||||||
|
<default key="_controller">Thelia\Controller\Admin\TemplateController::deleteAttributeAction</default>
|
||||||
|
</route>
|
||||||
|
|
||||||
|
|
||||||
<!-- attribute and attributes value management -->
|
<!-- attribute and attributes value management -->
|
||||||
|
|
||||||
|
|||||||
@@ -35,6 +35,10 @@ use Thelia\Model\TemplateAv;
|
|||||||
use Thelia\Model\TemplateAvQuery;
|
use Thelia\Model\TemplateAvQuery;
|
||||||
use Thelia\Core\Event\TemplateAvUpdateEvent;
|
use Thelia\Core\Event\TemplateAvUpdateEvent;
|
||||||
use Thelia\Core\Event\TemplateEvent;
|
use Thelia\Core\Event\TemplateEvent;
|
||||||
|
use Thelia\Core\Event\TemplateDeleteAttributeEvent;
|
||||||
|
use Thelia\Core\Event\TemplateAddAttributeEvent;
|
||||||
|
use Thelia\Core\Event\TemplateAddFeatureEvent;
|
||||||
|
use Thelia\Core\Event\TemplateDeleteFeatureEvent;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Manages templates sent by mail
|
* Manages templates sent by mail
|
||||||
@@ -193,4 +197,106 @@ class TemplateController extends AbstractCrudController
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getAjaxFeaturesAction() {
|
||||||
|
return $this->render(
|
||||||
|
'ajax/template-feature-list',
|
||||||
|
array('template_id' => $this->getRequest()->get('template_id'))
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getAjaxAttributesAction() {
|
||||||
|
return $this->render(
|
||||||
|
'ajax/template-attribute-list',
|
||||||
|
array('template_id' => $this->getRequest()->get('template_id'))
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function addAttributeAction() {
|
||||||
|
|
||||||
|
// Check current user authorization
|
||||||
|
if (null !== $response = $this->checkAuth("admin.configuration.template.attribute.add")) return $response;
|
||||||
|
|
||||||
|
$attribute_id = intval($this->getRequest()->get('attribute_id'));
|
||||||
|
|
||||||
|
if ($attribute_id > 0) {
|
||||||
|
$event = new TemplateAddAttributeEvent(
|
||||||
|
$this->getExistingObject(),
|
||||||
|
$attribute_id
|
||||||
|
);
|
||||||
|
|
||||||
|
try {
|
||||||
|
$this->dispatch(TheliaEvents::TEMPLATE_ADD_ATTRIBUTE, $event);
|
||||||
|
} catch (\Exception $ex) {
|
||||||
|
// Any error
|
||||||
|
return $this->errorPage($ex);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->redirectToEditionTemplate();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function deleteAttributeAction() {
|
||||||
|
|
||||||
|
// Check current user authorization
|
||||||
|
if (null !== $response = $this->checkAuth("admin.configuration.template.attribute.delete")) return $response;
|
||||||
|
|
||||||
|
$event = new TemplateDeleteAttributeEvent(
|
||||||
|
$this->getExistingObject(),
|
||||||
|
intval($this->getRequest()->get('attribute_id'))
|
||||||
|
);
|
||||||
|
|
||||||
|
try {
|
||||||
|
$this->dispatch(TheliaEvents::TEMPLATE_DELETE_ATTRIBUTE, $event);
|
||||||
|
} catch (\Exception $ex) {
|
||||||
|
// Any error
|
||||||
|
return $this->errorPage($ex);
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->redirectToEditionTemplate();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function addFeatureAction() {
|
||||||
|
|
||||||
|
// Check current user authorization
|
||||||
|
if (null !== $response = $this->checkAuth("admin.configuration.template.feature.add")) return $response;
|
||||||
|
|
||||||
|
$feature_id = intval($this->getRequest()->get('feature_id'));
|
||||||
|
|
||||||
|
if ($feature_id > 0) {
|
||||||
|
$event = new TemplateAddFeatureEvent(
|
||||||
|
$this->getExistingObject(),
|
||||||
|
$feature_id
|
||||||
|
);
|
||||||
|
|
||||||
|
try {
|
||||||
|
$this->dispatch(TheliaEvents::TEMPLATE_ADD_FEATURE, $event);
|
||||||
|
} catch (\Exception $ex) {
|
||||||
|
// Any error
|
||||||
|
return $this->errorPage($ex);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->redirectToEditionTemplate();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function deleteFeatureAction() {
|
||||||
|
|
||||||
|
// Check current user authorization
|
||||||
|
if (null !== $response = $this->checkAuth("admin.configuration.template.feature.delete")) return $response;
|
||||||
|
|
||||||
|
$event = new TemplateDeleteFeatureEvent(
|
||||||
|
$this->getExistingObject(),
|
||||||
|
intval($this->getRequest()->get('feature_id'))
|
||||||
|
);
|
||||||
|
|
||||||
|
try {
|
||||||
|
$this->dispatch(TheliaEvents::TEMPLATE_DELETE_FEATURE, $event);
|
||||||
|
} catch (\Exception $ex) {
|
||||||
|
// Any error
|
||||||
|
return $this->errorPage($ex);
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->redirectToEditionTemplate();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
51
core/lib/Thelia/Core/Event/TemplateAddAttributeEvent.php
Normal file
51
core/lib/Thelia/Core/Event/TemplateAddAttributeEvent.php
Normal file
@@ -0,0 +1,51 @@
|
|||||||
|
<?php
|
||||||
|
/*************************************************************************************/
|
||||||
|
/* */
|
||||||
|
/* Thelia */
|
||||||
|
/* */
|
||||||
|
/* Copyright (c) OpenStudio */
|
||||||
|
/* email : info@thelia.net */
|
||||||
|
/* web : http://www.thelia.net */
|
||||||
|
/* */
|
||||||
|
/* This program is free software; you can redistribute it and/or modify */
|
||||||
|
/* it under the terms of the GNU General Public License as published by */
|
||||||
|
/* the Free Software Foundation; either version 3 of the License */
|
||||||
|
/* */
|
||||||
|
/* This program is distributed in the hope that it will be useful, */
|
||||||
|
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
|
||||||
|
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
|
||||||
|
/* GNU General Public License for more details. */
|
||||||
|
/* */
|
||||||
|
/* You should have received a copy of the GNU General Public License */
|
||||||
|
/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||||
|
/* */
|
||||||
|
/*************************************************************************************/
|
||||||
|
|
||||||
|
namespace Thelia\Core\Event;
|
||||||
|
|
||||||
|
use Thelia\Model\Template;
|
||||||
|
class TemplateAddAttributeEvent extends TemplateEvent
|
||||||
|
{
|
||||||
|
protected $attribute_id;
|
||||||
|
|
||||||
|
public function __construct(Template $template, $attribute_id)
|
||||||
|
{
|
||||||
|
|
||||||
|
parent::__construct($template);
|
||||||
|
|
||||||
|
$this->attribute_id = $attribute_id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getAttributeId()
|
||||||
|
{
|
||||||
|
return $this->attribute_id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setAttributeId($attribute_id)
|
||||||
|
{
|
||||||
|
$this->attribute_id = $attribute_id;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
51
core/lib/Thelia/Core/Event/TemplateAddFeatureEvent.php
Normal file
51
core/lib/Thelia/Core/Event/TemplateAddFeatureEvent.php
Normal file
@@ -0,0 +1,51 @@
|
|||||||
|
<?php
|
||||||
|
/*************************************************************************************/
|
||||||
|
/* */
|
||||||
|
/* Thelia */
|
||||||
|
/* */
|
||||||
|
/* Copyright (c) OpenStudio */
|
||||||
|
/* email : info@thelia.net */
|
||||||
|
/* web : http://www.thelia.net */
|
||||||
|
/* */
|
||||||
|
/* This program is free software; you can redistribute it and/or modify */
|
||||||
|
/* it under the terms of the GNU General Public License as published by */
|
||||||
|
/* the Free Software Foundation; either version 3 of the License */
|
||||||
|
/* */
|
||||||
|
/* This program is distributed in the hope that it will be useful, */
|
||||||
|
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
|
||||||
|
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
|
||||||
|
/* GNU General Public License for more details. */
|
||||||
|
/* */
|
||||||
|
/* You should have received a copy of the GNU General Public License */
|
||||||
|
/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||||
|
/* */
|
||||||
|
/*************************************************************************************/
|
||||||
|
|
||||||
|
namespace Thelia\Core\Event;
|
||||||
|
|
||||||
|
use Thelia\Model\Template;
|
||||||
|
class TemplateAddFeatureEvent extends TemplateEvent
|
||||||
|
{
|
||||||
|
protected $feature_id;
|
||||||
|
|
||||||
|
public function __construct(Template $template, $feature_id)
|
||||||
|
{
|
||||||
|
|
||||||
|
parent::__construct($template);
|
||||||
|
|
||||||
|
$this->feature_id = $feature_id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getFeatureId()
|
||||||
|
{
|
||||||
|
return $this->feature_id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setFeatureId($feature_id)
|
||||||
|
{
|
||||||
|
$this->feature_id = $feature_id;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
51
core/lib/Thelia/Core/Event/TemplateDeleteAttributeEvent.php
Normal file
51
core/lib/Thelia/Core/Event/TemplateDeleteAttributeEvent.php
Normal file
@@ -0,0 +1,51 @@
|
|||||||
|
<?php
|
||||||
|
/*************************************************************************************/
|
||||||
|
/* */
|
||||||
|
/* Thelia */
|
||||||
|
/* */
|
||||||
|
/* Copyright (c) OpenStudio */
|
||||||
|
/* email : info@thelia.net */
|
||||||
|
/* web : http://www.thelia.net */
|
||||||
|
/* */
|
||||||
|
/* This program is free software; you can redistribute it and/or modify */
|
||||||
|
/* it under the terms of the GNU General Public License as published by */
|
||||||
|
/* the Free Software Foundation; either version 3 of the License */
|
||||||
|
/* */
|
||||||
|
/* This program is distributed in the hope that it will be useful, */
|
||||||
|
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
|
||||||
|
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
|
||||||
|
/* GNU General Public License for more details. */
|
||||||
|
/* */
|
||||||
|
/* You should have received a copy of the GNU General Public License */
|
||||||
|
/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||||
|
/* */
|
||||||
|
/*************************************************************************************/
|
||||||
|
|
||||||
|
namespace Thelia\Core\Event;
|
||||||
|
|
||||||
|
use Thelia\Model\Template;
|
||||||
|
|
||||||
|
class TemplateDeleteAttributeEvent extends TemplateEvent
|
||||||
|
{
|
||||||
|
protected $attribute_id;
|
||||||
|
|
||||||
|
public function __construct(Template $template, $attribute_id)
|
||||||
|
{
|
||||||
|
|
||||||
|
parent::__construct($template);
|
||||||
|
|
||||||
|
$this->attribute_id = $attribute_id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getAttributeId()
|
||||||
|
{
|
||||||
|
return $this->attribute_id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setAttributeId($attribute_id)
|
||||||
|
{
|
||||||
|
$this->attribute_id = $attribute_id;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
}
|
||||||
51
core/lib/Thelia/Core/Event/TemplateDeleteFeatureEvent.php
Normal file
51
core/lib/Thelia/Core/Event/TemplateDeleteFeatureEvent.php
Normal file
@@ -0,0 +1,51 @@
|
|||||||
|
<?php
|
||||||
|
/*************************************************************************************/
|
||||||
|
/* */
|
||||||
|
/* Thelia */
|
||||||
|
/* */
|
||||||
|
/* Copyright (c) OpenStudio */
|
||||||
|
/* email : info@thelia.net */
|
||||||
|
/* web : http://www.thelia.net */
|
||||||
|
/* */
|
||||||
|
/* This program is free software; you can redistribute it and/or modify */
|
||||||
|
/* it under the terms of the GNU General Public License as published by */
|
||||||
|
/* the Free Software Foundation; either version 3 of the License */
|
||||||
|
/* */
|
||||||
|
/* This program is distributed in the hope that it will be useful, */
|
||||||
|
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
|
||||||
|
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
|
||||||
|
/* GNU General Public License for more details. */
|
||||||
|
/* */
|
||||||
|
/* You should have received a copy of the GNU General Public License */
|
||||||
|
/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||||
|
/* */
|
||||||
|
/*************************************************************************************/
|
||||||
|
|
||||||
|
namespace Thelia\Core\Event;
|
||||||
|
|
||||||
|
use Thelia\Model\Template;
|
||||||
|
|
||||||
|
class TemplateDeleteFeatureEvent extends TemplateEvent
|
||||||
|
{
|
||||||
|
protected $feature_id;
|
||||||
|
|
||||||
|
public function __construct(Template $template, $feature_id)
|
||||||
|
{
|
||||||
|
|
||||||
|
parent::__construct($template);
|
||||||
|
|
||||||
|
$this->feature_id = $feature_id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getFeatureId()
|
||||||
|
{
|
||||||
|
return $this->feature_id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setFeatureId($feature_id)
|
||||||
|
{
|
||||||
|
$this->feature_id = $feature_id;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -343,6 +343,12 @@ final class TheliaEvents
|
|||||||
const TEMPLATE_UPDATE = "action.updateTemplate";
|
const TEMPLATE_UPDATE = "action.updateTemplate";
|
||||||
const TEMPLATE_DELETE = "action.deleteTemplate";
|
const TEMPLATE_DELETE = "action.deleteTemplate";
|
||||||
|
|
||||||
|
const TEMPLATE_ADD_ATTRIBUTE = "action.templateAddAttribute";
|
||||||
|
const TEMPLATE_DELETE_ATTRIBUTE = "action.templateDeleteAttribute";
|
||||||
|
|
||||||
|
const TEMPLATE_ADD_FEATURE = "action.templateAddFeature";
|
||||||
|
const TEMPLATE_DELETE_FEATURE = "action.templateDeleteFeature";
|
||||||
|
|
||||||
const BEFORE_CREATETEMPLATE = "action.before_createTemplate";
|
const BEFORE_CREATETEMPLATE = "action.before_createTemplate";
|
||||||
const AFTER_CREATETEMPLATE = "action.after_createTemplate";
|
const AFTER_CREATETEMPLATE = "action.after_createTemplate";
|
||||||
|
|
||||||
|
|||||||
@@ -64,6 +64,7 @@ class Attribute extends BaseI18nLoop
|
|||||||
Argument::createIntListTypeArgument('id'),
|
Argument::createIntListTypeArgument('id'),
|
||||||
Argument::createIntListTypeArgument('product'),
|
Argument::createIntListTypeArgument('product'),
|
||||||
Argument::createIntListTypeArgument('template'),
|
Argument::createIntListTypeArgument('template'),
|
||||||
|
Argument::createIntListTypeArgument('exclude_template'),
|
||||||
Argument::createIntListTypeArgument('exclude'),
|
Argument::createIntListTypeArgument('exclude'),
|
||||||
new Argument(
|
new Argument(
|
||||||
'order',
|
'order',
|
||||||
@@ -115,15 +116,25 @@ class Attribute extends BaseI18nLoop
|
|||||||
$template = $productObj->getTemplate();
|
$template = $productObj->getTemplate();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// If we have to filter by template, find all attributes assigned to this template, and filter by found IDs
|
// If we have to filter by template, find all attributes assigned to this template, and filter by found IDs
|
||||||
if (null !== $template) {
|
if (null !== $template) {
|
||||||
$search->filterById(
|
$search->filterById(
|
||||||
AttributeTemplateQuery::create()->filterByTemplateId($template)->select('id')->find(),
|
AttributeTemplateQuery::create()->filterByTemplateId($template)->select('attribute_id')->find(),
|
||||||
Criteria::IN
|
Criteria::IN
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$exclude_template = $this->getExcludeTemplate();
|
||||||
|
|
||||||
|
// If we have to filter by template, find all attributes assigned to this template, and filter by found IDs
|
||||||
|
if (null !== $exclude_template) {
|
||||||
|
// Exclure tous les attribut qui sont attachés aux templates indiqués
|
||||||
|
$search->filterById(
|
||||||
|
AttributeTemplateQuery::create()->filterByTemplateId($exclude_template)->select('attribute_id')->find(),
|
||||||
|
Criteria::NOT_IN
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
$orders = $this->getOrder();
|
$orders = $this->getOrder();
|
||||||
|
|
||||||
foreach ($orders as $order) {
|
foreach ($orders as $order) {
|
||||||
|
|||||||
@@ -38,6 +38,7 @@ use Thelia\Model\Map\ProductCategoryTableMap;
|
|||||||
use Thelia\Type\TypeCollection;
|
use Thelia\Type\TypeCollection;
|
||||||
use Thelia\Type;
|
use Thelia\Type;
|
||||||
use Thelia\Type\BooleanOrBothType;
|
use Thelia\Type\BooleanOrBothType;
|
||||||
|
use Thelia\Model\FeatureTemplateQuery;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
@@ -60,7 +61,8 @@ class Feature extends BaseI18nLoop
|
|||||||
return new ArgumentCollection(
|
return new ArgumentCollection(
|
||||||
Argument::createIntListTypeArgument('id'),
|
Argument::createIntListTypeArgument('id'),
|
||||||
Argument::createIntListTypeArgument('product'),
|
Argument::createIntListTypeArgument('product'),
|
||||||
Argument::createIntListTypeArgument('category'),
|
Argument::createIntListTypeArgument('template'),
|
||||||
|
Argument::createIntListTypeArgument('exclude_template'),
|
||||||
Argument::createBooleanOrBothTypeArgument('visible', 1),
|
Argument::createBooleanOrBothTypeArgument('visible', 1),
|
||||||
Argument::createIntListTypeArgument('exclude'),
|
Argument::createIntListTypeArgument('exclude'),
|
||||||
new Argument(
|
new Argument(
|
||||||
@@ -102,22 +104,33 @@ class Feature extends BaseI18nLoop
|
|||||||
if ($visible != BooleanOrBothType::ANY) $search->filterByVisible($visible);
|
if ($visible != BooleanOrBothType::ANY) $search->filterByVisible($visible);
|
||||||
|
|
||||||
$product = $this->getProduct();
|
$product = $this->getProduct();
|
||||||
$category = $this->getCategory();
|
$template = $this->getTemplate();
|
||||||
|
|
||||||
if (null !== $product) {
|
if (null !== $product) {
|
||||||
$productCategories = ProductCategoryQuery::create()->select(array(ProductCategoryTableMap::CATEGORY_ID))->filterByProductId($product, Criteria::IN)->find()->getData();
|
// Find the template assigned to the product.
|
||||||
|
$productObj = ProductQuery::create()->findPk($product);
|
||||||
|
|
||||||
if (null === $category) {
|
// Ignore if the product cannot be found.
|
||||||
$category = $productCategories;
|
if ($productObj !== null)
|
||||||
} else {
|
$template = $productObj->getTemplate();
|
||||||
$category = array_merge($category, $productCategories);
|
}
|
||||||
}
|
|
||||||
|
// If we have to filter by template, find all features assigned to this template, and filter by found IDs
|
||||||
|
if (null !== $template) {
|
||||||
|
$search->filterById(
|
||||||
|
FeatureTemplateQuery::create()->filterByTemplateId($template)->select('feature_id')->find(),
|
||||||
|
Criteria::IN
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (null !== $category) {
|
$exclude_template = $this->getExcludeTemplate();
|
||||||
$search->filterByCategory(
|
|
||||||
CategoryQuery::create()->filterById($category)->find(),
|
// If we have to filter by template, find all features assigned to this template, and filter by found IDs
|
||||||
Criteria::IN
|
if (null !== $exclude_template) {
|
||||||
|
// Exclure tous les attribut qui sont attachés aux templates indiqués
|
||||||
|
$search->filterById(
|
||||||
|
FeatureTemplateQuery::create()->filterByTemplateId($exclude_template)->select('feature_id')->find(),
|
||||||
|
Criteria::NOT_IN
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,15 +1,102 @@
|
|||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
{ifloop rel="free_attributes"}
|
{ifloop rel="free_attributes"}
|
||||||
<select name="free_attributes" id="free_attributes" class="form-control">
|
<form action="{url path='/admin/configuration/templates/attributes/add'}">
|
||||||
<option value="">Select an attribute...</option>
|
|
||||||
{loop name="free_attributes" type="attribute" template="$template_id" backend_context="1" lang="$edit_language_id"}
|
<input type="hidden" name="template_id" value="{$template_id}" />
|
||||||
<option value="{$ID}">{$TITLE}</option>
|
|
||||||
{/loop}
|
<div class="input-group">
|
||||||
</select>
|
<select required="required" name="attribute_id" id="attribute_id" class="form-control">
|
||||||
<span class="help-block">{intl l='Select an attribute and click (+) to add it to this template'}</span>
|
<option value="">Select an attribute...</option>
|
||||||
|
{loop name="free_attributes" type="attribute" exclude_template="$template_id" backend_context="1" lang="$edit_language_id"}
|
||||||
|
<option value="{$ID}">{$TITLE}</option>
|
||||||
|
{/loop}
|
||||||
|
</select>
|
||||||
|
<span class="input-group-btn">
|
||||||
|
<button class="btn btn-default btn-primary action-btn" type="submit"><span class="glyphicon glyphicon-plus-sign"></span></button>
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<span class="help-block">{intl l='Select an attribute and click (+) to add it to this template'}</span>
|
||||||
|
</form>
|
||||||
|
|
||||||
{/ifloop}
|
{/ifloop}
|
||||||
{elseloop rel="free_attributes"}
|
{elseloop rel="free_attributes"}
|
||||||
<div class="alert alert-info">There is currently no available attributes.</div>
|
<div class="alert alert-info">There is currently no available attributes.</div>
|
||||||
{/elseloop}
|
{/elseloop}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<table class="table table-striped table-condensed table-left-aligned">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th>{intl l='ID'}</th>
|
||||||
|
|
||||||
|
<th>{intl l='Attribute title'}</th>
|
||||||
|
|
||||||
|
{module_include location='template_attributes_table_header'}
|
||||||
|
|
||||||
|
<th class="actions">{intl l="Actions"}</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
|
||||||
|
<tbody>
|
||||||
|
{loop name="assigned_attributes" type="attribute" template="$template_id" backend_context="1" lang="$edit_language_id"}
|
||||||
|
<tr>
|
||||||
|
<td>{$ID}</td>
|
||||||
|
|
||||||
|
<td>
|
||||||
|
{$TITLE}
|
||||||
|
</td>
|
||||||
|
|
||||||
|
{module_include location='template_attributes_table_row'}
|
||||||
|
|
||||||
|
<td class="actions">
|
||||||
|
<div class="btn-group">
|
||||||
|
{loop type="auth" name="can_create" roles="ADMIN" permissions="admin.configuration.template.attribute.delete"}
|
||||||
|
<a class="btn btn-default btn-xs delete-attribute" title="{intl l='Delete this attribute'}" href="#delete_attribute_dialog" data-id="{$ID}" data-toggle="modal">
|
||||||
|
<span class="glyphicon glyphicon-trash"></span>
|
||||||
|
</a>
|
||||||
|
{/loop}
|
||||||
|
</div>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
{/loop}
|
||||||
|
|
||||||
|
{elseloop rel="assigned_attributes"}
|
||||||
|
<tr>
|
||||||
|
<td colspan="3">
|
||||||
|
<div class="alert alert-info">
|
||||||
|
{intl l="This template contains no attributes"}
|
||||||
|
</div>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
{/elseloop}
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
|
||||||
|
{* Delete value confirmation dialog *}
|
||||||
|
|
||||||
|
{capture "delete_attribute_dialog"}
|
||||||
|
<input type="hidden" name="template_id" value="{$template_id}" />
|
||||||
|
<input type="hidden" name="attribute_id" id="attribute_delete_id" value="" />
|
||||||
|
{/capture}
|
||||||
|
|
||||||
|
{include
|
||||||
|
file = "includes/generic-confirm-dialog.html"
|
||||||
|
|
||||||
|
dialog_id = "delete_attribute_dialog"
|
||||||
|
dialog_title = {intl l="Remove attribute"}
|
||||||
|
dialog_message = {intl l="Do you really want to remove this attribute from the template ?"}
|
||||||
|
|
||||||
|
form_action = {url path='/admin/configuration/templates/attributes/delete'}
|
||||||
|
form_content = {$smarty.capture.delete_attribute_dialog nofilter}
|
||||||
|
}
|
||||||
|
|
||||||
|
<script>
|
||||||
|
$(function() {
|
||||||
|
|
||||||
|
// Set proper attribute ID in delete attribute from
|
||||||
|
$('a.delete-attribute').click(function(ev) {
|
||||||
|
$('#attribute_delete_id').val($(this).data('id'));
|
||||||
|
});
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
|||||||
102
templates/admin/default/ajax/template-feature-list.html
Normal file
102
templates/admin/default/ajax/template-feature-list.html
Normal file
@@ -0,0 +1,102 @@
|
|||||||
|
<div class="form-group">
|
||||||
|
{ifloop rel="free_features"}
|
||||||
|
<form action="{url path='/admin/configuration/templates/features/add'}">
|
||||||
|
|
||||||
|
<input type="hidden" name="template_id" value="{$template_id}" />
|
||||||
|
|
||||||
|
<div class="input-group">
|
||||||
|
<select required="required" name="feature_id" id="feature_id" class="form-control">
|
||||||
|
<option value="">Select an feature...</option>
|
||||||
|
{loop name="free_features" type="feature" exclude_template="$template_id" backend_context="1" lang="$edit_language_id"}
|
||||||
|
<option value="{$ID}">{$TITLE}</option>
|
||||||
|
{/loop}
|
||||||
|
</select>
|
||||||
|
<span class="input-group-btn">
|
||||||
|
<button class="btn btn-default btn-primary action-btn" type="submit"><span class="glyphicon glyphicon-plus-sign"></span></button>
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<span class="help-block">{intl l='Select an feature and click (+) to add it to this template'}</span>
|
||||||
|
</form>
|
||||||
|
|
||||||
|
{/ifloop}
|
||||||
|
{elseloop rel="free_features"}
|
||||||
|
<div class="alert alert-info">There is currently no available features.</div>
|
||||||
|
{/elseloop}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<table class="table table-striped table-condensed table-left-aligned">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th>{intl l='ID'}</th>
|
||||||
|
|
||||||
|
<th>{intl l='Feature title'}</th>
|
||||||
|
|
||||||
|
{module_include location='template_features_table_header'}
|
||||||
|
|
||||||
|
<th class="actions">{intl l="Actions"}</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
|
||||||
|
<tbody>
|
||||||
|
{loop name="assigned_features" type="feature" template="$template_id" backend_context="1" lang="$edit_language_id"}
|
||||||
|
<tr>
|
||||||
|
<td>{$ID}</td>
|
||||||
|
|
||||||
|
<td>
|
||||||
|
{$TITLE}
|
||||||
|
</td>
|
||||||
|
|
||||||
|
{module_include location='template_features_table_row'}
|
||||||
|
|
||||||
|
<td class="actions">
|
||||||
|
<div class="btn-group">
|
||||||
|
{loop type="auth" name="can_create" roles="ADMIN" permissions="admin.configuration.template.feature.delete"}
|
||||||
|
<a class="btn btn-default btn-xs delete-feature" title="{intl l='Delete this feature'}" href="#delete_feature_dialog" data-id="{$ID}" data-toggle="modal">
|
||||||
|
<span class="glyphicon glyphicon-trash"></span>
|
||||||
|
</a>
|
||||||
|
{/loop}
|
||||||
|
</div>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
{/loop}
|
||||||
|
|
||||||
|
{elseloop rel="assigned_features"}
|
||||||
|
<tr>
|
||||||
|
<td colspan="3">
|
||||||
|
<div class="alert alert-info">
|
||||||
|
{intl l="This template contains no features"}
|
||||||
|
</div>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
{/elseloop}
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
|
||||||
|
{* Delete value confirmation dialog *}
|
||||||
|
|
||||||
|
{capture "delete_feature_dialog"}
|
||||||
|
<input type="hidden" name="template_id" value="{$template_id}" />
|
||||||
|
<input type="hidden" name="feature_id" id="feature_delete_id" value="" />
|
||||||
|
{/capture}
|
||||||
|
|
||||||
|
{include
|
||||||
|
file = "includes/generic-confirm-dialog.html"
|
||||||
|
|
||||||
|
dialog_id = "delete_feature_dialog"
|
||||||
|
dialog_title = {intl l="Remove feature"}
|
||||||
|
dialog_message = {intl l="Do you really want to remove this feature from the template ?"}
|
||||||
|
|
||||||
|
form_action = {url path='/admin/configuration/templates/features/delete'}
|
||||||
|
form_content = {$smarty.capture.delete_feature_dialog nofilter}
|
||||||
|
}
|
||||||
|
|
||||||
|
<script>
|
||||||
|
$(function() {
|
||||||
|
|
||||||
|
// Set proper feature ID in delete feature from
|
||||||
|
$('a.delete-feature').click(function(ev) {
|
||||||
|
$('#feature_delete_id').val($(this).data('id'));
|
||||||
|
});
|
||||||
|
});
|
||||||
|
</script>
|
||||||
@@ -108,8 +108,8 @@
|
|||||||
|
|
||||||
<script>
|
<script>
|
||||||
$(function() {
|
$(function() {
|
||||||
$('#attribute_list_management').load("{admin_viewurl view='ajax/template-attribute-list' template_id=$template_id}");
|
$('#feature_list_management').load("{url path='/admin/configuration/templates/features/list' template_id=$template_id}");
|
||||||
$('#feature_list_management').load("{admin_viewurl view='ajax/template-feature-list' template_id=$template_id}");
|
$('#attribute_list_management').load("{url path='/admin/configuration/templates/attributes/list' template_id=$template_id}");
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
{/block}
|
{/block}
|
||||||
Reference in New Issue
Block a user