diff --git a/core/lib/Thelia/Core/Template/Element/BaseLoop.php b/core/lib/Thelia/Core/Template/Element/BaseLoop.php index f7a958cad..e760f8dde 100755 --- a/core/lib/Thelia/Core/Template/Element/BaseLoop.php +++ b/core/lib/Thelia/Core/Template/Element/BaseLoop.php @@ -56,6 +56,19 @@ abstract class BaseLoop ); } + public function __call($name, $arguments) { + if (substr($name, 0, 3) == 'get') { + + $argName = strtolower(substr($name, 3)); + + return $this->getArg($argName)->getValue(); + } + + throw new \InvalidArgumentException(sprintf("Unsupported magic method %s. only getArgname() is supported.", $name)); + + } + + /** * Create a new Loop * @@ -83,6 +96,7 @@ abstract class BaseLoop $faultDetails = array(); while (($argument = $this->args->current()) !== false) { + $this->args->next(); $value = isset($nameValuePairs[$argument->name]) ? $nameValuePairs[$argument->name] : null; @@ -114,8 +128,6 @@ abstract class BaseLoop } $argument->setValue($value); - - $this->args->next(); } if (!empty($faultActor)) { diff --git a/core/lib/Thelia/Core/Template/Loop/Argument/Argument.php b/core/lib/Thelia/Core/Template/Loop/Argument/Argument.php index 721dde312..5b8b99f03 100755 --- a/core/lib/Thelia/Core/Template/Loop/Argument/Argument.php +++ b/core/lib/Thelia/Core/Template/Loop/Argument/Argument.php @@ -52,11 +52,11 @@ class Argument } public function getValue() { - return $this->value; + return $this->type->getFormattedValue($this->value); } public function setValue($value) { - $this->value = $value; + $this->value = $value === null ? null : (string)$value; } public static function createAnyTypeArgument($name, $default=null, $mandatory=false, $empty=true) diff --git a/core/lib/Thelia/Core/Template/Loop/Category.php b/core/lib/Thelia/Core/Template/Loop/Category.php index a80f42549..96809f5dc 100755 --- a/core/lib/Thelia/Core/Template/Loop/Category.php +++ b/core/lib/Thelia/Core/Template/Loop/Category.php @@ -83,7 +83,7 @@ class Category extends BaseLoop new Argument( 'order', new TypeCollection( - new Type\EnumType('alpha', 'alpha_reverse', 'reverse') + new Type\EnumListType('alpha', 'alpha_reverse', 'reverse') ) ), Argument::createBooleanTypeArgument('random', 0), @@ -100,21 +100,20 @@ class Category extends BaseLoop { $search = CategoryQuery::create(); - $id = $this->getArgValue('id'); + $id = $this->getId(); if (!is_null($id)) { $search->filterById($id, Criteria::IN); } - - $parent = $this->getArgValue('parent'); + $parent = $this->getParent(); if (!is_null($parent)) { $search->filterByParent($parent); } - $current = $this->getArgValue('current'); + $current = $this->getCurrent(); if ($current === true) { $search->filterById($this->request->get("category_id")); @@ -123,38 +122,47 @@ class Category extends BaseLoop } - $exclude = $this->getArgValue('exclude'); + $exclude = $this->getExclude(); if (!is_null($exclude)) { $search->filterById($exclude, Criteria::NOT_IN); } - $link = $this->getArgValue('link'); + $link = $this->getLink(); if (!is_null($link)) { $search->filterByLink($link); } - $search->filterByVisible($this->getArgValue('visible') ? 1 : 0); + $search->filterByVisible($this->getVisible() ? 1 : 0); - switch ($this->getArgValue('order')) { - case "alpha": - $search->addAscendingOrderByColumn(\Thelia\Model\CategoryI18nPeer::TITLE); - break; - case "alpha_reverse": - $search->addDescendingOrderByColumn(\Thelia\Model\CategoryI18nPeer::TITLE); - break; - case "reverse": - $search->orderByPosition(\Criteria::DESC); - break; - default: - $search->orderByPosition(); - break; + $orders = $this->getOrder(); + + if(null === $orders) { + $search->orderByPosition(); + } else { + foreach($orders as $order) { + switch ($order) { + case "alpha": + $search->addAscendingOrderByColumn(\Thelia\Model\CategoryI18nPeer::TITLE); + break; + case "alpha_reverse": + $search->addDescendingOrderByColumn(\Thelia\Model\CategoryI18nPeer::TITLE); + break; + case "reverse": + $search->orderByPosition(\Criteria::DESC); + break; + default: + $search->orderByPosition(); + break; + } + } } + $random = $this->getRandom(); - if ($this->getArgValue('random') === true) { + if ($random === true) { $search->clearOrderByColumns(); $search->addAscendingOrderByColumn('RAND()'); } diff --git a/core/lib/Thelia/Core/Template/Loop/Feed.php b/core/lib/Thelia/Core/Template/Loop/Feed.php index 8d6626013..f76c0c049 100644 --- a/core/lib/Thelia/Core/Template/Loop/Feed.php +++ b/core/lib/Thelia/Core/Template/Loop/Feed.php @@ -44,17 +44,8 @@ class Feed extends BaseLoop public function getArgDefinitions() { return new ArgumentCollection( - new Argument( - 'url', - new TypeCollection(new Type\AnyType()) - ), - new Argument( - 'timeout', - new TypeCollection( - new Type\IntType() - ), - 10 - ) + Argument::createAnyTypeArgument('url', null, true), + Argument::createIntTypeArgument('timeout', 10) ); } @@ -73,17 +64,17 @@ class Feed extends BaseLoop } } - $feed = new \SimplePie($this->getArgValue('url'), THELIA_ROOT . 'cache/feeds'); + $feed = new \SimplePie($this->getUrl(), THELIA_ROOT . 'cache/feeds'); $feed->init(); $feed->handle_content_type(); - $feed->set_timeout($this->getArgValue('timeout')); + $feed->set_timeout($this->getTimeout()); $items = $feed->get_items(); - $limit = min(count($items), $this->getArgValue('limit')); + $limit = min(count($items), $this->getLimit()); $loopResult = new LoopResult(); diff --git a/core/lib/Thelia/Core/Template/Loop/Product.php b/core/lib/Thelia/Core/Template/Loop/Product.php index acef5a27d..001c5c750 100755 --- a/core/lib/Thelia/Core/Template/Loop/Product.php +++ b/core/lib/Thelia/Core/Template/Loop/Product.php @@ -24,7 +24,6 @@ namespace Thelia\Core\Template\Loop; use Propel\Runtime\ActiveQuery\Criteria; - use Thelia\Core\Template\Element\BaseLoop; use Thelia\Core\Template\Element\LoopResult; use Thelia\Core\Template\Element\LoopResultRow; @@ -34,8 +33,8 @@ use Thelia\Core\Template\Loop\Argument\Argument; use Thelia\Log\Tlog; use Thelia\Model\CategoryQuery; +use Thelia\Model\Map\ProductTableMap; use Thelia\Model\ProductCategoryQuery; -use Thelia\Model\ProductPeer; use Thelia\Model\ProductQuery; use Thelia\Model\ConfigQuery; use Thelia\Type\TypeCollection; @@ -80,7 +79,7 @@ class Product extends BaseLoop new Argument( 'order', new TypeCollection( - new Type\EnumType(array('alpha', 'alpha_reverse', 'reverse', 'min_price', 'max_price', 'category', 'manual', 'manual_reverse', 'ref', 'promo', 'new')) + new Type\EnumListType(array('alpha', 'alpha_reverse', 'reverse', 'min_price', 'max_price', 'manual', 'manual_reverse', 'ref', 'promo', 'new')) ) ), Argument::createBooleanTypeArgument('random', 0), @@ -97,24 +96,26 @@ class Product extends BaseLoop { $search = ProductQuery::create(); - $id = $this->getArgValue('id'); + $search->withColumn('CASE WHEN ' . ProductTableMap::PROMO . '=1 THEN ' . ProductTableMap::PRICE2 . ' ELSE ' . ProductTableMap::PRICE . ' END', 'real_price'); + + $id = $this->getId(); if (!is_null($id)) { $search->filterById($id, Criteria::IN); } - $ref = $this->getArgValue('ref'); + $ref = $this->getRef(); if (!is_null($ref)) { $search->filterByRef($ref, Criteria::IN); } - $category = $this->getArgValue('category'); + $category = $this->getCategory(); if (!is_null($category)) { $categories = CategoryQuery::create()->filterById($category, Criteria::IN)->find(); - $depth = $this->getArgValue('depth'); + $depth = $this->getDepth(); if(null !== $depth) { foreach(CategoryQuery::findAllChild($category, $depth) as $subCategory) { @@ -128,7 +129,7 @@ class Product extends BaseLoop ); } - $new = $this->getArgValue('new'); + $new = $this->getNew(); if ($new === true) { $search->filterByNewness(1, Criteria::EQUAL); @@ -136,7 +137,7 @@ class Product extends BaseLoop $search->filterByNewness(0, Criteria::EQUAL); } - $promo = $this->getArgValue('promo'); + $promo = $this->getPromo(); if ($promo === true) { $search->filterByPromo(1, Criteria::EQUAL); @@ -144,49 +145,59 @@ class Product extends BaseLoop $search->filterByNewness(0, Criteria::EQUAL); } - $min_stock = $this->getArgValue('min_stock'); + $min_stock = $this->getMin_stock(); if (null != $min_stock) { $search->filterByQuantity($min_stock, Criteria::GREATER_EQUAL); } - $min_price = $this->getArgValue('min_price'); + $min_price = $this->getMin_price(); if(null !== $min_price) { - $search->condition('in_promo', ProductPeer::PROMO . Criteria::EQUAL . '1') - ->condition('not_in_promo', ProductPeer::PROMO . Criteria::NOT_EQUAL . '1') - ->condition('min_price2', ProductPeer::PRICE2 . Criteria::GREATER_EQUAL . '?', $min_price) - ->condition('min_price', ProductPeer::PRICE . Criteria::GREATER_EQUAL . '?', $min_price) + /** + * Following should work but does not : + * + * $search->filterBy('real_price', $max_price, Criteria::GREATER_EQUAL); + */ + $search->condition('in_promo', ProductTableMap::PROMO . Criteria::EQUAL . '1') + ->condition('not_in_promo', ProductTableMap::PROMO . Criteria::NOT_EQUAL . '1') + ->condition('min_price2', ProductTableMap::PRICE2 . Criteria::GREATER_EQUAL . '?', $min_price) + ->condition('min_price', ProductTableMap::PRICE . Criteria::GREATER_EQUAL . '?', $min_price) ->combine(array('in_promo', 'min_price2'), Criteria::LOGICAL_AND, 'in_promo_min_price') ->combine(array('not_in_promo', 'min_price'), Criteria::LOGICAL_AND, 'not_in_promo_min_price') ->where(array('not_in_promo_min_price', 'in_promo_min_price'), Criteria::LOGICAL_OR); } - $max_price = $this->getArgValue('max_price'); + $max_price = $this->getMax_price(); if(null !== $max_price) { - $search->condition('in_promo', ProductPeer::PROMO . Criteria::EQUAL . '1') - ->condition('not_in_promo', ProductPeer::PROMO . Criteria::NOT_EQUAL . '1') - ->condition('max_price2', ProductPeer::PRICE2 . Criteria::LESS_EQUAL . '?', $max_price) - ->condition('max_price', ProductPeer::PRICE . Criteria::LESS_EQUAL . '?', $max_price) + /** + * Following should work but does not : + * + * $search->filterBy('real_price', $max_price, Criteria::LESS_EQUAL); + */ + $search->condition('in_promo', ProductTableMap::PROMO . Criteria::EQUAL . '1') + ->condition('not_in_promo', ProductTableMap::PROMO . Criteria::NOT_EQUAL . '1') + ->condition('max_price2', ProductTableMap::PRICE2 . Criteria::LESS_EQUAL . '?', $max_price) + ->condition('max_price', ProductTableMap::PRICE . Criteria::LESS_EQUAL . '?', $max_price) ->combine(array('in_promo', 'max_price2'), Criteria::LOGICAL_AND, 'in_promo_max_price') ->combine(array('not_in_promo', 'max_price'), Criteria::LOGICAL_AND, 'not_in_promo_max_price') ->where(array('not_in_promo_max_price', 'in_promo_max_price'), Criteria::LOGICAL_OR); } - $min_weight = $this->getArgValue('min_weight'); + $min_weight = $this->getMin_weight(); if(null !== $min_weight) { $search->filterByWeight($min_weight, Criteria::GREATER_EQUAL); } - $max_weight = $this->getArgValue('max_weight'); + $max_weight = $this->getMax_weight(); if(null !== $max_weight) { $search->filterByWeight($max_weight, Criteria::LESS_EQUAL); } - $current = $this->getArgValue('current'); + $current = $this->getCurrent(); if ($current === true) { $search->filterById($this->request->get("product_id")); @@ -194,7 +205,7 @@ class Product extends BaseLoop $search->filterById($this->request->get("product_id"), Criteria::NOT_IN); } - $current_category = $this->getArgValue('current_category'); + $current_category = $this->getCurrent_category(); if ($current_category === true) { $search->filterByCategory( @@ -220,54 +231,65 @@ class Product extends BaseLoop ); } - $search->filterByVisible($this->getArgValue('visible')); + $search->filterByVisible($this->getVisible()); - switch ($this->getArgValue('order')) { - case "alpha": - $search->addAscendingOrderByColumn(\Thelia\Model\CategoryI18nPeer::TITLE); - break; - case "alpha_reverse": - $search->addDescendingOrderByColumn(\Thelia\Model\CategoryI18nPeer::TITLE); - break; - case "reverse": - $search->orderByPosition(Criteria::DESC); - break; - case "min_price": - //$search->order - //$search->orderByPosition(Criteria::DESC); - break; - /*case "max_price": - $search->orderByPosition(Criteria::DESC); - break; - case "category": - $search->orderByPosition(Criteria::DESC); - break;*/ - case "manual": - $search->addAscendingOrderByColumn(\Thelia\Model\ProductPeer::POSITION); - break; - case "manual_reverse": - $search->addDescendingOrderByColumn(\Thelia\Model\ProductPeer::POSITION); - break; - case "ref": - $search->addAscendingOrderByColumn(\Thelia\Model\ProductPeer::REF); - break; - case "promo": - $search->addDescendingOrderByColumn(\Thelia\Model\ProductPeer::PROMO); - break; - case "new": - $search->addDescendingOrderByColumn(\Thelia\Model\ProductPeer::NEWNESS); - break; - default: - $search->orderByPosition(); - break; + $orders = $this->getOrder(); + + if(null === $orders) { + $search->orderByPosition(); + } else { + foreach($orders as $order) { + switch ($order) { + case "alpha": + $search->addAscendingOrderByColumn(\Thelia\Model\Map\CategoryI18nTableMap::TITLE); + $search->addAscendingOrderByColumn(\Thelia\Model\Map\CategoryI18nTableMap::TITLE); + break; + case "alpha_reverse": + $search->addDescendingOrderByColumn(\Thelia\Model\Map\CategoryI18nTableMap::TITLE); + break; + case "reverse": + $search->orderByPosition(Criteria::DESC); + break; + case "min_price": + $search->orderBy('real_price', Criteria::ASC); + break; + case "max_price": + $search->orderBy('real_price', Criteria::DESC); + break; + case "manual": + if(null === $this->category || count($this->category) != 1) + throw new \InvalidArgumentException('Manual order cannot be set without single category argument'); + $search->addAscendingOrderByColumn(ProductTableMap::POSITION); + break; + case "manual_reverse": + if(null === $this->category || count($this->category) != 1) + throw new \InvalidArgumentException('Manual order cannot be set without single category argument'); + $search->addDescendingOrderByColumn(ProductTableMap::POSITION); + break; + case "ref": + $search->addAscendingOrderByColumn(ProductTableMap::REF); + break; + case "promo": + $search->addDescendingOrderByColumn(ProductTableMap::PROMO); + break; + case "new": + $search->addDescendingOrderByColumn(ProductTableMap::NEWNESS); + break; + default: + $search->orderByPosition(); + break; + } + } } - if ($this->getArgValue('random') === true) { + $random = $this->getRandom(); + + if ($random === true) { $search->clearOrderByColumns(); $search->addAscendingOrderByColumn('RAND()'); } - $exclude = $this->getArgValue('exclude'); + $exclude = $this->getExclude(); if (!is_null($exclude)) { $search->filterById($exclude, Criteria::NOT_IN); diff --git a/core/lib/Thelia/Tests/Type/AlphaNumStringListTypeTest.php b/core/lib/Thelia/Tests/Type/AlphaNumStringListTypeTest.php index 22d1c52ce..2a8ba5fa0 100755 --- a/core/lib/Thelia/Tests/Type/AlphaNumStringListTypeTest.php +++ b/core/lib/Thelia/Tests/Type/AlphaNumStringListTypeTest.php @@ -42,7 +42,7 @@ class AlphaNumStringListTypeTest extends \PHPUnit_Framework_TestCase public function testFormatAlphaNumStringListType() { $type = new AlphaNumStringListType(); - $this->assertTrue(is_array($type->getFormatedValue('FOO1,FOO_2,FOO-3'))); - $this->assertNull($type->getFormatedValue('5€')); + $this->assertTrue(is_array($type->getFormattedValue('FOO1,FOO_2,FOO-3'))); + $this->assertNull($type->getFormattedValue('5€')); } } diff --git a/core/lib/Thelia/Tests/Type/BooleanTypeTest.php b/core/lib/Thelia/Tests/Type/BooleanTypeTest.php index 84889ff40..d91cc6bc9 100755 --- a/core/lib/Thelia/Tests/Type/BooleanTypeTest.php +++ b/core/lib/Thelia/Tests/Type/BooleanTypeTest.php @@ -48,8 +48,8 @@ class BooleanTypeTest extends \PHPUnit_Framework_TestCase public function testFormatBooleanType() { $booleanType = new BooleanType(); - $this->assertTrue($booleanType->getFormatedValue('yes')); - $this->assertFalse($booleanType->getFormatedValue('no')); - $this->assertNull($booleanType->getFormatedValue('foo')); + $this->assertTrue($booleanType->getFormattedValue('yes')); + $this->assertFalse($booleanType->getFormattedValue('no')); + $this->assertNull($booleanType->getFormattedValue('foo')); } } diff --git a/core/lib/Thelia/Tests/Type/EnumListTypeTest.php b/core/lib/Thelia/Tests/Type/EnumListTypeTest.php new file mode 100755 index 000000000..a992fb0bd --- /dev/null +++ b/core/lib/Thelia/Tests/Type/EnumListTypeTest.php @@ -0,0 +1,50 @@ +. */ +/* */ +/*************************************************************************************/ + +namespace Thelia\Tests\Type; + +use Thelia\Type\EnumListType; + +/** + * + * @author Etienne Roudeix + * + */ +class EnumListTypeTest extends \PHPUnit_Framework_TestCase +{ + public function testEnumListType() + { + $enumListType = new EnumListType(array("cat", "dog", "frog")); + $this->assertTrue($enumListType->isValid('cat')); + $this->assertTrue($enumListType->isValid('cat,dog')); + $this->assertFalse($enumListType->isValid('potato')); + $this->assertFalse($enumListType->isValid('cat,monkey')); + } + + public function testFormatEnumListType() + { + $enumListType = new EnumListType(array("cat", "dog", "frog")); + $this->assertTrue(is_array($enumListType->getFormattedValue('cat,dog'))); + $this->assertNull($enumListType->getFormattedValue('cat,monkey')); + } +} diff --git a/core/lib/Thelia/Tests/Type/IntListTypeTest.php b/core/lib/Thelia/Tests/Type/IntListTypeTest.php index 6f9cc1e99..80ffa3e2e 100755 --- a/core/lib/Thelia/Tests/Type/IntListTypeTest.php +++ b/core/lib/Thelia/Tests/Type/IntListTypeTest.php @@ -43,7 +43,7 @@ class IntListTypeTest extends \PHPUnit_Framework_TestCase public function testFormatIntListType() { $intListType = new IntListType(); - $this->assertTrue(is_array($intListType->getFormatedValue('1,2,3'))); - $this->assertNull($intListType->getFormatedValue('foo')); + $this->assertTrue(is_array($intListType->getFormattedValue('1,2,3'))); + $this->assertNull($intListType->getFormattedValue('foo')); } } diff --git a/core/lib/Thelia/Tests/Type/JsonTypeTest.php b/core/lib/Thelia/Tests/Type/JsonTypeTest.php index 2dc15a2f5..79b2c59b8 100755 --- a/core/lib/Thelia/Tests/Type/JsonTypeTest.php +++ b/core/lib/Thelia/Tests/Type/JsonTypeTest.php @@ -42,7 +42,7 @@ class JsonTypeTest extends \PHPUnit_Framework_TestCase public function testFormatJsonType() { $jsonType = new JsonType(); - $this->assertTrue(is_array($jsonType->getFormatedValue('{"k0":"v0","k1":"v1","k2":"v2"}'))); - $this->assertNull($jsonType->getFormatedValue('foo')); + $this->assertTrue(is_array($jsonType->getFormattedValue('{"k0":"v0","k1":"v1","k2":"v2"}'))); + $this->assertNull($jsonType->getFormattedValue('foo')); } } diff --git a/core/lib/Thelia/Type/AlphaNumStringListType.php b/core/lib/Thelia/Type/AlphaNumStringListType.php index 1fa210cba..41af21e07 100755 --- a/core/lib/Thelia/Type/AlphaNumStringListType.php +++ b/core/lib/Thelia/Type/AlphaNumStringListType.php @@ -45,7 +45,7 @@ class AlphaNumStringListType implements TypeInterface return true; } - public function getFormatedValue($values) + public function getFormattedValue($values) { return $this->isValid($values) ? explode(',', $values) : null; } diff --git a/core/lib/Thelia/Type/AlphaNumStringType.php b/core/lib/Thelia/Type/AlphaNumStringType.php index b893f8a46..963237cb0 100755 --- a/core/lib/Thelia/Type/AlphaNumStringType.php +++ b/core/lib/Thelia/Type/AlphaNumStringType.php @@ -40,7 +40,7 @@ class AlphaNumStringType implements TypeInterface return preg_match('#^[a-zA-Z0-9\-_]+$#', $value) ? true : false; } - public function getFormatedValue($value) + public function getFormattedValue($value) { return $this->isValid($value) ? $value : null; } diff --git a/core/lib/Thelia/Type/AnyType.php b/core/lib/Thelia/Type/AnyType.php index 8e22d44eb..ca0a14616 100755 --- a/core/lib/Thelia/Type/AnyType.php +++ b/core/lib/Thelia/Type/AnyType.php @@ -40,7 +40,7 @@ class AnyType implements TypeInterface return true; } - public function getFormatedValue($value) + public function getFormattedValue($value) { return $value; } diff --git a/core/lib/Thelia/Type/BooleanType.php b/core/lib/Thelia/Type/BooleanType.php index 939ff0d79..0c85d3ba8 100755 --- a/core/lib/Thelia/Type/BooleanType.php +++ b/core/lib/Thelia/Type/BooleanType.php @@ -53,7 +53,7 @@ class BooleanType implements TypeInterface return in_array($value, $this->trueValuesArray) || in_array($value, $this->falseValuesArray); } - public function getFormatedValue($value) + public function getFormattedValue($value) { return $this->isValid($value) ? ( in_array($value, $this->trueValuesArray) ) : null; } diff --git a/core/lib/Thelia/Type/EnumListType.php b/core/lib/Thelia/Type/EnumListType.php new file mode 100755 index 000000000..1603dc89f --- /dev/null +++ b/core/lib/Thelia/Type/EnumListType.php @@ -0,0 +1,65 @@ +. */ +/* */ +/*************************************************************************************/ +namespace Thelia\Type; + +/** + * + * @author Etienne Roudeix + * + */ + +class EnumListType implements TypeInterface +{ + protected $values = array(); + + public function __construct($values = array()) + { + if(is_array($values)) + $this->values = $values; + } + + public function getType() + { + return 'Enum list type'; + } + + public function isValid($values) + { + foreach(explode(',', $values) as $value) { + if(!$this->isSingleValueValid($value)) + return false; + } + + return true; + } + + public function getFormattedValue($values) + { + return $this->isValid($values) ? explode(',', $values) : null; + } + + public function isSingleValueValid($value) + { + return in_array($value, $this->values); + } +} diff --git a/core/lib/Thelia/Type/EnumType.php b/core/lib/Thelia/Type/EnumType.php index 0aff0ec88..ce9914038 100755 --- a/core/lib/Thelia/Type/EnumType.php +++ b/core/lib/Thelia/Type/EnumType.php @@ -48,7 +48,7 @@ class EnumType implements TypeInterface return in_array($value, $this->values); } - public function getFormatedValue($value) + public function getFogetFormattedValuermatedValue($value) { return $this->isValid($value) ? $value : null; } diff --git a/core/lib/Thelia/Type/FloatType.php b/core/lib/Thelia/Type/FloatType.php index 83d3561a4..3c10df86c 100755 --- a/core/lib/Thelia/Type/FloatType.php +++ b/core/lib/Thelia/Type/FloatType.php @@ -40,7 +40,7 @@ class FloatType implements TypeInterface return filter_var($value, FILTER_VALIDATE_FLOAT) === false ? false : true; } - public function getFormatedValue($value) + public function getFormattedValue($value) { return $this->isValid($value) ? $value : null; } diff --git a/core/lib/Thelia/Type/IntListType.php b/core/lib/Thelia/Type/IntListType.php index b023173f7..cd4eadf22 100755 --- a/core/lib/Thelia/Type/IntListType.php +++ b/core/lib/Thelia/Type/IntListType.php @@ -45,7 +45,7 @@ class IntListType implements TypeInterface return true; } - public function getFormatedValue($values) + public function getFormattedValue($values) { return $this->isValid($values) ? explode(',', $values) : null; } diff --git a/core/lib/Thelia/Type/IntType.php b/core/lib/Thelia/Type/IntType.php index 4adc2e10e..c2d6dcfa8 100755 --- a/core/lib/Thelia/Type/IntType.php +++ b/core/lib/Thelia/Type/IntType.php @@ -40,7 +40,7 @@ class IntType implements TypeInterface return filter_var($value, FILTER_VALIDATE_INT) === false ? false : true; } - public function getFormatedValue($value) + public function getFormattedValue($value) { return $this->isValid($value) ? $value : null; } diff --git a/core/lib/Thelia/Type/JsonType.php b/core/lib/Thelia/Type/JsonType.php index 397967df9..39ee57d53 100755 --- a/core/lib/Thelia/Type/JsonType.php +++ b/core/lib/Thelia/Type/JsonType.php @@ -41,7 +41,7 @@ class JsonType implements TypeInterface return (json_last_error() == JSON_ERROR_NONE); } - public function getFormatedValue($value) + public function getFormattedValue($value) { return $this->isValid($value) ? json_decode($value, true) : null; } diff --git a/core/lib/Thelia/Type/TypeCollection.php b/core/lib/Thelia/Type/TypeCollection.php index bff384f92..460d9b96e 100755 --- a/core/lib/Thelia/Type/TypeCollection.php +++ b/core/lib/Thelia/Type/TypeCollection.php @@ -133,10 +133,10 @@ class TypeCollection implements \Iterator return false; } - public function getFormatedValue($value) { + public function getFormattedValue($value) { foreach($this as $type) { if($type->isValid($value)) { - return $type->getFormatedValue($value); + return $type->getFormattedValue($value); } } diff --git a/core/lib/Thelia/Type/TypeInterface.php b/core/lib/Thelia/Type/TypeInterface.php index 9268df7d5..b2ba11a4b 100755 --- a/core/lib/Thelia/Type/TypeInterface.php +++ b/core/lib/Thelia/Type/TypeInterface.php @@ -34,5 +34,5 @@ interface TypeInterface public function isValid($value); - public function getFormatedValue($value); + public function getFormattedValue($value); } diff --git a/templates/smarty-sample/category.html b/templates/smarty-sample/category.html index 594be9cc6..1589036a4 100755 --- a/templates/smarty-sample/category.html +++ b/templates/smarty-sample/category.html @@ -19,7 +19,7 @@
{/loop*}

PRODUCTS

-{loop name="product" type="product" order="min_price"} +{loop name="product" type="product" order="promo,min_price"}

PRODUCT : #REF / #TITLE

price : #PRICE €
promo price : #PROMO_PRICE €