From f3cba323c64b51889e82657136d69564639417a2 Mon Sep 17 00:00:00 2001 From: Franck Allimant Date: Sat, 2 Nov 2013 19:18:19 +0100 Subject: [PATCH] Changed 'template' loop into 'product-template' loop --- core/lib/Thelia/Config/Resources/loop.xml | 2 +- .../Core/Template/Loop/ProductTemplate.php | 108 ++++++++++++++++++ .../default/ajax/product-attributes-tab.html | 2 +- templates/admin/default/template-edit.html | 2 +- templates/admin/default/templates.html | 2 +- 5 files changed, 112 insertions(+), 4 deletions(-) create mode 100644 core/lib/Thelia/Core/Template/Loop/ProductTemplate.php diff --git a/core/lib/Thelia/Config/Resources/loop.xml b/core/lib/Thelia/Config/Resources/loop.xml index fe2c333d4..bf5c9f7f9 100644 --- a/core/lib/Thelia/Config/Resources/loop.xml +++ b/core/lib/Thelia/Config/Resources/loop.xml @@ -48,7 +48,7 @@ - + diff --git a/core/lib/Thelia/Core/Template/Loop/ProductTemplate.php b/core/lib/Thelia/Core/Template/Loop/ProductTemplate.php new file mode 100644 index 000000000..175ff0f91 --- /dev/null +++ b/core/lib/Thelia/Core/Template/Loop/ProductTemplate.php @@ -0,0 +1,108 @@ +. */ +/* */ +/*************************************************************************************/ + +namespace Thelia\Core\Template\Loop; + +use Propel\Runtime\ActiveQuery\Criteria; +use Thelia\Core\Template\Element\BaseI18nLoop; +use Thelia\Core\Template\Element\LoopResult; +use Thelia\Core\Template\Element\LoopResultRow; + +use Thelia\Core\Template\Loop\Argument\ArgumentCollection; +use Thelia\Core\Template\Loop\Argument\Argument; + +use Thelia\Model\Base\TemplateQuery; + +/** + * + * Template loop + * + * + * Class Template + * @package Thelia\Core\Template\Loop + * @author Etienne Roudeix + */ +class ProductTemplate extends BaseI18nLoop +{ + public $timestampable = true; + + /** + * @return ArgumentCollection + */ + protected function getArgDefinitions() + { + return new ArgumentCollection( + Argument::createIntListTypeArgument('id'), + Argument::createIntListTypeArgument('exclude') + ); + } + + /** + * @param $pagination + * + * @return \Thelia\Core\Template\Element\LoopResult + */ + public function exec(&$pagination) + { + $search = TemplateQuery::create(); + + $backendContext = $this->getBackend_context(); + + $lang = $this->getLang(); + + /* manage translations */ + $locale = $this->configureI18nProcessing($search, $columns = array('NAME')); + + $id = $this->getId(); + + if (null !== $id) { + $search->filterById($id, Criteria::IN); + } + + $exclude = $this->getExclude(); + + if (null !== $exclude) { + $search->filterById($exclude, Criteria::NOT_IN); + } + + /* perform search */ + $templates = $this->search($search, $pagination); + + $loopResult = new LoopResult($templates); + + foreach ($templates as $template) { + $loopResultRow = new LoopResultRow($loopResult, $template, $this->versionable, $this->timestampable, $this->countable); + + $loopResultRow + ->set("ID", $template->getId()) + ->set("IS_TRANSLATED" , $template->getVirtualColumn('IS_TRANSLATED')) + ->set("LOCALE" , $locale) + ->set("NAME" , $template->getVirtualColumn('i18n_NAME')) + ; + + $loopResult->addRow($loopResultRow); + } + + return $loopResult; + } +} diff --git a/templates/admin/default/ajax/product-attributes-tab.html b/templates/admin/default/ajax/product-attributes-tab.html index 2a62da2e3..f9913d413 100644 --- a/templates/admin/default/ajax/product-attributes-tab.html +++ b/templates/admin/default/ajax/product-attributes-tab.html @@ -25,7 +25,7 @@
diff --git a/templates/admin/default/template-edit.html b/templates/admin/default/template-edit.html index f9e1fd139..623854060 100644 --- a/templates/admin/default/template-edit.html +++ b/templates/admin/default/template-edit.html @@ -10,7 +10,7 @@
- {loop name="template_edit" type="template" id="$template_id" backend_context="1" lang="$edit_language_id"} + {loop name="template_edit" type="product-template" id="$template_id" backend_context="1" lang="$edit_language_id"}