+ */
+class FolderTree extends BaseI18nLoop
+{
+ /**
+ * @return ArgumentCollection
+ */
+ protected function getArgDefinitions()
+ {
+ return new ArgumentCollection(
+ Argument::createIntTypeArgument('folder', null, true),
+ Argument::createIntTypeArgument('depth', PHP_INT_MAX),
+ Argument::createBooleanOrBothTypeArgument('visible', true, false),
+ Argument::createIntListTypeArgument('exclude', array())
+ );
+ }
+
+ // changement de rubrique
+ protected function buildFolderTree($parent, $visible, $level, $max_level, $exclude, LoopResult &$loopResult)
+ {
+ if ($level > $max_level) return;
+
+ $search = FolderQuery::create();
+
+ $locale = $this->configureI18nProcessing($search, array(
+ 'TITLE'
+ ));
+
+ $search->filterByParent($parent);
+
+ if ($visible != BooleanOrBothType::ANY) $search->filterByVisible($visible);
+
+ if ($exclude != null) $search->filterById($exclude, Criteria::NOT_IN);
+
+ $search->orderByPosition(Criteria::ASC);
+
+ $results = $search->find();
+
+ foreach ($results as $result) {
+
+ $loopResultRow = new LoopResultRow();
+
+ $loopResultRow
+ ->set("ID", $result->getId())->set("TITLE", $result->getVirtualColumn('i18n_TITLE'))
+ ->set("PARENT", $result->getParent())->set("URL", $result->getUrl($locale))
+ ->set("VISIBLE", $result->getVisible() ? "1" : "0")->set("LEVEL", $level)
+ ;
+
+ $loopResult->addRow($loopResultRow);
+
+ $this->buildFolderTree($result->getId(), $visible, 1 + $level, $max_level, $exclude, $loopResult);
+ }
+ }
+
+ /**
+ * @param $pagination (ignored)
+ *
+ * @return \Thelia\Core\Template\Element\LoopResult
+ */
+ public function exec(&$pagination)
+ {
+ $id = $this->getFolder();
+ $depth = $this->getDepth();
+ $visible = $this->getVisible();
+ $exclude = $this->getExclude();
+
+ $loopResult = new LoopResult();
+
+ $this->buildFolderTree($id, $visible, 0, $depth, $exclude, $loopResult);
+
+ return $loopResult;
+ }
+}
diff --git a/core/lib/Thelia/Form/ProductCreationForm.php b/core/lib/Thelia/Form/ProductCreationForm.php
index a4ffdde32..9329ca2ec 100644
--- a/core/lib/Thelia/Form/ProductCreationForm.php
+++ b/core/lib/Thelia/Form/ProductCreationForm.php
@@ -43,35 +43,29 @@ class ProductCreationForm extends BaseForm
$this->formBuilder
->add("ref", "text", array(
"constraints" => $ref_constraints,
- "label" => "Product reference *",
- "label_attr" => array(
- "for" => "ref"
- )
+ "label" => "Product reference *",
+ "label_attr" => array("for" => "ref")
))
->add("title", "text", array(
"constraints" => array(
new NotBlank()
),
"label" => "Product title *",
- "label_attr" => array(
- "for" => "title"
- )
+ "label_attr" => array("for" => "title")
))
->add("default_category", "integer", array(
- "constraints" => array(
- new NotBlank()
- )
+ "constraints" => array(new NotBlank()),
+ "label" => Translator::getInstance()->trans("Default product category."),
+ "label_attr" => array("for" => "default_category_field")
))
->add("locale", "text", array(
- "constraints" => array(
- new NotBlank()
- )
+ "constraints" => array(new NotBlank())
))
->add("visible", "integer", array(
- "label" => Translator::getInstance()->trans("This product is online."),
- "label_attr" => array("for" => "visible_create")
+ "label" => Translator::getInstance()->trans("This product is online."),
+ "label_attr" => array("for" => "visible_field")
))
- ;
+ ;
}
public function checkDuplicateRef($value, ExecutionContextInterface $context)
diff --git a/core/lib/Thelia/Model/Accessory.php b/core/lib/Thelia/Model/Accessory.php
index 2e927ff7c..f24aab680 100755
--- a/core/lib/Thelia/Model/Accessory.php
+++ b/core/lib/Thelia/Model/Accessory.php
@@ -3,7 +3,77 @@
namespace Thelia\Model;
use Thelia\Model\Base\Accessory as BaseAccessory;
+use Thelia\Core\Event\TheliaEvents;
+use Propel\Runtime\Connection\ConnectionInterface;
+use Thelia\Core\Event\AccessoryEvent;
class Accessory extends BaseAccessory {
+ use \Thelia\Model\Tools\ModelEventDispatcherTrait;
+
+ use \Thelia\Model\Tools\PositionManagementTrait;
+
+ /**
+ * Calculate next position relative to our product
+ */
+ protected function addCriteriaToPositionQuery($query) {
+ $query->filterByProductId($this->getProductId());
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public function preInsert(ConnectionInterface $con = null)
+ {
+ $this->setPosition($this->getNextPosition());
+
+ $this->dispatchEvent(TheliaEvents::BEFORE_CREATEACCESSORY, new AccessoryEvent($this));
+
+ return true;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public function postInsert(ConnectionInterface $con = null)
+ {
+ $this->dispatchEvent(TheliaEvents::AFTER_CREATEACCESSORY, new AccessoryEvent($this));
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public function preUpdate(ConnectionInterface $con = null)
+ {
+ $this->dispatchEvent(TheliaEvents::BEFORE_UPDATEACCESSORY, new AccessoryEvent($this));
+
+ return true;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public function postUpdate(ConnectionInterface $con = null)
+ {
+ $this->dispatchEvent(TheliaEvents::AFTER_UPDATEACCESSORY, new AccessoryEvent($this));
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public function preDelete(ConnectionInterface $con = null)
+ {
+ $this->dispatchEvent(TheliaEvents::BEFORE_DELETEACCESSORY, new AccessoryEvent($this));
+
+ return true;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public function postDelete(ConnectionInterface $con = null)
+ {
+ $this->dispatchEvent(TheliaEvents::AFTER_DELETEACCESSORY, new AccessoryEvent($this));
+ }
+
}
diff --git a/core/lib/Thelia/Model/CategoryAssociatedContent.php b/core/lib/Thelia/Model/CategoryAssociatedContent.php
index 9296e6274..9154767bc 100644
--- a/core/lib/Thelia/Model/CategoryAssociatedContent.php
+++ b/core/lib/Thelia/Model/CategoryAssociatedContent.php
@@ -3,7 +3,66 @@
namespace Thelia\Model;
use Thelia\Model\Base\CategoryAssociatedContent as BaseCategoryAssociatedContent;
+use Thelia\Core\Event\CategoryAssociatedContentEvent;
+use Thelia\Core\Event\TheliaEvents;
+use Propel\Runtime\Connection\ConnectionInterface;
class CategoryAssociatedContent extends BaseCategoryAssociatedContent {
+ use \Thelia\Model\Tools\ModelEventDispatcherTrait;
+
+ /**
+ * {@inheritDoc}
+ */
+ public function preInsert(ConnectionInterface $con = null)
+ {
+ $this->dispatchEvent(TheliaEvents::BEFORE_CREATECATEGORY_ASSOCIATED_CONTENT, new CategoryAssociatedContentEvent($this));
+
+ return true;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public function postInsert(ConnectionInterface $con = null)
+ {
+ $this->dispatchEvent(TheliaEvents::AFTER_CREATECATEGORY_ASSOCIATED_CONTENT, new CategoryAssociatedContentEvent($this));
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public function preUpdate(ConnectionInterface $con = null)
+ {
+ $this->dispatchEvent(TheliaEvents::BEFORE_UPDATECATEGORY_ASSOCIATED_CONTENT, new CategoryAssociatedContentEvent($this));
+
+ return true;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public function postUpdate(ConnectionInterface $con = null)
+ {
+ $this->dispatchEvent(TheliaEvents::AFTER_UPDATECATEGORY_ASSOCIATED_CONTENT, new CategoryAssociatedContentEvent($this));
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public function preDelete(ConnectionInterface $con = null)
+ {
+ $this->dispatchEvent(TheliaEvents::BEFORE_DELETECATEGORY_ASSOCIATED_CONTENT, new CategoryAssociatedContentEvent($this));
+
+ return true;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public function postDelete(ConnectionInterface $con = null)
+ {
+ $this->dispatchEvent(TheliaEvents::AFTER_DELETECATEGORY_ASSOCIATED_CONTENT, new CategoryAssociatedContentEvent($this));
+ }
+
}
diff --git a/core/lib/Thelia/Model/ProductAssociatedContent.php b/core/lib/Thelia/Model/ProductAssociatedContent.php
index 9b007baf1..e07ee2cd6 100644
--- a/core/lib/Thelia/Model/ProductAssociatedContent.php
+++ b/core/lib/Thelia/Model/ProductAssociatedContent.php
@@ -3,7 +3,65 @@
namespace Thelia\Model;
use Thelia\Model\Base\ProductAssociatedContent as BaseProductAssociatedContent;
+use Propel\Runtime\Connection\ConnectionInterface;
+use Thelia\Core\Event\ProductAssociatedContentEvent;
+use Thelia\Core\Event\TheliaEvents;
class ProductAssociatedContent extends BaseProductAssociatedContent {
+ use \Thelia\Model\Tools\ModelEventDispatcherTrait;
+
+ /**
+ * {@inheritDoc}
+ */
+ public function preInsert(ConnectionInterface $con = null)
+ {
+ $this->dispatchEvent(TheliaEvents::BEFORE_CREATEPRODUCT_ASSOCIATED_CONTENT, new ProductAssociatedContentEvent($this));
+
+ return true;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public function postInsert(ConnectionInterface $con = null)
+ {
+ $this->dispatchEvent(TheliaEvents::AFTER_CREATEPRODUCT_ASSOCIATED_CONTENT, new ProductAssociatedContentEvent($this));
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public function preUpdate(ConnectionInterface $con = null)
+ {
+ $this->dispatchEvent(TheliaEvents::BEFORE_UPDATEPRODUCT_ASSOCIATED_CONTENT, new ProductAssociatedContentEvent($this));
+
+ return true;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public function postUpdate(ConnectionInterface $con = null)
+ {
+ $this->dispatchEvent(TheliaEvents::AFTER_UPDATEPRODUCT_ASSOCIATED_CONTENT, new ProductAssociatedContentEvent($this));
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public function preDelete(ConnectionInterface $con = null)
+ {
+ $this->dispatchEvent(TheliaEvents::BEFORE_DELETEPRODUCT_ASSOCIATED_CONTENT, new ProductAssociatedContentEvent($this));
+
+ return true;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public function postDelete(ConnectionInterface $con = null)
+ {
+ $this->dispatchEvent(TheliaEvents::AFTER_DELETEPRODUCT_ASSOCIATED_CONTENT, new ProductAssociatedContentEvent($this));
+ }
}
diff --git a/templates/admin/default/categories.html b/templates/admin/default/categories.html
index b24b625cb..990cafd56 100755
--- a/templates/admin/default/categories.html
+++ b/templates/admin/default/categories.html
@@ -267,14 +267,14 @@
{loop type="image" name="cat_image" source="product" source_id="$ID" limit="1" width="50" height="50" resize_mode="crop" backend_context="1"}
-
+
{/loop}
- | {$REF} |
+ {$REF} |
- {$TITLE} |
+ {$TITLE} |
{module_include location='product_list_row'}
@@ -306,7 +306,7 @@
{loop type="auth" name="can_change" roles="ADMIN" permissions="admin.product.edit"}
-
+
{/loop}
{loop type="auth" name="can_delete" roles="ADMIN" permissions="admin.product.delete"}
diff --git a/templates/admin/default/category-edit.html b/templates/admin/default/category-edit.html
index 05c9c02f8..b974a4564 100755
--- a/templates/admin/default/category-edit.html
+++ b/templates/admin/default/category-edit.html
@@ -40,24 +40,23 @@
-
+
{form name="thelia.admin.category.modification"}
-
-
-
+
+
| {intl l='ID'} |
- {intl l='Attribute title'} |
+ {intl l='Content title'} |
{module_include location='category_contents_table_header'}
@@ -247,13 +255,13 @@
-
+
-
@@ -289,7 +297,7 @@
{block name="javascript-initialization"}
-
+
@@ -319,12 +327,6 @@ $(function() {
ev.preventDefault();
});
- // Show proper tab, if defined
- {if ! empty($current_tab)}
- $('#tabbed-menu a[href="#{$current_tab}"]').tab('show')
- {/if}
-
-
// Set proper content ID in delete content from
$('a.delete-content').click(function(ev) {
$('#content_delete_id').val($(this).data('id'));
@@ -333,28 +335,41 @@ $(function() {
// Load content on folder selection
$('#folder_id').change(function(event) {
- $.ajax({
- url : '{url path="/admin/category/$category_id/available-related-content/"}' + $(this).val() + '.xml',
- type : 'get',
- dataType : 'json',
- success : function(json) {
- $('#content_id :not(:first-child)').remove();
- var have_content = false;
+ var val = $(this).val();
- $.each(json, function(idx, value) {
- $('#content_id').append($(' |