fix typo in method name

This commit is contained in:
Manuel Raynaud
2013-08-09 09:14:25 +02:00
parent 376471db04
commit cdf28e66cf
1177 changed files with 173536 additions and 140140 deletions

View File

@@ -80,7 +80,7 @@ abstract class BaseLoop
return array(
Argument::createIntTypeArgument('offset', 0),
Argument::createIntTypeArgument('page'),
Argument::createIntTypeArgument('limit', 10),
Argument::createIntTypeArgument('limit', PHP_INT_MAX),
);
}

View File

@@ -111,6 +111,19 @@ class Argument
);
}
public static function createBooleanOrBothTypeArgument($name, $default=null, $mandatory=false, $empty=true)
{
return new Argument(
$name,
new TypeCollection(
new Type\BooleanOrBothType()
),
$default,
$mandatory,
$empty
);
}
public static function createIntListTypeArgument($name, $default=null, $mandatory=false, $empty=true)
{
return new Argument(

View File

@@ -11,8 +11,37 @@ namespace Thelia\Core\Template\Loop;
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;
class Cart extends BaseLoop {
use \Thelia\Cart\CartTrait;
/**
*
* define all args used in your loop
*
* array key is your arg name.
*
* example :
*
* return array (
* "ref",
* "id" => "optional",
* "stock" => array(
* "optional",
* "default" => 10
* )
* );
*
* @return \Thelia\Core\Template\Loop\Argument\ArgumentCollection
*/
protected function getArgDefinitions()
{
return new ArgumentCollection(
);
}
/**
*
@@ -42,30 +71,33 @@ class Cart extends BaseLoop {
*/
public function exec(&$pagination)
{
// TODO: Implement exec() method.
$result = new LoopResult();
$cart = $this->getCart($this->request);
if($cart === null) {
return $result;
}
$cartItems = $cart->getCartItems();
foreach ($cartItems as $cartItem) {
$product = $cartItem->getProduct();
//$product->setLocale($this->request->getSession()->getLocale());
$loopResultRow = new LoopResultRow();
$loopResultRow->set("ITEM_ID", $cartItem->getId());
$loopResultRow->set("TITLE", $product->getTitle());
$loopResultRow->set("REF", $product->getRef());
$loopResultRow->set("QUANTITY", $cartItem->getQuantity());
$loopResultRow->set("PRICE", $cartItem->getPrice());
$loopResultRow->set("PRODUCT_ID", $product->getId());
$result->addRow($loopResultRow);
}
return $result;
}
/**
*
* define all args used in your loop
*
* array key is your arg name.
*
* example :
*
* return array (
* "ref",
* "id" => "optional",
* "stock" => array(
* "optional",
* "default" => 10
* )
* );
*
* @return \Thelia\Core\Template\Loop\Argument\ArgumentCollection
*/
protected function getArgDefinitions()
{
// TODO: Implement getArgDefinitions() method.
}
}

View File

@@ -36,6 +36,7 @@ use Thelia\Model\CategoryQuery;
use Thelia\Model\ConfigQuery;
use Thelia\Type\TypeCollection;
use Thelia\Type;
use Thelia\Type\BooleanOrBothType;
/**
*
@@ -73,7 +74,7 @@ class Category extends BaseLoop
Argument::createIntTypeArgument('parent'),
Argument::createBooleanTypeArgument('current'),
Argument::createBooleanTypeArgument('not_empty', 0),
Argument::createBooleanTypeArgument('visible', 1),
Argument::createBooleanOrBothTypeArgument('visible', 1),
new Argument(
'order',
new TypeCollection(
@@ -122,7 +123,8 @@ class Category extends BaseLoop
$search->filterById($exclude, Criteria::NOT_IN);
}
$search->filterByVisible($this->getVisible() ? 1 : 0);
if ($this->getVisible() != BooleanOrBothType::ANY)
$search->filterByVisible($this->getVisible() ? 1 : 0);
$orders = $this->getOrder();

View File

@@ -36,6 +36,7 @@ use Thelia\Model\CategoryQuery;
use Thelia\Model\ConfigQuery;
use Thelia\Type\TypeCollection;
use Thelia\Type;
use Thelia\Type\BooleanOrBothType;
/**
*
@@ -68,7 +69,7 @@ class CategoryPath extends BaseLoop
Argument::createIntTypeArgument('category', null, true),
Argument::createIntTypeArgument('depth'),
Argument::createIntTypeArgument('level'),
Argument::createBooleanTypeArgument('visible', true, false)
Argument::createBooleanOrBothTypeArgument('visible', true, false)
);
}
@@ -84,10 +85,12 @@ class CategoryPath extends BaseLoop
$search = CategoryQuery::create();
$search->filterById($id);
if ($visible == true) $search->filterByVisible($visible);
if ($visible != BooleanOrBothType::ANY) $search->filterByVisible($visible);
$results = array();
$ids = array();
do {
$category = $search->findOne();
@@ -106,6 +109,14 @@ class CategoryPath extends BaseLoop
$parent = $category->getParent();
if ($parent > 0) {
// Prevent circular refererences
if (in_array($parent, $ids)) {
throw new \LogicException(sprintf("Circular reference detected in category ID=%d hierarchy (category ID=%d appears more than one times in path)", $id, $parent));
}
$ids[] = $parent;
$search = CategoryQuery::create();
$search->filterById($parent);
if ($visible == true) $search->filterByVisible($visible);

View File

@@ -41,6 +41,7 @@ use Thelia\Model\ContentQuery;
use Thelia\Model\ConfigQuery;
use Thelia\Type\TypeCollection;
use Thelia\Type;
use Thelia\Type\BooleanOrBothType;
/**
*
@@ -64,7 +65,7 @@ class Content extends BaseLoop
Argument::createBooleanTypeArgument('current'),
Argument::createBooleanTypeArgument('current_folder'),
Argument::createIntTypeArgument('depth', 1),
Argument::createBooleanTypeArgument('visible', 1),
Argument::createBooleanOrBothTypeArgument('visible', 1),
new Argument(
'order',
new TypeCollection(
@@ -148,7 +149,7 @@ class Content extends BaseLoop
$visible = $this->getVisible();
$search->filterByVisible($visible);
if ($visible != BooleanOrBothType::ANY) $search->filterByVisible($visible);
$orders = $this->getOrder();

View File

@@ -40,6 +40,7 @@ use Thelia\Model\ConfigQuery;
use Thelia\Model\Map\ProductCategoryTableMap;
use Thelia\Type\TypeCollection;
use Thelia\Type;
use Thelia\Type\BooleanOrBothType;
/**
*
@@ -61,7 +62,7 @@ class Feature extends BaseLoop
Argument::createIntListTypeArgument('id'),
Argument::createIntListTypeArgument('product'),
Argument::createIntListTypeArgument('category'),
Argument::createBooleanTypeArgument('visible', 1),
Argument::createBooleanOrBothTypeArgument('visible', 1),
Argument::createIntListTypeArgument('exclude'),
new Argument(
'order',
@@ -96,7 +97,7 @@ class Feature extends BaseLoop
$visible = $this->getVisible();
$search->filterByVisible($visible);
if ($visible != BooleanOrBothType::ANY) $search->filterByVisible($visible);
$product = $this->getProduct();
$category = $this->getCategory();

View File

@@ -36,6 +36,7 @@ use Thelia\Model\FolderQuery;
use Thelia\Model\ConfigQuery;
use Thelia\Type\TypeCollection;
use Thelia\Type;
use Thelia\Type\BooleanOrBothType;
/**
* Class Folder
@@ -55,7 +56,7 @@ class Folder extends BaseLoop
Argument::createIntTypeArgument('parent'),
Argument::createBooleanTypeArgument('current'),
Argument::createBooleanTypeArgument('not_empty', 0),
Argument::createBooleanTypeArgument('visible', 1),
Argument::createBooleanOrBothTypeArgument('visible', 1),
new Argument(
'order',
new TypeCollection(
@@ -104,7 +105,9 @@ class Folder extends BaseLoop
$search->filterById($exclude, Criteria::NOT_IN);
}
$search->filterByVisible($this->getVisible() ? 1 : 0);
$visible = $this->getVisible();
if ($visible != BooleanOrBothType::ANY) $search->filterByVisible($visible ? 1 : 0);
$orders = $this->getOrder();

View File

@@ -44,6 +44,7 @@ use Thelia\Model\ProductQuery;
use Thelia\Model\ConfigQuery;
use Thelia\Type\TypeCollection;
use Thelia\Type;
use Thelia\Type\BooleanOrBothType;
/**
*
@@ -80,7 +81,7 @@ class Product extends BaseLoop
Argument::createBooleanTypeArgument('current'),
Argument::createBooleanTypeArgument('current_category'),
Argument::createIntTypeArgument('depth', 1),
Argument::createBooleanTypeArgument('visible', 1),
Argument::createBooleanOrBothTypeArgument('visible', 1),
new Argument(
'order',
new TypeCollection(
@@ -252,11 +253,10 @@ class Product extends BaseLoop
$visible = $this->getVisible();
$search->filterByVisible($visible);
if ($visible != BooleanOrBothType::ANY) $search->filterByVisible($visible ? 1 : 0);
$orders = $this->getOrder();
foreach($orders as $order) {
switch ($order) {
case "alpha":

View File

@@ -101,7 +101,8 @@ class Form extends AbstractSmartyPlugin
// Re-use the errored form
$instance = $errorForm;
$this->parserContext->clearErrorForm();
// Don't do that, as we may want to use this form firther in the template code
//$this->parserContext->clearErrorForm();
}
$instance->createView();

View File

@@ -49,7 +49,7 @@ class UrlGenerator extends AbstractSmartyPlugin
// the path to process
$path = $this->getParam($params, 'path');
return URL::absoluteUrl($path, $this->getArgsFromParam($params));
return URL::absoluteUrl($path, $this->getArgsFromParam($params, array('path')));
}
/**
@@ -84,7 +84,7 @@ class UrlGenerator extends AbstractSmartyPlugin
// the related action (optionale)
$action = $this->getParam($params, 'action');
$args = $this->getArgsFromParam($params);
$args = $this->getArgsFromParam($params, array('view', 'action'));
if (! empty($action)) $args['action'] = $action;
@@ -92,17 +92,23 @@ class UrlGenerator extends AbstractSmartyPlugin
}
/**
* Get URL parameters array from a comma separated list or arguments in the
* parameters.
* Get URL parameters array from parameters.
*
* @param array $params Smarty function params
* @return array the parameters array (either emply, of valued)
*/
private function getArgsFromParam($params) {
private function getArgsFromParam($params, $exclude = array()) {
$args = $this->getParam($params, array('arguments', 'args'));
$pairs = array();
return $args !== null ? explode($args, ',') : array();
foreach($params as $name => $value) {
if (in_array($name, $exclude)) continue;
$pairs[$name] = $value;
}
return $pairs;
}
/**