Merge branch 'admin'

Conflicts:
	core/lib/Thelia/Admin/Controller/BaseAdminController.php
	core/lib/Thelia/Config/Resources/config.xml
	core/lib/Thelia/Core/Template/Element/BaseLoop.php
	core/lib/Thelia/Core/Template/Loop/Category.php
	core/lib/Thelia/Core/Template/Smarty/Plugins/TheliaLoop.php
	core/lib/Thelia/Model/Admin.php
	core/lib/Thelia/Model/Customer.php
This commit is contained in:
franck
2013-07-08 11:27:37 +02:00
62 changed files with 752 additions and 282 deletions

View File

@@ -31,7 +31,9 @@
"smarty/smarty": "v3.1.13",
"kriswallsmith/assetic": "1.2.*@dev",
"leafo/lessphp": "0.3.*@dev",
"ptachoire/cssembed": "dev-master"
"ptachoire/cssembed": "dev-master",
"simplepie/simplepie": "dev-master"
},
"require-dev" : {
"fzaninotto/faker": "dev-master"

View File

@@ -79,4 +79,14 @@ class BaseAdminController extends ContainerAware
return $parser;
}
public function getFormFactory()
{
return BaseForm::getFormFactory($this->getRequest(), ConfigQuery::read("form.secret.admin", md5(__DIR__)));
}
public function getFormBuilder()
{
return $this->getFormFactory()->createBuilder("form");
}
}

View File

@@ -7,6 +7,7 @@
<loops>
<loop class="Thelia\Core\Template\Loop\Category" name="category"/>
<loop class="Thelia\Core\Template\Loop\Product" name="product"/>
<loop class="Thelia\Core\Template\Loop\Feed" name="feed"/>
</loops>

View File

@@ -0,0 +1,41 @@
<?php
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace use Thelia\Core\Security\Role;
/**
* Role is a simple implementation of a RoleInterface where the role is a
* string.
*
* @author Fabien Potencier <fabien@symfony.com>
*/
class Role implements RoleInterface
{
private $role;
/**
* Constructor.
*
* @param string $role The role name
*/
public function __construct($role)
{
$this->role = (string) $role;
}
/**
* {@inheritdoc}
*/
public function getRole()
{
return $this->role;
}
}

View File

@@ -0,0 +1,35 @@
<?php
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Thelia\Core\Security\Role;
/**
* RoleInterface represents a role granted to a user.
*
* A role must either have a string representation or it needs to be explicitly
* supported by at least one AccessDecisionManager.
*
* @author Fabien Potencier <fabien@symfony.com>
*/
interface RoleInterface
{
/**
* Returns the role.
*
* This method returns a string representation whenever possible.
*
* When the role cannot be represented with sufficient precision by a
* string, it should return null.
*
* @return string|null A string representation of the role, or null
*/
public function getRole();
}

View File

@@ -30,6 +30,20 @@ interface UserInterface {
*/
public function getAlgo();
/**
* Returns the roles granted to the user.
*
* <code>
* public function getRoles()
* {
* return array('ROLE_USER');
* }
* </code>
*
* @return Role[] The user roles
*/
public function getRoles();
/**
* Removes sensitive data from the user.
*

View File

@@ -38,16 +38,14 @@ abstract class BaseLoop
/**
* @var \Symfony\Component\HttpFoundation\Request
*/
public $request;
protected $request;
/**
* @var \Symfony\Component\EventDispatcher\EventDispatcherInterface
*/
public $dispatcher;
protected $dispatcher;
public $limit;
public $page;
public $offset;
private $args;
protected function getDefaultArgs()
{
@@ -59,6 +57,8 @@ abstract class BaseLoop
}
/**
* Create a new Loop
*
* @param \Symfony\Component\HttpFoundation\Request $request
* @param \Symfony\Component\EventDispatcher\EventDispatcherInterface $dispatcher
*/
@@ -66,14 +66,94 @@ abstract class BaseLoop
{
$this->request = $request;
$this->dispatcher = $dispatcher;
$this->args = $this->getArgDefinitions()->addArguments($this->getDefaultArgs());
}
/**
* @return \Thelia\Core\Template\Loop\Argument\ArgumentCollection
* Initialize the loop arguments.
*
* @param array $nameValuePairs a array of name => value pairs. The name is the name of the argument.
*
* @throws \InvalidArgumentException if somùe argument values are missing, or invalid
*/
public function getArgs()
{
return $this->defineArgs()->addArguments($this->getDefaultArgs());
public function initializeArgs(array $nameValuePairs) {
$faultActor = array();
$faultDetails = array();
while (($argument = $this->args->current()) !== false) {
$value = isset($nameValuePairs[$argument->name]) ? $nameValuePairs[$argument->name] : null;
/* check if mandatory */
if($value === null && $argument->mandatory) {
$faultActor[] = $argument->name;
$faultDetails[] = sprintf('"%s" parameter is missing', $argument->name);
continue;
}
/* check if empty */
if($value === '' && !$argument->empty) {
$faultActor[] = $argument->name;
$faultDetails[] = sprintf('"%s" parameter cannot be empty', $argument->name);
continue;
}
/* check type */
if($value !== null && !$argument->type->isValid($value)) {
$faultActor[] = $argument->name;
$faultDetails[] = sprintf('Invalid value for "%s" argument', $argument->name);
continue;
}
/* set default */
/* did it as last checking for we consider default value is acceptable no matter type or empty restriction */
if($value === null) {
$value = $argument->default;
}
$argument->setValue($value);
$this->args->next();
}
if (!empty($faultActor)) {
$complement = sprintf('[%s]', implode(', ', $faultDetails));
throw new \InvalidArgumentException($complement);
}
}
/**
* Return a loop argument
*
* @param string $argumentName the argument name
*
* @throws \InvalidArgumentException if argument is not found in loop argument list
* @return Argument the loop argument.
*/
public function getArg($argumentName) {
$arg = $this->args->get($argumentName);
if ($arg === null)
throw new \InvalidArgumentException("Undefined loop argument '$argumentName'");
return $arg;
}
/**
* Return a loop argument value
*
* @param string $argumentName the argument name
*
* @throws \InvalidArgumentException if argument is not found in loop argument list
* @return Argument the loop argument.
*/
public function getArgValue($argumentName) {
return $this->getArg($argumentName)->getValue();
}
/**
@@ -84,7 +164,7 @@ abstract class BaseLoop
*/
public function search(ModelCriteria $search, &$pagination = null)
{
if($this->page !== null) {
if($this->getArgValue('page') !== null) {
return $this->searchWithPagination($search, $pagination);
} else {
return $this->searchWithOffset($search);
@@ -98,10 +178,10 @@ abstract class BaseLoop
*/
public function searchWithOffset(ModelCriteria $search)
{
if($this->limit >= 0) {
$search->limit($this->limit);
if($this->getArgValue('limit') >= 0) {
$search->limit($this->getArgValue('limit'));
}
$search->offset($this->offset);
$search->offset($this->getArgValue('offset'));
return $search->find();
}
@@ -114,9 +194,9 @@ abstract class BaseLoop
*/
public function searchWithPagination(ModelCriteria $search, &$pagination)
{
$pagination = $search->paginate($this->page, $this->limit);
$pagination = $search->paginate($this->getArgValue('page'), $this->getArgValue('limit'));
if($this->page > $pagination->getLastPage()) {
if($this->getArgValue('page') > $pagination->getLastPage()) {
return array();
} else {
return $pagination;
@@ -148,7 +228,8 @@ abstract class BaseLoop
* @param $pagination
*
* @return mixed
*/abstract public function exec(&$pagination);
*/
abstract public function exec(&$pagination);
/**
*
@@ -169,6 +250,6 @@ abstract class BaseLoop
*
* @return \Thelia\Core\Template\Loop\Argument\ArgumentCollection
*/
abstract protected function defineArgs();
abstract protected function getArgDefinitions();
}

View File

@@ -38,12 +38,25 @@ class Argument
public $mandatory;
public $empty;
public function __construct($name, \Thelia\Type\TypeCollection $type, $default = null, $mandatory = false, $empty = true)
private $value;
public function __construct($name, \Thelia\Type\TypeCollection $type, $default = null, $mandatory = false, $empty = true, $value = null)
{
$this->name = $name;
$this->type = $type;
$this->mandatory = $mandatory ? true : false;
$this->default = $default;
$this->empty = $empty;
$this->setValue($value);
}
public function getValue() {
return $this->value;
}
public function setValue($value) {
$this->value = $value;
}
public static function createAnyTypeArgument($name, $default=null, $mandatory=false, $empty=true)

View File

@@ -30,14 +30,21 @@ namespace Thelia\Core\Template\Loop\Argument;
class ArgumentCollection implements \Iterator
{
private $position;
protected $arguments = array();
private $arguments = array();
public function __construct()
{
$this->addArguments(func_get_args());
}
public function hasKey($key) {
return isset($this->arguments[$key]);
}
public function get($key) {
return $this->hasKey($key) ? $this->arguments[$key] : null;
}
public function isEmpty()
{
return count($this->arguments) == 0;
@@ -64,7 +71,8 @@ class ArgumentCollection implements \Iterator
*/
public function addArgument(Argument $argument)
{
$this->arguments[] = $argument;
$this->arguments[$argument->name] = $argument;
return $this;
}
@@ -81,7 +89,7 @@ class ArgumentCollection implements \Iterator
*/
public function current()
{
return $this->arguments[$this->position];
return current($this->arguments);
}
/**
@@ -92,7 +100,7 @@ class ArgumentCollection implements \Iterator
*/
public function next()
{
$this->position++;
next($this->arguments);
}
/**
@@ -103,7 +111,7 @@ class ArgumentCollection implements \Iterator
*/
public function key()
{
return $this->position;
return key($this->arguments);
}
/**
@@ -115,7 +123,7 @@ class ArgumentCollection implements \Iterator
*/
public function valid()
{
return isset($this->arguments[$this->position]);
return $this->key() !== null;
}
/**
@@ -126,6 +134,6 @@ class ArgumentCollection implements \Iterator
*/
public function rewind()
{
$this->position = 0;
reset($this->arguments);
}
}

View File

@@ -68,20 +68,10 @@ use Thelia\Type;
*/
class Category extends BaseLoop
{
public $id;
public $parent;
public $current;
public $not_empty;
public $visible;
public $link;
public $order;
public $random;
public $exclude;
/**
* @return ArgumentCollection
*/
protected function defineArgs()
protected function getArgDefinitions()
{
return new ArgumentCollection(
Argument::createIntListTypeArgument('id'),
@@ -110,31 +100,45 @@ class Category extends BaseLoop
{
$search = CategoryQuery::create();
if (!is_null($this->id)) {
$search->filterById($this->id, Criteria::IN);
$id = $this->getArgValue('id');
if (!is_null($id)) {
$search->filterById($id, Criteria::IN);
}
if (!is_null($this->parent)) {
$search->filterByParent($this->parent);
$parent = $this->getArgValue('parent');
if (!is_null($parent)) {
$search->filterByParent($parent);
}
if ($this->current === true) {
$current = $this->getArgValue('current');
if ($current === true) {
$search->filterById($this->request->get("category_id"));
} elseif ($this->current === false) {
} elseif ($current === false) {
$search->filterById($this->request->get("category_id"), Criteria::NOT_IN);
}
if (!is_null($this->exclude)) {
$search->filterById($this->exclude, Criteria::NOT_IN);
$exclude = $this->getArgValue('exclude');
if (!is_null($exclude)) {
$search->filterById($exclude, Criteria::NOT_IN);
}
if (!is_null($this->link)) {
$search->filterByLink($this->link);
$link = $this->getArgValue('link');
if (!is_null($link)) {
$search->filterByLink($link);
}
$search->filterByVisible($this->visible ? 1 : 0);
$search->filterByVisible($this->getArgValue('visible') ? 1 : 0);
switch ($this->order) {
switch ($this->getArgValue('order')) {
case "alpha":
$search->addAscendingOrderByColumn(\Thelia\Model\CategoryI18nPeer::TITLE);
break;
@@ -149,7 +153,8 @@ class Category extends BaseLoop
break;
}
if ($this->random === true) {
if ($this->getArgValue('random') === true) {
$search->clearOrderByColumns();
$search->addAscendingOrderByColumn('RAND()');
}
@@ -161,7 +166,7 @@ class Category extends BaseLoop
*/
$search->joinWithI18n(
$this->request->getSession()->get('locale', 'en_US'),
$this->request->getSession()->getLocale(),
(ConfigQuery::read("default_lang_without_translation", 1)) ? Criteria::LEFT_JOIN : Criteria::INNER_JOIN
);
@@ -189,5 +194,4 @@ class Category extends BaseLoop
return $loopResult;
}
}

View File

@@ -0,0 +1,115 @@
<?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\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;
use Thelia\Core\Template\Loop\Argument\Argument;
use Thelia\Type\TypeCollection;
use Thelia\Type;
/**
*
* @package Thelia\Core\Template\Loop
*
* @author Franck Allimant <franck@cqfdev.fr>
*/
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
)
);
}
/**
*
*
* @return \Thelia\Core\Template\Element\LoopResult
*/
public function exec(&$pagination)
{
$cachedir = THELIA_ROOT . 'cache/feeds';
if (! is_dir($cachedir)) {
if (! mkdir($cachedir)) {
throw new \Exception(sprintf("Failed to create cache directory '%s'", $cachedir));
}
}
$feed = new \SimplePie($this->getArgValue('url'), THELIA_ROOT . 'cache/feeds');
$feed->init();
$feed->handle_content_type();
$feed->set_timeout($this->getArgValue('timeout'));
$items = $feed->get_items();
$limit = min(count($items), $this->getArgValue('limit'));
$loopResult = new LoopResult();
for($idx = 0; $idx < $limit; $idx++) {
$item = $items[$idx];
$link = $item->get_permalink();
$title = $item->get_title();
$author = $item->get_author();
$description = $item->get_description();
$date = $item->get_date('d/m/Y');
$loopResultRow = new LoopResultRow();
$loopResultRow->set("URL", $item->get_permalink());
$loopResultRow->set("TITLE", $item->get_title());
$loopResultRow->set("AUTHOR", $item->get_author());
$loopResultRow->set("DESCRIPTION", $item->get_description());
$loopResultRow->set("DATE", $item->get_date('d/m/Y')); // FIXME - date format should be an intl parameter
$loopResult->addRow($loopResultRow);
}
return $loopResult;
}
}

View File

@@ -52,24 +52,6 @@ use Thelia\Type;
*/
class Product extends BaseLoop
{
public $id;
public $ref;
public $category;
public $new;
public $promo;
public $min_price;
public $max_price;
public $min_stock;
public $min_weight;
public $max_weight;
public $current;
public $current_category;
public $depth;
public $visible;
public $order;
public $random;
public $exclude;
/**
* @return ArgumentCollection
*/
@@ -115,19 +97,27 @@ class Product extends BaseLoop
{
$search = ProductQuery::create();
if (!is_null($this->id)) {
$search->filterById($this->id, Criteria::IN);
$id = $this->getArgValue('id');
if (!is_null($id)) {
$search->filterById($id, Criteria::IN);
}
if (!is_null($this->ref)) {
$search->filterByRef($this->ref, Criteria::IN);
$ref = $this->getArgValue('ref');
if (!is_null($ref)) {
$search->filterByRef($ref, Criteria::IN);
}
if (!is_null($this->category)) {
$categories = CategoryQuery::create()->filterById($this->category, Criteria::IN)->find();
$category = $this->getArgValue('category');
if(null !== $this->depth) {
foreach(CategoryQuery::findAllChild($this->category, $this->depth) as $subCategory) {
if (!is_null($category)) {
$categories = CategoryQuery::create()->filterById($category, Criteria::IN)->find();
$depth = $this->getArgValue('depth');
if(null !== $depth) {
foreach(CategoryQuery::findAllChild($category, $depth) as $subCategory) {
$categories->prepend($subCategory);
}
}
@@ -138,57 +128,75 @@ class Product extends BaseLoop
);
}
if ($this->new === true) {
$new = $this->getArgValue('new');
if ($new === true) {
$search->filterByNewness(1, Criteria::EQUAL);
} else if($this->new === false) {
} else if($new === false) {
$search->filterByNewness(0, Criteria::EQUAL);
}
if ($this->promo === true) {
$promo = $this->getArgValue('promo');
if ($promo === true) {
$search->filterByPromo(1, Criteria::EQUAL);
} else if($this->promo === false) {
} else if($promo === false) {
$search->filterByNewness(0, Criteria::EQUAL);
}
if (null != $this->min_stock) {
$search->filterByQuantity($this->min_stock, Criteria::GREATER_EQUAL);
$min_stock = $this->getArgValue('min_stock');
if (null != $min_stock) {
$search->filterByQuantity($min_stock, Criteria::GREATER_EQUAL);
}
if(null !== $this->min_price) {
$min_price = $this->getArgValue('min_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 . '?', $this->min_price)
->condition('min_price', ProductPeer::PRICE . Criteria::GREATER_EQUAL . '?', $this->min_price)
->condition('min_price2', ProductPeer::PRICE2 . Criteria::GREATER_EQUAL . '?', $min_price)
->condition('min_price', ProductPeer::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);
}
if(null !== $this->max_price) {
$max_price = $this->getArgValue('max_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 . '?', $this->max_price)
->condition('max_price', ProductPeer::PRICE . Criteria::LESS_EQUAL . '?', $this->max_price)
->condition('max_price2', ProductPeer::PRICE2 . Criteria::LESS_EQUAL . '?', $max_price)
->condition('max_price', ProductPeer::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);
}
if(null !== $this->min_weight) {
$search->filterByWeight($this->min_weight, Criteria::GREATER_EQUAL);
$min_weight = $this->getArgValue('min_weight');
if(null !== $min_weight) {
$search->filterByWeight($min_weight, Criteria::GREATER_EQUAL);
}
if(null !== $this->max_weight) {
$search->filterByWeight($this->max_weight, Criteria::LESS_EQUAL);
$max_weight = $this->getArgValue('max_weight');
if(null !== $max_weight) {
$search->filterByWeight($max_weight, Criteria::LESS_EQUAL);
}
if ($this->current === true) {
$current = $this->getArgValue('current');
if ($current === true) {
$search->filterById($this->request->get("product_id"));
} elseif($this->current === false) {
} elseif($current === false) {
$search->filterById($this->request->get("product_id"), Criteria::NOT_IN);
}
if ($this->current_category === true) {
$current_category = $this->getArgValue('current_category');
if ($current_category === true) {
$search->filterByCategory(
CategoryQuery::create()->filterByProduct(
ProductCategoryQuery::create()->filterByProductId(
@@ -199,7 +207,7 @@ class Product extends BaseLoop
)->find(),
Criteria::IN
);
} elseif($this->current_category === false) {
} elseif($current_category === false) {
$search->filterByCategory(
CategoryQuery::create()->filterByProduct(
ProductCategoryQuery::create()->filterByProductId(
@@ -212,9 +220,9 @@ class Product extends BaseLoop
);
}
$search->filterByVisible($this->visible);
$search->filterByVisible($this->getArgValue('visible'));
switch ($this->order) {
switch ($this->getArgValue('order')) {
case "alpha":
$search->addAscendingOrderByColumn(\Thelia\Model\CategoryI18nPeer::TITLE);
break;
@@ -254,13 +262,15 @@ class Product extends BaseLoop
break;
}
if ($this->random === true) {
if ($this->getArgValue('random') === true) {
$search->clearOrderByColumns();
$search->addAscendingOrderByColumn('RAND()');
}
if (!is_null($this->exclude)) {
$search->filterById($this->exclude, Criteria::NOT_IN);
$exclude = $this->getArgValue('exclude');
if (!is_null($exclude)) {
$search->filterById($exclude, Criteria::NOT_IN);
}
/**
@@ -270,7 +280,7 @@ class Product extends BaseLoop
*/
$search->joinWithI18n(
$this->request->getSession()->get('locale', 'en_US'),
$this->request->getSession()->getLocale(),
(ConfigQuery::read("default_lang_without_translation", 1)) ? Criteria::LEFT_JOIN : Criteria::INNER_JOIN
);

View File

@@ -35,7 +35,7 @@ use Symfony\Component\EventDispatcher\EventDispatcherInterface;
class TheliaLoop implements SmartyPluginInterface
{
protected static $pagination = null;
protected $pagination = null;
protected $loopDefinition = array();
@@ -43,8 +43,9 @@ class TheliaLoop implements SmartyPluginInterface
protected $dispatcher;
protected $loopstack = array();
protected $varstack = array();
protected $loopstack = array();
public function __construct(Request $request, EventDispatcherInterface $dispatcher)
{
@@ -57,10 +58,10 @@ class TheliaLoop implements SmartyPluginInterface
*
* @return \PropelModelPager
*/
public static function getPagination($loopId)
protected function getPagination($loopId)
{
if(!empty(self::$pagination[$loopId])) {
return self::$pagination[$loopId];
if(!empty($this->pagination[$loopId])) {
return $this->pagination[$loopId];
} else {
return null;
}
@@ -92,13 +93,12 @@ class TheliaLoop implements SmartyPluginInterface
throw new \InvalidArgumentException("A loop named '$name' already exists in the current scope.");
}
$loop = $this->createLoopInstance(strtolower($params['type']));
$loop = $this->createLoopInstance($params);
$this->getLoopArgument($loop, $params);
$this->pagination[$name] = null;
self::$pagination[$name] = null;
$loopResults = $loop->exec($this->pagination[$name]);
$loopResults = $loop->exec(self::$pagination[$name]);
$this->loopstack[$name] = $loopResults;
} else {
@@ -130,13 +130,13 @@ class TheliaLoop implements SmartyPluginInterface
$template->assign($var, $val);
}
$repeat = true;
}
// Assign meta information
$template->assign('LOOP_COUNT', 1 + $loopResults->key());
$template->assign('LOOP_TOTAL', $loopResults->getCount());
$repeat = $loopResults->valid();
}
// Loop is terminated. Cleanup.
if (! $repeat) {
// Restore previous variables values before terminating
@@ -187,6 +187,7 @@ class TheliaLoop implements SmartyPluginInterface
*/
public function theliaIfLoop($params, $content, $template, &$repeat)
{
// When encountering close tag, check if loop has results.
if ($repeat === false) {
return $this->checkEmptyLoop($params, $template) ? '' : $content;
@@ -212,13 +213,15 @@ class TheliaLoop implements SmartyPluginInterface
$loopName = $params['rel'];
// Find loop results in the current template vars
/* $loopResults = $template->getTemplateVars($loopName);
if (empty($loopResults)) {
if (! isset($this->loopstack[$loopName])) {
throw new \InvalidArgumentException("Loop $loopName is not defined.");
}*/
}
$loopResults = $this->loopstack[$loopName];
// Find pagination
$pagination = self::getPagination($loopName);
$pagination = $this->getPagination($loopName);
if ($pagination === null) {
throw new \InvalidArgumentException("Loop $loopName : no pagination found.");
}
@@ -272,27 +275,33 @@ class TheliaLoop implements SmartyPluginInterface
*
* @param string $name
* @return \Thelia\Core\Template\Element\BaseLoop
* @throws InvalidElementException
* @throws ElementNotFoundException
* @throws \Thelia\Tpex\Exception\InvalidElementException
* @throws \Thelia\Tpex\Exception\ElementNotFoundException
*/
protected function createLoopInstance($name)
protected function createLoopInstance($smartyParams)
{
if (! isset($this->loopDefinition[$name])) {
throw new ElementNotFoundException(sprintf("%s loop does not exists", $name));
$type = strtolower($smartyParams['type']);
if (! isset($this->loopDefinition[$type])) {
throw new ElementNotFoundException(sprintf("%s loop does not exists", $type));
}
$class = new \ReflectionClass($this->loopDefinition[$name]);
$class = new \ReflectionClass($this->loopDefinition[$type]);
if ($class->isSubclassOf("Thelia\Core\Template\Element\BaseLoop") === false) {
throw new InvalidElementException(sprintf("%s Loop class have to extends Thelia\Core\Template\Element\BaseLoop",
$name));
$type));
}
return $class->newInstance(
$loop = $class->newInstance(
$this->request,
$this->dispatcher
);
$loop->initializeArgs($smartyParams);
return $loop;
}
/**
@@ -308,6 +317,7 @@ class TheliaLoop implements SmartyPluginInterface
$faultDetails = array();
$argumentsCollection = $loop->getArgs();
foreach( $argumentsCollection as $argument ) {
$value = isset($smartyParam[$argument->name]) ? (string)$smartyParam[$argument->name] : null;
@@ -364,7 +374,7 @@ class TheliaLoop implements SmartyPluginInterface
* "myLoop" => "My\Own\Loop"
* );
*
* @param array $loopDefinition
* @param array $loops
* @throws \InvalidArgumentException if loop name already exists
*/
public function setLoopList(array $loopDefinition)

View File

@@ -2,8 +2,40 @@
namespace Thelia\Model;
use Thelia\Core\Security\User\UserInterface;
use Thelia\Model\Base\Admin as BaseAdmin;
class Admin extends BaseAdmin {
/**
* Skeleton subclass for representing a row from the 'admin' table.
*
*
*
* You should add additional methods to this class to meet the
* application requirements. This class will only be generated as
* long as it does not already exist in the output directory.
*
* @package propel.generator.Thelia.Model
*/
class Admin extends BaseAdmin implements UserInterface
{
/**
* {@inheritDoc}
*/
public function getUsername() {
return $this->getLogin();
}
/**
* {@inheritDoc}
*/
public function eraseCredentials() {
$this->setPassword(null);
}
/**
* {@inheritDoc}
*/
public function getRoles() {
return array(new Role('USER_ADMIN'));
}
}

View File

@@ -6,11 +6,26 @@ use Thelia\Model\Base\Customer as BaseCustomer;
use Symfony\Component\DependencyInjection\Exception\InvalidArgumentException;
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
use Thelia\Core\Event\CustomRefEvent;
use Thelia\Core\Event\TheliaEvents;
use Thelia\Core\Security\User\UserInterface;
use Propel\Runtime\Connection\ConnectionInterface;
class Customer extends BaseCustomer {
/**
* Skeleton subclass for representing a row from the 'customer' table.
*
*
*
* You should add additional methods to this class to meet the
* application requirements. This class will only be generated as
* long as it does not already exist in the output directory.
*
* @package propel.generator.Thelia.Model
*/
class Customer extends BaseCustomer implements UserInterface
{
/**
* @var \Symfony\Component\EventDispatcher\EventDispatcherInterface
*/
@@ -97,4 +112,26 @@ class Customer extends BaseCustomer {
{
$this->dispatcher = $dispatcher;
}
/**
* {@inheritDoc}
*/
public function getUsername() {
return $this->getEmail();
}
/**
* {@inheritDoc}
*/
public function eraseCredentials() {
$this->setPassword(null);
}
/**
* {@inheritDoc}
*/
public function getRoles() {
return array(new Role('USER_CUSTOMER'));
}
}

View File

@@ -151,7 +151,7 @@ class AttributeAvI18nTableMap extends TableMap
$this->setUseIdGenerator(false);
// columns
$this->addForeignPrimaryKey('ID', 'Id', 'INTEGER' , 'attribute_av', 'ID', true, null, null);
$this->addPrimaryKey('LOCALE', 'Locale', 'VARCHAR', true, 5, 'en_US');
$this->addPrimaryKey('LOCALE', 'Locale', 'VARCHAR', true, 5, 'en_EN');
$this->addColumn('TITLE', 'Title', 'VARCHAR', false, 255, null);
$this->addColumn('DESCRIPTION', 'Description', 'CLOB', false, null, null);
$this->addColumn('CHAPO', 'Chapo', 'LONGVARCHAR', false, null, null);

View File

@@ -106,7 +106,7 @@ class AttributeAvTableMap extends TableMap
*
* @var string
*/
const DEFAULT_LOCALE = 'en_US';
const DEFAULT_LOCALE = 'en_EN';
/**
* holds an array of fieldnames

View File

@@ -151,7 +151,7 @@ class AttributeI18nTableMap extends TableMap
$this->setUseIdGenerator(false);
// columns
$this->addForeignPrimaryKey('ID', 'Id', 'INTEGER' , 'attribute', 'ID', true, null, null);
$this->addPrimaryKey('LOCALE', 'Locale', 'VARCHAR', true, 5, 'en_US');
$this->addPrimaryKey('LOCALE', 'Locale', 'VARCHAR', true, 5, 'en_EN');
$this->addColumn('TITLE', 'Title', 'VARCHAR', false, 255, null);
$this->addColumn('DESCRIPTION', 'Description', 'CLOB', false, null, null);
$this->addColumn('CHAPO', 'Chapo', 'LONGVARCHAR', false, null, null);

View File

@@ -101,7 +101,7 @@ class AttributeTableMap extends TableMap
*
* @var string
*/
const DEFAULT_LOCALE = 'en_US';
const DEFAULT_LOCALE = 'en_EN';
/**
* holds an array of fieldnames

View File

@@ -151,7 +151,7 @@ class CategoryI18nTableMap extends TableMap
$this->setUseIdGenerator(false);
// columns
$this->addForeignPrimaryKey('ID', 'Id', 'INTEGER' , 'category', 'ID', true, null, null);
$this->addPrimaryKey('LOCALE', 'Locale', 'VARCHAR', true, 5, 'en_US');
$this->addPrimaryKey('LOCALE', 'Locale', 'VARCHAR', true, 5, 'en_EN');
$this->addColumn('TITLE', 'Title', 'VARCHAR', false, 255, null);
$this->addColumn('DESCRIPTION', 'Description', 'CLOB', false, null, null);
$this->addColumn('CHAPO', 'Chapo', 'LONGVARCHAR', false, null, null);

View File

@@ -131,7 +131,7 @@ class CategoryTableMap extends TableMap
*
* @var string
*/
const DEFAULT_LOCALE = 'en_US';
const DEFAULT_LOCALE = 'en_EN';
/**
* holds an array of fieldnames

View File

@@ -151,7 +151,7 @@ class ConfigI18nTableMap extends TableMap
$this->setUseIdGenerator(false);
// columns
$this->addForeignPrimaryKey('ID', 'Id', 'INTEGER' , 'config', 'ID', true, null, null);
$this->addPrimaryKey('LOCALE', 'Locale', 'VARCHAR', true, 5, 'en_US');
$this->addPrimaryKey('LOCALE', 'Locale', 'VARCHAR', true, 5, 'en_EN');
$this->addColumn('TITLE', 'Title', 'VARCHAR', false, 255, null);
$this->addColumn('DESCRIPTION', 'Description', 'CLOB', false, null, null);
$this->addColumn('CHAPO', 'Chapo', 'LONGVARCHAR', false, null, null);

View File

@@ -116,7 +116,7 @@ class ConfigTableMap extends TableMap
*
* @var string
*/
const DEFAULT_LOCALE = 'en_US';
const DEFAULT_LOCALE = 'en_EN';
/**
* holds an array of fieldnames

View File

@@ -151,7 +151,7 @@ class ContentI18nTableMap extends TableMap
$this->setUseIdGenerator(false);
// columns
$this->addForeignPrimaryKey('ID', 'Id', 'INTEGER' , 'content', 'ID', true, null, null);
$this->addPrimaryKey('LOCALE', 'Locale', 'VARCHAR', true, 5, 'en_US');
$this->addPrimaryKey('LOCALE', 'Locale', 'VARCHAR', true, 5, 'en_EN');
$this->addColumn('TITLE', 'Title', 'VARCHAR', false, 255, null);
$this->addColumn('DESCRIPTION', 'Description', 'CLOB', false, null, null);
$this->addColumn('CHAPO', 'Chapo', 'LONGVARCHAR', false, null, null);

View File

@@ -121,7 +121,7 @@ class ContentTableMap extends TableMap
*
* @var string
*/
const DEFAULT_LOCALE = 'en_US';
const DEFAULT_LOCALE = 'en_EN';
/**
* holds an array of fieldnames

View File

@@ -151,7 +151,7 @@ class CountryI18nTableMap extends TableMap
$this->setUseIdGenerator(false);
// columns
$this->addForeignPrimaryKey('ID', 'Id', 'INTEGER' , 'country', 'ID', true, null, null);
$this->addPrimaryKey('LOCALE', 'Locale', 'VARCHAR', true, 5, 'en_US');
$this->addPrimaryKey('LOCALE', 'Locale', 'VARCHAR', true, 5, 'en_EN');
$this->addColumn('TITLE', 'Title', 'VARCHAR', false, 255, null);
$this->addColumn('DESCRIPTION', 'Description', 'CLOB', false, null, null);
$this->addColumn('CHAPO', 'Chapo', 'LONGVARCHAR', false, null, null);

View File

@@ -116,7 +116,7 @@ class CountryTableMap extends TableMap
*
* @var string
*/
const DEFAULT_LOCALE = 'en_US';
const DEFAULT_LOCALE = 'en_EN';
/**
* holds an array of fieldnames

View File

@@ -141,7 +141,7 @@ class CustomerTitleI18nTableMap extends TableMap
$this->setUseIdGenerator(false);
// columns
$this->addForeignPrimaryKey('ID', 'Id', 'INTEGER' , 'customer_title', 'ID', true, null, null);
$this->addPrimaryKey('LOCALE', 'Locale', 'VARCHAR', true, 5, 'en_US');
$this->addPrimaryKey('LOCALE', 'Locale', 'VARCHAR', true, 5, 'en_EN');
$this->addColumn('SHORT', 'Short', 'VARCHAR', false, 10, null);
$this->addColumn('LONG', 'Long', 'VARCHAR', false, 45, null);
} // initialize()

View File

@@ -106,7 +106,7 @@ class CustomerTitleTableMap extends TableMap
*
* @var string
*/
const DEFAULT_LOCALE = 'en_US';
const DEFAULT_LOCALE = 'en_EN';
/**
* holds an array of fieldnames

View File

@@ -151,7 +151,7 @@ class DocumentI18nTableMap extends TableMap
$this->setUseIdGenerator(false);
// columns
$this->addForeignPrimaryKey('ID', 'Id', 'INTEGER' , 'document', 'ID', true, null, null);
$this->addPrimaryKey('LOCALE', 'Locale', 'VARCHAR', true, 5, 'en_US');
$this->addPrimaryKey('LOCALE', 'Locale', 'VARCHAR', true, 5, 'en_EN');
$this->addColumn('TITLE', 'Title', 'VARCHAR', false, 255, null);
$this->addColumn('DESCRIPTION', 'Description', 'CLOB', false, null, null);
$this->addColumn('CHAPO', 'Chapo', 'LONGVARCHAR', false, null, null);

View File

@@ -126,7 +126,7 @@ class DocumentTableMap extends TableMap
*
* @var string
*/
const DEFAULT_LOCALE = 'en_US';
const DEFAULT_LOCALE = 'en_EN';
/**
* holds an array of fieldnames

View File

@@ -151,7 +151,7 @@ class FeatureAvI18nTableMap extends TableMap
$this->setUseIdGenerator(false);
// columns
$this->addForeignPrimaryKey('ID', 'Id', 'INTEGER' , 'feature_av', 'ID', true, null, null);
$this->addPrimaryKey('LOCALE', 'Locale', 'VARCHAR', true, 5, 'en_US');
$this->addPrimaryKey('LOCALE', 'Locale', 'VARCHAR', true, 5, 'en_EN');
$this->addColumn('TITLE', 'Title', 'VARCHAR', false, 255, null);
$this->addColumn('DESCRIPTION', 'Description', 'CLOB', false, null, null);
$this->addColumn('CHAPO', 'Chapo', 'LONGVARCHAR', false, null, null);

View File

@@ -101,7 +101,7 @@ class FeatureAvTableMap extends TableMap
*
* @var string
*/
const DEFAULT_LOCALE = 'en_US';
const DEFAULT_LOCALE = 'en_EN';
/**
* holds an array of fieldnames

View File

@@ -151,7 +151,7 @@ class FeatureI18nTableMap extends TableMap
$this->setUseIdGenerator(false);
// columns
$this->addForeignPrimaryKey('ID', 'Id', 'INTEGER' , 'feature', 'ID', true, null, null);
$this->addPrimaryKey('LOCALE', 'Locale', 'VARCHAR', true, 5, 'en_US');
$this->addPrimaryKey('LOCALE', 'Locale', 'VARCHAR', true, 5, 'en_EN');
$this->addColumn('TITLE', 'Title', 'VARCHAR', false, 255, null);
$this->addColumn('DESCRIPTION', 'Description', 'CLOB', false, null, null);
$this->addColumn('CHAPO', 'Chapo', 'LONGVARCHAR', false, null, null);

View File

@@ -106,7 +106,7 @@ class FeatureTableMap extends TableMap
*
* @var string
*/
const DEFAULT_LOCALE = 'en_US';
const DEFAULT_LOCALE = 'en_EN';
/**
* holds an array of fieldnames

View File

@@ -151,7 +151,7 @@ class FolderI18nTableMap extends TableMap
$this->setUseIdGenerator(false);
// columns
$this->addForeignPrimaryKey('ID', 'Id', 'INTEGER' , 'folder', 'ID', true, null, null);
$this->addPrimaryKey('LOCALE', 'Locale', 'VARCHAR', true, 5, 'en_US');
$this->addPrimaryKey('LOCALE', 'Locale', 'VARCHAR', true, 5, 'en_EN');
$this->addColumn('TITLE', 'Title', 'VARCHAR', false, 255, null);
$this->addColumn('DESCRIPTION', 'Description', 'CLOB', false, null, null);
$this->addColumn('CHAPO', 'Chapo', 'LONGVARCHAR', false, null, null);

View File

@@ -131,7 +131,7 @@ class FolderTableMap extends TableMap
*
* @var string
*/
const DEFAULT_LOCALE = 'en_US';
const DEFAULT_LOCALE = 'en_EN';
/**
* holds an array of fieldnames

View File

@@ -151,7 +151,7 @@ class GroupI18nTableMap extends TableMap
$this->setUseIdGenerator(false);
// columns
$this->addForeignPrimaryKey('ID', 'Id', 'INTEGER' , 'group', 'ID', true, null, null);
$this->addPrimaryKey('LOCALE', 'Locale', 'VARCHAR', true, 5, 'en_US');
$this->addPrimaryKey('LOCALE', 'Locale', 'VARCHAR', true, 5, 'en_EN');
$this->addColumn('TITLE', 'Title', 'VARCHAR', false, 255, null);
$this->addColumn('DESCRIPTION', 'Description', 'CLOB', false, null, null);
$this->addColumn('CHAPO', 'Chapo', 'LONGVARCHAR', false, null, null);

View File

@@ -101,7 +101,7 @@ class GroupTableMap extends TableMap
*
* @var string
*/
const DEFAULT_LOCALE = 'en_US';
const DEFAULT_LOCALE = 'en_EN';
/**
* holds an array of fieldnames

View File

@@ -151,7 +151,7 @@ class ImageI18nTableMap extends TableMap
$this->setUseIdGenerator(false);
// columns
$this->addForeignPrimaryKey('ID', 'Id', 'INTEGER' , 'image', 'ID', true, null, null);
$this->addPrimaryKey('LOCALE', 'Locale', 'VARCHAR', true, 5, 'en_US');
$this->addPrimaryKey('LOCALE', 'Locale', 'VARCHAR', true, 5, 'en_EN');
$this->addColumn('TITLE', 'Title', 'VARCHAR', false, 255, null);
$this->addColumn('DESCRIPTION', 'Description', 'CLOB', false, null, null);
$this->addColumn('CHAPO', 'Chapo', 'LONGVARCHAR', false, null, null);

View File

@@ -126,7 +126,7 @@ class ImageTableMap extends TableMap
*
* @var string
*/
const DEFAULT_LOCALE = 'en_US';
const DEFAULT_LOCALE = 'en_EN';
/**
* holds an array of fieldnames

View File

@@ -146,7 +146,7 @@ class MessageI18nTableMap extends TableMap
$this->setUseIdGenerator(false);
// columns
$this->addForeignPrimaryKey('ID', 'Id', 'INTEGER' , 'message', 'ID', true, null, null);
$this->addPrimaryKey('LOCALE', 'Locale', 'VARCHAR', true, 5, 'en_US');
$this->addPrimaryKey('LOCALE', 'Locale', 'VARCHAR', true, 5, 'en_EN');
$this->addColumn('TITLE', 'Title', 'LONGVARCHAR', false, null, null);
$this->addColumn('DESCRIPTION', 'Description', 'CLOB', false, null, null);
$this->addColumn('DESCRIPTION_HTML', 'DescriptionHtml', 'CLOB', false, null, null);

View File

@@ -126,7 +126,7 @@ class MessageTableMap extends TableMap
*
* @var string
*/
const DEFAULT_LOCALE = 'en_US';
const DEFAULT_LOCALE = 'en_EN';
/**
* holds an array of fieldnames

View File

@@ -151,7 +151,7 @@ class ModuleI18nTableMap extends TableMap
$this->setUseIdGenerator(false);
// columns
$this->addForeignPrimaryKey('ID', 'Id', 'INTEGER' , 'module', 'ID', true, null, null);
$this->addPrimaryKey('LOCALE', 'Locale', 'VARCHAR', true, 5, 'en_US');
$this->addPrimaryKey('LOCALE', 'Locale', 'VARCHAR', true, 5, 'en_EN');
$this->addColumn('TITLE', 'Title', 'VARCHAR', false, 255, null);
$this->addColumn('DESCRIPTION', 'Description', 'CLOB', false, null, null);
$this->addColumn('CHAPO', 'Chapo', 'LONGVARCHAR', false, null, null);

View File

@@ -116,7 +116,7 @@ class ModuleTableMap extends TableMap
*
* @var string
*/
const DEFAULT_LOCALE = 'en_US';
const DEFAULT_LOCALE = 'en_EN';
/**
* holds an array of fieldnames

View File

@@ -151,7 +151,7 @@ class OrderStatusI18nTableMap extends TableMap
$this->setUseIdGenerator(false);
// columns
$this->addForeignPrimaryKey('ID', 'Id', 'INTEGER' , 'order_status', 'ID', true, null, null);
$this->addPrimaryKey('LOCALE', 'Locale', 'VARCHAR', true, 5, 'en_US');
$this->addPrimaryKey('LOCALE', 'Locale', 'VARCHAR', true, 5, 'en_EN');
$this->addColumn('TITLE', 'Title', 'VARCHAR', false, 255, null);
$this->addColumn('DESCRIPTION', 'Description', 'CLOB', false, null, null);
$this->addColumn('CHAPO', 'Chapo', 'LONGVARCHAR', false, null, null);

View File

@@ -101,7 +101,7 @@ class OrderStatusTableMap extends TableMap
*
* @var string
*/
const DEFAULT_LOCALE = 'en_US';
const DEFAULT_LOCALE = 'en_EN';
/**
* holds an array of fieldnames

View File

@@ -151,7 +151,7 @@ class ProductI18nTableMap extends TableMap
$this->setUseIdGenerator(false);
// columns
$this->addForeignPrimaryKey('ID', 'Id', 'INTEGER' , 'product', 'ID', true, null, null);
$this->addPrimaryKey('LOCALE', 'Locale', 'VARCHAR', true, 5, 'en_US');
$this->addPrimaryKey('LOCALE', 'Locale', 'VARCHAR', true, 5, 'en_EN');
$this->addColumn('TITLE', 'Title', 'VARCHAR', false, 255, null);
$this->addColumn('DESCRIPTION', 'Description', 'CLOB', false, null, null);
$this->addColumn('CHAPO', 'Chapo', 'LONGVARCHAR', false, null, null);

View File

@@ -166,7 +166,7 @@ class ProductTableMap extends TableMap
*
* @var string
*/
const DEFAULT_LOCALE = 'en_US';
const DEFAULT_LOCALE = 'en_EN';
/**
* holds an array of fieldnames

View File

@@ -151,7 +151,7 @@ class ResourceI18nTableMap extends TableMap
$this->setUseIdGenerator(false);
// columns
$this->addForeignPrimaryKey('ID', 'Id', 'INTEGER' , 'resource', 'ID', true, null, null);
$this->addPrimaryKey('LOCALE', 'Locale', 'VARCHAR', true, 5, 'en_US');
$this->addPrimaryKey('LOCALE', 'Locale', 'VARCHAR', true, 5, 'en_EN');
$this->addColumn('TITLE', 'Title', 'VARCHAR', false, 255, null);
$this->addColumn('DESCRIPTION', 'Description', 'CLOB', false, null, null);
$this->addColumn('CHAPO', 'Chapo', 'LONGVARCHAR', false, null, null);

View File

@@ -101,7 +101,7 @@ class ResourceTableMap extends TableMap
*
* @var string
*/
const DEFAULT_LOCALE = 'en_US';
const DEFAULT_LOCALE = 'en_EN';
/**
* holds an array of fieldnames

View File

@@ -141,7 +141,7 @@ class TaxI18nTableMap extends TableMap
$this->setUseIdGenerator(false);
// columns
$this->addForeignPrimaryKey('ID', 'Id', 'INTEGER' , 'tax', 'ID', true, null, null);
$this->addPrimaryKey('LOCALE', 'Locale', 'VARCHAR', true, 5, 'en_US');
$this->addPrimaryKey('LOCALE', 'Locale', 'VARCHAR', true, 5, 'en_EN');
$this->addColumn('TITLE', 'Title', 'VARCHAR', false, 255, null);
$this->addColumn('DESCRIPTION', 'Description', 'LONGVARCHAR', false, null, null);
} // initialize()

View File

@@ -131,7 +131,7 @@ class TaxRuleI18nTableMap extends TableMap
$this->setUseIdGenerator(false);
// columns
$this->addForeignPrimaryKey('ID', 'Id', 'INTEGER' , 'tax_rule', 'ID', true, null, null);
$this->addPrimaryKey('LOCALE', 'Locale', 'VARCHAR', true, 5, 'en_US');
$this->addPrimaryKey('LOCALE', 'Locale', 'VARCHAR', true, 5, 'en_EN');
} // initialize()
/**

View File

@@ -111,7 +111,7 @@ class TaxRuleTableMap extends TableMap
*
* @var string
*/
const DEFAULT_LOCALE = 'en_US';
const DEFAULT_LOCALE = 'en_EN';
/**
* holds an array of fieldnames

View File

@@ -101,7 +101,7 @@ class TaxTableMap extends TableMap
*
* @var string
*/
const DEFAULT_LOCALE = 'en_US';
const DEFAULT_LOCALE = 'en_EN';
/**
* holds an array of fieldnames

View File

@@ -35,7 +35,7 @@ use Thelia\Type\TypeCollection;
*/
class ArgumentTest extends \PHPUnit_Framework_TestCase
{
public function testArgumentCollectionConstruction()
public function testArgumentCollectionCreateAndWalk()
{
$collection = new ArgumentCollection(
new Argument(
@@ -61,30 +61,19 @@ class ArgumentTest extends \PHPUnit_Framework_TestCase
)
);
$this->assertAttributeEquals(
array(
0 => new Argument(
'arg0',
new TypeCollection(
new Type\AnyType()
)
),
1 => new Argument(
'arg1',
new TypeCollection(
new Type\AnyType()
)
),
2 => new Argument(
'arg2',
new TypeCollection(
new Type\AnyType()
)
),
),
'arguments',
$collection
);
$this->assertTrue($collection->getCount() == 3);
$this->assertTrue($collection->key() == 'arg0');
$collection->next();
$this->assertTrue($collection->key() == 'arg1');
$collection->next();
$this->assertTrue($collection->key() == 'arg2');
$collection->next();
$this->assertFalse($collection->valid());
$collection->rewind();
$this->assertTrue($collection->key() == 'arg0');
}
public function testArgumentCollectionFetch()

View File

@@ -56,15 +56,63 @@ a {
// Bootstrap Adjustements ------------------------------------------------------
.btn-primary, .row h3 .btn-large, .row-fluid h3 .btn-large, .row-fluid h4 .btn-large {
background: -moz-linear-gradient(center bottom , #E3530B 0%, #F39922 100%) repeat scroll 0 0 #E9730F;
box-shadow: 0 0 2px rgba(250, 250, 250, 0.5) inset, 0 1px 3px rgba(0, 0, 0, 0.2);
hr {
border: 0;
border-top: 1px solid rgba(0, 0, 0, 0.1);
border-bottom: 1px solid rgba(250, 250, 250, 0.1);
width: 90%;
margin: 0 auto;
clear: both;
margin-top: 20px;
}
.btn-primary, .btn-large {
background: #e9730f;
background-image: linear-gradient(bottom, rgb(227,83,11) 0%, rgb(243,153,34) 100%);
background-image: -o-linear-gradient(bottom, rgb(227,83,11) 0%, rgb(243,153,34) 100%);
background-image: -moz-linear-gradient(bottom, rgb(227,83,11) 0%, rgb(243,153,34) 100%);
background-image: -webkit-linear-gradient(bottom, rgb(227,83,11) 0%, rgb(243,153,34) 100%);
background-image: -ms-linear-gradient(bottom, rgb(227,83,11) 0%, rgb(243,153,34) 100%);
background-image: -webkit-gradient(
linear,
left bottom,
left top,
color-stop(0, rgb(227,83,11)),
color-stop(1, rgb(243,153,34))
);
box-shadow: inset 0px 0px 2px rgba(250,250,250,0.5), 0px 1px 3px rgba(0,0,0,0.2);
color: white;
}
// -- Brandbar ----------------------------------------------------------------
.btn-large:hover, .btn-primary:hover {
background: #e9730f;
background-image: linear-gradient(bottom, rgb(227,83,11) 0%, rgb(243,153,34) 100%);
background-image: -o-linear-gradient(bottom, rgb(227,83,11) 0%, rgb(243,153,34) 100%);
background-image: -moz-linear-gradient(bottom, rgb(227,83,11) 0%, rgb(243,153,34) 100%);
background-image: -webkit-linear-gradient(bottom, rgb(227,83,11) 0%, rgb(243,153,34) 100%);
background-image: -ms-linear-gradient(bottom, rgb(227,83,11) 0%, rgb(243,153,34) 100%);
background-image: -webkit-gradient(
linear,
left bottom,
left top,
color-stop(0, rgb(227,83,11)),
color-stop(1, rgb(243,153,34))
);
box-shadow: inset 0px 0px 2px rgba(250,250,250,0.8), 0px 1px 3px rgba(0,0,0,0.2);
color: white;
}
/* --- BRAND BAR ---*/
.modal-footer {
background: none repeat scroll 0 0 transparent;
border: medium none;
box-shadow: none;
color: #7D756A;
margin-bottom: 0;
padding: 35px 15px 15px;
text-align: left;
}
// -- Brandbar ----------------------------------------------------------------
.loginpage {
.brandbar {
@@ -73,6 +121,10 @@ a {
.hero-unit {
background-color: transparent !important;
h1 {
margin-bottom: 25px;
}
}
.well {
@@ -146,7 +198,33 @@ a {
}
}
// -- Feed list on home page --------------------------------------------------
.feed-list {
h2 {
font-size: 24px;
line-height: 120%;
color: #E9730F;
a {
&:hover {
color: inherit;
text-decoration: none;
}
}
}
h3 {
margin-bottom: 0;
padding-bottom: 0;
font-size: 90%;
line-height: 100%;
}
.feed-list-item{
padding: 10px 20px;
}
}
// -- Login form --------------------------------------------------------------
.form-signin {

View File

@@ -1,3 +1,15 @@
<hr />
<footer class="modal-footer">
<div class="container">
<p>{intl l='&copy; Thelia 2012'}
- <a href="http://www.openstudio.fr/" target="_blank">{intl l='Édité par OpenStudio'}</a>
- <a href="http://forum.thelia.net/" target="_blank">{intl l='Forum Thelia'}</a>
- <a href="http://contrib.thelia.net/" target="_blank">{intl l='Contributions Thelia'}</a>
<span class="pull-right">{intl l='interface par <a target="_blank" href="http://www.steaw-webdesign.com/">Steaw-Webdesign</a>'}</span>
</p>
</div>
</footer>
{* Include required JS files *}
{javascripts file='../assets/js/jquery.min.js'}

View File

@@ -7,10 +7,6 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0">
{stylesheets file='../assets/css/*' filters='less,cssembed'}
<link rel="stylesheet" href="{$asset_url}">
{/stylesheets}
{stylesheets file='../assets/bootstrap/css/bootstrap.css' filters='cssembed'}
<link rel="stylesheet" href="{$asset_url}">
{/stylesheets}
@@ -19,6 +15,10 @@
<link rel="stylesheet" href="{$asset_url}">
{/stylesheets}
{stylesheets file='../assets/css/*' filters='less,cssembed'}
<link rel="stylesheet" href="{$asset_url}">
{/stylesheets}
{* TODO allow modules to include CSS here *}
</head>
<body>

View File

@@ -1,16 +1,14 @@
{$page_title={intl l='Thelia'}}
{$page_title={intl l='Welcome'}}
{include file='includes/header.inc.html'}
<div class="loginpage">
{{intl l='abcd'}|capitalize}
<div class="brandbar container">
<a class="brand" href="index.php">{images file='assets/img/logo-thelia-34px.png'}<img src="{$asset_url}" alt="{intl l='Thelia, solution e-commerce libre'}" />{/images}</a>
</div>
<div id="wrapper" class="container">
{*
{thelia_module action='index_top'}
*}
{module_include location='index_top'}
<div class="hero-unit">
<h1>{intl l='Thelia Back Office'}</h1>
@@ -31,34 +29,26 @@
<label class="checkbox"> <input type="checkbox" name="remember" value="yes"> {intl l='Remember me'}</label>
{/form_field}
<button type="submit" class="btn btn-primary">{intl l='Login'} <i class="icon-play"></i></button>
<div class="pull-right"><button type="submit" class="btn btn-primary">{intl l='Login'} <i class="icon-play icon-white"></i></button></div>
</form>
</div>
<div class="row-fluid">
{module_include location='index_middle'}
<div class="row-fluid feed-list">
{loop type="feed" name="thelia_feeds" url="http://thelia.net/Flux-rss.html?id_rubrique=8" limit="3"}
<div class="span4 feed-list-item">
<h3>{$DATE}</h3>
<h2><a href="#URL" target="_blank" title="{intl l='Lire la suite'}">{$TITLE|strip_tags}</a></h2>
<p>{$DESCRIPTION|strip_tags|truncate:250:"...":true}</p>
<p><a class="btn" href="#URL" target="_blank">{intl l='Lire la suite »'}</a></p>
</div>
{/loop}
</div>
</div>
<div>
<h2>We DO display loops in back-office !</h2>
<ul>
{loop type="category" name="catloop1"}
<li>{$__COUNT__}/{$__TOTAL__} : {$ID} {$TITLE}, children: {$NB_CHILD}
{ifloop rel="inner1"}
<ul>
{loop type="category" name="inner1" parent="{$ID}"}
<li>Sub cat {$ID} (parent is {$PARENT}): {$TITLE}</li>
{/loop}
</ul>
{/ifloop}
</li>
{/loop}
</ul>
</div>
</div>
{*
{thelia_module action='index_bottom'}
*}
{module_include location='index_bottom'}
</div>
{include file='includes/footer.inc.html'}

View File

@@ -1,12 +0,0 @@
Options +FollowSymlinks -Indexes
AddDefaultCharset UTF-8
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index_dev.php [L,QSA]
</IfModule>