lil loop refactor
This commit is contained in:
@@ -0,0 +1,36 @@
|
||||
<?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\Template\Element;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Etienne Roudeix <eroudeix@openstudio.fr>
|
||||
*
|
||||
*/
|
||||
interface ArraySearchLoopInterface
|
||||
{
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function buildArray();
|
||||
}
|
||||
@@ -36,6 +36,8 @@ use Thelia\Model\Tools\ModelCriteriaTools;
|
||||
*/
|
||||
abstract class BaseI18nLoop extends BaseLoop
|
||||
{
|
||||
protected $locale;
|
||||
|
||||
/**
|
||||
* Define common loop arguments
|
||||
*
|
||||
@@ -65,9 +67,7 @@ abstract class BaseI18nLoop extends BaseLoop
|
||||
{
|
||||
/* manage translations */
|
||||
|
||||
$fr = $this->getForce_return();
|
||||
|
||||
return ModelCriteriaTools::getI18n(
|
||||
$this->locale = ModelCriteriaTools::getI18n(
|
||||
$this->getBackend_context(),
|
||||
$this->getLang(),
|
||||
$search,
|
||||
|
||||
@@ -27,6 +27,7 @@ use Propel\Runtime\ActiveQuery\Criteria;
|
||||
use Symfony\Component\DependencyInjection\ContainerInterface;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
|
||||
use Thelia\Core\Template\Element\Exception\LoopException;
|
||||
use Thelia\Core\Template\Loop\Argument\Argument;
|
||||
use Propel\Runtime\ActiveQuery\ModelCriteria;
|
||||
use Thelia\Core\Security\SecurityContext;
|
||||
@@ -62,9 +63,9 @@ abstract class BaseLoop
|
||||
|
||||
protected $args;
|
||||
|
||||
public $countable = true;
|
||||
public $timestampable = false;
|
||||
public $versionable = false;
|
||||
protected $countable = true;
|
||||
protected $timestampable = false;
|
||||
protected $versionable = false;
|
||||
|
||||
/**
|
||||
* Create a new Loop
|
||||
@@ -73,6 +74,8 @@ abstract class BaseLoop
|
||||
*/
|
||||
public function __construct(ContainerInterface $container)
|
||||
{
|
||||
$this->checkInterface();
|
||||
|
||||
$this->container = $container;
|
||||
|
||||
$this->request = $container->get('request');
|
||||
@@ -240,6 +243,9 @@ abstract class BaseLoop
|
||||
*/
|
||||
protected function search(ModelCriteria $search, &$pagination = null)
|
||||
{
|
||||
if (false === $this->countable) {
|
||||
return $search->find();
|
||||
}
|
||||
if ($this instanceof SearchLoopInterface) {
|
||||
$searchTerm = $this->getSearch_term();
|
||||
$searchIn = $this->getSearch_in();
|
||||
@@ -271,6 +277,29 @@ abstract class BaseLoop
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
protected function searchArray(array $search, &$pagination = null)
|
||||
{
|
||||
if (false === $this->countable) {
|
||||
return $search;
|
||||
}
|
||||
if ($this->getArgValue('page') !== null) {
|
||||
|
||||
$nbPage = ceil(count($search)/$this->getArgValue('limit'));
|
||||
if($this->getArgValue('page') > $nbPage || $this->getArgValue('page') <= 0) {
|
||||
return array();
|
||||
}
|
||||
|
||||
$firstItem = ($this->getArgValue('page')-1) * $this->getArgValue('limit') + 1;
|
||||
|
||||
return array_slice($search, $firstItem, $firstItem + $this->getArgValue('limit'), false);
|
||||
|
||||
} else {
|
||||
return array_slice($search, $this->getArgValue('offset'), $this->getArgValue('limit'), false);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param ModelCriteria $search
|
||||
*
|
||||
@@ -304,18 +333,84 @@ abstract class BaseLoop
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* this function have to be implement in your own loop class.
|
||||
*
|
||||
* All loops parameters can be accessible via getter.
|
||||
*
|
||||
* for example, ref parameter is accessible through getRef method
|
||||
*
|
||||
* @param $pagination
|
||||
*
|
||||
* @return LoopResult
|
||||
*/
|
||||
abstract public function exec(&$pagination);
|
||||
public function exec(&$pagination)
|
||||
{
|
||||
if($this instanceof PropelSearchLoopInterface) {
|
||||
$searchModelCriteria = $this->buildModelCriteria();
|
||||
if(null === $searchModelCriteria) {
|
||||
$results = array();
|
||||
} else {
|
||||
$results = $this->search(
|
||||
$searchModelCriteria,
|
||||
$pagination
|
||||
);
|
||||
}
|
||||
} elseif ($this instanceof ArraySearchLoopInterface) {
|
||||
$searchArray = $this->buildArray();
|
||||
if(null === $searchArray) {
|
||||
$results = array();
|
||||
} else {
|
||||
$results = $this->searchArray(
|
||||
$searchArray,
|
||||
$pagination
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
$loopResult = new LoopResult($results);
|
||||
|
||||
if(true === $this->countable) {
|
||||
$loopResult->setCountable();
|
||||
}
|
||||
if(true === $this->timestampable) {
|
||||
$loopResult->setTimestamped();
|
||||
}
|
||||
if(true === $this->versionable) {
|
||||
$loopResult->setVersioned();
|
||||
}
|
||||
|
||||
return $this->parseResults($loopResult);
|
||||
}
|
||||
|
||||
protected function checkInterface()
|
||||
{
|
||||
/* Must implement either :
|
||||
* - PropelSearchLoopInterface
|
||||
* - ArraySearchLoopInterface
|
||||
*/
|
||||
$searchInterface = false;
|
||||
if($this instanceof PropelSearchLoopInterface) {
|
||||
if(true === $searchInterface) {
|
||||
throw new LoopException('Loop cannot implements multiple Search Interfaces : `PropelSearchLoopInterface`, `ArraySearchLoopInterface`', LoopException::MULTIPLE_SEARCH_INTERFACE);
|
||||
}
|
||||
$searchInterface = true;
|
||||
}
|
||||
if($this instanceof ArraySearchLoopInterface) {
|
||||
if(true === $searchInterface) {
|
||||
throw new LoopException('Loop cannot implements multiple Search Interfaces : `PropelSearchLoopInterface`, `ArraySearchLoopInterface`', LoopException::MULTIPLE_SEARCH_INTERFACE);
|
||||
}
|
||||
$searchInterface = true;
|
||||
}
|
||||
|
||||
if(false === $searchInterface) {
|
||||
throw new LoopException('Loop must implements one of the following interfaces : `PropelSearchLoopInterface`, `ArraySearchLoopInterface`', LoopException::SEARCH_INTERFACE_NOT_FOUND);
|
||||
}
|
||||
|
||||
/* Only PropelSearch allows timestamp and version */
|
||||
if(!$this instanceof PropelSearchLoopInterface) {
|
||||
if(true === $this->timestampable) {
|
||||
throw new LoopException("Loop must implements 'PropelSearchLoopInterface' to be timestampable", LoopException::NOT_TIMESTAMPED);
|
||||
}
|
||||
if(true === $this->versionable) {
|
||||
throw new LoopException("Loop must implements 'PropelSearchLoopInterface' to be versionable", LoopException::NOT_VERSIONED);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
abstract public function parseResults(LoopResult $loopResult);
|
||||
|
||||
/**
|
||||
*
|
||||
|
||||
@@ -0,0 +1,46 @@
|
||||
<?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\Template\Element\Exception;
|
||||
|
||||
class LoopException extends \RuntimeException
|
||||
{
|
||||
const UNKNOWN_EXCEPTION = 0;
|
||||
|
||||
const NOT_TIMESTAMPED = 100;
|
||||
const NOT_VERSIONED = 101;
|
||||
|
||||
const MULTIPLE_SEARCH_INTERFACE = 400;
|
||||
const SEARCH_INTERFACE_NOT_FOUND = 404;
|
||||
|
||||
public function __construct($message, $code = null, $arguments = array(), $previous = null)
|
||||
{
|
||||
if (is_array($arguments)) {
|
||||
$this->arguments = $arguments;
|
||||
}
|
||||
if ($code === null) {
|
||||
$code = self::UNKNOWN_EXCEPTION;
|
||||
}
|
||||
parent::__construct($message, $code, $previous);
|
||||
}
|
||||
}
|
||||
@@ -32,14 +32,40 @@ class LoopResult implements \Iterator
|
||||
private $position;
|
||||
protected $collection = array();
|
||||
|
||||
public $modelCollection = null;
|
||||
public $resultsCollection = null;
|
||||
|
||||
public function __construct($modelCollection = null)
|
||||
protected $versioned = false;
|
||||
protected $timestamped = false;
|
||||
protected $countable = false;
|
||||
|
||||
public function __construct($resultsCollection)
|
||||
{
|
||||
$this->position = 0;
|
||||
if ($modelCollection instanceof ObjectCollection || $modelCollection instanceof PropelModelPager || is_array($modelCollection)) {
|
||||
$this->modelCollection = $modelCollection;
|
||||
}
|
||||
$this->resultsCollection = $resultsCollection;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param boolean $countable
|
||||
*/
|
||||
public function setCountable($countable = true)
|
||||
{
|
||||
$this->countable = true === $countable;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param boolean $timestamped
|
||||
*/
|
||||
public function setTimestamped($timestamped = true)
|
||||
{
|
||||
$this->timestamped = true === $timestamped;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param boolean $versioned
|
||||
*/
|
||||
public function setVersioned($versioned = true)
|
||||
{
|
||||
$this->versioned = true === $versioned;
|
||||
}
|
||||
|
||||
public function isEmpty()
|
||||
@@ -49,6 +75,21 @@ class LoopResult implements \Iterator
|
||||
|
||||
public function addRow(LoopResultRow $row)
|
||||
{
|
||||
if (true === $this->versioned) {
|
||||
foreach ($this->getVersionOutputs() as $output) {
|
||||
$row->set($output[0], $row->model->$output[1]());
|
||||
}
|
||||
}
|
||||
if (true === $this->timestamped) {
|
||||
foreach ($this->getTimestampOutputs() as $output) {
|
||||
$row->set($output[0], $row->model->$output[1]());
|
||||
}
|
||||
}
|
||||
if (true === $this->countable) {
|
||||
$row->set('LOOP_COUNT', 1 + $this->getCount());
|
||||
$row->set('LOOP_TOTAL', $this->getResultDataCollectionCount());
|
||||
}
|
||||
|
||||
$this->collection[] = $row;
|
||||
}
|
||||
|
||||
@@ -57,17 +98,22 @@ class LoopResult implements \Iterator
|
||||
return count($this->collection);
|
||||
}
|
||||
|
||||
public function getModelCollectionCount()
|
||||
public function getResultDataCollectionCount()
|
||||
{
|
||||
if ($this->modelCollection instanceof ObjectCollection || $this->modelCollection instanceof PropelModelPager) {
|
||||
return $this->modelCollection->count();
|
||||
} elseif (is_array($this->modelCollection)) {
|
||||
return count($this->modelCollection);
|
||||
if ($this->resultsCollection instanceof ObjectCollection || $this->resultsCollection instanceof PropelModelPager) {
|
||||
return $this->resultsCollection->count();
|
||||
} elseif (is_array($this->resultsCollection)) {
|
||||
return count($this->resultsCollection);
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
public function getResultDataCollection()
|
||||
{
|
||||
return $this->resultsCollection;
|
||||
}
|
||||
|
||||
/**
|
||||
* (PHP 5 >= 5.0.0)<br/>
|
||||
* Return the current element
|
||||
@@ -123,4 +169,21 @@ class LoopResult implements \Iterator
|
||||
{
|
||||
$this->position = 0;
|
||||
}
|
||||
|
||||
protected function getTimestampOutputs()
|
||||
{
|
||||
return array(
|
||||
array('CREATE_DATE', 'getCreatedAt'),
|
||||
array('UPDATE_DATE', 'getUpdatedAt'),
|
||||
);
|
||||
}
|
||||
|
||||
protected function getVersionOutputs()
|
||||
{
|
||||
return array(
|
||||
array('VERSION', 'getVersion'),
|
||||
array('VERSION_DATE', 'getVersionCreatedAt'),
|
||||
array('VERSION_AUTHOR', 'getVersionCreatedBy'),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,28 +30,12 @@ class LoopResultRow
|
||||
protected $substitution = array();
|
||||
|
||||
public $model = null;
|
||||
public $loopResult;
|
||||
|
||||
public $versionable = false;
|
||||
public $timestampable = false;
|
||||
public $countable = false;
|
||||
|
||||
public function __construct($loopResult = null, $model = null, $versionable = false, $timestampable = false, $countable = true)
|
||||
public function __construct($model = null)
|
||||
{
|
||||
if ($model instanceof ActiveRecordInterface) {
|
||||
$this->model = $model;
|
||||
|
||||
$this->versionable = $versionable;
|
||||
$this->timestampable = $timestampable;
|
||||
}
|
||||
|
||||
if ($loopResult instanceof LoopResult) {
|
||||
$this->loopResult = $loopResult;
|
||||
|
||||
$this->countable = $countable;
|
||||
}
|
||||
|
||||
$this->assignDefaultOutputs();
|
||||
}
|
||||
|
||||
public function set($key, $value)
|
||||
@@ -75,39 +59,4 @@ class LoopResultRow
|
||||
{
|
||||
return array_keys($this->substitution);
|
||||
}
|
||||
|
||||
protected function getTimestampOutputs()
|
||||
{
|
||||
return array(
|
||||
array('CREATE_DATE', 'getCreatedAt'),
|
||||
array('UPDATE_DATE', 'getUpdatedAt'),
|
||||
);
|
||||
}
|
||||
|
||||
protected function getVersionOutputs()
|
||||
{
|
||||
return array(
|
||||
array('VERSION', 'getVersion'),
|
||||
array('VERSION_DATE', 'getVersionCreatedAt'),
|
||||
array('VERSION_AUTHOR', 'getVersionCreatedBy'),
|
||||
);
|
||||
}
|
||||
|
||||
protected function assignDefaultOutputs()
|
||||
{
|
||||
if (true === $this->versionable) {
|
||||
foreach ($this->getVersionOutputs() as $output) {
|
||||
$this->set($output[0], $this->model->$output[1]());
|
||||
}
|
||||
}
|
||||
if (true === $this->timestampable) {
|
||||
foreach ($this->getTimestampOutputs() as $output) {
|
||||
$this->set($output[0], $this->model->$output[1]());
|
||||
}
|
||||
}
|
||||
if (true === $this->countable) {
|
||||
$this->set('LOOP_COUNT', 1 + $this->loopResult->getCount());
|
||||
$this->set('LOOP_TOTAL', $this->loopResult->getModelCollectionCount());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,36 @@
|
||||
<?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\Template\Element;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Etienne Roudeix <eroudeix@openstudio.fr>
|
||||
*
|
||||
*/
|
||||
interface PropelSearchLoopInterface
|
||||
{
|
||||
/**
|
||||
* @return \Propel\Runtime\ActiveQuery\ModelCriteria
|
||||
*/
|
||||
public function buildModelCriteria();
|
||||
}
|
||||
@@ -45,6 +45,9 @@ use Thelia\Type;
|
||||
*/
|
||||
class Accessory extends Product
|
||||
{
|
||||
protected $accessoryId;
|
||||
protected $accessoryPosition;
|
||||
|
||||
/**
|
||||
* @return ArgumentCollection
|
||||
*/
|
||||
@@ -64,12 +67,7 @@ class Accessory extends Product
|
||||
return $argumentCollection;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $pagination
|
||||
*
|
||||
* @return \Thelia\Core\Template\Element\LoopResult
|
||||
*/
|
||||
public function exec(&$pagination)
|
||||
public function buildModelCriteria()
|
||||
{
|
||||
$search = AccessoryQuery::create();
|
||||
|
||||
@@ -93,40 +91,45 @@ class Accessory extends Product
|
||||
|
||||
$accessories = $this->search($search);
|
||||
|
||||
$accessoryIdList = array(0);
|
||||
$accessoryPosition = $accessoryId = array();
|
||||
$this->accessoryIdList = array(0);
|
||||
$this->accessoryPosition = $this->accessoryId = array();
|
||||
|
||||
foreach ($accessories as $accessory) {
|
||||
|
||||
$accessoryProductId = $accessory->getAccessory();
|
||||
|
||||
array_push($accessoryIdList, $accessoryProductId);
|
||||
array_push($this->accessoryIdList, $accessoryProductId);
|
||||
|
||||
$accessoryPosition[$accessoryProductId] = $accessory->getPosition();
|
||||
$accessoryId[$accessoryProductId] = $accessory->getId();
|
||||
$this->accessoryPosition[$accessoryProductId] = $accessory->getPosition();
|
||||
$this->accessoryId[$accessoryProductId] = $accessory->getId();
|
||||
}
|
||||
|
||||
$receivedIdList = $this->getId();
|
||||
|
||||
/* if an Id list is receive, loop will only match accessories from this list */
|
||||
if ($receivedIdList === null) {
|
||||
$this->args->get('id')->setValue( implode(',', $accessoryIdList) );
|
||||
$this->args->get('id')->setValue( implode(',', $this->accessoryIdList) );
|
||||
} else {
|
||||
$this->args->get('id')->setValue( implode(',', array_intersect($receivedIdList, $accessoryIdList)) );
|
||||
$this->args->get('id')->setValue( implode(',', array_intersect($receivedIdList, $this->accessoryIdList)) );
|
||||
}
|
||||
|
||||
$loopResult = parent::exec($pagination);
|
||||
return parent::buildModelCriteria();
|
||||
}
|
||||
|
||||
foreach ($loopResult as $loopResultRow) {
|
||||
public function parseResults(LoopResult $results)
|
||||
{
|
||||
$results = parent::parseResults($results);
|
||||
|
||||
foreach ($results as $loopResultRow) {
|
||||
|
||||
$accessoryProductId = $loopResultRow->get('ID');
|
||||
|
||||
$loopResultRow
|
||||
->set("ID" , $accessoryId[$accessoryProductId])
|
||||
->set("POSITION", $accessoryPosition[$accessoryProductId])
|
||||
->set("ID" , $this->accessoryId[$accessoryProductId])
|
||||
->set("POSITION", $this->accessoryPosition[$accessoryProductId])
|
||||
;
|
||||
}
|
||||
|
||||
return $loopResult;
|
||||
return $results;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,6 +28,7 @@ use Thelia\Core\Template\Element\BaseLoop;
|
||||
use Thelia\Core\Template\Element\LoopResult;
|
||||
use Thelia\Core\Template\Element\LoopResultRow;
|
||||
|
||||
use Thelia\Core\Template\Element\PropelSearchLoopInterface;
|
||||
use Thelia\Core\Template\Loop\Argument\ArgumentCollection;
|
||||
use Thelia\Core\Template\Loop\Argument\Argument;
|
||||
|
||||
@@ -44,9 +45,9 @@ use Thelia\Type;
|
||||
* @package Thelia\Core\Template\Loop
|
||||
* @author Etienne Roudeix <eroudeix@openstudio.fr>
|
||||
*/
|
||||
class Address extends BaseLoop
|
||||
class Address extends BaseLoop implements PropelSearchLoopInterface
|
||||
{
|
||||
public $timestampable = true;
|
||||
protected $timestampable = true;
|
||||
|
||||
/**
|
||||
* @return ArgumentCollection
|
||||
@@ -80,12 +81,7 @@ class Address extends BaseLoop
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $pagination
|
||||
*
|
||||
* @return \Thelia\Core\Template\Element\LoopResult
|
||||
*/
|
||||
public function exec(&$pagination)
|
||||
public function buildModelCriteria()
|
||||
{
|
||||
$search = AddressQuery::create();
|
||||
|
||||
@@ -100,7 +96,7 @@ class Address extends BaseLoop
|
||||
if ($customer === 'current') {
|
||||
$currentCustomer = $this->securityContext->getCustomerUser();
|
||||
if ($currentCustomer === null) {
|
||||
return new LoopResult();
|
||||
return null;
|
||||
} else {
|
||||
$search->filterByCustomerId($currentCustomer->getId(), Criteria::EQUAL);
|
||||
}
|
||||
@@ -122,12 +118,14 @@ class Address extends BaseLoop
|
||||
$search->filterById($exclude, Criteria::NOT_IN);
|
||||
}
|
||||
|
||||
$addresses = $this->search($search, $pagination);
|
||||
return $search;
|
||||
|
||||
$loopResult = new LoopResult($addresses);
|
||||
}
|
||||
|
||||
foreach ($addresses as $address) {
|
||||
$loopResultRow = new LoopResultRow($loopResult, $address, $this->versionable, $this->timestampable, $this->countable);
|
||||
public function parseResults(LoopResult $loopResult)
|
||||
{
|
||||
foreach ($loopResult->getResultDataCollection() as $address) {
|
||||
$loopResultRow = new LoopResultRow($address);
|
||||
$loopResultRow
|
||||
->set("ID", $address->getId())
|
||||
->set("LABEL", $address->getLabel())
|
||||
|
||||
@@ -28,6 +28,7 @@ use Thelia\Core\Template\Element\BaseLoop;
|
||||
use Thelia\Core\Template\Element\LoopResult;
|
||||
use Thelia\Core\Template\Element\LoopResultRow;
|
||||
|
||||
use Thelia\Core\Template\Element\PropelSearchLoopInterface;
|
||||
use Thelia\Core\Template\Loop\Argument\ArgumentCollection;
|
||||
use Thelia\Core\Template\Loop\Argument\Argument;
|
||||
|
||||
@@ -43,9 +44,9 @@ use Thelia\Type;
|
||||
* @package Thelia\Core\Template\Loop
|
||||
* @author Etienne Roudeix <eroudeix@openstudio.fr>
|
||||
*/
|
||||
class Admin extends BaseLoop
|
||||
class Admin extends BaseLoop implements PropelSearchLoopInterface
|
||||
{
|
||||
public $timestampable = true;
|
||||
protected $timestampable = true;
|
||||
|
||||
/**
|
||||
* @return ArgumentCollection
|
||||
@@ -58,12 +59,7 @@ class Admin extends BaseLoop
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $pagination
|
||||
*
|
||||
* @return \Thelia\Core\Template\Element\LoopResult
|
||||
*/
|
||||
public function exec(&$pagination)
|
||||
public function buildModelCriteria()
|
||||
{
|
||||
$search = AdminQuery::create();
|
||||
|
||||
@@ -81,13 +77,14 @@ class Admin extends BaseLoop
|
||||
|
||||
$search->orderByFirstname(Criteria::ASC);
|
||||
|
||||
/* perform search */
|
||||
$admins = $this->search($search, $pagination);
|
||||
return $search;
|
||||
|
||||
$loopResult = new LoopResult($admins);
|
||||
}
|
||||
|
||||
foreach ($admins as $admin) {
|
||||
$loopResultRow = new LoopResultRow($loopResult, $admin, $this->versionable, $this->timestampable, $this->countable);
|
||||
public function parseResults(LoopResult $loopResult)
|
||||
{
|
||||
foreach ($loopResult->getResultDataCollection() as $admin) {
|
||||
$loopResultRow = new LoopResultRow($admin);
|
||||
$loopResultRow->set("ID", $admin->getId())
|
||||
->set("PROFILE",$admin->getProfileId())
|
||||
->set("FIRSTNAME",$admin->getFirstname())
|
||||
@@ -99,5 +96,6 @@ class Admin extends BaseLoop
|
||||
}
|
||||
|
||||
return $loopResult;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,6 +26,7 @@ use Propel\Runtime\ActiveQuery\Criteria;
|
||||
use Thelia\Core\Template\Element\BaseLoop;
|
||||
use Thelia\Core\Template\Element\LoopResult;
|
||||
use Thelia\Core\Template\Element\LoopResultRow;
|
||||
use Thelia\Core\Template\Element\PropelSearchLoopInterface;
|
||||
use Thelia\Core\Template\Loop\Argument\Argument;
|
||||
use Thelia\Core\Template\Loop\Argument\ArgumentCollection;
|
||||
use Thelia\Model\AreaQuery;
|
||||
@@ -35,9 +36,9 @@ use Thelia\Model\AreaQuery;
|
||||
* @package Thelia\Core\Template\Loop
|
||||
* @author Manuel Raynaud <mraynaud@openstudio.fr>
|
||||
*/
|
||||
class Area extends BaseLoop
|
||||
class Area extends BaseLoop implements PropelSearchLoopInterface
|
||||
{
|
||||
public $timestampable = true;
|
||||
protected $timestampable = true;
|
||||
|
||||
/**
|
||||
*
|
||||
@@ -80,19 +81,7 @@ class Area extends BaseLoop
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* this function have to be implement in your own loop class.
|
||||
*
|
||||
* All loops parameters can be accessible via getter.
|
||||
*
|
||||
* for example, ref parameter is accessible through getRef method
|
||||
*
|
||||
* @param $pagination
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function exec(&$pagination)
|
||||
public function buildModelCriteria()
|
||||
{
|
||||
$id = $this->getId();
|
||||
|
||||
@@ -117,14 +106,14 @@ class Area extends BaseLoop
|
||||
->where('`without_zone`.delivery_module_id '.Criteria::ISNULL);
|
||||
}
|
||||
|
||||
//echo $search->toString(); exit;
|
||||
return $search;
|
||||
|
||||
$areas = $this->search($search, $pagination);
|
||||
}
|
||||
|
||||
$loopResult = new LoopResult($areas);
|
||||
|
||||
foreach ($areas as $area) {
|
||||
$loopResultRow = new LoopResultRow($loopResult, $area, $this->versionable, $this->timestampable, $this->countable);
|
||||
public function parseResults(LoopResult $loopResult)
|
||||
{
|
||||
foreach ($loopResult->getResultDataCollection() as $area) {
|
||||
$loopResultRow = new LoopResultRow($area);
|
||||
|
||||
$loopResultRow
|
||||
->set('ID', $area->getId())
|
||||
@@ -136,6 +125,7 @@ class Area extends BaseLoop
|
||||
}
|
||||
|
||||
return $loopResult;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -46,6 +46,9 @@ use Thelia\Type;
|
||||
*/
|
||||
class AssociatedContent extends Content
|
||||
{
|
||||
protected $contentId;
|
||||
protected $contentPosition;
|
||||
|
||||
/**
|
||||
* @return ArgumentCollection
|
||||
*/
|
||||
@@ -68,16 +71,8 @@ class AssociatedContent extends Content
|
||||
return $argumentCollection;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $pagination
|
||||
*
|
||||
* @return LoopResult
|
||||
* @throws \InvalidArgumentException
|
||||
*/
|
||||
public function exec(&$pagination)
|
||||
public function buildModelCriteria()
|
||||
{
|
||||
//
|
||||
|
||||
$product = $this->getProduct();
|
||||
$category = $this->getCategory();
|
||||
|
||||
@@ -136,16 +131,15 @@ class AssociatedContent extends Content
|
||||
|
||||
$associatedContentIdList = array(0);
|
||||
|
||||
$contentIdList = array(0);
|
||||
$contentPosition = $contentId = array();
|
||||
$this->contentPosition = $this->contentId = array();
|
||||
|
||||
foreach ($associatedContents as $associatedContent) {
|
||||
|
||||
$associatedContentId = $associatedContent->getContentId();
|
||||
|
||||
array_push($associatedContentIdList, $associatedContentId);
|
||||
$contentPosition[$associatedContentId] = $associatedContent->getPosition();
|
||||
$contentId[$associatedContentId] = $associatedContent->getId();
|
||||
$this->contentPosition[$associatedContentId] = $associatedContent->getPosition();
|
||||
$this->contentId[$associatedContentId] = $associatedContent->getId();
|
||||
}
|
||||
|
||||
$receivedIdList = $this->getId();
|
||||
@@ -157,18 +151,23 @@ class AssociatedContent extends Content
|
||||
$this->args->get('id')->setValue( implode(',', array_intersect($receivedIdList, $associatedContentIdList)) );
|
||||
}
|
||||
|
||||
$loopResult = parent::exec($pagination);
|
||||
return parent::buildModelCriteria();
|
||||
}
|
||||
|
||||
foreach ($loopResult as $loopResultRow) {
|
||||
public function parseResults(LoopResult $results)
|
||||
{
|
||||
$results = parent::parseResults($results);
|
||||
|
||||
foreach ($results as $loopResultRow) {
|
||||
|
||||
$relatedContentId = $loopResultRow->get('ID');
|
||||
|
||||
$loopResultRow
|
||||
->set("ID" , $contentId[$relatedContentId])
|
||||
->set("POSITION", $contentPosition[$relatedContentId])
|
||||
->set("ID" , $this->contentId[$relatedContentId])
|
||||
->set("POSITION", $this->contentPosition[$relatedContentId])
|
||||
;
|
||||
}
|
||||
|
||||
return $loopResult;
|
||||
return $results;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,6 +28,7 @@ use Thelia\Core\Template\Element\BaseI18nLoop;
|
||||
use Thelia\Core\Template\Element\LoopResult;
|
||||
use Thelia\Core\Template\Element\LoopResultRow;
|
||||
|
||||
use Thelia\Core\Template\Element\PropelSearchLoopInterface;
|
||||
use Thelia\Core\Template\Loop\Argument\ArgumentCollection;
|
||||
use Thelia\Core\Template\Loop\Argument\Argument;
|
||||
|
||||
@@ -47,9 +48,11 @@ use Thelia\Model\Map\AttributeTemplateTableMap;
|
||||
* @package Thelia\Core\Template\Loop
|
||||
* @author Etienne Roudeix <eroudeix@openstudio.fr>
|
||||
*/
|
||||
class Attribute extends BaseI18nLoop
|
||||
class Attribute extends BaseI18nLoop implements PropelSearchLoopInterface
|
||||
{
|
||||
public $timestampable = true;
|
||||
protected $useAttributePosistion;
|
||||
|
||||
protected $timestampable = true;
|
||||
|
||||
/**
|
||||
* @return ArgumentCollection
|
||||
@@ -72,12 +75,7 @@ class Attribute extends BaseI18nLoop
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $pagination
|
||||
*
|
||||
* @return \Thelia\Core\Template\Element\LoopResult
|
||||
*/
|
||||
public function exec(&$pagination)
|
||||
public function buildModelCriteria()
|
||||
{
|
||||
$search = AttributeQuery::create();
|
||||
|
||||
@@ -86,7 +84,7 @@ class Attribute extends BaseI18nLoop
|
||||
$lang = $this->getLang();
|
||||
|
||||
/* manage translations */
|
||||
$locale = $this->configureI18nProcessing($search);
|
||||
$this->configureI18nProcessing($search);
|
||||
|
||||
$id = $this->getId();
|
||||
|
||||
@@ -104,7 +102,7 @@ class Attribute extends BaseI18nLoop
|
||||
$template = $this->getTemplate();
|
||||
$exclude_template = $this->getExcludeTemplate();
|
||||
|
||||
$use_attribute_pos = true;
|
||||
$this->useAttributePosistion = true;
|
||||
|
||||
if (null !== $product) {
|
||||
// Find all template assigned to the products.
|
||||
@@ -132,7 +130,7 @@ class Attribute extends BaseI18nLoop
|
||||
->filterByTemplate(TemplateQuery::create()->findById($template), Criteria::IN)
|
||||
;
|
||||
|
||||
$use_attribute_pos = false;
|
||||
$this->useAttributePosistion = false;
|
||||
} elseif (null !== $exclude_template) {
|
||||
|
||||
// Join with attribute_template table to get position
|
||||
@@ -144,7 +142,7 @@ class Attribute extends BaseI18nLoop
|
||||
->filterById($exclude_attributes, Criteria::NOT_IN)
|
||||
;
|
||||
|
||||
$use_attribute_pos = false;
|
||||
$this->useAttributePosistion = false;
|
||||
}
|
||||
|
||||
$orders = $this->getOrder();
|
||||
@@ -164,13 +162,13 @@ class Attribute extends BaseI18nLoop
|
||||
$search->addDescendingOrderByColumn('i18n_TITLE');
|
||||
break;
|
||||
case "manual":
|
||||
if ($use_attribute_pos)
|
||||
if ($this->useAttributePosistion)
|
||||
$search->orderByPosition(Criteria::ASC);
|
||||
else
|
||||
$search->addAscendingOrderByColumn(AttributeTemplateTableMap::POSITION);
|
||||
break;
|
||||
case "manual_reverse":
|
||||
if ($use_attribute_pos)
|
||||
if ($this->useAttributePosistion)
|
||||
$search->orderByPosition(Criteria::DESC);
|
||||
else
|
||||
$search->addDescendingOrderByColumn(AttributeTemplateTableMap::POSITION);
|
||||
@@ -178,26 +176,28 @@ class Attribute extends BaseI18nLoop
|
||||
}
|
||||
}
|
||||
|
||||
/* perform search */
|
||||
$attributes = $this->search($search, $pagination);
|
||||
return $search;
|
||||
|
||||
$loopResult = new LoopResult($attributes);
|
||||
}
|
||||
|
||||
foreach ($attributes as $attribute) {
|
||||
$loopResultRow = new LoopResultRow($loopResult, $attribute, $this->versionable, $this->timestampable, $this->countable);
|
||||
public function parseResults(LoopResult $loopResult)
|
||||
{
|
||||
foreach ($loopResult->getResultDataCollection() as $attribute) {
|
||||
$loopResultRow = new LoopResultRow($attribute);
|
||||
$loopResultRow->set("ID", $attribute->getId())
|
||||
->set("IS_TRANSLATED",$attribute->getVirtualColumn('IS_TRANSLATED'))
|
||||
->set("LOCALE",$locale)
|
||||
->set("LOCALE",$this->locale)
|
||||
->set("TITLE",$attribute->getVirtualColumn('i18n_TITLE'))
|
||||
->set("CHAPO", $attribute->getVirtualColumn('i18n_CHAPO'))
|
||||
->set("DESCRIPTION", $attribute->getVirtualColumn('i18n_DESCRIPTION'))
|
||||
->set("POSTSCRIPTUM", $attribute->getVirtualColumn('i18n_POSTSCRIPTUM'))
|
||||
->set("POSITION", $use_attribute_pos ? $attribute->getPosition() : $attribute->getVirtualColumn('position'))
|
||||
->set("POSITION", $this->useAttributePosistion ? $attribute->getPosition() : $attribute->getVirtualColumn('position'))
|
||||
;
|
||||
|
||||
$loopResult->addRow($loopResultRow);
|
||||
}
|
||||
|
||||
return $loopResult;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,6 +28,7 @@ use Thelia\Core\Template\Element\BaseI18nLoop;
|
||||
use Thelia\Core\Template\Element\LoopResult;
|
||||
use Thelia\Core\Template\Element\LoopResultRow;
|
||||
|
||||
use Thelia\Core\Template\Element\PropelSearchLoopInterface;
|
||||
use Thelia\Core\Template\Loop\Argument\ArgumentCollection;
|
||||
use Thelia\Core\Template\Loop\Argument\Argument;
|
||||
|
||||
@@ -43,9 +44,9 @@ use Thelia\Type;
|
||||
* @package Thelia\Core\Template\Loop
|
||||
* @author Etienne Roudeix <eroudeix@openstudio.fr>
|
||||
*/
|
||||
class AttributeAvailability extends BaseI18nLoop
|
||||
class AttributeAvailability extends BaseI18nLoop implements PropelSearchLoopInterface
|
||||
{
|
||||
public $timestampable = true;
|
||||
protected $timestampable = true;
|
||||
|
||||
/**
|
||||
* @return ArgumentCollection
|
||||
@@ -66,17 +67,12 @@ class AttributeAvailability extends BaseI18nLoop
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $pagination
|
||||
*
|
||||
* @return \Thelia\Core\Template\Element\LoopResult
|
||||
*/
|
||||
public function exec(&$pagination)
|
||||
public function buildModelCriteria()
|
||||
{
|
||||
$search = AttributeAvQuery::create();
|
||||
|
||||
/* manage translations */
|
||||
$locale = $this->configureI18nProcessing($search);
|
||||
$this->configureI18nProcessing($search);
|
||||
|
||||
$id = $this->getId();
|
||||
|
||||
@@ -121,18 +117,19 @@ class AttributeAvailability extends BaseI18nLoop
|
||||
}
|
||||
}
|
||||
|
||||
/* perform search */
|
||||
$attributesAv = $this->search($search, $pagination);
|
||||
return $search;
|
||||
|
||||
$loopResult = new LoopResult($attributesAv);
|
||||
}
|
||||
|
||||
foreach ($attributesAv as $attributeAv) {
|
||||
$loopResultRow = new LoopResultRow($loopResult, $attributeAv, $this->versionable, $this->timestampable, $this->countable);
|
||||
public function parseResults(LoopResult $loopResult)
|
||||
{
|
||||
foreach ($loopResult->getResultDataCollection() as $attributeAv) {
|
||||
$loopResultRow = new LoopResultRow($attributeAv);
|
||||
$loopResultRow
|
||||
->set("ID" , $attributeAv->getId())
|
||||
->set("ATTRIBUTE_ID" , $attributeAv->getAttributeId())
|
||||
->set("IS_TRANSLATED", $attributeAv->getVirtualColumn('IS_TRANSLATED'))
|
||||
->set("LOCALE" , $locale)
|
||||
->set("LOCALE" , $this->locale)
|
||||
->set("TITLE" , $attributeAv->getVirtualColumn('i18n_TITLE'))
|
||||
->set("CHAPO" , $attributeAv->getVirtualColumn('i18n_CHAPO'))
|
||||
->set("DESCRIPTION" , $attributeAv->getVirtualColumn('i18n_DESCRIPTION'))
|
||||
@@ -144,5 +141,6 @@ class AttributeAvailability extends BaseI18nLoop
|
||||
}
|
||||
|
||||
return $loopResult;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,6 +28,7 @@ use Thelia\Core\Template\Element\BaseI18nLoop;
|
||||
use Thelia\Core\Template\Element\LoopResult;
|
||||
use Thelia\Core\Template\Element\LoopResultRow;
|
||||
|
||||
use Thelia\Core\Template\Element\PropelSearchLoopInterface;
|
||||
use Thelia\Core\Template\Loop\Argument\ArgumentCollection;
|
||||
use Thelia\Core\Template\Loop\Argument\Argument;
|
||||
|
||||
@@ -45,9 +46,9 @@ use Thelia\Type;
|
||||
* @package Thelia\Core\Template\Loop
|
||||
* @author Etienne Roudeix <eroudeix@openstudio.fr>
|
||||
*/
|
||||
class AttributeCombination extends BaseI18nLoop
|
||||
class AttributeCombination extends BaseI18nLoop implements PropelSearchLoopInterface
|
||||
{
|
||||
public $timestampable = true;
|
||||
protected $timestampable = true;
|
||||
|
||||
/**
|
||||
* @return ArgumentCollection
|
||||
@@ -66,17 +67,12 @@ class AttributeCombination extends BaseI18nLoop
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $pagination
|
||||
*
|
||||
* @return \Thelia\Core\Template\Element\LoopResult
|
||||
*/
|
||||
public function exec(&$pagination)
|
||||
public function buildModelCriteria()
|
||||
{
|
||||
$search = AttributeCombinationQuery::create();
|
||||
|
||||
/* manage attribute translations */
|
||||
$locale = $this->configureI18nProcessing(
|
||||
$this->configureI18nProcessing(
|
||||
$search,
|
||||
array('TITLE', 'CHAPO', 'DESCRIPTION', 'POSTSCRIPTUM'),
|
||||
AttributeTableMap::TABLE_NAME,
|
||||
@@ -84,7 +80,7 @@ class AttributeCombination extends BaseI18nLoop
|
||||
);
|
||||
|
||||
/* manage attributeAv translations */
|
||||
$locale = $this->configureI18nProcessing(
|
||||
$this->configureI18nProcessing(
|
||||
$search,
|
||||
array('TITLE', 'CHAPO', 'DESCRIPTION', 'POSTSCRIPTUM'),
|
||||
AttributeAvTableMap::TABLE_NAME,
|
||||
@@ -108,15 +104,17 @@ class AttributeCombination extends BaseI18nLoop
|
||||
}
|
||||
}
|
||||
|
||||
$attributeCombinations = $this->search($search, $pagination);
|
||||
return $search;
|
||||
|
||||
$loopResult = new LoopResult($attributeCombinations);
|
||||
}
|
||||
|
||||
foreach ($attributeCombinations as $attributeCombination) {
|
||||
$loopResultRow = new LoopResultRow($loopResult, $attributeCombination, $this->versionable, $this->timestampable, $this->countable);
|
||||
public function parseResults(LoopResult $loopResult)
|
||||
{
|
||||
foreach ($loopResult->getResultDataCollection() as $attributeCombination) {
|
||||
$loopResultRow = new LoopResultRow($attributeCombination);
|
||||
|
||||
$loopResultRow
|
||||
->set("LOCALE",$locale)
|
||||
->set("LOCALE",$this->locale)
|
||||
->set("ATTRIBUTE_TITLE", $attributeCombination->getVirtualColumn(AttributeTableMap::TABLE_NAME . '_i18n_TITLE'))
|
||||
->set("ATTRIBUTE_CHAPO", $attributeCombination->getVirtualColumn(AttributeTableMap::TABLE_NAME . '_i18n_CHAPO'))
|
||||
->set("ATTRIBUTE_DESCRIPTION", $attributeCombination->getVirtualColumn(AttributeTableMap::TABLE_NAME . '_i18n_DESCRIPTION'))
|
||||
@@ -130,5 +128,6 @@ class AttributeCombination extends BaseI18nLoop
|
||||
}
|
||||
|
||||
return $loopResult;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
namespace Thelia\Core\Template\Loop;
|
||||
|
||||
use Thelia\Core\Security\AccessManager;
|
||||
use Thelia\Core\Template\Element\ArraySearchLoopInterface;
|
||||
use Thelia\Core\Template\Element\BaseLoop;
|
||||
use Thelia\Core\Template\Element\LoopResult;
|
||||
use Thelia\Core\Template\Element\LoopResultRow;
|
||||
@@ -40,7 +41,7 @@ use Thelia\Type\TypeCollection;
|
||||
*
|
||||
* @author Franck Allimant <franck@cqfdev.fr>
|
||||
*/
|
||||
class Auth extends BaseLoop
|
||||
class Auth extends BaseLoop implements ArraySearchLoopInterface
|
||||
{
|
||||
public function getArgDefinitions()
|
||||
{
|
||||
@@ -69,19 +70,17 @@ class Auth extends BaseLoop
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $pagination
|
||||
*
|
||||
* @return LoopResult
|
||||
*/
|
||||
public function exec(&$pagination)
|
||||
public function buildArray()
|
||||
{
|
||||
return array();
|
||||
}
|
||||
|
||||
public function parseResults(LoopResult $loopResult)
|
||||
{
|
||||
$roles = $this->getRole();
|
||||
$resource = $this->getResource();
|
||||
$access = $this->getAccess();
|
||||
|
||||
$loopResult = new LoopResult();
|
||||
|
||||
try {
|
||||
if (true === $this->securityContext->isGranted($roles, $resource === null ? array() : $resource, $access === null ? array() : $access)) {
|
||||
|
||||
|
||||
@@ -24,6 +24,8 @@
|
||||
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\PropelSearchLoopInterface;
|
||||
use Thelia\Core\Template\Loop\Argument\Argument;
|
||||
use Thelia\Core\Template\Loop\Argument\ArgumentCollection;
|
||||
use Thelia\Model\ModuleQuery;
|
||||
@@ -32,9 +34,9 @@ use Thelia\Model\ModuleQuery;
|
||||
* @package Thelia\Core\Template\Loop
|
||||
* @author Manuel Raynaud <mraynaud@openstudio.fr>
|
||||
*/
|
||||
class BaseSpecificModule extends BaseI18nLoop
|
||||
abstract class BaseSpecificModule extends BaseI18nLoop implements PropelSearchLoopInterface
|
||||
{
|
||||
public $timestampable = true;
|
||||
protected $timestampable = true;
|
||||
|
||||
/**
|
||||
*
|
||||
@@ -76,19 +78,7 @@ class BaseSpecificModule extends BaseI18nLoop
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* this function have to be implement in your own loop class.
|
||||
*
|
||||
* All loops parameters can be accesible via getter.
|
||||
*
|
||||
* for example, ref parameter is accessible through getRef method
|
||||
*
|
||||
* @param $pagination
|
||||
*
|
||||
* @return \Thelia\Model\ModuleQuery
|
||||
*/
|
||||
public function exec(&$pagination)
|
||||
public function buildModelCriteria()
|
||||
{
|
||||
$search = ModuleQuery::create();
|
||||
|
||||
@@ -102,7 +92,12 @@ class BaseSpecificModule extends BaseI18nLoop
|
||||
$search->filterById($exclude, Criteria::NOT_IN);
|
||||
}
|
||||
|
||||
$this->configureI18nProcessing($search);
|
||||
|
||||
$search->filterByType($this->getModuleType(), Criteria::EQUAL);
|
||||
|
||||
return $search;
|
||||
}
|
||||
|
||||
abstract protected function getModuleType();
|
||||
}
|
||||
|
||||
@@ -9,15 +9,15 @@
|
||||
|
||||
namespace Thelia\Core\Template\Loop;
|
||||
|
||||
use Thelia\Core\Template\Element\ArraySearchLoopInterface;
|
||||
use Thelia\Core\Template\Element\BaseLoop;
|
||||
use Thelia\Core\Template\Element\LoopResult;
|
||||
use Thelia\Core\Template\Element\LoopResultRow;
|
||||
use Thelia\Core\Template\Loop\Argument\Argument;
|
||||
use Thelia\Core\Template\Loop\Argument\ArgumentCollection;
|
||||
use Thelia\Model\CountryQuery;
|
||||
use Thelia\Type;
|
||||
|
||||
class Cart extends BaseLoop
|
||||
class Cart extends BaseLoop implements ArraySearchLoopInterface
|
||||
{
|
||||
use \Thelia\Cart\CartTrait;
|
||||
/**
|
||||
@@ -41,80 +41,29 @@ class Cart extends BaseLoop
|
||||
*/
|
||||
protected function getArgDefinitions()
|
||||
{
|
||||
return new ArgumentCollection(
|
||||
Argument::createIntTypeArgument('limit'),
|
||||
Argument::createAnyTypeArgument('position')
|
||||
);
|
||||
return new ArgumentCollection();
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* this function have to be implement in your own loop class.
|
||||
*
|
||||
* All your parameters are defined in defineArgs() and can be accessible like a class property.
|
||||
*
|
||||
* example :
|
||||
*
|
||||
* public function defineArgs()
|
||||
* {
|
||||
* return array (
|
||||
* "ref",
|
||||
* "id" => "optional",
|
||||
* "stock" => array(
|
||||
* "optional",
|
||||
* "default" => 10
|
||||
* )
|
||||
* );
|
||||
* }
|
||||
*
|
||||
* you can retrieve ref value using $this->ref
|
||||
*
|
||||
* @param $pagination
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function exec(&$pagination)
|
||||
public function buildArray()
|
||||
{
|
||||
|
||||
$cart = $this->getCart($this->request);
|
||||
|
||||
$cartItems = $cart->getCartItems();
|
||||
$result = new LoopResult($cartItems);
|
||||
|
||||
if ($cart === null) {
|
||||
return $result;
|
||||
if(null === $cart) {
|
||||
return array();
|
||||
}
|
||||
|
||||
$limit = $this->getLimit();
|
||||
|
||||
$countCartItems = count($cartItems);
|
||||
|
||||
if ($limit <= 0 || $limit >= $countCartItems) {
|
||||
$limit = $countCartItems;
|
||||
}
|
||||
|
||||
$position = $this->getPosition();
|
||||
|
||||
if (isset($position)) {
|
||||
if ($position == "first") {
|
||||
$limit = 1;
|
||||
$cartItems = array($cartItems[0]);
|
||||
} elseif ($position == "last") {
|
||||
$limit = 1;
|
||||
$cartItems = array(end($cartItems));
|
||||
}
|
||||
|
||||
// @TODO : if the position is a number
|
||||
}
|
||||
return iterator_to_array($cart->getCartItems());
|
||||
}
|
||||
|
||||
public function parseResults(LoopResult $loopResult)
|
||||
{
|
||||
$taxCountry = CountryQuery::create()->findPk(64); // @TODO : make it magic;
|
||||
|
||||
for ($i=0; $i<$limit; $i ++) {
|
||||
$cartItem = $cartItems[$i];
|
||||
foreach($loopResult->getResultDataCollection() as $cartItem) {
|
||||
$product = $cartItem->getProduct();
|
||||
$productSaleElement = $cartItem->getProductSaleElements();
|
||||
|
||||
$loopResultRow = new LoopResultRow($result, $cartItem, $this->versionable, $this->timestampable, $this->countable);
|
||||
$loopResultRow = new LoopResultRow();
|
||||
|
||||
$loopResultRow->set("ITEM_ID", $cartItem->getId());
|
||||
$loopResultRow->set("TITLE", $product->getTitle());
|
||||
@@ -130,10 +79,11 @@ class Cart extends BaseLoop
|
||||
->set("PROMO_TAXED_PRICE", $cartItem->getTaxedPromoPrice($taxCountry))
|
||||
->set("IS_PROMO", $cartItem->getPromo() === 1 ? 1 : 0);
|
||||
$loopResultRow->set("PRODUCT_SALE_ELEMENTS_ID", $productSaleElement->getId());
|
||||
$result->addRow($loopResultRow);
|
||||
|
||||
$loopResult->addRow($loopResultRow);
|
||||
}
|
||||
|
||||
return $result;
|
||||
return $loopResult;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -28,6 +28,7 @@ use Thelia\Core\Template\Element\BaseI18nLoop;
|
||||
use Thelia\Core\Template\Element\LoopResult;
|
||||
use Thelia\Core\Template\Element\LoopResultRow;
|
||||
|
||||
use Thelia\Core\Template\Element\PropelSearchLoopInterface;
|
||||
use Thelia\Core\Template\Loop\Argument\ArgumentCollection;
|
||||
use Thelia\Core\Template\Loop\Argument\Argument;
|
||||
|
||||
@@ -61,10 +62,10 @@ use Thelia\Model\ProductQuery;
|
||||
* @author Manuel Raynaud <mraynaud@openstudio.fr>
|
||||
* @author Etienne Roudeix <eroudeix@openstudio.fr>
|
||||
*/
|
||||
class Category extends BaseI18nLoop
|
||||
class Category extends BaseI18nLoop implements PropelSearchLoopInterface
|
||||
{
|
||||
public $timestampable = true;
|
||||
public $versionable = true;
|
||||
protected $timestampable = true;
|
||||
protected $versionable = true;
|
||||
|
||||
/**
|
||||
* @return ArgumentCollection
|
||||
@@ -90,17 +91,12 @@ class Category extends BaseI18nLoop
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $pagination
|
||||
*
|
||||
* @return \Thelia\Core\Template\Element\LoopResult
|
||||
*/
|
||||
public function exec(&$pagination)
|
||||
public function buildModelCriteria()
|
||||
{
|
||||
$search = CategoryQuery::create();
|
||||
|
||||
/* manage translations */
|
||||
$locale = $this->configureI18nProcessing($search);
|
||||
$this->configureI18nProcessing($search);
|
||||
|
||||
$id = $this->getId();
|
||||
|
||||
@@ -184,16 +180,16 @@ class Category extends BaseI18nLoop
|
||||
}
|
||||
}
|
||||
|
||||
/* perform search */
|
||||
$categories = $this->search($search, $pagination);
|
||||
|
||||
/* @todo */
|
||||
$notEmpty = $this->getNot_empty();
|
||||
|
||||
$loopResult = new LoopResult($categories);
|
||||
return $search;
|
||||
|
||||
foreach ($categories as $category) {
|
||||
}
|
||||
|
||||
public function parseResults(LoopResult $loopResult)
|
||||
{
|
||||
foreach ($loopResult->getResultDataCollection() as $category) {
|
||||
// Find previous and next category
|
||||
$previous = CategoryQuery::create()
|
||||
->filterByParent($category->getParent())
|
||||
@@ -214,18 +210,18 @@ class Category extends BaseI18nLoop
|
||||
* if ($this->getNotEmpty() && $category->countAllProducts() == 0) continue;
|
||||
*/
|
||||
|
||||
$loopResultRow = new LoopResultRow($loopResult, $category, $this->versionable, $this->timestampable, $this->countable);
|
||||
$loopResultRow = new LoopResultRow($category);
|
||||
|
||||
$loopResultRow
|
||||
->set("ID", $category->getId())
|
||||
->set("IS_TRANSLATED",$category->getVirtualColumn('IS_TRANSLATED'))
|
||||
->set("LOCALE",$locale)
|
||||
->set("LOCALE",$this->locale)
|
||||
->set("TITLE", $category->getVirtualColumn('i18n_TITLE'))
|
||||
->set("CHAPO", $category->getVirtualColumn('i18n_CHAPO'))
|
||||
->set("DESCRIPTION", $category->getVirtualColumn('i18n_DESCRIPTION'))
|
||||
->set("POSTSCRIPTUM", $category->getVirtualColumn('i18n_POSTSCRIPTUM'))
|
||||
->set("PARENT", $category->getParent())
|
||||
->set("URL", $category->getUrl($locale))
|
||||
->set("URL", $category->getUrl($this->locale))
|
||||
->set("PRODUCT_COUNT", $category->countAllProducts())
|
||||
->set("CHILD_COUNT", $category->countChild())
|
||||
->set("VISIBLE", $category->getVisible() ? "1" : "0")
|
||||
@@ -236,11 +232,12 @@ class Category extends BaseI18nLoop
|
||||
|
||||
->set("PREVIOUS", $previous != null ? $previous->getId() : -1)
|
||||
->set("NEXT" , $next != null ? $next->getId() : -1)
|
||||
;
|
||||
;
|
||||
|
||||
$loopResult->addRow($loopResultRow);
|
||||
}
|
||||
|
||||
return $loopResult;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,6 +23,7 @@
|
||||
|
||||
namespace Thelia\Core\Template\Loop;
|
||||
|
||||
use Thelia\Core\Template\Element\ArraySearchLoopInterface;
|
||||
use Thelia\Core\Template\Element\BaseI18nLoop;
|
||||
use Thelia\Core\Template\Element\LoopResult;
|
||||
use Thelia\Core\Template\Element\LoopResultRow;
|
||||
@@ -54,7 +55,7 @@ use Thelia\Type\BooleanOrBothType;
|
||||
* @package Thelia\Core\Template\Loop
|
||||
* @author Franck Allimant <franck@cqfdev.fr>
|
||||
*/
|
||||
class CategoryPath extends BaseI18nLoop
|
||||
class CategoryPath extends BaseI18nLoop implements ArraySearchLoopInterface
|
||||
{
|
||||
/**
|
||||
* @return ArgumentCollection
|
||||
@@ -69,19 +70,14 @@ class CategoryPath extends BaseI18nLoop
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $pagination (ignored)
|
||||
*
|
||||
* @return \Thelia\Core\Template\Element\LoopResult
|
||||
*/
|
||||
public function exec(&$pagination)
|
||||
public function buildArray()
|
||||
{
|
||||
$id = $this->getCategory();
|
||||
$visible = $this->getVisible();
|
||||
|
||||
$search = CategoryQuery::create();
|
||||
|
||||
$locale = $this->configureI18nProcessing($search, array('TITLE'));
|
||||
$this->configureI18nProcessing($search, array('TITLE'));
|
||||
|
||||
$search->filterById($id);
|
||||
if ($visible != BooleanOrBothType::ANY) $search->filterByVisible($visible);
|
||||
@@ -95,16 +91,12 @@ class CategoryPath extends BaseI18nLoop
|
||||
|
||||
if ($category != null) {
|
||||
|
||||
$loopResultRow = new LoopResultRow();
|
||||
|
||||
$loopResultRow
|
||||
->set("TITLE",$category->getVirtualColumn('i18n_TITLE'))
|
||||
->set("URL", $category->getUrl($locale))
|
||||
->set("ID", $category->getId())
|
||||
->set("LOCALE",$locale)
|
||||
;
|
||||
|
||||
$results[] = $loopResultRow;
|
||||
$results[] = array(
|
||||
"ID" => $category->getId(),
|
||||
"TITLE" => $category->getVirtualColumn('i18n_TITLE'),
|
||||
"URL" => $category->getUrl($this->locale),
|
||||
"LOCALE" => $this->locale,
|
||||
);
|
||||
|
||||
$parent = $category->getParent();
|
||||
|
||||
@@ -128,11 +120,18 @@ class CategoryPath extends BaseI18nLoop
|
||||
} while ($category != null && $parent > 0);
|
||||
|
||||
// Reverse list and build the final result
|
||||
$results = array_reverse($results);
|
||||
return array_reverse($results);
|
||||
}
|
||||
|
||||
$loopResult = new LoopResult();
|
||||
|
||||
foreach($results as $result) $loopResult->addRow($result);
|
||||
public function parseResults(LoopResult $loopResult)
|
||||
{
|
||||
foreach($loopResult->getResultDataCollection() as $result) {
|
||||
$loopResultRow = new LoopResultRow($result);
|
||||
foreach($result as $output => $outputValue) {
|
||||
$loopResultRow->set($output, $outputValue);
|
||||
}
|
||||
$loopResult->addRow($loopResultRow);
|
||||
}
|
||||
|
||||
return $loopResult;
|
||||
}
|
||||
|
||||
@@ -23,6 +23,7 @@
|
||||
|
||||
namespace Thelia\Core\Template\Loop;
|
||||
use Propel\Runtime\ActiveQuery\Criteria;
|
||||
use Thelia\Core\Template\Element\ArraySearchLoopInterface;
|
||||
use Thelia\Core\Template\Element\LoopResult;
|
||||
use Thelia\Core\Template\Element\LoopResultRow;
|
||||
|
||||
@@ -45,7 +46,7 @@ use Thelia\Core\Template\Element\BaseI18nLoop;
|
||||
* @package Thelia\Core\Template\Loop
|
||||
* @author Franck Allimant <franck@cqfdev.fr>
|
||||
*/
|
||||
class CategoryTree extends BaseI18nLoop
|
||||
class CategoryTree extends BaseI18nLoop implements ArraySearchLoopInterface
|
||||
{
|
||||
/**
|
||||
* @return ArgumentCollection
|
||||
@@ -59,13 +60,13 @@ class CategoryTree extends BaseI18nLoop
|
||||
}
|
||||
|
||||
// changement de rubrique
|
||||
protected function buildCategoryTree($parent, $visible, $level, $previousLevel, $max_level, $exclude, LoopResult &$loopResult)
|
||||
protected function buildCategoryTree($parent, $visible, $level, $previousLevel, $max_level, $exclude, &$resultsList)
|
||||
{
|
||||
if ($level > $max_level) return;
|
||||
|
||||
$search = CategoryQuery::create();
|
||||
|
||||
$locale = $this->configureI18nProcessing($search, array(
|
||||
$this->configureI18nProcessing($search, array(
|
||||
'TITLE'
|
||||
));
|
||||
|
||||
@@ -81,41 +82,45 @@ class CategoryTree extends BaseI18nLoop
|
||||
|
||||
foreach ($results as $result) {
|
||||
|
||||
$loopResultRow = new LoopResultRow();
|
||||
$resultsList[] = array(
|
||||
"ID" => $result->getId(),
|
||||
"TITLE" => $result->getVirtualColumn('i18n_TITLE'),
|
||||
"PARENT" => $result->getParent(),
|
||||
"URL" => $result->getUrl($this->locale),
|
||||
"VISIBLE" => $result->getVisible() ? "1" : "0",
|
||||
"LEVEL" => $level,
|
||||
'CHILD_COUNT' => $result->countChild(),
|
||||
'PREV_LEVEL' => $previousLevel,
|
||||
);
|
||||
|
||||
$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)
|
||||
->set('CHILD_COUNT', $result->countChild())
|
||||
->set('PREV_LEVEL', $previousLevel)
|
||||
;
|
||||
|
||||
$loopResult->addRow($loopResultRow);
|
||||
|
||||
$this->buildCategoryTree($result->getId(), $visible, 1 + $level, $level, $max_level, $exclude, $loopResult);
|
||||
$this->buildCategoryTree($result->getId(), $visible, 1 + $level, $level, $max_level, $exclude, $resultsList);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $pagination (ignored)
|
||||
*
|
||||
* @return \Thelia\Core\Template\Element\LoopResult
|
||||
*/
|
||||
public function exec(&$pagination)
|
||||
public function parseResults(LoopResult $loopResult)
|
||||
{
|
||||
foreach($loopResult->getResultDataCollection() as $result) {
|
||||
$loopResultRow = new LoopResultRow($result);
|
||||
foreach($result as $output => $outputValue) {
|
||||
$loopResultRow->set($output, $outputValue);
|
||||
}
|
||||
$loopResult->addRow($loopResultRow);
|
||||
}
|
||||
|
||||
return $loopResult;
|
||||
}
|
||||
|
||||
public function buildArray()
|
||||
{
|
||||
$id = $this->getCategory();
|
||||
$depth = $this->getDepth();
|
||||
$visible = $this->getVisible();
|
||||
$exclude = $this->getExclude();
|
||||
|
||||
$loopResult = new LoopResult();
|
||||
$resultsList = array();
|
||||
|
||||
$this->buildCategoryTree($id, $visible, 0, 0, $depth, $exclude, $loopResult);
|
||||
$this->buildCategoryTree($id, $visible, 0, 0, $depth, $exclude, $resultsList);
|
||||
|
||||
return $loopResult;
|
||||
return $resultsList;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,6 +28,7 @@ use Thelia\Core\Template\Element\BaseI18nLoop;
|
||||
use Thelia\Core\Template\Element\LoopResult;
|
||||
use Thelia\Core\Template\Element\LoopResultRow;
|
||||
|
||||
use Thelia\Core\Template\Element\PropelSearchLoopInterface;
|
||||
use Thelia\Core\Template\Loop\Argument\Argument;
|
||||
|
||||
use Thelia\Core\Template\Loop\Argument\ArgumentCollection;
|
||||
@@ -48,9 +49,9 @@ use Thelia\Type\EnumListType;
|
||||
* @package Thelia\Core\Template\Loop
|
||||
* @author Franck Allimant <franck@cqfdev.fr>
|
||||
*/
|
||||
class Config extends BaseI18nLoop
|
||||
class Config extends BaseI18nLoop implements PropelSearchLoopInterface
|
||||
{
|
||||
public $timestampable = true;
|
||||
protected $timestampable = true;
|
||||
|
||||
/**
|
||||
* @return ArgumentCollection
|
||||
@@ -80,20 +81,16 @@ class Config extends BaseI18nLoop
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $pagination (ignored)
|
||||
*
|
||||
* @return \Thelia\Core\Template\Element\LoopResult
|
||||
*/
|
||||
public function exec(&$pagination)
|
||||
public function buildModelCriteria()
|
||||
{
|
||||
$id = $this->getId();
|
||||
$name = $this->getVariable();
|
||||
$secured = $this->getSecured();
|
||||
$exclude = $this->getExclude();
|
||||
|
||||
$search = ConfigQuery::create();
|
||||
|
||||
$locale = $this->configureI18nProcessing($search);
|
||||
$this->configureI18nProcessing($search);
|
||||
|
||||
if (! is_null($id))
|
||||
$search->filterById($id);
|
||||
@@ -145,20 +142,21 @@ class Config extends BaseI18nLoop
|
||||
}
|
||||
}
|
||||
|
||||
$results = $this->search($search, $pagination);
|
||||
return $search;
|
||||
|
||||
$loopResult = new LoopResult($results);
|
||||
}
|
||||
|
||||
foreach ($results as $result) {
|
||||
|
||||
$loopResultRow = new LoopResultRow($loopResult, $result, $this->versionable, $this->timestampable, $this->countable);
|
||||
public function parseResults(LoopResult $loopResult)
|
||||
{
|
||||
foreach ($loopResult->getResultDataCollection() as $result) {
|
||||
$loopResultRow = new LoopResultRow($result);
|
||||
|
||||
$loopResultRow
|
||||
->set("ID" , $result->getId())
|
||||
->set("NAME" , $result->getName())
|
||||
->set("VALUE" , $result->getValue())
|
||||
->set("IS_TRANSLATED", $result->getVirtualColumn('IS_TRANSLATED'))
|
||||
->set("LOCALE" , $locale)
|
||||
->set("LOCALE" , $this->locale)
|
||||
->set("TITLE" , $result->getVirtualColumn('i18n_TITLE'))
|
||||
->set("CHAPO" , $result->getVirtualColumn('i18n_CHAPO'))
|
||||
->set("DESCRIPTION" , $result->getVirtualColumn('i18n_DESCRIPTION'))
|
||||
@@ -171,5 +169,6 @@ class Config extends BaseI18nLoop
|
||||
}
|
||||
|
||||
return $loopResult;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,6 +28,7 @@ use Thelia\Core\Template\Element\BaseI18nLoop;
|
||||
use Thelia\Core\Template\Element\LoopResult;
|
||||
use Thelia\Core\Template\Element\LoopResultRow;
|
||||
|
||||
use Thelia\Core\Template\Element\PropelSearchLoopInterface;
|
||||
use Thelia\Core\Template\Loop\Argument\ArgumentCollection;
|
||||
use Thelia\Core\Template\Loop\Argument\Argument;
|
||||
|
||||
@@ -47,10 +48,10 @@ use Thelia\Type\BooleanOrBothType;
|
||||
* @package Thelia\Core\Template\Loop
|
||||
* @author Etienne Roudeix <eroudeix@openstudio.fr>
|
||||
*/
|
||||
class Content extends BaseI18nLoop
|
||||
class Content extends BaseI18nLoop implements PropelSearchLoopInterface
|
||||
{
|
||||
public $timestampable = true;
|
||||
public $versionable = true;
|
||||
protected $timestampable = true;
|
||||
protected $versionable = true;
|
||||
|
||||
/**
|
||||
* @return ArgumentCollection
|
||||
@@ -77,19 +78,13 @@ class Content extends BaseI18nLoop
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $pagination
|
||||
*
|
||||
* @return LoopResult
|
||||
* @throws \InvalidArgumentException
|
||||
*/
|
||||
public function exec(&$pagination)
|
||||
public function buildModelCriteria()
|
||||
{
|
||||
|
||||
$search = ContentQuery::create();
|
||||
|
||||
/* manage translations */
|
||||
$locale = $this->configureI18nProcessing($search);
|
||||
$this->configureI18nProcessing($search);
|
||||
|
||||
$id = $this->getId();
|
||||
|
||||
@@ -205,26 +200,25 @@ class Content extends BaseI18nLoop
|
||||
);
|
||||
}
|
||||
|
||||
/* perform search */
|
||||
$search->groupBy(ContentTableMap::ID);
|
||||
return $search;
|
||||
|
||||
$contents = $this->search($search, $pagination);
|
||||
}
|
||||
|
||||
$loopResult = new LoopResult($contents);
|
||||
|
||||
foreach ($contents as $content) {
|
||||
$loopResultRow = new LoopResultRow($loopResult, $content, $this->versionable, $this->timestampable, $this->countable);
|
||||
public function parseResults(LoopResult $loopResult)
|
||||
{
|
||||
foreach ($loopResult->getResultDataCollection() as $content) {
|
||||
$loopResultRow = new LoopResultRow($content);
|
||||
|
||||
$loopResultRow->set("ID", $content->getId())
|
||||
->set("IS_TRANSLATED",$content->getVirtualColumn('IS_TRANSLATED'))
|
||||
->set("LOCALE",$locale)
|
||||
->set("LOCALE",$this->locale)
|
||||
->set("TITLE",$content->getVirtualColumn('i18n_TITLE'))
|
||||
->set("CHAPO", $content->getVirtualColumn('i18n_CHAPO'))
|
||||
->set("DESCRIPTION", $content->getVirtualColumn('i18n_DESCRIPTION'))
|
||||
->set("POSTSCRIPTUM", $content->getVirtualColumn('i18n_POSTSCRIPTUM'))
|
||||
->set("POSITION", $content->getPosition())
|
||||
->set("DEFAULT_FOLDER", $content->getDefaultFolderId())
|
||||
->set("URL", $content->getUrl($locale))
|
||||
->set("URL", $content->getUrl($this->locale))
|
||||
->set("VISIBLE", $content->getVisible())
|
||||
;
|
||||
|
||||
@@ -232,6 +226,7 @@ class Content extends BaseI18nLoop
|
||||
}
|
||||
|
||||
return $loopResult;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -28,6 +28,7 @@ use Thelia\Core\Template\Element\BaseI18nLoop;
|
||||
use Thelia\Core\Template\Element\LoopResult;
|
||||
use Thelia\Core\Template\Element\LoopResultRow;
|
||||
|
||||
use Thelia\Core\Template\Element\PropelSearchLoopInterface;
|
||||
use Thelia\Core\Template\Loop\Argument\ArgumentCollection;
|
||||
use Thelia\Core\Template\Loop\Argument\Argument;
|
||||
|
||||
@@ -42,9 +43,9 @@ use Thelia\Model\CountryQuery;
|
||||
* @package Thelia\Core\Template\Loop
|
||||
* @author Etienne Roudeix <eroudeix@openstudio.fr>
|
||||
*/
|
||||
class Country extends BaseI18nLoop
|
||||
class Country extends BaseI18nLoop implements PropelSearchLoopInterface
|
||||
{
|
||||
public $timestampable = true;
|
||||
protected $timestampable = true;
|
||||
|
||||
/**
|
||||
* @return ArgumentCollection
|
||||
@@ -59,17 +60,12 @@ class Country extends BaseI18nLoop
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $pagination
|
||||
*
|
||||
* @return \Thelia\Core\Template\Element\LoopResult
|
||||
*/
|
||||
public function exec(&$pagination)
|
||||
public function buildModelCriteria()
|
||||
{
|
||||
$search = CountryQuery::create();
|
||||
|
||||
/* manage translations */
|
||||
$locale = $this->configureI18nProcessing($search);
|
||||
$this->configureI18nProcessing($search);
|
||||
|
||||
$id = $this->getId();
|
||||
|
||||
@@ -99,16 +95,17 @@ class Country extends BaseI18nLoop
|
||||
|
||||
$search->addAscendingOrderByColumn('i18n_TITLE');
|
||||
|
||||
/* perform search */
|
||||
$countries = $this->search($search, $pagination);
|
||||
return $search;
|
||||
|
||||
$loopResult = new LoopResult($countries);
|
||||
}
|
||||
|
||||
foreach ($countries as $country) {
|
||||
$loopResultRow = new LoopResultRow($loopResult, $country, $this->versionable, $this->timestampable, $this->countable);
|
||||
public function parseResults(LoopResult $loopResult)
|
||||
{
|
||||
foreach ($loopResult->getResultDataCollection() as $country) {
|
||||
$loopResultRow = new LoopResultRow($country);
|
||||
$loopResultRow->set("ID", $country->getId())
|
||||
->set("IS_TRANSLATED",$country->getVirtualColumn('IS_TRANSLATED'))
|
||||
->set("LOCALE",$locale)
|
||||
->set("LOCALE",$this->locale)
|
||||
->set("TITLE",$country->getVirtualColumn('i18n_TITLE'))
|
||||
->set("CHAPO", $country->getVirtualColumn('i18n_CHAPO'))
|
||||
->set("DESCRIPTION", $country->getVirtualColumn('i18n_DESCRIPTION'))
|
||||
@@ -118,11 +115,12 @@ class Country extends BaseI18nLoop
|
||||
->set("ISOALPHA3", $country->getIsoalpha3())
|
||||
->set("IS_DEFAULT", $country->getByDefault() ? "1" : "0")
|
||||
->set("IS_SHOP_COUNTRY", $country->getShopCountry() ? "1" : "0")
|
||||
;
|
||||
;
|
||||
|
||||
$loopResult->addRow($loopResultRow);
|
||||
}
|
||||
|
||||
return $loopResult;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,6 +31,7 @@ use Thelia\Core\HttpFoundation\Request;
|
||||
use Thelia\Core\Template\Element\BaseI18nLoop;
|
||||
use Thelia\Core\Template\Element\LoopResult;
|
||||
use Thelia\Core\Template\Element\LoopResultRow;
|
||||
use Thelia\Core\Template\Element\PropelSearchLoopInterface;
|
||||
use Thelia\Core\Template\Loop\Argument\Argument;
|
||||
use Thelia\Core\Template\Loop\Argument\ArgumentCollection;
|
||||
use Thelia\Coupon\Type\CouponInterface;
|
||||
@@ -49,7 +50,7 @@ use Thelia\Type;
|
||||
* @author Guillaume MOREL <gmorel@openstudio.fr>
|
||||
*
|
||||
*/
|
||||
class Coupon extends BaseI18nLoop
|
||||
class Coupon extends BaseI18nLoop implements PropelSearchLoopInterface
|
||||
{
|
||||
/**
|
||||
* Define all args used in your loop
|
||||
@@ -64,19 +65,12 @@ class Coupon extends BaseI18nLoop
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute Loop
|
||||
*
|
||||
* @param PropelModelPager $pagination Pagination manager
|
||||
*
|
||||
* @return \Thelia\Core\Template\Element\LoopResult
|
||||
*/
|
||||
public function exec(&$pagination)
|
||||
public function buildModelCriteria()
|
||||
{
|
||||
$search = CouponQuery::create();
|
||||
|
||||
/* manage translations */
|
||||
$locale = $this->configureI18nProcessing($search, array('TITLE', 'DESCRIPTION', 'SHORT_DESCRIPTION'));
|
||||
$this->configureI18nProcessing($search, array('TITLE', 'DESCRIPTION', 'SHORT_DESCRIPTION'));
|
||||
|
||||
$id = $this->getId();
|
||||
$isEnabled = $this->getIsEnabled();
|
||||
@@ -89,10 +83,11 @@ class Coupon extends BaseI18nLoop
|
||||
$search->filterByIsEnabled($isEnabled ? true : false);
|
||||
}
|
||||
|
||||
// Perform search
|
||||
$coupons = $this->search($search, $pagination);
|
||||
return $search;
|
||||
}
|
||||
|
||||
$loopResult = new LoopResult();
|
||||
public function parseResults(LoopResult $loopResult)
|
||||
{
|
||||
/** @var ConditionFactory $conditionFactory */
|
||||
$conditionFactory = $this->container->get('thelia.condition.factory');
|
||||
|
||||
@@ -102,8 +97,8 @@ class Coupon extends BaseI18nLoop
|
||||
$lang = $request->getSession()->getLang();
|
||||
|
||||
/** @var MCoupon $coupon */
|
||||
foreach ($coupons as $coupon) {
|
||||
$loopResultRow = new LoopResultRow();
|
||||
foreach ($loopResult->getResultDataCollection() as $coupon) {
|
||||
$loopResultRow = new LoopResultRow($coupon);
|
||||
$conditions = $conditionFactory->unserializeConditionCollection(
|
||||
$coupon->getSerializedConditions()
|
||||
);
|
||||
@@ -136,7 +131,7 @@ class Coupon extends BaseI18nLoop
|
||||
}
|
||||
$loopResultRow->set("ID", $coupon->getId())
|
||||
->set("IS_TRANSLATED", $coupon->getVirtualColumn('IS_TRANSLATED'))
|
||||
->set("LOCALE", $locale)
|
||||
->set("LOCALE", $this->locale)
|
||||
->set("CODE", $coupon->getCode())
|
||||
->set("TITLE", $coupon->getVirtualColumn('i18n_TITLE'))
|
||||
->set("SHORT_DESCRIPTION", $coupon->getVirtualColumn('i18n_SHORT_DESCRIPTION'))
|
||||
|
||||
@@ -28,6 +28,7 @@ use Thelia\Core\Template\Element\BaseI18nLoop;
|
||||
use Thelia\Core\Template\Element\LoopResult;
|
||||
use Thelia\Core\Template\Element\LoopResultRow;
|
||||
|
||||
use Thelia\Core\Template\Element\PropelSearchLoopInterface;
|
||||
use Thelia\Core\Template\Loop\Argument\ArgumentCollection;
|
||||
use Thelia\Core\Template\Loop\Argument\Argument;
|
||||
|
||||
@@ -44,9 +45,9 @@ use Thelia\Type\EnumListType;
|
||||
* @package Thelia\Core\Template\Loop
|
||||
* @author Etienne Roudeix <eroudeix@openstudio.fr>
|
||||
*/
|
||||
class Currency extends BaseI18nLoop
|
||||
class Currency extends BaseI18nLoop implements PropelSearchLoopInterface
|
||||
{
|
||||
public $timestampable = true;
|
||||
protected $timestampable = true;
|
||||
|
||||
/**
|
||||
* @return ArgumentCollection
|
||||
@@ -76,17 +77,12 @@ class Currency extends BaseI18nLoop
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $pagination
|
||||
*
|
||||
* @return \Thelia\Core\Template\Element\LoopResult
|
||||
*/
|
||||
public function exec(&$pagination)
|
||||
public function buildModelCriteria()
|
||||
{
|
||||
$search = CurrencyQuery::create();
|
||||
|
||||
/* manage translations */
|
||||
$locale = $this->configureI18nProcessing($search, array('NAME'));
|
||||
$this->configureI18nProcessing($search, array('NAME'));
|
||||
|
||||
$id = $this->getId();
|
||||
|
||||
@@ -162,17 +158,18 @@ class Currency extends BaseI18nLoop
|
||||
}
|
||||
|
||||
/* perform search */
|
||||
$currencies = $this->search($search, $pagination);
|
||||
return $search;
|
||||
|
||||
$loopResult = new LoopResult($currencies);
|
||||
}
|
||||
|
||||
foreach ($currencies as $currency) {
|
||||
|
||||
$loopResultRow = new LoopResultRow($loopResult, $currency, $this->versionable, $this->timestampable, $this->countable);
|
||||
public function parseResults(LoopResult $loopResult)
|
||||
{
|
||||
foreach ($loopResult->getResultDataCollection() as $currency) {
|
||||
$loopResultRow = new LoopResultRow($currency);
|
||||
$loopResultRow
|
||||
->set("ID" , $currency->getId())
|
||||
->set("IS_TRANSLATED" , $currency->getVirtualColumn('IS_TRANSLATED'))
|
||||
->set("LOCALE" , $locale)
|
||||
->set("LOCALE" , $this->locale)
|
||||
->set("NAME" , $currency->getVirtualColumn('i18n_NAME'))
|
||||
->set("ISOCODE" , $currency->getCode())
|
||||
->set("SYMBOL" , $currency->getSymbol())
|
||||
@@ -185,5 +182,6 @@ class Currency extends BaseI18nLoop
|
||||
}
|
||||
|
||||
return $loopResult;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,6 +28,7 @@ use Thelia\Core\Template\Element\BaseLoop;
|
||||
use Thelia\Core\Template\Element\LoopResult;
|
||||
use Thelia\Core\Template\Element\LoopResultRow;
|
||||
|
||||
use Thelia\Core\Template\Element\PropelSearchLoopInterface;
|
||||
use Thelia\Core\Template\Element\SearchLoopInterface;
|
||||
use Thelia\Core\Template\Loop\Argument\ArgumentCollection;
|
||||
use Thelia\Core\Template\Loop\Argument\Argument;
|
||||
@@ -45,9 +46,9 @@ use Thelia\Type;
|
||||
* @package Thelia\Core\Template\Loop
|
||||
* @author Etienne Roudeix <eroudeix@openstudio.fr>
|
||||
*/
|
||||
class Customer extends BaseLoop implements SearchLoopInterface
|
||||
class Customer extends BaseLoop implements SearchLoopInterface, PropelSearchLoopInterface
|
||||
{
|
||||
public $timestampable = true;
|
||||
protected $timestampable = true;
|
||||
|
||||
/**
|
||||
* @return ArgumentCollection
|
||||
@@ -109,12 +110,7 @@ class Customer extends BaseLoop implements SearchLoopInterface
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $pagination
|
||||
*
|
||||
* @return \Thelia\Core\Template\Element\LoopResult
|
||||
*/
|
||||
public function exec(&$pagination)
|
||||
public function buildModelCriteria()
|
||||
{
|
||||
$search = CustomerQuery::create();
|
||||
|
||||
@@ -123,7 +119,7 @@ class Customer extends BaseLoop implements SearchLoopInterface
|
||||
if ($current === true) {
|
||||
$currentCustomer = $this->securityContext->getCustomerUser();
|
||||
if ($currentCustomer === null) {
|
||||
return new LoopResult();
|
||||
return null;
|
||||
} else {
|
||||
$search->filterById($currentCustomer->getId(), Criteria::EQUAL);
|
||||
}
|
||||
@@ -155,12 +151,14 @@ class Customer extends BaseLoop implements SearchLoopInterface
|
||||
$search->filterBySponsor($sponsor, Criteria::EQUAL);
|
||||
}
|
||||
|
||||
$customers = $this->search($search, $pagination);
|
||||
return $search;
|
||||
|
||||
$loopResult = new LoopResult($customers);
|
||||
}
|
||||
|
||||
foreach ($customers as $customer) {
|
||||
$loopResultRow = new LoopResultRow($loopResult, $customer, $this->versionable, $this->timestampable, $this->countable);
|
||||
public function parseResults(LoopResult $loopResult)
|
||||
{
|
||||
foreach ($loopResult->getResultDataCollection() as $customer) {
|
||||
$loopResultRow = new LoopResultRow($customer);
|
||||
$loopResultRow->set("ID", $customer->getId());
|
||||
$loopResultRow->set("REF", $customer->getRef());
|
||||
$loopResultRow->set("TITLE", $customer->getTitleId());
|
||||
@@ -175,5 +173,6 @@ class Customer extends BaseLoop implements SearchLoopInterface
|
||||
}
|
||||
|
||||
return $loopResult;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,7 +22,6 @@
|
||||
/*************************************************************************************/
|
||||
|
||||
namespace Thelia\Core\Template\Loop;
|
||||
use Propel\Runtime\ActiveQuery\Criteria;
|
||||
use Thelia\Core\Template\Element\LoopResult;
|
||||
use Thelia\Core\Template\Element\LoopResultRow;
|
||||
use Thelia\Core\Template\Loop\Argument\Argument;
|
||||
@@ -33,6 +32,7 @@ use Thelia\Module\BaseModule;
|
||||
* Class Delivery
|
||||
* @package Thelia\Core\Template\Loop
|
||||
* @author Manuel Raynaud <mraynaud@openstudio.fr>
|
||||
* @author Etienne Roudeix <eroudeix@gmail.com>
|
||||
*/
|
||||
class Delivery extends BaseSpecificModule
|
||||
{
|
||||
@@ -48,14 +48,8 @@ class Delivery extends BaseSpecificModule
|
||||
return $collection;
|
||||
}
|
||||
|
||||
public function exec(&$pagination)
|
||||
public function parseResults(LoopResult $loopResult)
|
||||
{
|
||||
$search = parent::exec($pagination);
|
||||
/* manage translations */
|
||||
$locale = $this->configureI18nProcessing($search);
|
||||
|
||||
$search->filterByType(BaseModule::DELIVERY_MODULE_TYPE, Criteria::EQUAL);
|
||||
|
||||
$countryId = $this->getCountry();
|
||||
if (null !== $countryId) {
|
||||
$country = CountryQuery::create()->findPk($countryId);
|
||||
@@ -66,13 +60,8 @@ class Delivery extends BaseSpecificModule
|
||||
$country = CountryQuery::create()->findOneByByDefault(1);
|
||||
}
|
||||
|
||||
/* perform search */
|
||||
$deliveryModules = $this->search($search, $pagination);
|
||||
|
||||
$loopResult = new LoopResult($deliveryModules);
|
||||
|
||||
foreach ($deliveryModules as $deliveryModule) {
|
||||
$loopResultRow = new LoopResultRow($loopResult, $deliveryModule, $this->versionable, $this->timestampable, $this->countable);
|
||||
foreach ($loopResult->getResultDataCollection() as $deliveryModule) {
|
||||
$loopResultRow = new LoopResultRow($deliveryModule);
|
||||
|
||||
$moduleReflection = new \ReflectionClass($deliveryModule->getFullNamespace());
|
||||
if ($moduleReflection->isSubclassOf("Thelia\Module\DeliveryModuleInterface") === false) {
|
||||
@@ -97,4 +86,9 @@ class Delivery extends BaseSpecificModule
|
||||
|
||||
return $loopResult;
|
||||
}
|
||||
|
||||
protected function getModuleType()
|
||||
{
|
||||
return BaseModule::DELIVERY_MODULE_TYPE;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,6 +23,7 @@
|
||||
|
||||
namespace Thelia\Core\Template\Loop;
|
||||
use Thelia\Core\Template\Element\BaseI18nLoop;
|
||||
use Thelia\Core\Template\Element\PropelSearchLoopInterface;
|
||||
use Thelia\Core\Template\Loop\Argument\Argument;
|
||||
use Thelia\Core\Event\Document\DocumentEvent;
|
||||
use Thelia\Core\Event\TheliaEvents;
|
||||
@@ -41,9 +42,12 @@ use Thelia\Log\Tlog;
|
||||
*
|
||||
* @author Franck Allimant <franck@cqfdev.fr>
|
||||
*/
|
||||
class Document extends BaseI18nLoop
|
||||
class Document extends BaseI18nLoop implements PropelSearchLoopInterface
|
||||
{
|
||||
public $timestampable = true;
|
||||
protected $objectType;
|
||||
protected $objectId;
|
||||
|
||||
protected $timestampable = true;
|
||||
|
||||
/**
|
||||
* @var array Possible document sources
|
||||
@@ -195,18 +199,15 @@ class Document extends BaseI18nLoop
|
||||
return $search;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param unknown $pagination
|
||||
*/
|
||||
public function exec(&$pagination)
|
||||
public function buildModelCriteria()
|
||||
{
|
||||
// Select the proper query to use, and get the object type
|
||||
$object_type = $object_id = null;
|
||||
$this->objectType = $this->objectId = null;
|
||||
|
||||
$search = $this->getSearchQuery($object_type, $object_id);
|
||||
$search = $this->getSearchQuery($this->objectType, $this->objectId);
|
||||
|
||||
/* manage translations */
|
||||
$locale = $this->configureI18nProcessing($search);
|
||||
$this->configureI18nProcessing($search);
|
||||
|
||||
$id = $this->getId();
|
||||
|
||||
@@ -221,14 +222,13 @@ class Document extends BaseI18nLoop
|
||||
// Create document processing event
|
||||
$event = new DocumentEvent($this->request);
|
||||
|
||||
// echo "sql=".$search->toString();
|
||||
return $search;
|
||||
|
||||
$results = $this->search($search, $pagination);
|
||||
|
||||
$loopResult = new LoopResult($results);
|
||||
|
||||
foreach ($results as $result) {
|
||||
}
|
||||
|
||||
public function parseResults(LoopResult $loopResult)
|
||||
{
|
||||
foreach ($loopResult->getResultDataCollection() as $result) {
|
||||
// Create document processing event
|
||||
$event = new DocumentEvent($this->request);
|
||||
|
||||
@@ -236,22 +236,22 @@ class Document extends BaseI18nLoop
|
||||
$source_filepath = sprintf("%s%s/%s/%s",
|
||||
THELIA_ROOT,
|
||||
ConfigQuery::read('documents_library_path', 'local/media/documents'),
|
||||
$object_type,
|
||||
$this->objectType,
|
||||
$result->getFile()
|
||||
);
|
||||
);
|
||||
|
||||
$event->setSourceFilepath($source_filepath);
|
||||
$event->setCacheSubdirectory($object_type);
|
||||
$event->setCacheSubdirectory($this->objectType);
|
||||
|
||||
try {
|
||||
// Dispatch document processing event
|
||||
$this->dispatcher->dispatch(TheliaEvents::DOCUMENT_PROCESS, $event);
|
||||
|
||||
$loopResultRow = new LoopResultRow($loopResult, $result, $this->versionable, $this->timestampable, $this->countable);
|
||||
$loopResultRow = new LoopResultRow($result);
|
||||
|
||||
$loopResultRow
|
||||
->set("ID" , $result->getId())
|
||||
->set("LOCALE" , $locale)
|
||||
->set("LOCALE" , $this->locale)
|
||||
->set("DOCUMENT_URL" , $event->getFileUrl())
|
||||
->set("DOCUMENT_PATH" , $event->getDocumentPath())
|
||||
->set("ORIGINAL_DOCUMENT_PATH", $source_filepath)
|
||||
@@ -260,8 +260,8 @@ class Document extends BaseI18nLoop
|
||||
->set("DESCRIPTION" , $result->getVirtualColumn('i18n_DESCRIPTION'))
|
||||
->set("POSTSCRIPTUM" , $result->getVirtualColumn('i18n_POSTSCRIPTUM'))
|
||||
->set("POSITION" , $result->getPosition())
|
||||
->set("OBJECT_TYPE" , $object_type)
|
||||
->set("OBJECT_ID" , $object_id)
|
||||
->set("OBJECT_TYPE" , $this->objectType)
|
||||
->set("OBJECT_ID" , $this->objectId)
|
||||
;
|
||||
|
||||
$loopResult->addRow($loopResultRow);
|
||||
@@ -272,5 +272,6 @@ class Document extends BaseI18nLoop
|
||||
}
|
||||
|
||||
return $loopResult;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,6 +28,7 @@ use Thelia\Core\Template\Element\BaseI18nLoop;
|
||||
use Thelia\Core\Template\Element\LoopResult;
|
||||
use Thelia\Core\Template\Element\LoopResultRow;
|
||||
|
||||
use Thelia\Core\Template\Element\PropelSearchLoopInterface;
|
||||
use Thelia\Core\Template\Loop\Argument\ArgumentCollection;
|
||||
use Thelia\Core\Template\Loop\Argument\Argument;
|
||||
|
||||
@@ -50,9 +51,11 @@ use Thelia\Model\Map\FeatureTemplateTableMap;
|
||||
* @package Thelia\Core\Template\Loop
|
||||
* @author Etienne Roudeix <eroudeix@openstudio.fr>
|
||||
*/
|
||||
class Feature extends BaseI18nLoop
|
||||
class Feature extends BaseI18nLoop implements PropelSearchLoopInterface
|
||||
{
|
||||
public $timestampable = true;
|
||||
protected $useFeaturePosition;
|
||||
|
||||
protected $timestampable = true;
|
||||
|
||||
/**
|
||||
* @return ArgumentCollection
|
||||
@@ -77,17 +80,12 @@ class Feature extends BaseI18nLoop
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $pagination
|
||||
*
|
||||
* @return \Thelia\Core\Template\Element\LoopResult
|
||||
*/
|
||||
public function exec(&$pagination)
|
||||
public function buildModelCriteria()
|
||||
{
|
||||
$search = FeatureQuery::create();
|
||||
|
||||
/* manage translations */
|
||||
$locale = $this->configureI18nProcessing($search);
|
||||
$this->configureI18nProcessing($search);
|
||||
|
||||
$id = $this->getId();
|
||||
|
||||
@@ -109,7 +107,7 @@ class Feature extends BaseI18nLoop
|
||||
$template = $this->getTemplate();
|
||||
$exclude_template = $this->getExcludeTemplate();
|
||||
|
||||
$use_feature_pos = true;
|
||||
$this->useFeaturePosition = true;
|
||||
|
||||
if (null !== $product) {
|
||||
// Find all template assigned to the products.
|
||||
@@ -137,7 +135,7 @@ class Feature extends BaseI18nLoop
|
||||
->filterByTemplate(TemplateQuery::create()->findById($template), Criteria::IN)
|
||||
;
|
||||
|
||||
$use_feature_pos = false;
|
||||
$this->useFeaturePosition = false;
|
||||
}
|
||||
|
||||
if (null !== $exclude_template) {
|
||||
@@ -149,7 +147,7 @@ class Feature extends BaseI18nLoop
|
||||
->filterById($exclude_features, Criteria::NOT_IN)
|
||||
;
|
||||
|
||||
$use_feature_pos = false;
|
||||
$this->useFeaturePosition = false;
|
||||
}
|
||||
|
||||
$title = $this->getTitle();
|
||||
@@ -186,13 +184,13 @@ class Feature extends BaseI18nLoop
|
||||
$search->addDescendingOrderByColumn('i18n_TITLE');
|
||||
break;
|
||||
case "manual":
|
||||
if ($use_feature_pos)
|
||||
if ($this->useFeaturePosition)
|
||||
$search->orderByPosition(Criteria::ASC);
|
||||
else
|
||||
$search->addAscendingOrderByColumn(FeatureTemplateTableMap::POSITION);
|
||||
break;
|
||||
case "manual_reverse":
|
||||
if ($use_feature_pos)
|
||||
if ($this->useFeaturePosition)
|
||||
$search->orderByPosition(Criteria::DESC);
|
||||
else
|
||||
$search->addDescendingOrderByColumn(FeatureTemplateTableMap::POSITION);
|
||||
@@ -201,26 +199,28 @@ class Feature extends BaseI18nLoop
|
||||
|
||||
}
|
||||
|
||||
/* perform search */
|
||||
$features = $this->search($search, $pagination);
|
||||
return $search;
|
||||
|
||||
$loopResult = new LoopResult($features);
|
||||
}
|
||||
|
||||
foreach ($features as $feature) {
|
||||
$loopResultRow = new LoopResultRow($loopResult, $feature, $this->versionable, $this->timestampable, $this->countable);
|
||||
public function parseResults(LoopResult $loopResult)
|
||||
{
|
||||
foreach ($loopResult->getResultDataCollection() as $feature) {
|
||||
$loopResultRow = new LoopResultRow($feature);
|
||||
$loopResultRow->set("ID", $feature->getId())
|
||||
->set("IS_TRANSLATED",$feature->getVirtualColumn('IS_TRANSLATED'))
|
||||
->set("LOCALE",$locale)
|
||||
->set("LOCALE",$this->locale)
|
||||
->set("TITLE",$feature->getVirtualColumn('i18n_TITLE'))
|
||||
->set("CHAPO", $feature->getVirtualColumn('i18n_CHAPO'))
|
||||
->set("DESCRIPTION", $feature->getVirtualColumn('i18n_DESCRIPTION'))
|
||||
->set("POSTSCRIPTUM", $feature->getVirtualColumn('i18n_POSTSCRIPTUM'))
|
||||
->set("POSITION", $use_feature_pos ? $feature->getPosition() : $feature->getVirtualColumn('position'))
|
||||
->set("POSITION", $this->useFeaturePosition ? $feature->getPosition() : $feature->getVirtualColumn('position'))
|
||||
;
|
||||
|
||||
$loopResult->addRow($loopResultRow);
|
||||
}
|
||||
|
||||
return $loopResult;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,6 +28,7 @@ use Thelia\Core\Template\Element\BaseI18nLoop;
|
||||
use Thelia\Core\Template\Element\LoopResult;
|
||||
use Thelia\Core\Template\Element\LoopResultRow;
|
||||
|
||||
use Thelia\Core\Template\Element\PropelSearchLoopInterface;
|
||||
use Thelia\Core\Template\Loop\Argument\ArgumentCollection;
|
||||
use Thelia\Core\Template\Loop\Argument\Argument;
|
||||
|
||||
@@ -43,9 +44,9 @@ use Thelia\Type;
|
||||
* @package Thelia\Core\Template\Loop
|
||||
* @author Etienne Roudeix <eroudeix@openstudio.fr>
|
||||
*/
|
||||
class FeatureAvailability extends BaseI18nLoop
|
||||
class FeatureAvailability extends BaseI18nLoop implements PropelSearchLoopInterface
|
||||
{
|
||||
public $timestampable = true;
|
||||
protected $timestampable = true;
|
||||
|
||||
/**
|
||||
* @return ArgumentCollection
|
||||
@@ -66,17 +67,12 @@ class FeatureAvailability extends BaseI18nLoop
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $pagination
|
||||
*
|
||||
* @return \Thelia\Core\Template\Element\LoopResult
|
||||
*/
|
||||
public function exec(&$pagination)
|
||||
public function buildModelCriteria()
|
||||
{
|
||||
$search = FeatureAvQuery::create();
|
||||
|
||||
/* manage translations */
|
||||
$locale = $this->configureI18nProcessing($search);
|
||||
$this->configureI18nProcessing($search);
|
||||
|
||||
$id = $this->getId();
|
||||
|
||||
@@ -115,16 +111,17 @@ class FeatureAvailability extends BaseI18nLoop
|
||||
}
|
||||
}
|
||||
|
||||
/* perform search */
|
||||
$featuresAv = $this->search($search, $pagination);
|
||||
return $search;
|
||||
|
||||
$loopResult = new LoopResult($featuresAv);
|
||||
}
|
||||
|
||||
foreach ($featuresAv as $featureAv) {
|
||||
$loopResultRow = new LoopResultRow($loopResult, $featureAv, $this->versionable, $this->timestampable, $this->countable);
|
||||
public function parseResults(LoopResult $loopResult)
|
||||
{
|
||||
foreach ($loopResult->getResultDataCollection() as $featureAv) {
|
||||
$loopResultRow = new LoopResultRow($featureAv);
|
||||
$loopResultRow->set("ID", $featureAv->getId())
|
||||
->set("IS_TRANSLATED",$featureAv->getVirtualColumn('IS_TRANSLATED'))
|
||||
->set("LOCALE",$locale)
|
||||
->set("LOCALE",$this->locale)
|
||||
->set("TITLE",$featureAv->getVirtualColumn('i18n_TITLE'))
|
||||
->set("CHAPO", $featureAv->getVirtualColumn('i18n_CHAPO'))
|
||||
->set("DESCRIPTION", $featureAv->getVirtualColumn('i18n_DESCRIPTION'))
|
||||
@@ -135,5 +132,6 @@ class FeatureAvailability extends BaseI18nLoop
|
||||
}
|
||||
|
||||
return $loopResult;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,6 +28,7 @@ use Thelia\Core\Template\Element\BaseI18nLoop;
|
||||
use Thelia\Core\Template\Element\LoopResult;
|
||||
use Thelia\Core\Template\Element\LoopResultRow;
|
||||
|
||||
use Thelia\Core\Template\Element\PropelSearchLoopInterface;
|
||||
use Thelia\Core\Template\Loop\Argument\ArgumentCollection;
|
||||
use Thelia\Core\Template\Loop\Argument\Argument;
|
||||
|
||||
@@ -45,9 +46,9 @@ use Thelia\Type;
|
||||
* @package Thelia\Core\Template\Loop
|
||||
* @author Etienne Roudeix <eroudeix@openstudio.fr>
|
||||
*/
|
||||
class FeatureValue extends BaseI18nLoop
|
||||
class FeatureValue extends BaseI18nLoop implements PropelSearchLoopInterface
|
||||
{
|
||||
public $timestampable = true;
|
||||
protected $timestampable = true;
|
||||
|
||||
/**
|
||||
* @return ArgumentCollection
|
||||
@@ -70,17 +71,12 @@ class FeatureValue extends BaseI18nLoop
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $pagination
|
||||
*
|
||||
* @return \Thelia\Core\Template\Element\LoopResult
|
||||
*/
|
||||
public function exec(&$pagination)
|
||||
public function buildModelCriteria()
|
||||
{
|
||||
$search = FeatureProductQuery::create();
|
||||
|
||||
// manage featureAv translations
|
||||
$locale = $this->configureI18nProcessing(
|
||||
$this->configureI18nProcessing(
|
||||
$search,
|
||||
array('TITLE', 'CHAPO', 'DESCRIPTION', 'POSTSCRIPTUM'),
|
||||
FeatureAvTableMap::TABLE_NAME,
|
||||
@@ -127,13 +123,14 @@ class FeatureValue extends BaseI18nLoop
|
||||
}
|
||||
}
|
||||
|
||||
$featureValues = $this->search($search, $pagination);
|
||||
return $search;
|
||||
|
||||
$loopResult = new LoopResult($featureValues);
|
||||
}
|
||||
|
||||
foreach ($featureValues as $featureValue) {
|
||||
|
||||
$loopResultRow = new LoopResultRow($loopResult, $featureValue, $this->versionable, $this->timestampable, $this->countable);
|
||||
public function parseResults(LoopResult $loopResult)
|
||||
{
|
||||
foreach ($loopResult->getResultDataCollection() as $featureValue) {
|
||||
$loopResultRow = new LoopResultRow($featureValue);
|
||||
|
||||
$loopResultRow
|
||||
->set("ID" , $featureValue->getId())
|
||||
@@ -144,7 +141,7 @@ class FeatureValue extends BaseI18nLoop
|
||||
->set("IS_FREE_TEXT" , is_null($featureValue->getFeatureAvId()) ? 1 : 0)
|
||||
->set("IS_FEATURE_AV" , is_null($featureValue->getFeatureAvId()) ? 0 : 1)
|
||||
|
||||
->set("LOCALE" , $locale)
|
||||
->set("LOCALE" , $this->locale)
|
||||
->set("TITLE" , $featureValue->getVirtualColumn(FeatureAvTableMap::TABLE_NAME . '_i18n_TITLE'))
|
||||
->set("CHAPO" , $featureValue->getVirtualColumn(FeatureAvTableMap::TABLE_NAME . '_i18n_CHAPO'))
|
||||
->set("DESCRIPTION" , $featureValue->getVirtualColumn(FeatureAvTableMap::TABLE_NAME . '_i18n_DESCRIPTION'))
|
||||
@@ -157,5 +154,6 @@ class FeatureValue extends BaseI18nLoop
|
||||
}
|
||||
|
||||
return $loopResult;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,13 +23,13 @@
|
||||
|
||||
namespace Thelia\Core\Template\Loop;
|
||||
|
||||
use Thelia\Core\Template\Element\ArraySearchLoopInterface;
|
||||
use Thelia\Core\Template\Element\BaseLoop;
|
||||
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\Tools\DateTimeFormat;
|
||||
|
||||
/**
|
||||
*
|
||||
@@ -37,7 +37,7 @@ use Thelia\Tools\DateTimeFormat;
|
||||
*
|
||||
* @author Franck Allimant <franck@cqfdev.fr>
|
||||
*/
|
||||
class Feed extends BaseLoop
|
||||
class Feed extends BaseLoop implements ArraySearchLoopInterface
|
||||
{
|
||||
public function getArgDefinitions()
|
||||
{
|
||||
@@ -47,12 +47,7 @@ class Feed extends BaseLoop
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @return \Thelia\Core\Template\Element\LoopResult
|
||||
*/
|
||||
public function exec(&$pagination)
|
||||
public function buildArray()
|
||||
{
|
||||
$cachedir = THELIA_ROOT . 'cache/feeds';
|
||||
|
||||
@@ -72,26 +67,15 @@ class Feed extends BaseLoop
|
||||
|
||||
$items = $feed->get_items();
|
||||
|
||||
$limit = min(count($items), $this->getLimit());
|
||||
return $items;
|
||||
|
||||
$indexes = array();
|
||||
for ($idx = 0; $idx < $limit; $idx++) {
|
||||
$indexes[] = $idx;
|
||||
}
|
||||
}
|
||||
|
||||
$loopResult = new LoopResult($indexes);
|
||||
public function parseResults(LoopResult $loopResult)
|
||||
{
|
||||
foreach ($loopResult->getResultDataCollection() as $item) {
|
||||
|
||||
foreach ($indexes as $idx) {
|
||||
|
||||
$item = $items[$idx];
|
||||
|
||||
$link = $item->get_permalink();
|
||||
|
||||
$title = $item->get_title();
|
||||
$author = $item->get_author();
|
||||
$description = $item->get_description();
|
||||
|
||||
$loopResultRow = new LoopResultRow($loopResult, null, $this->versionable, $this->timestampable, $this->countable);
|
||||
$loopResultRow = new LoopResultRow();
|
||||
|
||||
$loopResultRow
|
||||
->set("URL" , $item->get_permalink())
|
||||
|
||||
@@ -28,6 +28,7 @@ use Thelia\Core\Template\Element\BaseI18nLoop;
|
||||
use Thelia\Core\Template\Element\LoopResult;
|
||||
use Thelia\Core\Template\Element\LoopResultRow;
|
||||
|
||||
use Thelia\Core\Template\Element\PropelSearchLoopInterface;
|
||||
use Thelia\Core\Template\Loop\Argument\ArgumentCollection;
|
||||
use Thelia\Core\Template\Loop\Argument\Argument;
|
||||
|
||||
@@ -43,10 +44,10 @@ use Thelia\Type\BooleanOrBothType;
|
||||
* @package Thelia\Core\Template\Loop
|
||||
* @author Etienne Roudeix <eroudeix@openstudio.fr>
|
||||
*/
|
||||
class Folder extends BaseI18nLoop
|
||||
class Folder extends BaseI18nLoop implements PropelSearchLoopInterface
|
||||
{
|
||||
public $timestampable = true;
|
||||
public $versionable = true;
|
||||
protected $timestampable = true;
|
||||
protected $versionable = true;
|
||||
|
||||
/**
|
||||
* @return ArgumentCollection
|
||||
@@ -71,17 +72,12 @@ class Folder extends BaseI18nLoop
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $pagination
|
||||
*
|
||||
* @return \Thelia\Core\Template\Element\LoopResult
|
||||
*/
|
||||
public function exec(&$pagination)
|
||||
public function buildModelCriteria()
|
||||
{
|
||||
$search = FolderQuery::create();
|
||||
|
||||
/* manage translations */
|
||||
$locale = $this->configureI18nProcessing($search);
|
||||
$this->configureI18nProcessing($search);
|
||||
|
||||
$id = $this->getId();
|
||||
|
||||
@@ -148,33 +144,28 @@ class Folder extends BaseI18nLoop
|
||||
}
|
||||
}
|
||||
|
||||
/* perform search */
|
||||
$folders = $this->search($search, $pagination);
|
||||
|
||||
/* @todo */
|
||||
$notEmpty = $this->getNot_empty();
|
||||
|
||||
$loopResult = new LoopResult($folders);
|
||||
return $search;
|
||||
|
||||
foreach ($folders as $folder) {
|
||||
}
|
||||
|
||||
/*
|
||||
* no cause pagination lost :
|
||||
* if ($notEmpty && $folder->countAllProducts() == 0) continue;
|
||||
*/
|
||||
|
||||
$loopResultRow = new LoopResultRow($loopResult, $folder, $this->versionable, $this->timestampable, $this->countable);
|
||||
public function parseResults(LoopResult $loopResult)
|
||||
{
|
||||
foreach ($loopResult->getResultDataCollection() as $folder) {
|
||||
$loopResultRow = new LoopResultRow($folder);
|
||||
|
||||
$loopResultRow
|
||||
->set("ID", $folder->getId())
|
||||
->set("IS_TRANSLATED",$folder->getVirtualColumn('IS_TRANSLATED'))
|
||||
->set("LOCALE",$locale)
|
||||
->set("LOCALE",$this->locale)
|
||||
->set("TITLE",$folder->getVirtualColumn('i18n_TITLE'))
|
||||
->set("CHAPO", $folder->getVirtualColumn('i18n_CHAPO'))
|
||||
->set("DESCRIPTION", $folder->getVirtualColumn('i18n_DESCRIPTION'))
|
||||
->set("POSTSCRIPTUM", $folder->getVirtualColumn('i18n_POSTSCRIPTUM'))
|
||||
->set("PARENT", $folder->getParent())
|
||||
->set("URL", $folder->getUrl($locale))
|
||||
->set("URL", $folder->getUrl($this->locale))
|
||||
->set("CHILD_COUNT", $folder->countChild())
|
||||
->set("CONTENT_COUNT", $folder->countAllContents())
|
||||
->set("VISIBLE", $folder->getVisible() ? "1" : "0")
|
||||
@@ -185,5 +176,6 @@ class Folder extends BaseI18nLoop
|
||||
}
|
||||
|
||||
return $loopResult;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,6 +22,7 @@
|
||||
/*************************************************************************************/
|
||||
|
||||
namespace Thelia\Core\Template\Loop;
|
||||
use Thelia\Core\Template\Element\ArraySearchLoopInterface;
|
||||
use Thelia\Core\Template\Element\BaseI18nLoop;
|
||||
use Thelia\Core\Template\Element\LoopResult;
|
||||
use Thelia\Core\Template\Element\LoopResultRow;
|
||||
@@ -35,9 +36,8 @@ use Thelia\Type\BooleanOrBothType;
|
||||
* @package Thelia\Core\Template\Loop
|
||||
* @author Manuel Raynaud <mraynaud@openstudio.fr>
|
||||
*/
|
||||
class FolderPath extends BaseI18nLoop
|
||||
class FolderPath extends BaseI18nLoop implements ArraySearchLoopInterface
|
||||
{
|
||||
|
||||
/**
|
||||
*
|
||||
* define all args used in your loop
|
||||
@@ -80,26 +80,14 @@ class FolderPath extends BaseI18nLoop
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* this function have to be implement in your own loop class.
|
||||
*
|
||||
* All loops parameters can be accessible via getter.
|
||||
*
|
||||
* for example, ref parameter is accessible through getRef method
|
||||
*
|
||||
* @param $pagination
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function exec(&$pagination)
|
||||
public function buildArray()
|
||||
{
|
||||
$id = $this->getFolder();
|
||||
$visible = $this->getVisible();
|
||||
|
||||
$search = FolderQuery::create();
|
||||
|
||||
$locale = $this->configureI18nProcessing($search, array('TITLE'));
|
||||
$this->configureI18nProcessing($search, array('TITLE'));
|
||||
|
||||
$search->filterById($id);
|
||||
if ($visible != BooleanOrBothType::ANY) $search->filterByVisible($visible);
|
||||
@@ -113,16 +101,12 @@ class FolderPath extends BaseI18nLoop
|
||||
|
||||
if ($folder != null) {
|
||||
|
||||
$loopResultRow = new LoopResultRow();
|
||||
|
||||
$loopResultRow
|
||||
->set("TITLE",$folder->getVirtualColumn('i18n_TITLE'))
|
||||
->set("URL", $folder->getUrl($locale))
|
||||
->set("ID", $folder->getId())
|
||||
->set("LOCALE",$locale)
|
||||
;
|
||||
|
||||
$results[] = $loopResultRow;
|
||||
$results[] = array(
|
||||
"ID" => $result->getId(),
|
||||
"TITLE" => $result->getVirtualColumn('i18n_TITLE'),
|
||||
"URL" => $result->getUrl($this->locale),
|
||||
"LOCALE" => $this->locale,
|
||||
);
|
||||
|
||||
$parent = $folder->getParent();
|
||||
|
||||
@@ -146,13 +130,19 @@ class FolderPath extends BaseI18nLoop
|
||||
} while ($folder != null && $parent > 0);
|
||||
|
||||
// Reverse list and build the final result
|
||||
$results = array_reverse($results);
|
||||
return array_reverse($results);
|
||||
}
|
||||
|
||||
$loopResult = new LoopResult();
|
||||
|
||||
foreach($results as $result) $loopResult->addRow($result);
|
||||
public function parseResults(LoopResult $loopResult)
|
||||
{
|
||||
foreach($loopResult->getResultDataCollection() as $result) {
|
||||
$loopResultRow = new LoopResultRow($result);
|
||||
foreach($result as $output => $outputValue) {
|
||||
$loopResultRow->set($output, $outputValue);
|
||||
}
|
||||
$loopResult->addRow($loopResultRow);
|
||||
}
|
||||
|
||||
return $loopResult;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -23,6 +23,7 @@
|
||||
|
||||
namespace Thelia\Core\Template\Loop;
|
||||
use Propel\Runtime\ActiveQuery\Criteria;
|
||||
use Thelia\Core\Template\Element\ArraySearchLoopInterface;
|
||||
use Thelia\Core\Template\Element\LoopResult;
|
||||
use Thelia\Core\Template\Element\LoopResultRow;
|
||||
|
||||
@@ -45,7 +46,7 @@ use Thelia\Core\Template\Element\BaseI18nLoop;
|
||||
* @package Thelia\Core\Template\Loop
|
||||
* @author Franck Allimant <franck@cqfdev.fr>
|
||||
*/
|
||||
class FolderTree extends BaseI18nLoop
|
||||
class FolderTree extends BaseI18nLoop implements ArraySearchLoopInterface
|
||||
{
|
||||
/**
|
||||
* @return ArgumentCollection
|
||||
@@ -61,13 +62,13 @@ class FolderTree extends BaseI18nLoop
|
||||
}
|
||||
|
||||
// changement de rubrique
|
||||
protected function buildFolderTree($parent, $visible, $level, $max_level, $exclude, LoopResult &$loopResult)
|
||||
protected function buildFolderTree($parent, $visible, $level, $max_level, $exclude, &$resultsList)
|
||||
{
|
||||
if ($level > $max_level) return;
|
||||
|
||||
$search = FolderQuery::create();
|
||||
|
||||
$locale = $this->configureI18nProcessing($search, array(
|
||||
$this->configureI18nProcessing($search, array(
|
||||
'TITLE'
|
||||
));
|
||||
|
||||
@@ -83,36 +84,44 @@ class FolderTree extends BaseI18nLoop
|
||||
|
||||
foreach ($results as $result) {
|
||||
|
||||
$loopResultRow = new LoopResultRow();
|
||||
$resultsList[] = array(
|
||||
"ID" => $result->getId(),
|
||||
"TITLE" => $result->getVirtualColumn('i18n_TITLE'),
|
||||
"PARENT" => $result->getParent(),
|
||||
"URL" => $result->getUrl($this->locale),
|
||||
"VISIBLE" => $result->getVisible() ? "1" : "0",
|
||||
"LEVEL" => $level,
|
||||
'CHILD_COUNT' => $result->countChild(),
|
||||
);
|
||||
|
||||
$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);
|
||||
$this->buildFolderTree($result->getId(), $visible, 1 + $level, $max_level, $exclude, $resultsList);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $pagination (ignored)
|
||||
*
|
||||
* @return \Thelia\Core\Template\Element\LoopResult
|
||||
*/
|
||||
public function exec(&$pagination)
|
||||
public function parseResults(LoopResult $loopResult)
|
||||
{
|
||||
foreach($loopResult->getResultDataCollection() as $result) {
|
||||
$loopResultRow = new LoopResultRow($result);
|
||||
foreach($result as $output => $outputValue) {
|
||||
$loopResultRow->set($output, $outputValue);
|
||||
}
|
||||
$loopResult->addRow($loopResultRow);
|
||||
}
|
||||
|
||||
return $loopResult;
|
||||
}
|
||||
|
||||
public function buildArray()
|
||||
{
|
||||
$id = $this->getFolder();
|
||||
$depth = $this->getDepth();
|
||||
$visible = $this->getVisible();
|
||||
$exclude = $this->getExclude();
|
||||
|
||||
$loopResult = new LoopResult();
|
||||
$resultsList = array();
|
||||
|
||||
$this->buildFolderTree($id, $visible, 0, $depth, $exclude, $loopResult);
|
||||
$this->buildFolderTree($id, $visible, 0, $depth, $exclude, $resultsList);
|
||||
|
||||
return $loopResult;
|
||||
return $resultsList;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,6 +23,7 @@
|
||||
|
||||
namespace Thelia\Core\Template\Loop;
|
||||
use Thelia\Core\Template\Element\BaseI18nLoop;
|
||||
use Thelia\Core\Template\Element\PropelSearchLoopInterface;
|
||||
use Thelia\Core\Template\Loop\Argument\Argument;
|
||||
use Thelia\Core\Event\Image\ImageEvent;
|
||||
use Thelia\Core\Event\TheliaEvents;
|
||||
@@ -41,9 +42,12 @@ use Thelia\Log\Tlog;
|
||||
*
|
||||
* @author Franck Allimant <franck@cqfdev.fr>
|
||||
*/
|
||||
class Image extends BaseI18nLoop
|
||||
class Image extends BaseI18nLoop implements PropelSearchLoopInterface
|
||||
{
|
||||
public $timestampable = true;
|
||||
protected $objectType;
|
||||
protected $objectId;
|
||||
|
||||
protected $timestampable = true;
|
||||
|
||||
/**
|
||||
* @var array Possible image sources
|
||||
@@ -210,19 +214,16 @@ class Image extends BaseI18nLoop
|
||||
return $search;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param unknown $pagination
|
||||
*/
|
||||
public function exec(&$pagination)
|
||||
public function buildModelCriteria()
|
||||
{
|
||||
|
||||
// Select the proper query to use, and get the object type
|
||||
$object_type = $object_id = null;
|
||||
$this->objectType = $this->objectId = null;
|
||||
|
||||
$search = $this->getSearchQuery($object_type, $object_id);
|
||||
$search = $this->getSearchQuery($this->objectType, $this->objectId);
|
||||
|
||||
/* manage translations */
|
||||
$locale = $this->configureI18nProcessing($search);
|
||||
$this->configureI18nProcessing($search);
|
||||
|
||||
$id = $this->getId();
|
||||
|
||||
@@ -234,6 +235,14 @@ class Image extends BaseI18nLoop
|
||||
if (!is_null($exclude))
|
||||
$search->filterById($exclude, Criteria::NOT_IN);
|
||||
|
||||
// echo "sql=".$search->toString();
|
||||
|
||||
return $search;
|
||||
|
||||
}
|
||||
|
||||
public function parseResults(LoopResult $loopResult)
|
||||
{
|
||||
// Create image processing event
|
||||
$event = new ImageEvent($this->request);
|
||||
|
||||
@@ -264,16 +273,11 @@ class Image extends BaseI18nLoop
|
||||
|
||||
}
|
||||
|
||||
// echo "sql=".$search->toString();
|
||||
|
||||
$results = $this->search($search, $pagination);
|
||||
|
||||
$loopResult = new LoopResult($results);
|
||||
|
||||
foreach ($results as $result) {
|
||||
|
||||
foreach ($loopResult->getResultDataCollection() as $result) {
|
||||
// Create image processing event
|
||||
$event = new ImageEvent($this->request);
|
||||
|
||||
// ERO : following is duplicated, guess it's useless at this point
|
||||
//$event = new ImageEvent($this->request);
|
||||
|
||||
// Setup required transformations
|
||||
if (! is_null($width)) $event->setWidth($width);
|
||||
@@ -288,22 +292,22 @@ class Image extends BaseI18nLoop
|
||||
$source_filepath = sprintf("%s%s/%s/%s",
|
||||
THELIA_ROOT,
|
||||
ConfigQuery::read('images_library_path', 'local/media/images'),
|
||||
$object_type,
|
||||
$this->objectType,
|
||||
$result->getFile()
|
||||
);
|
||||
);
|
||||
|
||||
$event->setSourceFilepath($source_filepath);
|
||||
$event->setCacheSubdirectory($object_type);
|
||||
$event->setCacheSubdirectory($this->objectType);
|
||||
|
||||
try {
|
||||
// Dispatch image processing event
|
||||
$this->dispatcher->dispatch(TheliaEvents::IMAGE_PROCESS, $event);
|
||||
|
||||
$loopResultRow = new LoopResultRow($loopResult, $result, $this->versionable, $this->timestampable, $this->countable);
|
||||
$loopResultRow = new LoopResultRow($result);
|
||||
|
||||
$loopResultRow
|
||||
->set("ID" , $result->getId())
|
||||
->set("LOCALE" ,$locale)
|
||||
->set("LOCALE" ,$this->locale)
|
||||
->set("IMAGE_URL" , $event->getFileUrl())
|
||||
->set("ORIGINAL_IMAGE_URL" , $event->getOriginalFileUrl())
|
||||
->set("IMAGE_PATH" , $event->getCacheFilepath())
|
||||
@@ -313,8 +317,8 @@ class Image extends BaseI18nLoop
|
||||
->set("DESCRIPTION" , $result->getVirtualColumn('i18n_DESCRIPTION'))
|
||||
->set("POSTSCRIPTUM" , $result->getVirtualColumn('i18n_POSTSCRIPTUM'))
|
||||
->set("POSITION" , $result->getPosition())
|
||||
->set("OBJECT_TYPE" , $object_type)
|
||||
->set("OBJECT_ID" , $object_id)
|
||||
->set("OBJECT_TYPE" , $this->objectType)
|
||||
->set("OBJECT_ID" , $this->objectId)
|
||||
;
|
||||
|
||||
$loopResult->addRow($loopResultRow);
|
||||
@@ -325,5 +329,6 @@ class Image extends BaseI18nLoop
|
||||
}
|
||||
|
||||
return $loopResult;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,6 +28,7 @@ use Thelia\Core\Template\Element\BaseLoop;
|
||||
use Thelia\Core\Template\Element\LoopResult;
|
||||
use Thelia\Core\Template\Element\LoopResultRow;
|
||||
|
||||
use Thelia\Core\Template\Element\PropelSearchLoopInterface;
|
||||
use Thelia\Core\Template\Loop\Argument\Argument;
|
||||
|
||||
use Thelia\Model\LangQuery;
|
||||
@@ -43,9 +44,9 @@ use Thelia\Core\Template\Loop\Argument\ArgumentCollection;
|
||||
* @package Thelia\Core\Template\Loop
|
||||
* @author Franck Allimant <franck@cqfdev.fr>
|
||||
*/
|
||||
class Lang extends BaseLoop
|
||||
class Lang extends BaseLoop implements PropelSearchLoopInterface
|
||||
{
|
||||
public $timestampable = true;
|
||||
protected $timestampable = true;
|
||||
|
||||
/**
|
||||
* @return ArgumentCollection
|
||||
@@ -59,12 +60,7 @@ class Lang extends BaseLoop
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $pagination (ignored)
|
||||
*
|
||||
* @return \Thelia\Core\Template\Element\LoopResult
|
||||
*/
|
||||
public function exec(&$pagination)
|
||||
public function buildModelCriteria()
|
||||
{
|
||||
$id = $this->getId();
|
||||
$exclude = $this->getExclude();
|
||||
@@ -84,13 +80,14 @@ class Lang extends BaseLoop
|
||||
|
||||
$search->orderByPosition(Criteria::ASC);
|
||||
|
||||
$results = $this->search($search, $pagination);
|
||||
return $search;
|
||||
|
||||
$loopResult = new LoopResult($results);
|
||||
}
|
||||
|
||||
foreach ($results as $result) {
|
||||
|
||||
$loopResultRow = new LoopResultRow($loopResult, $result, $this->versionable, $this->timestampable, $this->countable);
|
||||
public function parseResults(LoopResult $loopResult)
|
||||
{
|
||||
foreach ($loopResult->getResultDataCollection() as $result) {
|
||||
$loopResultRow = new LoopResultRow($result);
|
||||
|
||||
$loopResultRow
|
||||
->set("ID", $result->getId())
|
||||
@@ -108,5 +105,6 @@ class Lang extends BaseLoop
|
||||
}
|
||||
|
||||
return $loopResult;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,6 +28,7 @@ use Thelia\Core\Template\Element\BaseI18nLoop;
|
||||
use Thelia\Core\Template\Element\LoopResult;
|
||||
use Thelia\Core\Template\Element\LoopResultRow;
|
||||
|
||||
use Thelia\Core\Template\Element\PropelSearchLoopInterface;
|
||||
use Thelia\Core\Template\Loop\Argument\Argument;
|
||||
|
||||
use Thelia\Core\Template\Loop\Argument\ArgumentCollection;
|
||||
@@ -46,9 +47,9 @@ use Thelia\Type\BooleanOrBothType;
|
||||
* @package Thelia\Core\Template\Loop
|
||||
* @author Franck Allimant <franck@cqfdev.fr>
|
||||
*/
|
||||
class Message extends BaseI18nLoop
|
||||
class Message extends BaseI18nLoop implements PropelSearchLoopInterface
|
||||
{
|
||||
public $timestampable = true;
|
||||
protected $timestampable = true;
|
||||
|
||||
/**
|
||||
* @return ArgumentCollection
|
||||
@@ -64,20 +65,16 @@ class Message extends BaseI18nLoop
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $pagination (ignored)
|
||||
*
|
||||
* @return \Thelia\Core\Template\Element\LoopResult
|
||||
*/
|
||||
public function exec(&$pagination)
|
||||
public function buildModelCriteria()
|
||||
{
|
||||
$id = $this->getId();
|
||||
$name = $this->getVariable();
|
||||
$secured = $this->getSecured();
|
||||
$exclude = $this->getExclude();
|
||||
|
||||
$search = MessageQuery::create();
|
||||
|
||||
$locale = $this->configureI18nProcessing($search, array(
|
||||
$this->configureI18nProcessing($search, array(
|
||||
'TITLE',
|
||||
'SUBJECT',
|
||||
'TEXT_MESSAGE',
|
||||
@@ -100,19 +97,20 @@ class Message extends BaseI18nLoop
|
||||
|
||||
$search->orderByName(Criteria::ASC);
|
||||
|
||||
$results = $this->search($search, $pagination);
|
||||
return $search;
|
||||
|
||||
$loopResult = new LoopResult($results);
|
||||
}
|
||||
|
||||
foreach ($results as $result) {
|
||||
|
||||
$loopResultRow = new LoopResultRow($loopResult, $result, $this->versionable, $this->timestampable, $this->countable);
|
||||
public function parseResults(LoopResult $loopResult)
|
||||
{
|
||||
foreach ($loopResult->getResultDataCollection() as $result) {
|
||||
$loopResultRow = new LoopResultRow($result);
|
||||
|
||||
$loopResultRow
|
||||
->set("ID" , $result->getId())
|
||||
->set("NAME" , $result->getName())
|
||||
->set("IS_TRANSLATED", $result->getVirtualColumn('IS_TRANSLATED'))
|
||||
->set("LOCALE" , $locale)
|
||||
->set("LOCALE" , $this->locale)
|
||||
->set("TITLE" , $result->getVirtualColumn('i18n_TITLE'))
|
||||
->set("SUBJECT" , $result->getVirtualColumn('i18n_SUBJECT'))
|
||||
->set("TEXT_MESSAGE" , $result->getVirtualColumn('i18n_TEXT_MESSAGE'))
|
||||
@@ -124,5 +122,6 @@ class Message extends BaseI18nLoop
|
||||
}
|
||||
|
||||
return $loopResult;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -29,6 +29,7 @@ use Thelia\Core\Template\Element\BaseI18nLoop;
|
||||
use Thelia\Core\Template\Element\LoopResult;
|
||||
use Thelia\Core\Template\Element\LoopResultRow;
|
||||
|
||||
use Thelia\Core\Template\Element\PropelSearchLoopInterface;
|
||||
use Thelia\Core\Template\Loop\Argument\ArgumentCollection;
|
||||
use Thelia\Core\Template\Loop\Argument\Argument;
|
||||
|
||||
@@ -46,9 +47,9 @@ use Thelia\Type;
|
||||
* @package Thelia\Core\Template\Loop
|
||||
* @author Etienne Roudeix <eroudeix@openstudio.fr>
|
||||
*/
|
||||
class Module extends BaseI18nLoop
|
||||
class Module extends BaseI18nLoop implements PropelSearchLoopInterface
|
||||
{
|
||||
public $timestampable = true;
|
||||
protected $timestampable = true;
|
||||
|
||||
/**
|
||||
* @return ArgumentCollection
|
||||
@@ -79,17 +80,12 @@ class Module extends BaseI18nLoop
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $pagination
|
||||
*
|
||||
* @return \Thelia\Core\Template\Element\LoopResult
|
||||
*/
|
||||
public function exec(&$pagination)
|
||||
public function buildModelCriteria()
|
||||
{
|
||||
$search = ModuleQuery::create();
|
||||
|
||||
/* manage translations */
|
||||
$locale = $this->configureI18nProcessing($search);
|
||||
$this->configureI18nProcessing($search);
|
||||
|
||||
$id = $this->getId();
|
||||
|
||||
@@ -131,16 +127,17 @@ class Module extends BaseI18nLoop
|
||||
|
||||
$search->orderByPosition();
|
||||
|
||||
/* perform search */
|
||||
$modules = $this->search($search, $pagination);
|
||||
return $search;
|
||||
|
||||
$loopResult = new LoopResult($modules);
|
||||
}
|
||||
|
||||
foreach ($modules as $module) {
|
||||
$loopResultRow = new LoopResultRow($loopResult, $module, $this->versionable, $this->timestampable, $this->countable);
|
||||
public function parseResults(LoopResult $loopResult)
|
||||
{
|
||||
foreach ($loopResult->getResultDataCollection() as $module) {
|
||||
$loopResultRow = new LoopResultRow($module);
|
||||
$loopResultRow->set("ID", $module->getId())
|
||||
->set("IS_TRANSLATED",$module->getVirtualColumn('IS_TRANSLATED'))
|
||||
->set("LOCALE",$locale)
|
||||
->set("LOCALE",$this->locale)
|
||||
->set("TITLE",$module->getVirtualColumn('i18n_TITLE'))
|
||||
->set("CHAPO", $module->getVirtualColumn('i18n_CHAPO'))
|
||||
->set("DESCRIPTION", $module->getVirtualColumn('i18n_DESCRIPTION'))
|
||||
@@ -151,7 +148,7 @@ class Module extends BaseI18nLoop
|
||||
->set("CLASS", $module->getFullNamespace())
|
||||
->set("POSITION", $module->getPosition());
|
||||
|
||||
if (null !== $profile) {
|
||||
if (null !== $this->getProfile()) {
|
||||
$accessValue = $module->getVirtualColumn('access');
|
||||
$manager = new AccessManager($accessValue);
|
||||
|
||||
@@ -165,5 +162,6 @@ class Module extends BaseI18nLoop
|
||||
}
|
||||
|
||||
return $loopResult;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,6 +28,7 @@ use Thelia\Core\Template\Element\BaseLoop;
|
||||
use Thelia\Core\Template\Element\LoopResult;
|
||||
|
||||
use Thelia\Core\Template\Element\LoopResultRow;
|
||||
use Thelia\Core\Template\Element\PropelSearchLoopInterface;
|
||||
use Thelia\Core\Template\Element\SearchLoopInterface;
|
||||
use Thelia\Core\Template\Loop\Argument\ArgumentCollection;
|
||||
use Thelia\Core\Template\Loop\Argument\Argument;
|
||||
@@ -43,11 +44,11 @@ use Thelia\Type;
|
||||
* @author Franck Allimant <franck@cqfdev.fr>
|
||||
* @author Etienne Roudeix <eroudeix@openstudio.fr>
|
||||
*/
|
||||
class Order extends BaseLoop implements SearchLoopInterface
|
||||
class Order extends BaseLoop implements SearchLoopInterface, PropelSearchLoopInterface
|
||||
{
|
||||
public $countable = true;
|
||||
public $timestampable = true;
|
||||
public $versionable = false;
|
||||
protected $countable = true;
|
||||
protected $timestampable = true;
|
||||
protected $versionable = false;
|
||||
|
||||
public function getArgDefinitions()
|
||||
{
|
||||
@@ -131,12 +132,7 @@ class Order extends BaseLoop implements SearchLoopInterface
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $pagination
|
||||
*
|
||||
* @return LoopResult
|
||||
*/
|
||||
public function exec(&$pagination)
|
||||
public function buildModelCriteria()
|
||||
{
|
||||
$search = OrderQuery::create();
|
||||
|
||||
@@ -151,7 +147,7 @@ class Order extends BaseLoop implements SearchLoopInterface
|
||||
if ($customer === 'current') {
|
||||
$currentCustomer = $this->securityContext->getCustomerUser();
|
||||
if ($currentCustomer === null) {
|
||||
return new LoopResult();
|
||||
return null;
|
||||
} else {
|
||||
$search->filterByCustomerId($currentCustomer->getId(), Criteria::EQUAL);
|
||||
}
|
||||
@@ -178,14 +174,16 @@ class Order extends BaseLoop implements SearchLoopInterface
|
||||
}
|
||||
}
|
||||
|
||||
$orders = $this->search($search, $pagination);
|
||||
return $search;
|
||||
|
||||
$loopResult = new LoopResult($orders);
|
||||
}
|
||||
|
||||
foreach ($orders as $order) {
|
||||
public function parseResults(LoopResult $loopResult)
|
||||
{
|
||||
foreach ($loopResult->getResultDataCollection() as $order) {
|
||||
$tax = 0;
|
||||
$amount = $order->getTotalAmount($tax);
|
||||
$loopResultRow = new LoopResultRow($loopResult, $order, $this->versionable, $this->timestampable, $this->countable);
|
||||
$loopResultRow = new LoopResultRow($order);
|
||||
$loopResultRow
|
||||
->set("ID", $order->getId())
|
||||
->set("REF", $order->getRef())
|
||||
@@ -213,5 +211,6 @@ class Order extends BaseLoop implements SearchLoopInterface
|
||||
}
|
||||
|
||||
return $loopResult;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,6 +28,7 @@ use Thelia\Core\Template\Element\BaseLoop;
|
||||
use Thelia\Core\Template\Element\LoopResult;
|
||||
use Thelia\Core\Template\Element\LoopResultRow;
|
||||
|
||||
use Thelia\Core\Template\Element\PropelSearchLoopInterface;
|
||||
use Thelia\Core\Template\Loop\Argument\ArgumentCollection;
|
||||
use Thelia\Core\Template\Loop\Argument\Argument;
|
||||
|
||||
@@ -42,9 +43,9 @@ use Thelia\Model\OrderAddressQuery;
|
||||
* @package Thelia\Core\Template\Loop
|
||||
* @author Etienne Roudeix <eroudeix@openstudio.fr>
|
||||
*/
|
||||
class OrderAddress extends BaseLoop
|
||||
class OrderAddress extends BaseLoop implements PropelSearchLoopInterface
|
||||
{
|
||||
public $timestampable = true;
|
||||
protected $timestampable = true;
|
||||
|
||||
/**
|
||||
* @return ArgumentCollection
|
||||
@@ -56,12 +57,7 @@ class OrderAddress extends BaseLoop
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $pagination
|
||||
*
|
||||
* @return \Thelia\Core\Template\Element\LoopResult
|
||||
*/
|
||||
public function exec(&$pagination)
|
||||
public function buildModelCriteria()
|
||||
{
|
||||
$search = OrderAddressQuery::create();
|
||||
|
||||
@@ -69,12 +65,14 @@ class OrderAddress extends BaseLoop
|
||||
|
||||
$search->filterById($id, Criteria::IN);
|
||||
|
||||
$orderAddresses = $this->search($search, $pagination);
|
||||
return $search;
|
||||
|
||||
$loopResult = new LoopResult($orderAddresses);
|
||||
}
|
||||
|
||||
foreach ($orderAddresses as $orderAddress) {
|
||||
$loopResultRow = new LoopResultRow($loopResult, $orderAddress, $this->versionable, $this->timestampable, $this->countable);
|
||||
public function parseResults(LoopResult $loopResult)
|
||||
{
|
||||
foreach ($loopResult->getResultDataCollection() as $orderAddress) {
|
||||
$loopResultRow = new LoopResultRow($orderAddress);
|
||||
$loopResultRow
|
||||
->set("ID", $orderAddress->getId())
|
||||
->set("TITLE", $orderAddress->getCustomerTitleId())
|
||||
@@ -94,5 +92,6 @@ class OrderAddress extends BaseLoop
|
||||
}
|
||||
|
||||
return $loopResult;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,6 +28,7 @@ use Thelia\Core\Template\Element\BaseLoop;
|
||||
use Thelia\Core\Template\Element\LoopResult;
|
||||
use Thelia\Core\Template\Element\LoopResultRow;
|
||||
|
||||
use Thelia\Core\Template\Element\PropelSearchLoopInterface;
|
||||
use Thelia\Core\Template\Loop\Argument\ArgumentCollection;
|
||||
use Thelia\Core\Template\Loop\Argument\Argument;
|
||||
|
||||
@@ -41,9 +42,9 @@ use Thelia\Model\Base\OrderProductQuery;
|
||||
* @package Thelia\Core\Template\Loop
|
||||
* @author Etienne Roudeix <eroudeix@openstudio.fr>
|
||||
*/
|
||||
class OrderProduct extends BaseLoop
|
||||
class OrderProduct extends BaseLoop implements PropelSearchLoopInterface
|
||||
{
|
||||
public $timestampable = true;
|
||||
protected $timestampable = true;
|
||||
|
||||
/**
|
||||
* @return ArgumentCollection
|
||||
@@ -55,13 +56,7 @@ class OrderProduct extends BaseLoop
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $pagination
|
||||
*
|
||||
* @return \Thelia\Core\Template\Element\LoopResult
|
||||
* @throws \InvalidArgumentException
|
||||
*/
|
||||
public function exec(&$pagination)
|
||||
public function buildModelCriteria()
|
||||
{
|
||||
$search = OrderProductQuery::create();
|
||||
|
||||
@@ -76,44 +71,47 @@ class OrderProduct extends BaseLoop
|
||||
|
||||
$search->orderById(Criteria::ASC);
|
||||
|
||||
$products = $this->search($search, $pagination);
|
||||
return $search;
|
||||
|
||||
}
|
||||
|
||||
$loopResult = new LoopResult($products);
|
||||
public function parseResults(LoopResult $loopResult)
|
||||
{
|
||||
foreach ($loopResult->getResultDataCollection() as $orderProduct) {
|
||||
$loopResultRow = new LoopResultRow($orderProduct);
|
||||
|
||||
foreach ($products as $product) {
|
||||
$loopResultRow = new LoopResultRow($loopResult, $product, $this->versionable, $this->timestampable, $this->countable);
|
||||
$price = $orderProduct->getPrice();
|
||||
$taxedPrice = $price + round($orderProduct->getVirtualColumn('TOTAL_TAX'), 2);
|
||||
$promoPrice = $orderProduct->getPromoPrice();
|
||||
$taxedPromoPrice = $promoPrice + round($orderProduct->getVirtualColumn('TOTAL_PROMO_TAX'), 2);
|
||||
|
||||
$price = $product->getPrice();
|
||||
$taxedPrice = $price + round($product->getVirtualColumn('TOTAL_TAX'), 2);
|
||||
$promoPrice = $product->getPromoPrice();
|
||||
$taxedPromoPrice = $promoPrice + round($product->getVirtualColumn('TOTAL_PROMO_TAX'), 2);
|
||||
|
||||
$loopResultRow->set("ID", $product->getId())
|
||||
->set("REF", $product->getProductRef())
|
||||
->set("PRODUCT_SALE_ELEMENTS_REF", $product->getProductSaleElementsRef())
|
||||
->set("WAS_NEW", $product->getWasNew() === 1 ? 1 : 0)
|
||||
->set("WAS_IN_PROMO", $product->getWasInPromo() === 1 ? 1 : 0)
|
||||
->set("WEIGHT", $product->getWeight())
|
||||
->set("TITLE", $product->getTitle())
|
||||
->set("CHAPO", $product->getChapo())
|
||||
->set("DESCRIPTION", $product->getDescription())
|
||||
->set("POSTSCRIPTUM", $product->getPostscriptum())
|
||||
->set("QUANTITY", $product->getQuantity())
|
||||
$loopResultRow->set("ID", $orderProduct->getId())
|
||||
->set("REF", $orderProduct->getProductRef())
|
||||
->set("PRODUCT_SALE_ELEMENTS_REF", $orderProduct->getProductSaleElementsRef())
|
||||
->set("WAS_NEW", $orderProduct->getWasNew() === 1 ? 1 : 0)
|
||||
->set("WAS_IN_PROMO", $orderProduct->getWasInPromo() === 1 ? 1 : 0)
|
||||
->set("WEIGHT", $orderProduct->getWeight())
|
||||
->set("TITLE", $orderProduct->getTitle())
|
||||
->set("CHAPO", $orderProduct->getChapo())
|
||||
->set("DESCRIPTION", $orderProduct->getDescription())
|
||||
->set("POSTSCRIPTUM", $orderProduct->getPostscriptum())
|
||||
->set("QUANTITY", $orderProduct->getQuantity())
|
||||
->set("PRICE", $price)
|
||||
->set("PRICE_TAX", $taxedPrice - $price)
|
||||
->set("TAXED_PRICE", $taxedPrice)
|
||||
->set("PROMO_PRICE", $promoPrice)
|
||||
->set("PROMO_PRICE_TAX", $taxedPromoPrice - $promoPrice)
|
||||
->set("TAXED_PROMO_PRICE", $taxedPromoPrice)
|
||||
->set("TAX_RULE_TITLE", $product->getTaxRuleTitle())
|
||||
->set("TAX_RULE_DESCRIPTION", $product->getTaxRuledescription())
|
||||
->set("PARENT", $product->getParent())
|
||||
->set("EAN_CODE", $product->getEanCode())
|
||||
->set("TAX_RULE_TITLE", $orderProduct->getTaxRuleTitle())
|
||||
->set("TAX_RULE_DESCRIPTION", $orderProduct->getTaxRuledescription())
|
||||
->set("PARENT", $orderProduct->getParent())
|
||||
->set("EAN_CODE", $orderProduct->getEanCode())
|
||||
;
|
||||
|
||||
$loopResult->addRow($loopResultRow);
|
||||
}
|
||||
|
||||
return $loopResult;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,6 +28,7 @@ use Thelia\Core\Template\Element\BaseI18nLoop;
|
||||
use Thelia\Core\Template\Element\LoopResult;
|
||||
use Thelia\Core\Template\Element\LoopResultRow;
|
||||
|
||||
use Thelia\Core\Template\Element\PropelSearchLoopInterface;
|
||||
use Thelia\Core\Template\Loop\Argument\ArgumentCollection;
|
||||
use Thelia\Core\Template\Loop\Argument\Argument;
|
||||
|
||||
@@ -43,9 +44,9 @@ use Thelia\Type;
|
||||
* @package Thelia\Core\Template\Loop
|
||||
* @author Etienne Roudeix <eroudeix@openstudio.fr>
|
||||
*/
|
||||
class OrderProductAttributeCombination extends BaseI18nLoop
|
||||
class OrderProductAttributeCombination extends BaseI18nLoop implements PropelSearchLoopInterface
|
||||
{
|
||||
public $timestampable = true;
|
||||
protected $timestampable = true;
|
||||
|
||||
/**
|
||||
* @return ArgumentCollection
|
||||
@@ -64,12 +65,7 @@ class OrderProductAttributeCombination extends BaseI18nLoop
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $pagination
|
||||
*
|
||||
* @return \Thelia\Core\Template\Element\LoopResult
|
||||
*/
|
||||
public function exec(&$pagination)
|
||||
public function buildModelCriteria()
|
||||
{
|
||||
$search = OrderProductAttributeCombinationQuery::create();
|
||||
|
||||
@@ -90,28 +86,30 @@ class OrderProductAttributeCombination extends BaseI18nLoop
|
||||
}
|
||||
}
|
||||
|
||||
$attributeCombinations = $this->search($search, $pagination);
|
||||
return $search;
|
||||
|
||||
}
|
||||
|
||||
$loopResult = new LoopResult($attributeCombinations);
|
||||
|
||||
foreach ($attributeCombinations as $attributeCombination) {
|
||||
$loopResultRow = new LoopResultRow($loopResult, $attributeCombination, $this->versionable, $this->timestampable, $this->countable);
|
||||
public function parseResults(LoopResult $loopResult)
|
||||
{
|
||||
foreach ($loopResult->getResultDataCollection() as $orderAttributeCombination) {
|
||||
$loopResultRow = new LoopResultRow($orderAttributeCombination);
|
||||
|
||||
$loopResultRow
|
||||
->set("LOCALE",$locale)
|
||||
->set("ATTRIBUTE_TITLE", $attributeCombination->getAttributeTitle())
|
||||
->set("ATTRIBUTE_CHAPO", $attributeCombination->getAttributeChapo())
|
||||
->set("ATTRIBUTE_DESCRIPTION", $attributeCombination->getAttributeDescription())
|
||||
->set("ATTRIBUTE_POSTSCRIPTUM", $attributeCombination->getAttributePostscriptum())
|
||||
->set("ATTRIBUTE_AVAILABILITY_TITLE", $attributeCombination->getAttributeAvTitle())
|
||||
->set("ATTRIBUTE_AVAILABILITY_CHAPO", $attributeCombination->getAttributeAvChapo())
|
||||
->set("ATTRIBUTE_AVAILABILITY_DESCRIPTION", $attributeCombination->getAttributeAvDescription())
|
||||
->set("ATTRIBUTE_AVAILABILITY_POSTSCRIPTUM", $attributeCombination->getAttributeAvPostscriptum())
|
||||
->set("ATTRIBUTE_TITLE", $orderAttributeCombination->getAttributeTitle())
|
||||
->set("ATTRIBUTE_CHAPO", $orderAttributeCombination->getAttributeChapo())
|
||||
->set("ATTRIBUTE_DESCRIPTION", $orderAttributeCombination->getAttributeDescription())
|
||||
->set("ATTRIBUTE_POSTSCRIPTUM", $orderAttributeCombination->getAttributePostscriptum())
|
||||
->set("ATTRIBUTE_AVAILABILITY_TITLE", $orderAttributeCombination->getAttributeAvTitle())
|
||||
->set("ATTRIBUTE_AVAILABILITY_CHAPO", $orderAttributeCombination->getAttributeAvChapo())
|
||||
->set("ATTRIBUTE_AVAILABILITY_DESCRIPTION", $orderAttributeCombination->getAttributeAvDescription())
|
||||
->set("ATTRIBUTE_AVAILABILITY_POSTSCRIPTUM", $orderAttributeCombination->getAttributeAvPostscriptum())
|
||||
;
|
||||
|
||||
$loopResult->addRow($loopResultRow);
|
||||
}
|
||||
|
||||
return $loopResult;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,6 +28,7 @@ use Thelia\Core\Template\Element\BaseI18nLoop;
|
||||
use Thelia\Core\Template\Element\LoopResult;
|
||||
use Thelia\Core\Template\Element\LoopResultRow;
|
||||
|
||||
use Thelia\Core\Template\Element\PropelSearchLoopInterface;
|
||||
use Thelia\Core\Template\Loop\Argument\ArgumentCollection;
|
||||
use Thelia\Core\Template\Loop\Argument\Argument;
|
||||
|
||||
@@ -42,9 +43,9 @@ use Thelia\Model\OrderStatusQuery;
|
||||
* @package Thelia\Core\Template\Loop
|
||||
* @author Etienne Roudeix <eroudeix@openstudio.fr>
|
||||
*/
|
||||
class OrderStatus extends BaseI18nLoop
|
||||
class OrderStatus extends BaseI18nLoop implements PropelSearchLoopInterface
|
||||
{
|
||||
public $timestampable = true;
|
||||
protected $timestampable = true;
|
||||
|
||||
/**
|
||||
* @return ArgumentCollection
|
||||
@@ -56,17 +57,12 @@ class OrderStatus extends BaseI18nLoop
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $pagination
|
||||
*
|
||||
* @return \Thelia\Core\Template\Element\LoopResult
|
||||
*/
|
||||
public function exec(&$pagination)
|
||||
public function buildModelCriteria()
|
||||
{
|
||||
$search = OrderStatusQuery::create();
|
||||
|
||||
/* manage translations */
|
||||
$locale = $this->configureI18nProcessing($search);
|
||||
$this->configureI18nProcessing($search);
|
||||
|
||||
$id = $this->getId();
|
||||
|
||||
@@ -74,16 +70,17 @@ class OrderStatus extends BaseI18nLoop
|
||||
$search->filterById($id, Criteria::IN);
|
||||
}
|
||||
|
||||
/* perform search */
|
||||
$orderStatusList = $this->search($search, $pagination);
|
||||
return $search;
|
||||
|
||||
$loopResult = new LoopResult($orderStatusList);
|
||||
}
|
||||
|
||||
foreach ($orderStatusList as $orderStatus) {
|
||||
$loopResultRow = new LoopResultRow($loopResult, $orderStatus, $this->versionable, $this->timestampable, $this->countable);
|
||||
public function parseResults(LoopResult $loopResult)
|
||||
{
|
||||
foreach ($loopResult->getResultDataCollection() as $orderStatus) {
|
||||
$loopResultRow = new LoopResultRow($orderStatus);
|
||||
$loopResultRow->set("ID", $orderStatus->getId())
|
||||
->set("IS_TRANSLATED",$orderStatus->getVirtualColumn('IS_TRANSLATED'))
|
||||
->set("LOCALE",$locale)
|
||||
->set("LOCALE",$this->locale)
|
||||
->set("CODE", $orderStatus->getCode())
|
||||
->set("TITLE", $orderStatus->getVirtualColumn('i18n_TITLE'))
|
||||
->set("CHAPO", $orderStatus->getVirtualColumn('i18n_CHAPO'))
|
||||
@@ -95,5 +92,6 @@ class OrderStatus extends BaseI18nLoop
|
||||
}
|
||||
|
||||
return $loopResult;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,9 +22,9 @@
|
||||
/*************************************************************************************/
|
||||
|
||||
namespace Thelia\Core\Template\Loop;
|
||||
use Propel\Runtime\ActiveQuery\Criteria;
|
||||
use Thelia\Core\Template\Element\LoopResult;
|
||||
use Thelia\Core\Template\Element\LoopResultRow;
|
||||
use Thelia\Core\Template\Element\PropelSearchLoopInterface;
|
||||
use Thelia\Module\BaseModule;
|
||||
|
||||
/**
|
||||
@@ -32,7 +32,7 @@ use Thelia\Module\BaseModule;
|
||||
* @package Thelia\Core\Template\Loop
|
||||
* @author Etienne Roudeix <eroudeix@gmail.com>
|
||||
*/
|
||||
class Payment extends BaseSpecificModule
|
||||
class Payment extends BaseSpecificModule implements PropelSearchLoopInterface
|
||||
{
|
||||
|
||||
public function getArgDefinitions()
|
||||
@@ -42,21 +42,10 @@ class Payment extends BaseSpecificModule
|
||||
return $collection;
|
||||
}
|
||||
|
||||
public function exec(&$pagination)
|
||||
public function parseResults(LoopResult $loopResult)
|
||||
{
|
||||
$search = parent::exec($pagination);
|
||||
/* manage translations */
|
||||
$locale = $this->configureI18nProcessing($search);
|
||||
|
||||
$search->filterByType(BaseModule::PAYMENT_MODULE_TYPE, Criteria::EQUAL);
|
||||
|
||||
/* perform search */
|
||||
$paymentModules = $this->search($search, $pagination);
|
||||
|
||||
$loopResult = new LoopResult($paymentModules);
|
||||
|
||||
foreach ($paymentModules as $paymentModule) {
|
||||
$loopResultRow = new LoopResultRow($loopResult, $paymentModule, $this->versionable, $this->timestampable, $this->countable);
|
||||
foreach ($loopResult->getResultDataCollection() as $paymentModule) {
|
||||
$loopResultRow = new LoopResultRow($paymentModule);
|
||||
|
||||
$moduleReflection = new \ReflectionClass($paymentModule->getFullNamespace());
|
||||
if ($moduleReflection->isSubclassOf("Thelia\Module\PaymentModuleInterface") === false) {
|
||||
@@ -80,4 +69,9 @@ class Payment extends BaseSpecificModule
|
||||
|
||||
return $loopResult;
|
||||
}
|
||||
|
||||
protected function getModuleType()
|
||||
{
|
||||
return BaseModule::PAYMENT_MODULE_TYPE;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -29,6 +29,7 @@ use Thelia\Core\Template\Element\BaseI18nLoop;
|
||||
use Thelia\Core\Template\Element\LoopResult;
|
||||
use Thelia\Core\Template\Element\LoopResultRow;
|
||||
|
||||
use Thelia\Core\Template\Element\PropelSearchLoopInterface;
|
||||
use Thelia\Core\Template\Element\SearchLoopInterface;
|
||||
use Thelia\Core\Template\Loop\Argument\ArgumentCollection;
|
||||
use Thelia\Core\Template\Loop\Argument\Argument;
|
||||
@@ -52,10 +53,10 @@ use Thelia\Type;
|
||||
* @package Thelia\Core\Template\Loop
|
||||
* @author Etienne Roudeix <eroudeix@openstudio.fr>
|
||||
*/
|
||||
class Product extends BaseI18nLoop implements SearchLoopInterface
|
||||
class Product extends BaseI18nLoop implements PropelSearchLoopInterface, SearchLoopInterface
|
||||
{
|
||||
public $timestampable = true;
|
||||
public $versionable = true;
|
||||
protected $timestampable = true;
|
||||
protected $versionable = true;
|
||||
|
||||
/**
|
||||
* @return ArgumentCollection
|
||||
@@ -161,17 +162,11 @@ class Product extends BaseI18nLoop implements SearchLoopInterface
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $pagination
|
||||
*
|
||||
* @return \Thelia\Core\Template\Element\LoopResult
|
||||
* @throws \InvalidArgumentException
|
||||
*/
|
||||
public function exec(&$pagination)
|
||||
public function buildModelCriteria()
|
||||
{
|
||||
$complex = $this->getComplex();
|
||||
if (true === $complex) {
|
||||
return $this->execComplex($pagination);
|
||||
return $this->buildComplex();
|
||||
}
|
||||
|
||||
$currencyId = $this->getCurrency();
|
||||
@@ -227,7 +222,7 @@ class Product extends BaseI18nLoop implements SearchLoopInterface
|
||||
}
|
||||
|
||||
/* manage translations */
|
||||
$locale = $this->configureI18nProcessing($search);
|
||||
$this->configureI18nProcessing($search);
|
||||
|
||||
$id = $this->getId();
|
||||
|
||||
@@ -459,16 +454,21 @@ class Product extends BaseI18nLoop implements SearchLoopInterface
|
||||
}
|
||||
}
|
||||
|
||||
/* perform search */
|
||||
$products = $this->search($search, $pagination);
|
||||
return $search;
|
||||
}
|
||||
|
||||
$loopResult = new LoopResult($products);
|
||||
public function parseResults(LoopResult $loopResult)
|
||||
{
|
||||
$complex = $this->getComplex();
|
||||
if (true === $complex) {
|
||||
return $this->parseComplex($loopResult);
|
||||
}
|
||||
|
||||
$taxCountry = CountryQuery::create()->findPk(64); // @TODO : make it magic
|
||||
|
||||
foreach ($products as $product) {
|
||||
foreach ($loopResult->getResultDataCollection() as $product) {
|
||||
|
||||
$loopResultRow = new LoopResultRow($loopResult, $product, $this->versionable, $this->timestampable, $this->countable);
|
||||
$loopResultRow = new LoopResultRow($product);
|
||||
|
||||
$price = $product->getVirtualColumn('price');
|
||||
try {
|
||||
@@ -512,12 +512,12 @@ class Product extends BaseI18nLoop implements SearchLoopInterface
|
||||
->set("ID" , $product->getId())
|
||||
->set("REF" , $product->getRef())
|
||||
->set("IS_TRANSLATED" , $product->getVirtualColumn('IS_TRANSLATED'))
|
||||
->set("LOCALE" , $locale)
|
||||
->set("LOCALE" , $this->locale)
|
||||
->set("TITLE" , $product->getVirtualColumn('i18n_TITLE'))
|
||||
->set("CHAPO" , $product->getVirtualColumn('i18n_CHAPO'))
|
||||
->set("DESCRIPTION" , $product->getVirtualColumn('i18n_DESCRIPTION'))
|
||||
->set("POSTSCRIPTUM" , $product->getVirtualColumn('i18n_POSTSCRIPTUM'))
|
||||
->set("URL" , $product->getUrl($locale))
|
||||
->set("URL" , $product->getUrl($this->locale))
|
||||
->set("BEST_PRICE" , $product->getVirtualColumn('is_promo') ? $promoPrice : $price)
|
||||
->set("BEST_PRICE_TAX" , $taxedPrice - $product->getVirtualColumn('is_promo') ? $taxedPromoPrice - $promoPrice : $taxedPrice - $price)
|
||||
->set("BEST_TAXED_PRICE" , $product->getVirtualColumn('is_promo') ? $taxedPromoPrice : $taxedPrice)
|
||||
@@ -551,13 +551,7 @@ class Product extends BaseI18nLoop implements SearchLoopInterface
|
||||
return $loopResult;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $pagination
|
||||
*
|
||||
* @return \Thelia\Core\Template\Element\LoopResult
|
||||
* @throws \InvalidArgumentException
|
||||
*/
|
||||
public function execComplex(&$pagination)
|
||||
public function buildComplex()
|
||||
{
|
||||
$currencyId = $this->getCurrency();
|
||||
if (null !== $currencyId) {
|
||||
@@ -575,7 +569,7 @@ class Product extends BaseI18nLoop implements SearchLoopInterface
|
||||
$search = ProductQuery::create();
|
||||
|
||||
/* manage translations */
|
||||
$locale = $this->configureI18nProcessing($search);
|
||||
$this->configureI18nProcessing($search);
|
||||
|
||||
$attributeNonStrictMatch = $this->getAttribute_non_strict_match();
|
||||
$isPSELeftJoinList = array();
|
||||
@@ -978,16 +972,18 @@ class Product extends BaseI18nLoop implements SearchLoopInterface
|
||||
}
|
||||
}
|
||||
|
||||
/* perform search */
|
||||
$products = $this->search($search, $pagination);
|
||||
return $search;
|
||||
}
|
||||
|
||||
$loopResult = new LoopResult($products);
|
||||
public function parseComplex(LoopResult $results)
|
||||
{
|
||||
$loopResult = new LoopResult($results);
|
||||
|
||||
$taxCountry = CountryQuery::create()->findPk(64); // @TODO : make it magic
|
||||
|
||||
foreach ($products as $product) {
|
||||
foreach ($loopResult->getResultDataCollection() as $product) {
|
||||
|
||||
$loopResultRow = new LoopResultRow($loopResult, $product, $this->versionable, $this->timestampable, $this->countable);
|
||||
$loopResultRow = new LoopResultRow($product);
|
||||
|
||||
$price = $product->getRealLowestPrice();
|
||||
|
||||
@@ -1023,12 +1019,12 @@ class Product extends BaseI18nLoop implements SearchLoopInterface
|
||||
->set("ID" , $product->getId())
|
||||
->set("REF" , $product->getRef())
|
||||
->set("IS_TRANSLATED" , $product->getVirtualColumn('IS_TRANSLATED'))
|
||||
->set("LOCALE" , $locale)
|
||||
->set("LOCALE" , $this->locale)
|
||||
->set("TITLE" , $product->getVirtualColumn('i18n_TITLE'))
|
||||
->set("CHAPO" , $product->getVirtualColumn('i18n_CHAPO'))
|
||||
->set("DESCRIPTION" , $product->getVirtualColumn('i18n_DESCRIPTION'))
|
||||
->set("POSTSCRIPTUM" , $product->getVirtualColumn('i18n_POSTSCRIPTUM'))
|
||||
->set("URL" , $product->getUrl($locale))
|
||||
->set("URL" , $product->getUrl($this->locale))
|
||||
->set("BEST_PRICE" , $price)
|
||||
->set("BEST_PRICE_TAX" , $taxedPrice - $price)
|
||||
->set("BEST_TAXED_PRICE" , $taxedPrice)
|
||||
|
||||
@@ -28,6 +28,7 @@ use Thelia\Core\Template\Element\BaseLoop;
|
||||
use Thelia\Core\Template\Element\LoopResult;
|
||||
use Thelia\Core\Template\Element\LoopResultRow;
|
||||
|
||||
use Thelia\Core\Template\Element\PropelSearchLoopInterface;
|
||||
use Thelia\Core\Template\Loop\Argument\ArgumentCollection;
|
||||
use Thelia\Core\Template\Loop\Argument\Argument;
|
||||
|
||||
@@ -49,9 +50,9 @@ use Thelia\Type;
|
||||
* @package Thelia\Core\Template\Loop
|
||||
* @author Etienne Roudeix <eroudeix@openstudio.fr>
|
||||
*/
|
||||
class ProductSaleElements extends BaseLoop
|
||||
class ProductSaleElements extends BaseLoop implements PropelSearchLoopInterface
|
||||
{
|
||||
public $timestampable = true;
|
||||
protected $timestampable = true;
|
||||
|
||||
/**
|
||||
* @return ArgumentCollection
|
||||
@@ -77,13 +78,7 @@ class ProductSaleElements extends BaseLoop
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $pagination
|
||||
*
|
||||
* @return \Thelia\Core\Template\Element\LoopResult
|
||||
* @throws \InvalidArgumentException
|
||||
*/
|
||||
public function exec(&$pagination)
|
||||
public function buildModelCriteria()
|
||||
{
|
||||
$search = ProductSaleElementsQuery::create();
|
||||
|
||||
@@ -144,14 +139,16 @@ class ProductSaleElements extends BaseLoop
|
||||
|
||||
$search->groupById();
|
||||
|
||||
$PSEValues = $this->search($search, $pagination);
|
||||
return $search;
|
||||
|
||||
$loopResult = new LoopResult($PSEValues);
|
||||
}
|
||||
|
||||
public function parseResults(LoopResult $loopResult)
|
||||
{
|
||||
$taxCountry = CountryQuery::create()->findPk(64); // @TODO : make it magic
|
||||
|
||||
foreach ($PSEValues as $PSEValue) {
|
||||
$loopResultRow = new LoopResultRow($loopResult, $PSEValue, $this->versionable, $this->timestampable, $this->countable);
|
||||
foreach ($loopResult->getResultDataCollection() as $PSEValue) {
|
||||
$loopResultRow = new LoopResultRow($PSEValue);
|
||||
|
||||
$price = $PSEValue->getPrice();
|
||||
try {
|
||||
@@ -189,5 +186,6 @@ class ProductSaleElements extends BaseLoop
|
||||
}
|
||||
|
||||
return $loopResult;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,6 +28,7 @@ use Thelia\Core\Template\Element\BaseI18nLoop;
|
||||
use Thelia\Core\Template\Element\LoopResult;
|
||||
use Thelia\Core\Template\Element\LoopResultRow;
|
||||
|
||||
use Thelia\Core\Template\Element\PropelSearchLoopInterface;
|
||||
use Thelia\Core\Template\Loop\Argument\ArgumentCollection;
|
||||
use Thelia\Core\Template\Loop\Argument\Argument;
|
||||
|
||||
@@ -42,9 +43,9 @@ use Thelia\Model\Base\TemplateQuery;
|
||||
* @package Thelia\Core\Template\Loop
|
||||
* @author Etienne Roudeix <eroudeix@openstudio.fr>
|
||||
*/
|
||||
class ProductTemplate extends BaseI18nLoop
|
||||
class ProductTemplate extends BaseI18nLoop implements PropelSearchLoopInterface
|
||||
{
|
||||
public $timestampable = true;
|
||||
protected $timestampable = true;
|
||||
|
||||
/**
|
||||
* @return ArgumentCollection
|
||||
@@ -57,12 +58,7 @@ class ProductTemplate extends BaseI18nLoop
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $pagination
|
||||
*
|
||||
* @return \Thelia\Core\Template\Element\LoopResult
|
||||
*/
|
||||
public function exec(&$pagination)
|
||||
public function buildModelCriteria()
|
||||
{
|
||||
$search = TemplateQuery::create();
|
||||
|
||||
@@ -71,7 +67,7 @@ class ProductTemplate extends BaseI18nLoop
|
||||
$lang = $this->getLang();
|
||||
|
||||
/* manage translations */
|
||||
$locale = $this->configureI18nProcessing($search, $columns = array('NAME'));
|
||||
$this->configureI18nProcessing($search, $columns = array('NAME'));
|
||||
|
||||
$id = $this->getId();
|
||||
|
||||
@@ -85,18 +81,19 @@ class ProductTemplate extends BaseI18nLoop
|
||||
$search->filterById($exclude, Criteria::NOT_IN);
|
||||
}
|
||||
|
||||
/* perform search */
|
||||
$templates = $this->search($search, $pagination);
|
||||
return $search;
|
||||
|
||||
$loopResult = new LoopResult($templates);
|
||||
}
|
||||
|
||||
foreach ($templates as $template) {
|
||||
$loopResultRow = new LoopResultRow($loopResult, $template, $this->versionable, $this->timestampable, $this->countable);
|
||||
public function parseResults(LoopResult $loopResult)
|
||||
{
|
||||
foreach ($loopResult->getResultDataCollection() as $template) {
|
||||
$loopResultRow = new LoopResultRow($template);
|
||||
|
||||
$loopResultRow
|
||||
->set("ID", $template->getId())
|
||||
->set("IS_TRANSLATED" , $template->getVirtualColumn('IS_TRANSLATED'))
|
||||
->set("LOCALE" , $locale)
|
||||
->set("LOCALE" , $this->locale)
|
||||
->set("NAME" , $template->getVirtualColumn('i18n_NAME'))
|
||||
;
|
||||
|
||||
@@ -104,5 +101,6 @@ class ProductTemplate extends BaseI18nLoop
|
||||
}
|
||||
|
||||
return $loopResult;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,6 +28,7 @@ use Thelia\Core\Template\Element\BaseI18nLoop;
|
||||
use Thelia\Core\Template\Element\LoopResult;
|
||||
use Thelia\Core\Template\Element\LoopResultRow;
|
||||
|
||||
use Thelia\Core\Template\Element\PropelSearchLoopInterface;
|
||||
use Thelia\Core\Template\Loop\Argument\ArgumentCollection;
|
||||
use Thelia\Core\Template\Loop\Argument\Argument;
|
||||
|
||||
@@ -43,9 +44,9 @@ use Thelia\Type;
|
||||
* @package Thelia\Core\Template\Loop
|
||||
* @author Etienne Roudeix <eroudeix@openstudio.fr>
|
||||
*/
|
||||
class Profile extends BaseI18nLoop
|
||||
class Profile extends BaseI18nLoop implements PropelSearchLoopInterface
|
||||
{
|
||||
public $timestampable = true;
|
||||
protected $timestampable = true;
|
||||
|
||||
/**
|
||||
* @return ArgumentCollection
|
||||
@@ -57,17 +58,12 @@ class Profile extends BaseI18nLoop
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $pagination
|
||||
*
|
||||
* @return \Thelia\Core\Template\Element\LoopResult
|
||||
*/
|
||||
public function exec(&$pagination)
|
||||
public function buildModelCriteria()
|
||||
{
|
||||
$search = ProfileQuery::create();
|
||||
|
||||
/* manage translations */
|
||||
$locale = $this->configureI18nProcessing($search);
|
||||
$this->configureI18nProcessing($search);
|
||||
|
||||
$id = $this->getId();
|
||||
|
||||
@@ -77,16 +73,17 @@ class Profile extends BaseI18nLoop
|
||||
|
||||
$search->orderById(Criteria::ASC);
|
||||
|
||||
/* perform search */
|
||||
$profiles = $this->search($search, $pagination);
|
||||
return $search;
|
||||
|
||||
$loopResult = new LoopResult($profiles);
|
||||
}
|
||||
|
||||
foreach ($profiles as $profile) {
|
||||
$loopResultRow = new LoopResultRow($loopResult, $profile, $this->versionable, $this->timestampable, $this->countable);
|
||||
public function parseResults(LoopResult $loopResult)
|
||||
{
|
||||
foreach ($loopResult->getResultDataCollection() as $profile) {
|
||||
$loopResultRow = new LoopResultRow($profile);
|
||||
$loopResultRow->set("ID", $profile->getId())
|
||||
->set("IS_TRANSLATED",$profile->getVirtualColumn('IS_TRANSLATED'))
|
||||
->set("LOCALE",$locale)
|
||||
->set("LOCALE",$this->locale)
|
||||
->set("CODE",$profile->getCode())
|
||||
->set("TITLE",$profile->getVirtualColumn('i18n_TITLE'))
|
||||
->set("CHAPO", $profile->getVirtualColumn('i18n_CHAPO'))
|
||||
|
||||
@@ -29,6 +29,7 @@ use Thelia\Core\Template\Element\BaseI18nLoop;
|
||||
use Thelia\Core\Template\Element\LoopResult;
|
||||
use Thelia\Core\Template\Element\LoopResultRow;
|
||||
|
||||
use Thelia\Core\Template\Element\PropelSearchLoopInterface;
|
||||
use Thelia\Core\Template\Loop\Argument\ArgumentCollection;
|
||||
use Thelia\Core\Template\Loop\Argument\Argument;
|
||||
|
||||
@@ -44,9 +45,9 @@ use Thelia\Type;
|
||||
* @package Thelia\Core\Template\Loop
|
||||
* @author Etienne Roudeix <eroudeix@openstudio.fr>
|
||||
*/
|
||||
class Resource extends BaseI18nLoop
|
||||
class Resource extends BaseI18nLoop implements PropelSearchLoopInterface
|
||||
{
|
||||
public $timestampable = true;
|
||||
protected $timestampable = true;
|
||||
|
||||
/**
|
||||
* @return ArgumentCollection
|
||||
@@ -64,17 +65,12 @@ class Resource extends BaseI18nLoop
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $pagination
|
||||
*
|
||||
* @return \Thelia\Core\Template\Element\LoopResult
|
||||
*/
|
||||
public function exec(&$pagination)
|
||||
public function buildModelCriteria()
|
||||
{
|
||||
$search = ResourceQuery::create();
|
||||
|
||||
/* manage translations */
|
||||
$locale = $this->configureI18nProcessing($search);
|
||||
$this->configureI18nProcessing($search);
|
||||
|
||||
$profile = $this->getProfile();
|
||||
|
||||
@@ -92,16 +88,17 @@ class Resource extends BaseI18nLoop
|
||||
|
||||
$search->orderById(Criteria::ASC);
|
||||
|
||||
/* perform search */
|
||||
$resources = $this->search($search, $pagination);
|
||||
return $search;
|
||||
|
||||
$loopResult = new LoopResult($resources);
|
||||
}
|
||||
|
||||
foreach ($resources as $resource) {
|
||||
$loopResultRow = new LoopResultRow($loopResult, $resource, $this->versionable, $this->timestampable, $this->countable);
|
||||
public function parseResults(LoopResult $loopResult)
|
||||
{
|
||||
foreach ($loopResult->getResultDataCollection() as $resource) {
|
||||
$loopResultRow = new LoopResultRow($resource);
|
||||
$loopResultRow->set("ID", $resource->getId())
|
||||
->set("IS_TRANSLATED",$resource->getVirtualColumn('IS_TRANSLATED'))
|
||||
->set("LOCALE",$locale)
|
||||
->set("LOCALE",$this->locale)
|
||||
->set("CODE",$resource->getCode())
|
||||
->set("TITLE",$resource->getVirtualColumn('i18n_TITLE'))
|
||||
->set("CHAPO", $resource->getVirtualColumn('i18n_CHAPO'))
|
||||
@@ -109,7 +106,7 @@ class Resource extends BaseI18nLoop
|
||||
->set("POSTSCRIPTUM", $resource->getVirtualColumn('i18n_POSTSCRIPTUM'))
|
||||
;
|
||||
|
||||
if (null !== $profile) {
|
||||
if (null !== $this->getProfile()) {
|
||||
$accessValue = $resource->getVirtualColumn('access');
|
||||
$manager = new AccessManager($accessValue);
|
||||
|
||||
@@ -123,5 +120,6 @@ class Resource extends BaseI18nLoop
|
||||
}
|
||||
|
||||
return $loopResult;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,6 +28,7 @@ use Thelia\Core\Template\Element\BaseI18nLoop;
|
||||
use Thelia\Core\Template\Element\LoopResult;
|
||||
use Thelia\Core\Template\Element\LoopResultRow;
|
||||
|
||||
use Thelia\Core\Template\Element\PropelSearchLoopInterface;
|
||||
use Thelia\Core\Template\Loop\Argument\ArgumentCollection;
|
||||
use Thelia\Core\Template\Loop\Argument\Argument;
|
||||
|
||||
@@ -45,9 +46,9 @@ use Thelia\Model\TaxQuery;
|
||||
* @package Thelia\Core\Template\Loop
|
||||
* @author Etienne Roudeix <eroudeix@openstudio.fr>
|
||||
*/
|
||||
class Tax extends BaseI18nLoop
|
||||
class Tax extends BaseI18nLoop implements PropelSearchLoopInterface
|
||||
{
|
||||
public $timestampable = true;
|
||||
protected $timestampable = true;
|
||||
|
||||
/**
|
||||
* @return ArgumentCollection
|
||||
@@ -70,17 +71,12 @@ class Tax extends BaseI18nLoop
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $pagination
|
||||
*
|
||||
* @return \Thelia\Core\Template\Element\LoopResult
|
||||
*/
|
||||
public function exec(&$pagination)
|
||||
public function buildModelCriteria()
|
||||
{
|
||||
$search = TaxQuery::create();
|
||||
|
||||
/* manage translations */
|
||||
$locale = $this->configureI18nProcessing($search, array('TITLE', 'DESCRIPTION'));
|
||||
$this->configureI18nProcessing($search, array('TITLE', 'DESCRIPTION'));
|
||||
|
||||
$id = $this->getId();
|
||||
|
||||
@@ -142,21 +138,21 @@ class Tax extends BaseI18nLoop
|
||||
}
|
||||
}
|
||||
|
||||
/* perform search */
|
||||
$taxes = $this->search($search, $pagination);
|
||||
return $search;
|
||||
|
||||
$loopResult = new LoopResult($taxes);
|
||||
}
|
||||
|
||||
foreach ($taxes as $tax) {
|
||||
|
||||
$loopResultRow = new LoopResultRow($loopResult, $tax, $this->versionable, $this->timestampable, $this->countable);
|
||||
public function parseResults(LoopResult $loopResult)
|
||||
{
|
||||
foreach ($loopResult->getResultDataCollection() as $tax) {
|
||||
$loopResultRow = new LoopResultRow($tax);
|
||||
|
||||
$loopResultRow
|
||||
->set("ID" , $tax->getId())
|
||||
->set("TYPE" , $tax->getType())
|
||||
->set("REQUIREMENTS" , $tax->getRequirements())
|
||||
->set("IS_TRANSLATED" , $tax->getVirtualColumn('IS_TRANSLATED'))
|
||||
->set("LOCALE" , $locale)
|
||||
->set("LOCALE" , $this->locale)
|
||||
->set("TITLE" , $tax->getVirtualColumn('i18n_TITLE'))
|
||||
->set("DESCRIPTION" , $tax->getVirtualColumn('i18n_DESCRIPTION'))
|
||||
;
|
||||
@@ -165,5 +161,6 @@ class Tax extends BaseI18nLoop
|
||||
}
|
||||
|
||||
return $loopResult;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,6 +28,7 @@ use Thelia\Core\Template\Element\BaseI18nLoop;
|
||||
use Thelia\Core\Template\Element\LoopResult;
|
||||
use Thelia\Core\Template\Element\LoopResultRow;
|
||||
|
||||
use Thelia\Core\Template\Element\PropelSearchLoopInterface;
|
||||
use Thelia\Core\Template\Loop\Argument\ArgumentCollection;
|
||||
use Thelia\Core\Template\Loop\Argument\Argument;
|
||||
|
||||
@@ -44,9 +45,9 @@ use Thelia\Model\TaxRuleQuery;
|
||||
* @package Thelia\Core\Template\Loop
|
||||
* @author Etienne Roudeix <eroudeix@openstudio.fr>
|
||||
*/
|
||||
class TaxRule extends BaseI18nLoop
|
||||
class TaxRule extends BaseI18nLoop implements PropelSearchLoopInterface
|
||||
{
|
||||
public $timestampable = true;
|
||||
protected $timestampable = true;
|
||||
|
||||
/**
|
||||
* @return ArgumentCollection
|
||||
@@ -66,17 +67,12 @@ class TaxRule extends BaseI18nLoop
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $pagination
|
||||
*
|
||||
* @return \Thelia\Core\Template\Element\LoopResult
|
||||
*/
|
||||
public function exec(&$pagination)
|
||||
public function buildModelCriteria()
|
||||
{
|
||||
$search = TaxRuleQuery::create();
|
||||
|
||||
/* manage translations */
|
||||
$locale = $this->configureI18nProcessing($search, array('TITLE', 'DESCRIPTION'));
|
||||
$this->configureI18nProcessing($search, array('TITLE', 'DESCRIPTION'));
|
||||
|
||||
$id = $this->getId();
|
||||
|
||||
@@ -109,27 +105,28 @@ class TaxRule extends BaseI18nLoop
|
||||
}
|
||||
}
|
||||
|
||||
/* perform search */
|
||||
$tax_rules = $this->search($search, $pagination);
|
||||
return $search;
|
||||
|
||||
$loopResult = new LoopResult($tax_rules);
|
||||
}
|
||||
|
||||
foreach ($tax_rules as $tax_rule) {
|
||||
|
||||
$loopResultRow = new LoopResultRow($loopResult, $tax_rule, $this->versionable, $this->timestampable, $this->countable);
|
||||
public function parseResults(LoopResult $loopResult)
|
||||
{
|
||||
foreach ($loopResult->getResultDataCollection() as $taxRule) {
|
||||
$loopResultRow = new LoopResultRow($taxRule);
|
||||
|
||||
$loopResultRow
|
||||
->set("ID" , $tax_rule->getId())
|
||||
->set("IS_TRANSLATED" , $tax_rule->getVirtualColumn('IS_TRANSLATED'))
|
||||
->set("LOCALE" , $locale)
|
||||
->set("TITLE" , $tax_rule->getVirtualColumn('i18n_TITLE'))
|
||||
->set("DESCRIPTION" , $tax_rule->getVirtualColumn('i18n_DESCRIPTION'))
|
||||
->set("IS_DEFAULT" , $tax_rule->getIsDefault() ? '1' : '0')
|
||||
->set("ID" , $taxRule->getId())
|
||||
->set("IS_TRANSLATED" , $taxRule->getVirtualColumn('IS_TRANSLATED'))
|
||||
->set("LOCALE" , $this->locale)
|
||||
->set("TITLE" , $taxRule->getVirtualColumn('i18n_TITLE'))
|
||||
->set("DESCRIPTION" , $taxRule->getVirtualColumn('i18n_DESCRIPTION'))
|
||||
->set("IS_DEFAULT" , $taxRule->getIsDefault() ? '1' : '0')
|
||||
;
|
||||
|
||||
$loopResult->addRow($loopResultRow);
|
||||
}
|
||||
|
||||
return $loopResult;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -29,6 +29,7 @@ use Thelia\Core\Template\Element\BaseI18nLoop;
|
||||
use Thelia\Core\Template\Element\LoopResult;
|
||||
use Thelia\Core\Template\Element\LoopResultRow;
|
||||
|
||||
use Thelia\Core\Template\Element\PropelSearchLoopInterface;
|
||||
use Thelia\Core\Template\Loop\Argument\ArgumentCollection;
|
||||
use Thelia\Core\Template\Loop\Argument\Argument;
|
||||
|
||||
@@ -49,9 +50,11 @@ use Thelia\Model\TaxRuleCountryQuery;
|
||||
* @package Thelia\Core\Template\Loop
|
||||
* @author Etienne Roudeix <eroudeix@openstudio.fr>
|
||||
*/
|
||||
class TaxRuleCountry extends BaseI18nLoop
|
||||
class TaxRuleCountry extends BaseI18nLoop implements PropelSearchLoopInterface
|
||||
{
|
||||
public $timestampable = true;
|
||||
protected $taxCountForOriginCountry;
|
||||
|
||||
protected $timestampable = true;
|
||||
|
||||
/**
|
||||
* @return ArgumentCollection
|
||||
@@ -71,12 +74,7 @@ class TaxRuleCountry extends BaseI18nLoop
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $pagination
|
||||
*
|
||||
* @return \Thelia\Core\Template\Element\LoopResult
|
||||
*/
|
||||
public function exec(&$pagination)
|
||||
public function buildModelCriteria()
|
||||
{
|
||||
$search = TaxRuleCountryQuery::create();
|
||||
|
||||
@@ -86,9 +84,9 @@ class TaxRuleCountry extends BaseI18nLoop
|
||||
$taxRule = $this->getTax_rule();
|
||||
|
||||
if ($ask === 'countries') {
|
||||
$taxCountForOriginCountry = TaxRuleCountryQuery::create()->filterByCountryId($country)->count();
|
||||
$this->taxCountForOriginCountry = TaxRuleCountryQuery::create()->filterByCountryId($country)->count();
|
||||
|
||||
if ($taxCountForOriginCountry > 0) {
|
||||
if ($this->taxCountForOriginCountry > 0) {
|
||||
$search->groupByCountryId();
|
||||
|
||||
$originalCountryJoin = new Join();
|
||||
@@ -101,7 +99,7 @@ class TaxRuleCountry extends BaseI18nLoop
|
||||
$search->addJoinObject($originalCountryJoin, 's_to_o');
|
||||
$search->where('`origin`.`COUNTRY_ID`' . Criteria::EQUAL . '?', $country, \PDO::PARAM_INT);
|
||||
|
||||
$search->having('COUNT(*)=?', $taxCountForOriginCountry, \PDO::PARAM_INT);
|
||||
$search->having('COUNT(*)=?', $this->taxCountForOriginCountry, \PDO::PARAM_INT);
|
||||
|
||||
$search->filterByTaxRuleId($taxRule);
|
||||
|
||||
@@ -142,17 +140,17 @@ class TaxRuleCountry extends BaseI18nLoop
|
||||
$search->orderByPosition(Criteria::ASC);
|
||||
}
|
||||
|
||||
/* perform search */
|
||||
$taxRuleCountries = $this->search($search, $pagination);
|
||||
return $search;
|
||||
|
||||
$loopResult = new LoopResult($taxRuleCountries);
|
||||
}
|
||||
|
||||
foreach ($taxRuleCountries as $taxRuleCountry) {
|
||||
public function parseResults(LoopResult $loopResult)
|
||||
{
|
||||
foreach ($loopResult->getResultDataCollection() as $taxRuleCountry) {
|
||||
$loopResultRow = new LoopResultRow($taxRuleCountry);
|
||||
|
||||
$loopResultRow = new LoopResultRow($loopResult, $taxRuleCountry, $this->versionable, $this->timestampable, $this->countable);
|
||||
|
||||
if ($ask === 'countries') {
|
||||
if ($taxCountForOriginCountry > 0) {
|
||||
if ($this->getAsk() === 'countries') {
|
||||
if ($this->taxCountForOriginCountry > 0) {
|
||||
$loopResultRow
|
||||
->set("COUNTRY" , $taxRuleCountry->getCountryId())
|
||||
->set("COUNTRY_TITLE" , $taxRuleCountry->getVirtualColumn(CountryTableMap::TABLE_NAME . '_i18n_TITLE'))
|
||||
@@ -167,7 +165,7 @@ class TaxRuleCountry extends BaseI18nLoop
|
||||
->set("COUNTRY_DESCRIPTION" , $taxRuleCountry->getVirtualColumn('i18n_DESCRIPTION'))
|
||||
->set("COUNTRY_POSTSCRIPTUM" , $taxRuleCountry->getVirtualColumn('i18n_POSTSCRIPTUM'));
|
||||
}
|
||||
} elseif ($ask === 'taxes') {
|
||||
} elseif ($this->getAsk() === 'taxes') {
|
||||
$loopResultRow
|
||||
->set("TAX_RULE" , $taxRuleCountry->getTaxRuleId())
|
||||
->set("COUNTRY" , $taxRuleCountry->getCountryId())
|
||||
@@ -182,5 +180,6 @@ class TaxRuleCountry extends BaseI18nLoop
|
||||
}
|
||||
|
||||
return $loopResult;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,6 +28,7 @@ use Thelia\Core\Template\Element\BaseI18nLoop;
|
||||
use Thelia\Core\Template\Element\LoopResult;
|
||||
use Thelia\Core\Template\Element\LoopResultRow;
|
||||
|
||||
use Thelia\Core\Template\Element\PropelSearchLoopInterface;
|
||||
use Thelia\Core\Template\Loop\Argument\ArgumentCollection;
|
||||
use Thelia\Core\Template\Loop\Argument\Argument;
|
||||
|
||||
@@ -42,9 +43,9 @@ use Thelia\Model\Base\TemplateQuery;
|
||||
* @package Thelia\Core\Template\Loop
|
||||
* @author Etienne Roudeix <eroudeix@openstudio.fr>
|
||||
*/
|
||||
class Template extends BaseI18nLoop
|
||||
class Template extends BaseI18nLoop implements PropelSearchLoopInterface
|
||||
{
|
||||
public $timestampable = true;
|
||||
protected $timestampable = true;
|
||||
|
||||
/**
|
||||
* @return ArgumentCollection
|
||||
@@ -57,12 +58,7 @@ class Template extends BaseI18nLoop
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $pagination
|
||||
*
|
||||
* @return \Thelia\Core\Template\Element\LoopResult
|
||||
*/
|
||||
public function exec(&$pagination)
|
||||
public function buildModelCriteria()
|
||||
{
|
||||
$search = TemplateQuery::create();
|
||||
|
||||
@@ -71,7 +67,7 @@ class Template extends BaseI18nLoop
|
||||
$lang = $this->getLang();
|
||||
|
||||
/* manage translations */
|
||||
$locale = $this->configureI18nProcessing($search, $columns = array('NAME'));
|
||||
$this->configureI18nProcessing($search, $columns = array('NAME'));
|
||||
|
||||
$id = $this->getId();
|
||||
|
||||
@@ -85,18 +81,19 @@ class Template extends BaseI18nLoop
|
||||
$search->filterById($exclude, Criteria::NOT_IN);
|
||||
}
|
||||
|
||||
/* perform search */
|
||||
$templates = $this->search($search, $pagination);
|
||||
return $search;
|
||||
|
||||
$loopResult = new LoopResult($templates);
|
||||
}
|
||||
|
||||
foreach ($templates as $template) {
|
||||
$loopResultRow = new LoopResultRow($loopResult, $template, $this->versionable, $this->timestampable, $this->countable);
|
||||
public function parseResults(LoopResult $loopResult)
|
||||
{
|
||||
foreach ($loopResult->getResultDataCollection() as $template) {
|
||||
$loopResultRow = new LoopResultRow($template);
|
||||
|
||||
$loopResultRow
|
||||
->set("ID", $template->getId())
|
||||
->set("IS_TRANSLATED" , $template->getVirtualColumn('IS_TRANSLATED'))
|
||||
->set("LOCALE" , $locale)
|
||||
->set("LOCALE" , $this->locale)
|
||||
->set("NAME" , $template->getVirtualColumn('i18n_NAME'))
|
||||
;
|
||||
|
||||
@@ -104,5 +101,6 @@ class Template extends BaseI18nLoop
|
||||
}
|
||||
|
||||
return $loopResult;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,6 +28,7 @@ use Thelia\Core\Template\Element\BaseI18nLoop;
|
||||
use Thelia\Core\Template\Element\LoopResult;
|
||||
use Thelia\Core\Template\Element\LoopResultRow;
|
||||
|
||||
use Thelia\Core\Template\Element\PropelSearchLoopInterface;
|
||||
use Thelia\Core\Template\Loop\Argument\ArgumentCollection;
|
||||
use Thelia\Core\Template\Loop\Argument\Argument;
|
||||
|
||||
@@ -42,9 +43,9 @@ use Thelia\Model\CustomerTitleQuery;
|
||||
* @package Thelia\Core\Template\Loop
|
||||
* @author Etienne Roudeix <eroudeix@openstudio.fr>
|
||||
*/
|
||||
class Title extends BaseI18nLoop
|
||||
class Title extends BaseI18nLoop implements PropelSearchLoopInterface
|
||||
{
|
||||
public $timestampable = true;
|
||||
protected $timestampable = true;
|
||||
|
||||
/**
|
||||
* @return ArgumentCollection
|
||||
@@ -56,17 +57,12 @@ class Title extends BaseI18nLoop
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $pagination
|
||||
*
|
||||
* @return \Thelia\Core\Template\Element\LoopResult
|
||||
*/
|
||||
public function exec(&$pagination)
|
||||
public function buildModelCriteria()
|
||||
{
|
||||
$search = CustomerTitleQuery::create();
|
||||
|
||||
/* manage translations */
|
||||
$locale = $this->configureI18nProcessing($search, array('SHORT', 'LONG'));
|
||||
$this->configureI18nProcessing($search, array('SHORT', 'LONG'));
|
||||
|
||||
$id = $this->getId();
|
||||
|
||||
@@ -76,16 +72,17 @@ class Title extends BaseI18nLoop
|
||||
|
||||
$search->orderByPosition();
|
||||
|
||||
/* perform search */
|
||||
$titles = $this->search($search, $pagination);
|
||||
return $search;
|
||||
|
||||
$loopResult = new LoopResult($titles);
|
||||
}
|
||||
|
||||
foreach ($titles as $title) {
|
||||
$loopResultRow = new LoopResultRow($loopResult, $title, $this->versionable, $this->timestampable, $this->countable);
|
||||
public function parseResults(LoopResult $loopResult)
|
||||
{
|
||||
foreach ($loopResult->getResultDataCollection() as $title) {
|
||||
$loopResultRow = new LoopResultRow($title);
|
||||
$loopResultRow->set("ID", $title->getId())
|
||||
->set("IS_TRANSLATED",$title->getVirtualColumn('IS_TRANSLATED'))
|
||||
->set("LOCALE",$locale)
|
||||
->set("LOCALE",$this->locale)
|
||||
->set("DEFAULT", $title->getByDefault())
|
||||
->set("SHORT", $title->getVirtualColumn('i18n_SHORT'))
|
||||
->set("LONG", $title->getVirtualColumn('i18n_LONG'))
|
||||
@@ -95,5 +92,6 @@ class Title extends BaseI18nLoop
|
||||
}
|
||||
|
||||
return $loopResult;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user