Merge branch 'master' of https://github.com/thelia/thelia
This commit is contained in:
@@ -5,6 +5,7 @@
|
||||
xsi:schemaLocation="http://thelia.net/schema/dic/config http://thelia.net/schema/dic/config/thelia-1.0.xsd">
|
||||
|
||||
<loops>
|
||||
<loop class="Thelia\Core\Template\Loop\Accessory" name="accessory"/>
|
||||
<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"/>
|
||||
|
||||
@@ -51,7 +51,7 @@ abstract class BaseLoop
|
||||
protected $securityContext;
|
||||
|
||||
|
||||
private $args;
|
||||
protected $args;
|
||||
|
||||
/**
|
||||
* Create a new Loop
|
||||
@@ -143,8 +143,6 @@ abstract class BaseLoop
|
||||
|
||||
$argument->setValue($value);
|
||||
}
|
||||
|
||||
$this->args->next();
|
||||
}
|
||||
|
||||
if (!empty($faultActor)) {
|
||||
|
||||
119
core/lib/Thelia/Core/Template/Loop/Accessory.php
Executable file
119
core/lib/Thelia/Core/Template/Loop/Accessory.php
Executable file
@@ -0,0 +1,119 @@
|
||||
<?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\Loop\Product;
|
||||
|
||||
use Propel\Runtime\ActiveQuery\Criteria;
|
||||
use Propel\Runtime\ActiveQuery\Join;
|
||||
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\Log\Tlog;
|
||||
|
||||
use Thelia\Model\AccessoryQuery;
|
||||
use Thelia\Model\ProductQuery;
|
||||
use Thelia\Model\ConfigQuery;
|
||||
use Thelia\Type\TypeCollection;
|
||||
use Thelia\Type;
|
||||
|
||||
/**
|
||||
*
|
||||
* Accessory loop
|
||||
*
|
||||
*
|
||||
* Class Accessory
|
||||
* @package Thelia\Core\Template\Loop
|
||||
* @author Etienne Roudeix <eroudeix@openstudio.fr>
|
||||
*/
|
||||
class Accessory extends Product
|
||||
{
|
||||
/**
|
||||
* @return ArgumentCollection
|
||||
*/
|
||||
protected function getArgDefinitions()
|
||||
{
|
||||
$argumentCollection = parent::getArgDefinitions();
|
||||
|
||||
$argumentCollection->addArgument(
|
||||
Argument::createIntTypeArgument('product', null, true)
|
||||
);
|
||||
|
||||
$argumentCollection->get('order')->default = "accessory";
|
||||
|
||||
$argumentCollection->get('order')->type->getKey(0)->addValue('accessory');
|
||||
$argumentCollection->get('order')->type->getKey(0)->addValue('accessory_reverse');
|
||||
|
||||
return $argumentCollection;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $pagination
|
||||
*
|
||||
* @return \Thelia\Core\Template\Element\LoopResult
|
||||
*/
|
||||
public function exec(&$pagination)
|
||||
{
|
||||
$search = AccessoryQuery::create();
|
||||
|
||||
$product = $this->getProduct();
|
||||
$search->filterByProductId($product, Criteria::IN);
|
||||
|
||||
$order = $this->getOrder();
|
||||
$orderByAccessory = array_search('accessory', $order);
|
||||
$orderByAccessoryReverse = array_search('accessory_reverse', $order);
|
||||
if($orderByAccessory !== false) {
|
||||
$search->orderByPosition(Criteria::ASC);
|
||||
$order[$orderByAccessory] = 'given_id';
|
||||
$this->args->get('order')->setValue( implode(',', $order) );
|
||||
}
|
||||
if($orderByAccessoryReverse !== false) {
|
||||
$search->orderByPosition(Criteria::DESC);
|
||||
$order[$orderByAccessoryReverse] = 'given_id';
|
||||
$this->args->get('order')->setValue( implode(',', $order) );
|
||||
}
|
||||
|
||||
$accessories = $this->search($search);
|
||||
|
||||
$accessoryIdList = array(0);
|
||||
foreach ($accessories as $accessory) {
|
||||
array_push($accessoryIdList, $accessory->getAccessory());
|
||||
}
|
||||
|
||||
$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) );
|
||||
} else {
|
||||
$this->args->get('id')->setValue( implode(',', array_intersect($receivedIdList, $accessoryIdList)) );
|
||||
}
|
||||
|
||||
return parent::exec($pagination);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -46,12 +46,7 @@ use Thelia\Type;
|
||||
* - current : current id is used if you are on a category page
|
||||
* - not_empty : if value is 1, category and subcategories must have at least 1 product
|
||||
* - visible : default 1, if you want category not visible put 0
|
||||
* - order : all value available :
|
||||
* * alpha : sorting by title alphabetical order
|
||||
* * alpha_reverse : sorting by title alphabetical reverse order
|
||||
* * reverse : sorting by position descending
|
||||
* * by default results are sorting by position ascending
|
||||
* - random : if 1, random results. Default value is 0
|
||||
* - order : all value available : 'alpha', 'alpha_reverse', 'manual' (default), 'manual-reverse', 'random'
|
||||
* - exclude : all category id you want to exclude (as for id, an integer or a "string list" can be used)
|
||||
*
|
||||
* example :
|
||||
@@ -79,14 +74,13 @@ class Category extends BaseLoop
|
||||
Argument::createBooleanTypeArgument('current'),
|
||||
Argument::createBooleanTypeArgument('not_empty', 0),
|
||||
Argument::createBooleanTypeArgument('visible', 1),
|
||||
Argument::createAnyTypeArgument('link'),
|
||||
new Argument(
|
||||
'order',
|
||||
new TypeCollection(
|
||||
new Type\EnumListType('alpha', 'alpha_reverse', 'reverse')
|
||||
)
|
||||
new Type\EnumListType(array('alpha', 'alpha_reverse', 'manual', 'manual-reverse', 'random'))
|
||||
),
|
||||
'manual'
|
||||
),
|
||||
Argument::createBooleanTypeArgument('random', 0),
|
||||
Argument::createIntListTypeArgument('exclude')
|
||||
);
|
||||
}
|
||||
@@ -128,45 +122,32 @@ class Category extends BaseLoop
|
||||
$search->filterById($exclude, Criteria::NOT_IN);
|
||||
}
|
||||
|
||||
|
||||
$link = $this->getLink();
|
||||
|
||||
if (!is_null($link)) {
|
||||
$search->filterByLink($link);
|
||||
}
|
||||
|
||||
$search->filterByVisible($this->getVisible() ? 1 : 0);
|
||||
|
||||
$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;
|
||||
}
|
||||
foreach($orders as $order) {
|
||||
switch ($order) {
|
||||
case "alpha":
|
||||
$search->addAscendingOrderByColumn(\Thelia\Model\Map\CategoryI18nTableMap::TITLE);
|
||||
break;
|
||||
case "alpha_reverse":
|
||||
$search->addDescendingOrderByColumn(\Thelia\Model\Map\CategoryI18nTableMap::TITLE);
|
||||
break;
|
||||
case "manual-reverse":
|
||||
$search->orderByPosition(Criteria::DESC);
|
||||
break;
|
||||
case "manual":
|
||||
$search->orderByPosition(Criteria::ASC);
|
||||
break;
|
||||
case "random":
|
||||
$search->clearOrderByColumns();
|
||||
$search->addAscendingOrderByColumn('RAND()');
|
||||
break(2);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
$random = $this->getRandom();
|
||||
|
||||
if ($random === true) {
|
||||
$search->clearOrderByColumns();
|
||||
$search->addAscendingOrderByColumn('RAND()');
|
||||
}
|
||||
|
||||
/**
|
||||
* \Criteria::INNER_JOIN in second parameter for joinWithI18n exclude query without translation.
|
||||
*
|
||||
@@ -194,8 +175,7 @@ class Category extends BaseLoop
|
||||
$loopResultRow->set("PARENT", $category->getParent());
|
||||
$loopResultRow->set("ID", $category->getId());
|
||||
$loopResultRow->set("URL", $category->getUrl());
|
||||
$loopResultRow->set("LINK", $category->getLink());
|
||||
$loopResultRow->set("NB_CHILD", $category->countChild());
|
||||
$loopResultRow->set("PRODUCT_COUNT", $category->countChild());
|
||||
|
||||
$loopResult->addRow($loopResultRow);
|
||||
}
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
namespace Thelia\Core\Template\Loop;
|
||||
|
||||
use Propel\Runtime\ActiveQuery\Criteria;
|
||||
use Propel\Runtime\ActiveQuery\Join;
|
||||
use Thelia\Core\Template\Element\BaseLoop;
|
||||
use Thelia\Core\Template\Element\LoopResult;
|
||||
use Thelia\Core\Template\Element\LoopResultRow;
|
||||
@@ -32,7 +33,11 @@ use Thelia\Core\Template\Loop\Argument\ArgumentCollection;
|
||||
use Thelia\Core\Template\Loop\Argument\Argument;
|
||||
use Thelia\Log\Tlog;
|
||||
|
||||
use Thelia\Model\Base\FeatureProdQuery;
|
||||
use Thelia\Model\CategoryQuery;
|
||||
use Thelia\Model\FeatureAvQuery;
|
||||
use Thelia\Model\FeatureQuery;
|
||||
use Thelia\Model\Map\FeatureProdTableMap;
|
||||
use Thelia\Model\Map\ProductTableMap;
|
||||
use Thelia\Model\ProductCategoryQuery;
|
||||
use Thelia\Model\ProductQuery;
|
||||
@@ -74,16 +79,29 @@ class Product extends BaseLoop
|
||||
Argument::createFloatTypeArgument('max_weight'),
|
||||
Argument::createBooleanTypeArgument('current'),
|
||||
Argument::createBooleanTypeArgument('current_category'),
|
||||
Argument::createIntTypeArgument('depth'),
|
||||
Argument::createIntTypeArgument('depth', 1),
|
||||
Argument::createBooleanTypeArgument('visible', 1),
|
||||
new Argument(
|
||||
'order',
|
||||
new TypeCollection(
|
||||
new Type\EnumListType(array('alpha', 'alpha_reverse', 'reverse', 'min_price', 'max_price', 'manual', 'manual_reverse', 'ref', 'promo', 'new'))
|
||||
new Type\EnumListType(array('alpha', 'alpha_reverse', 'min_price', 'max_price', 'manual', 'manual_reverse', 'ref', 'promo', 'new', 'random', 'given_id'))
|
||||
),
|
||||
'manual'
|
||||
),
|
||||
Argument::createIntListTypeArgument('exclude'),
|
||||
Argument::createIntListTypeArgument('exclude_category'),
|
||||
new Argument(
|
||||
'feature_available',
|
||||
new TypeCollection(
|
||||
new Type\IntToCombinedIntsListType()
|
||||
)
|
||||
),
|
||||
Argument::createBooleanTypeArgument('random', 0),
|
||||
Argument::createIntListTypeArgument('exclude')
|
||||
new Argument(
|
||||
'feature_values',
|
||||
new TypeCollection(
|
||||
new Type\IntToCombinedStringsListType()
|
||||
)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
@@ -231,70 +249,133 @@ class Product extends BaseLoop
|
||||
);
|
||||
}
|
||||
|
||||
$search->filterByVisible($this->getVisible());
|
||||
$visible = $this->getVisible();
|
||||
|
||||
$search->filterByVisible($visible);
|
||||
|
||||
$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;
|
||||
}
|
||||
|
||||
foreach($orders as $order) {
|
||||
switch ($order) {
|
||||
case "alpha":
|
||||
$search->addAscendingOrderByColumn(\Thelia\Model\Map\ProductI18nTableMap::TITLE);
|
||||
break;
|
||||
case "alpha_reverse":
|
||||
$search->addDescendingOrderByColumn(\Thelia\Model\Map\ProductI18nTableMap::TITLE);
|
||||
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->orderByPosition(Criteria::ASC);
|
||||
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->orderByPosition(Criteria::DESC);
|
||||
break;
|
||||
case "ref":
|
||||
$search->orderByRef(Criteria::ASC);
|
||||
break;
|
||||
case "promo":
|
||||
$search->orderByPromo(Criteria::DESC);
|
||||
break;
|
||||
case "new":
|
||||
$search->orderByNewness(Criteria::DESC);
|
||||
break;
|
||||
case "given_id":
|
||||
if(null === $id)
|
||||
throw new \InvalidArgumentException('Given_id order cannot be set without `id` argument');
|
||||
foreach($id as $singleId) {
|
||||
$givenIdMatched = 'given_id_matched_' . $singleId;
|
||||
$search->withColumn(ProductTableMap::ID . "='$singleId'", $givenIdMatched);
|
||||
$search->orderBy($givenIdMatched, Criteria::DESC);
|
||||
}
|
||||
break;
|
||||
case "random":
|
||||
$search->clearOrderByColumns();
|
||||
$search->addAscendingOrderByColumn('RAND()');
|
||||
break(2);
|
||||
}
|
||||
}
|
||||
|
||||
$random = $this->getRandom();
|
||||
|
||||
if ($random === true) {
|
||||
$search->clearOrderByColumns();
|
||||
$search->addAscendingOrderByColumn('RAND()');
|
||||
}
|
||||
|
||||
$exclude = $this->getExclude();
|
||||
|
||||
if (!is_null($exclude)) {
|
||||
$search->filterById($exclude, Criteria::NOT_IN);
|
||||
}
|
||||
|
||||
$exclude_category = $this->getExclude_category();
|
||||
|
||||
if (!is_null($exclude_category)) {
|
||||
$search->filterByCategory(
|
||||
CategoryQuery::create()->filterById($exclude_category, Criteria::IN)->find(),
|
||||
Criteria::NOT_IN
|
||||
);
|
||||
}
|
||||
|
||||
$feature_available = $this->getFeature_available();
|
||||
|
||||
if(null !== $feature_available) {
|
||||
foreach($feature_available as $feature => $feature_choice) {
|
||||
foreach($feature_choice['values'] as $feature_av) {
|
||||
$featureAlias = 'fa_' . $feature;
|
||||
if($feature_av != '*')
|
||||
$featureAlias .= '_' . $feature_av;
|
||||
$search->joinFeatureProd($featureAlias, Criteria::LEFT_JOIN)
|
||||
->addJoinCondition($featureAlias, "`$featureAlias`.FEATURE_ID = ?", $feature, null, \PDO::PARAM_INT);
|
||||
if($feature_av != '*')
|
||||
$search->addJoinCondition($featureAlias, "`$featureAlias`.FEATURE_AV_ID = ?", $feature_av, null, \PDO::PARAM_INT);
|
||||
}
|
||||
|
||||
/* format for mysql */
|
||||
$sqlWhereString = $feature_choice['expression'];
|
||||
if($sqlWhereString == '*') {
|
||||
$sqlWhereString = 'NOT ISNULL(`fa_' . $feature . '`.ID)';
|
||||
} else {
|
||||
$sqlWhereString = preg_replace('#([0-9]+)#', 'NOT ISNULL(`fa_' . $feature . '_' . '\1`.ID)', $sqlWhereString);
|
||||
$sqlWhereString = str_replace('&', ' AND ', $sqlWhereString);
|
||||
$sqlWhereString = str_replace('|', ' OR ', $sqlWhereString);
|
||||
}
|
||||
|
||||
$search->where("(" . $sqlWhereString . ")");
|
||||
}
|
||||
}
|
||||
|
||||
$feature_values = $this->getFeature_values();
|
||||
|
||||
if(null !== $feature_values) {
|
||||
foreach($feature_values as $feature => $feature_choice) {
|
||||
foreach($feature_choice['values'] as $feature_value) {
|
||||
$featureAlias = 'fv_' . $feature;
|
||||
if($feature_value != '*')
|
||||
$featureAlias .= '_' . $feature_value;
|
||||
$search->joinFeatureProd($featureAlias, Criteria::LEFT_JOIN)
|
||||
->addJoinCondition($featureAlias, "`$featureAlias`.FEATURE_ID = ?", $feature, null, \PDO::PARAM_INT);
|
||||
if($feature_value != '*')
|
||||
$search->addJoinCondition($featureAlias, "`$featureAlias`.BY_DEFAULT = ?", $feature_value, null, \PDO::PARAM_STR);
|
||||
}
|
||||
|
||||
/* format for mysql */
|
||||
$sqlWhereString = $feature_choice['expression'];
|
||||
if($sqlWhereString == '*') {
|
||||
$sqlWhereString = 'NOT ISNULL(`fv_' . $feature . '`.ID)';
|
||||
} else {
|
||||
$sqlWhereString = preg_replace('#([a-zA-Z0-9_\-]+)#', 'NOT ISNULL(`fv_' . $feature . '_' . '\1`.ID)', $sqlWhereString);
|
||||
$sqlWhereString = str_replace('&', ' AND ', $sqlWhereString);
|
||||
$sqlWhereString = str_replace('|', ' OR ', $sqlWhereString);
|
||||
}
|
||||
|
||||
$search->where("(" . $sqlWhereString . ")");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Criteria::INNER_JOIN in second parameter for joinWithI18n exclude query without translation.
|
||||
*
|
||||
@@ -306,6 +387,8 @@ class Product extends BaseLoop
|
||||
(ConfigQuery::read("default_lang_without_translation", 1)) ? Criteria::LEFT_JOIN : Criteria::INNER_JOIN
|
||||
);
|
||||
|
||||
$search->groupBy(ProductTableMap::ID);
|
||||
|
||||
$products = $this->search($search, $pagination);
|
||||
|
||||
$loopResult = new LoopResult();
|
||||
@@ -324,8 +407,6 @@ class Product extends BaseLoop
|
||||
$loopResultRow->set("PROMO", $product->getPromo());
|
||||
$loopResultRow->set("NEW", $product->getNewness());
|
||||
|
||||
//$loopResultRow->set("URL", $product->getUrl());
|
||||
|
||||
$loopResult->addRow($loopResultRow);
|
||||
}
|
||||
|
||||
|
||||
@@ -92,12 +92,6 @@ abstract class Category implements ActiveRecordInterface
|
||||
*/
|
||||
protected $parent;
|
||||
|
||||
/**
|
||||
* The value for the link field.
|
||||
* @var string
|
||||
*/
|
||||
protected $link;
|
||||
|
||||
/**
|
||||
* The value for the visible field.
|
||||
* @var int
|
||||
@@ -601,17 +595,6 @@ abstract class Category implements ActiveRecordInterface
|
||||
return $this->parent;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the [link] column value.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getLink()
|
||||
{
|
||||
|
||||
return $this->link;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the [visible] column value.
|
||||
*
|
||||
@@ -758,27 +741,6 @@ abstract class Category implements ActiveRecordInterface
|
||||
return $this;
|
||||
} // setParent()
|
||||
|
||||
/**
|
||||
* Set the value of [link] column.
|
||||
*
|
||||
* @param string $v new value
|
||||
* @return \Thelia\Model\Category The current object (for fluent API support)
|
||||
*/
|
||||
public function setLink($v)
|
||||
{
|
||||
if ($v !== null) {
|
||||
$v = (string) $v;
|
||||
}
|
||||
|
||||
if ($this->link !== $v) {
|
||||
$this->link = $v;
|
||||
$this->modifiedColumns[] = CategoryTableMap::LINK;
|
||||
}
|
||||
|
||||
|
||||
return $this;
|
||||
} // setLink()
|
||||
|
||||
/**
|
||||
* Set the value of [visible] column.
|
||||
*
|
||||
@@ -973,37 +935,34 @@ abstract class Category implements ActiveRecordInterface
|
||||
$col = $row[TableMap::TYPE_NUM == $indexType ? 1 + $startcol : CategoryTableMap::translateFieldName('Parent', TableMap::TYPE_PHPNAME, $indexType)];
|
||||
$this->parent = (null !== $col) ? (int) $col : null;
|
||||
|
||||
$col = $row[TableMap::TYPE_NUM == $indexType ? 2 + $startcol : CategoryTableMap::translateFieldName('Link', TableMap::TYPE_PHPNAME, $indexType)];
|
||||
$this->link = (null !== $col) ? (string) $col : null;
|
||||
|
||||
$col = $row[TableMap::TYPE_NUM == $indexType ? 3 + $startcol : CategoryTableMap::translateFieldName('Visible', TableMap::TYPE_PHPNAME, $indexType)];
|
||||
$col = $row[TableMap::TYPE_NUM == $indexType ? 2 + $startcol : CategoryTableMap::translateFieldName('Visible', TableMap::TYPE_PHPNAME, $indexType)];
|
||||
$this->visible = (null !== $col) ? (int) $col : null;
|
||||
|
||||
$col = $row[TableMap::TYPE_NUM == $indexType ? 4 + $startcol : CategoryTableMap::translateFieldName('Position', TableMap::TYPE_PHPNAME, $indexType)];
|
||||
$col = $row[TableMap::TYPE_NUM == $indexType ? 3 + $startcol : CategoryTableMap::translateFieldName('Position', TableMap::TYPE_PHPNAME, $indexType)];
|
||||
$this->position = (null !== $col) ? (int) $col : null;
|
||||
|
||||
$col = $row[TableMap::TYPE_NUM == $indexType ? 5 + $startcol : CategoryTableMap::translateFieldName('CreatedAt', TableMap::TYPE_PHPNAME, $indexType)];
|
||||
$col = $row[TableMap::TYPE_NUM == $indexType ? 4 + $startcol : CategoryTableMap::translateFieldName('CreatedAt', TableMap::TYPE_PHPNAME, $indexType)];
|
||||
if ($col === '0000-00-00 00:00:00') {
|
||||
$col = null;
|
||||
}
|
||||
$this->created_at = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null;
|
||||
|
||||
$col = $row[TableMap::TYPE_NUM == $indexType ? 6 + $startcol : CategoryTableMap::translateFieldName('UpdatedAt', TableMap::TYPE_PHPNAME, $indexType)];
|
||||
$col = $row[TableMap::TYPE_NUM == $indexType ? 5 + $startcol : CategoryTableMap::translateFieldName('UpdatedAt', TableMap::TYPE_PHPNAME, $indexType)];
|
||||
if ($col === '0000-00-00 00:00:00') {
|
||||
$col = null;
|
||||
}
|
||||
$this->updated_at = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null;
|
||||
|
||||
$col = $row[TableMap::TYPE_NUM == $indexType ? 7 + $startcol : CategoryTableMap::translateFieldName('Version', TableMap::TYPE_PHPNAME, $indexType)];
|
||||
$col = $row[TableMap::TYPE_NUM == $indexType ? 6 + $startcol : CategoryTableMap::translateFieldName('Version', TableMap::TYPE_PHPNAME, $indexType)];
|
||||
$this->version = (null !== $col) ? (int) $col : null;
|
||||
|
||||
$col = $row[TableMap::TYPE_NUM == $indexType ? 8 + $startcol : CategoryTableMap::translateFieldName('VersionCreatedAt', TableMap::TYPE_PHPNAME, $indexType)];
|
||||
$col = $row[TableMap::TYPE_NUM == $indexType ? 7 + $startcol : CategoryTableMap::translateFieldName('VersionCreatedAt', TableMap::TYPE_PHPNAME, $indexType)];
|
||||
if ($col === '0000-00-00 00:00:00') {
|
||||
$col = null;
|
||||
}
|
||||
$this->version_created_at = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null;
|
||||
|
||||
$col = $row[TableMap::TYPE_NUM == $indexType ? 9 + $startcol : CategoryTableMap::translateFieldName('VersionCreatedBy', TableMap::TYPE_PHPNAME, $indexType)];
|
||||
$col = $row[TableMap::TYPE_NUM == $indexType ? 8 + $startcol : CategoryTableMap::translateFieldName('VersionCreatedBy', TableMap::TYPE_PHPNAME, $indexType)];
|
||||
$this->version_created_by = (null !== $col) ? (string) $col : null;
|
||||
$this->resetModified();
|
||||
|
||||
@@ -1013,7 +972,7 @@ abstract class Category implements ActiveRecordInterface
|
||||
$this->ensureConsistency();
|
||||
}
|
||||
|
||||
return $startcol + 10; // 10 = CategoryTableMap::NUM_HYDRATE_COLUMNS.
|
||||
return $startcol + 9; // 9 = CategoryTableMap::NUM_HYDRATE_COLUMNS.
|
||||
|
||||
} catch (Exception $e) {
|
||||
throw new PropelException("Error populating \Thelia\Model\Category object", 0, $e);
|
||||
@@ -1506,9 +1465,6 @@ abstract class Category implements ActiveRecordInterface
|
||||
if ($this->isColumnModified(CategoryTableMap::PARENT)) {
|
||||
$modifiedColumns[':p' . $index++] = 'PARENT';
|
||||
}
|
||||
if ($this->isColumnModified(CategoryTableMap::LINK)) {
|
||||
$modifiedColumns[':p' . $index++] = 'LINK';
|
||||
}
|
||||
if ($this->isColumnModified(CategoryTableMap::VISIBLE)) {
|
||||
$modifiedColumns[':p' . $index++] = 'VISIBLE';
|
||||
}
|
||||
@@ -1547,9 +1503,6 @@ abstract class Category implements ActiveRecordInterface
|
||||
case 'PARENT':
|
||||
$stmt->bindValue($identifier, $this->parent, PDO::PARAM_INT);
|
||||
break;
|
||||
case 'LINK':
|
||||
$stmt->bindValue($identifier, $this->link, PDO::PARAM_STR);
|
||||
break;
|
||||
case 'VISIBLE':
|
||||
$stmt->bindValue($identifier, $this->visible, PDO::PARAM_INT);
|
||||
break;
|
||||
@@ -1640,27 +1593,24 @@ abstract class Category implements ActiveRecordInterface
|
||||
return $this->getParent();
|
||||
break;
|
||||
case 2:
|
||||
return $this->getLink();
|
||||
break;
|
||||
case 3:
|
||||
return $this->getVisible();
|
||||
break;
|
||||
case 4:
|
||||
case 3:
|
||||
return $this->getPosition();
|
||||
break;
|
||||
case 5:
|
||||
case 4:
|
||||
return $this->getCreatedAt();
|
||||
break;
|
||||
case 6:
|
||||
case 5:
|
||||
return $this->getUpdatedAt();
|
||||
break;
|
||||
case 7:
|
||||
case 6:
|
||||
return $this->getVersion();
|
||||
break;
|
||||
case 8:
|
||||
case 7:
|
||||
return $this->getVersionCreatedAt();
|
||||
break;
|
||||
case 9:
|
||||
case 8:
|
||||
return $this->getVersionCreatedBy();
|
||||
break;
|
||||
default:
|
||||
@@ -1694,14 +1644,13 @@ abstract class Category implements ActiveRecordInterface
|
||||
$result = array(
|
||||
$keys[0] => $this->getId(),
|
||||
$keys[1] => $this->getParent(),
|
||||
$keys[2] => $this->getLink(),
|
||||
$keys[3] => $this->getVisible(),
|
||||
$keys[4] => $this->getPosition(),
|
||||
$keys[5] => $this->getCreatedAt(),
|
||||
$keys[6] => $this->getUpdatedAt(),
|
||||
$keys[7] => $this->getVersion(),
|
||||
$keys[8] => $this->getVersionCreatedAt(),
|
||||
$keys[9] => $this->getVersionCreatedBy(),
|
||||
$keys[2] => $this->getVisible(),
|
||||
$keys[3] => $this->getPosition(),
|
||||
$keys[4] => $this->getCreatedAt(),
|
||||
$keys[5] => $this->getUpdatedAt(),
|
||||
$keys[6] => $this->getVersion(),
|
||||
$keys[7] => $this->getVersionCreatedAt(),
|
||||
$keys[8] => $this->getVersionCreatedBy(),
|
||||
);
|
||||
$virtualColumns = $this->virtualColumns;
|
||||
foreach($virtualColumns as $key => $virtualColumn)
|
||||
@@ -1778,27 +1727,24 @@ abstract class Category implements ActiveRecordInterface
|
||||
$this->setParent($value);
|
||||
break;
|
||||
case 2:
|
||||
$this->setLink($value);
|
||||
break;
|
||||
case 3:
|
||||
$this->setVisible($value);
|
||||
break;
|
||||
case 4:
|
||||
case 3:
|
||||
$this->setPosition($value);
|
||||
break;
|
||||
case 5:
|
||||
case 4:
|
||||
$this->setCreatedAt($value);
|
||||
break;
|
||||
case 6:
|
||||
case 5:
|
||||
$this->setUpdatedAt($value);
|
||||
break;
|
||||
case 7:
|
||||
case 6:
|
||||
$this->setVersion($value);
|
||||
break;
|
||||
case 8:
|
||||
case 7:
|
||||
$this->setVersionCreatedAt($value);
|
||||
break;
|
||||
case 9:
|
||||
case 8:
|
||||
$this->setVersionCreatedBy($value);
|
||||
break;
|
||||
} // switch()
|
||||
@@ -1827,14 +1773,13 @@ abstract class Category implements ActiveRecordInterface
|
||||
|
||||
if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]);
|
||||
if (array_key_exists($keys[1], $arr)) $this->setParent($arr[$keys[1]]);
|
||||
if (array_key_exists($keys[2], $arr)) $this->setLink($arr[$keys[2]]);
|
||||
if (array_key_exists($keys[3], $arr)) $this->setVisible($arr[$keys[3]]);
|
||||
if (array_key_exists($keys[4], $arr)) $this->setPosition($arr[$keys[4]]);
|
||||
if (array_key_exists($keys[5], $arr)) $this->setCreatedAt($arr[$keys[5]]);
|
||||
if (array_key_exists($keys[6], $arr)) $this->setUpdatedAt($arr[$keys[6]]);
|
||||
if (array_key_exists($keys[7], $arr)) $this->setVersion($arr[$keys[7]]);
|
||||
if (array_key_exists($keys[8], $arr)) $this->setVersionCreatedAt($arr[$keys[8]]);
|
||||
if (array_key_exists($keys[9], $arr)) $this->setVersionCreatedBy($arr[$keys[9]]);
|
||||
if (array_key_exists($keys[2], $arr)) $this->setVisible($arr[$keys[2]]);
|
||||
if (array_key_exists($keys[3], $arr)) $this->setPosition($arr[$keys[3]]);
|
||||
if (array_key_exists($keys[4], $arr)) $this->setCreatedAt($arr[$keys[4]]);
|
||||
if (array_key_exists($keys[5], $arr)) $this->setUpdatedAt($arr[$keys[5]]);
|
||||
if (array_key_exists($keys[6], $arr)) $this->setVersion($arr[$keys[6]]);
|
||||
if (array_key_exists($keys[7], $arr)) $this->setVersionCreatedAt($arr[$keys[7]]);
|
||||
if (array_key_exists($keys[8], $arr)) $this->setVersionCreatedBy($arr[$keys[8]]);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1848,7 +1793,6 @@ abstract class Category implements ActiveRecordInterface
|
||||
|
||||
if ($this->isColumnModified(CategoryTableMap::ID)) $criteria->add(CategoryTableMap::ID, $this->id);
|
||||
if ($this->isColumnModified(CategoryTableMap::PARENT)) $criteria->add(CategoryTableMap::PARENT, $this->parent);
|
||||
if ($this->isColumnModified(CategoryTableMap::LINK)) $criteria->add(CategoryTableMap::LINK, $this->link);
|
||||
if ($this->isColumnModified(CategoryTableMap::VISIBLE)) $criteria->add(CategoryTableMap::VISIBLE, $this->visible);
|
||||
if ($this->isColumnModified(CategoryTableMap::POSITION)) $criteria->add(CategoryTableMap::POSITION, $this->position);
|
||||
if ($this->isColumnModified(CategoryTableMap::CREATED_AT)) $criteria->add(CategoryTableMap::CREATED_AT, $this->created_at);
|
||||
@@ -1920,7 +1864,6 @@ abstract class Category implements ActiveRecordInterface
|
||||
public function copyInto($copyObj, $deepCopy = false, $makeNew = true)
|
||||
{
|
||||
$copyObj->setParent($this->getParent());
|
||||
$copyObj->setLink($this->getLink());
|
||||
$copyObj->setVisible($this->getVisible());
|
||||
$copyObj->setPosition($this->getPosition());
|
||||
$copyObj->setCreatedAt($this->getCreatedAt());
|
||||
@@ -4939,7 +4882,6 @@ abstract class Category implements ActiveRecordInterface
|
||||
{
|
||||
$this->id = null;
|
||||
$this->parent = null;
|
||||
$this->link = null;
|
||||
$this->visible = null;
|
||||
$this->position = null;
|
||||
$this->created_at = null;
|
||||
@@ -5352,7 +5294,6 @@ abstract class Category implements ActiveRecordInterface
|
||||
$version = new ChildCategoryVersion();
|
||||
$version->setId($this->getId());
|
||||
$version->setParent($this->getParent());
|
||||
$version->setLink($this->getLink());
|
||||
$version->setVisible($this->getVisible());
|
||||
$version->setPosition($this->getPosition());
|
||||
$version->setCreatedAt($this->getCreatedAt());
|
||||
@@ -5399,7 +5340,6 @@ abstract class Category implements ActiveRecordInterface
|
||||
$loadedObjects['ChildCategory'][$version->getId()][$version->getVersion()] = $this;
|
||||
$this->setId($version->getId());
|
||||
$this->setParent($version->getParent());
|
||||
$this->setLink($version->getLink());
|
||||
$this->setVisible($version->getVisible());
|
||||
$this->setPosition($version->getPosition());
|
||||
$this->setCreatedAt($version->getCreatedAt());
|
||||
|
||||
@@ -24,7 +24,6 @@ use Thelia\Model\Map\CategoryTableMap;
|
||||
*
|
||||
* @method ChildCategoryQuery orderById($order = Criteria::ASC) Order by the id column
|
||||
* @method ChildCategoryQuery orderByParent($order = Criteria::ASC) Order by the parent column
|
||||
* @method ChildCategoryQuery orderByLink($order = Criteria::ASC) Order by the link column
|
||||
* @method ChildCategoryQuery orderByVisible($order = Criteria::ASC) Order by the visible column
|
||||
* @method ChildCategoryQuery orderByPosition($order = Criteria::ASC) Order by the position column
|
||||
* @method ChildCategoryQuery orderByCreatedAt($order = Criteria::ASC) Order by the created_at column
|
||||
@@ -35,7 +34,6 @@ use Thelia\Model\Map\CategoryTableMap;
|
||||
*
|
||||
* @method ChildCategoryQuery groupById() Group by the id column
|
||||
* @method ChildCategoryQuery groupByParent() Group by the parent column
|
||||
* @method ChildCategoryQuery groupByLink() Group by the link column
|
||||
* @method ChildCategoryQuery groupByVisible() Group by the visible column
|
||||
* @method ChildCategoryQuery groupByPosition() Group by the position column
|
||||
* @method ChildCategoryQuery groupByCreatedAt() Group by the created_at column
|
||||
@@ -89,7 +87,6 @@ use Thelia\Model\Map\CategoryTableMap;
|
||||
*
|
||||
* @method ChildCategory findOneById(int $id) Return the first ChildCategory filtered by the id column
|
||||
* @method ChildCategory findOneByParent(int $parent) Return the first ChildCategory filtered by the parent column
|
||||
* @method ChildCategory findOneByLink(string $link) Return the first ChildCategory filtered by the link column
|
||||
* @method ChildCategory findOneByVisible(int $visible) Return the first ChildCategory filtered by the visible column
|
||||
* @method ChildCategory findOneByPosition(int $position) Return the first ChildCategory filtered by the position column
|
||||
* @method ChildCategory findOneByCreatedAt(string $created_at) Return the first ChildCategory filtered by the created_at column
|
||||
@@ -100,7 +97,6 @@ use Thelia\Model\Map\CategoryTableMap;
|
||||
*
|
||||
* @method array findById(int $id) Return ChildCategory objects filtered by the id column
|
||||
* @method array findByParent(int $parent) Return ChildCategory objects filtered by the parent column
|
||||
* @method array findByLink(string $link) Return ChildCategory objects filtered by the link column
|
||||
* @method array findByVisible(int $visible) Return ChildCategory objects filtered by the visible column
|
||||
* @method array findByPosition(int $position) Return ChildCategory objects filtered by the position column
|
||||
* @method array findByCreatedAt(string $created_at) Return ChildCategory objects filtered by the created_at column
|
||||
@@ -203,7 +199,7 @@ abstract class CategoryQuery extends ModelCriteria
|
||||
*/
|
||||
protected function findPkSimple($key, $con)
|
||||
{
|
||||
$sql = 'SELECT ID, PARENT, LINK, VISIBLE, POSITION, CREATED_AT, UPDATED_AT, VERSION, VERSION_CREATED_AT, VERSION_CREATED_BY FROM category WHERE ID = :p0';
|
||||
$sql = 'SELECT ID, PARENT, VISIBLE, POSITION, CREATED_AT, UPDATED_AT, VERSION, VERSION_CREATED_AT, VERSION_CREATED_BY FROM category WHERE ID = :p0';
|
||||
try {
|
||||
$stmt = $con->prepare($sql);
|
||||
$stmt->bindValue(':p0', $key, PDO::PARAM_INT);
|
||||
@@ -374,35 +370,6 @@ abstract class CategoryQuery extends ModelCriteria
|
||||
return $this->addUsingAlias(CategoryTableMap::PARENT, $parent, $comparison);
|
||||
}
|
||||
|
||||
/**
|
||||
* Filter the query on the link column
|
||||
*
|
||||
* Example usage:
|
||||
* <code>
|
||||
* $query->filterByLink('fooValue'); // WHERE link = 'fooValue'
|
||||
* $query->filterByLink('%fooValue%'); // WHERE link LIKE '%fooValue%'
|
||||
* </code>
|
||||
*
|
||||
* @param string $link The value to use as filter.
|
||||
* Accepts wildcards (* and % trigger a LIKE)
|
||||
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
|
||||
*
|
||||
* @return ChildCategoryQuery The current query, for fluid interface
|
||||
*/
|
||||
public function filterByLink($link = null, $comparison = null)
|
||||
{
|
||||
if (null === $comparison) {
|
||||
if (is_array($link)) {
|
||||
$comparison = Criteria::IN;
|
||||
} elseif (preg_match('/[\%\*]/', $link)) {
|
||||
$link = str_replace('*', '%', $link);
|
||||
$comparison = Criteria::LIKE;
|
||||
}
|
||||
}
|
||||
|
||||
return $this->addUsingAlias(CategoryTableMap::LINK, $link, $comparison);
|
||||
}
|
||||
|
||||
/**
|
||||
* Filter the query on the visible column
|
||||
*
|
||||
|
||||
@@ -67,12 +67,6 @@ abstract class CategoryVersion implements ActiveRecordInterface
|
||||
*/
|
||||
protected $parent;
|
||||
|
||||
/**
|
||||
* The value for the link field.
|
||||
* @var string
|
||||
*/
|
||||
protected $link;
|
||||
|
||||
/**
|
||||
* The value for the visible field.
|
||||
* @var int
|
||||
@@ -418,17 +412,6 @@ abstract class CategoryVersion implements ActiveRecordInterface
|
||||
return $this->parent;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the [link] column value.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getLink()
|
||||
{
|
||||
|
||||
return $this->link;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the [visible] column value.
|
||||
*
|
||||
@@ -579,27 +562,6 @@ abstract class CategoryVersion implements ActiveRecordInterface
|
||||
return $this;
|
||||
} // setParent()
|
||||
|
||||
/**
|
||||
* Set the value of [link] column.
|
||||
*
|
||||
* @param string $v new value
|
||||
* @return \Thelia\Model\CategoryVersion The current object (for fluent API support)
|
||||
*/
|
||||
public function setLink($v)
|
||||
{
|
||||
if ($v !== null) {
|
||||
$v = (string) $v;
|
||||
}
|
||||
|
||||
if ($this->link !== $v) {
|
||||
$this->link = $v;
|
||||
$this->modifiedColumns[] = CategoryVersionTableMap::LINK;
|
||||
}
|
||||
|
||||
|
||||
return $this;
|
||||
} // setLink()
|
||||
|
||||
/**
|
||||
* Set the value of [visible] column.
|
||||
*
|
||||
@@ -794,37 +756,34 @@ abstract class CategoryVersion implements ActiveRecordInterface
|
||||
$col = $row[TableMap::TYPE_NUM == $indexType ? 1 + $startcol : CategoryVersionTableMap::translateFieldName('Parent', TableMap::TYPE_PHPNAME, $indexType)];
|
||||
$this->parent = (null !== $col) ? (int) $col : null;
|
||||
|
||||
$col = $row[TableMap::TYPE_NUM == $indexType ? 2 + $startcol : CategoryVersionTableMap::translateFieldName('Link', TableMap::TYPE_PHPNAME, $indexType)];
|
||||
$this->link = (null !== $col) ? (string) $col : null;
|
||||
|
||||
$col = $row[TableMap::TYPE_NUM == $indexType ? 3 + $startcol : CategoryVersionTableMap::translateFieldName('Visible', TableMap::TYPE_PHPNAME, $indexType)];
|
||||
$col = $row[TableMap::TYPE_NUM == $indexType ? 2 + $startcol : CategoryVersionTableMap::translateFieldName('Visible', TableMap::TYPE_PHPNAME, $indexType)];
|
||||
$this->visible = (null !== $col) ? (int) $col : null;
|
||||
|
||||
$col = $row[TableMap::TYPE_NUM == $indexType ? 4 + $startcol : CategoryVersionTableMap::translateFieldName('Position', TableMap::TYPE_PHPNAME, $indexType)];
|
||||
$col = $row[TableMap::TYPE_NUM == $indexType ? 3 + $startcol : CategoryVersionTableMap::translateFieldName('Position', TableMap::TYPE_PHPNAME, $indexType)];
|
||||
$this->position = (null !== $col) ? (int) $col : null;
|
||||
|
||||
$col = $row[TableMap::TYPE_NUM == $indexType ? 5 + $startcol : CategoryVersionTableMap::translateFieldName('CreatedAt', TableMap::TYPE_PHPNAME, $indexType)];
|
||||
$col = $row[TableMap::TYPE_NUM == $indexType ? 4 + $startcol : CategoryVersionTableMap::translateFieldName('CreatedAt', TableMap::TYPE_PHPNAME, $indexType)];
|
||||
if ($col === '0000-00-00 00:00:00') {
|
||||
$col = null;
|
||||
}
|
||||
$this->created_at = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null;
|
||||
|
||||
$col = $row[TableMap::TYPE_NUM == $indexType ? 6 + $startcol : CategoryVersionTableMap::translateFieldName('UpdatedAt', TableMap::TYPE_PHPNAME, $indexType)];
|
||||
$col = $row[TableMap::TYPE_NUM == $indexType ? 5 + $startcol : CategoryVersionTableMap::translateFieldName('UpdatedAt', TableMap::TYPE_PHPNAME, $indexType)];
|
||||
if ($col === '0000-00-00 00:00:00') {
|
||||
$col = null;
|
||||
}
|
||||
$this->updated_at = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null;
|
||||
|
||||
$col = $row[TableMap::TYPE_NUM == $indexType ? 7 + $startcol : CategoryVersionTableMap::translateFieldName('Version', TableMap::TYPE_PHPNAME, $indexType)];
|
||||
$col = $row[TableMap::TYPE_NUM == $indexType ? 6 + $startcol : CategoryVersionTableMap::translateFieldName('Version', TableMap::TYPE_PHPNAME, $indexType)];
|
||||
$this->version = (null !== $col) ? (int) $col : null;
|
||||
|
||||
$col = $row[TableMap::TYPE_NUM == $indexType ? 8 + $startcol : CategoryVersionTableMap::translateFieldName('VersionCreatedAt', TableMap::TYPE_PHPNAME, $indexType)];
|
||||
$col = $row[TableMap::TYPE_NUM == $indexType ? 7 + $startcol : CategoryVersionTableMap::translateFieldName('VersionCreatedAt', TableMap::TYPE_PHPNAME, $indexType)];
|
||||
if ($col === '0000-00-00 00:00:00') {
|
||||
$col = null;
|
||||
}
|
||||
$this->version_created_at = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null;
|
||||
|
||||
$col = $row[TableMap::TYPE_NUM == $indexType ? 9 + $startcol : CategoryVersionTableMap::translateFieldName('VersionCreatedBy', TableMap::TYPE_PHPNAME, $indexType)];
|
||||
$col = $row[TableMap::TYPE_NUM == $indexType ? 8 + $startcol : CategoryVersionTableMap::translateFieldName('VersionCreatedBy', TableMap::TYPE_PHPNAME, $indexType)];
|
||||
$this->version_created_by = (null !== $col) ? (string) $col : null;
|
||||
$this->resetModified();
|
||||
|
||||
@@ -834,7 +793,7 @@ abstract class CategoryVersion implements ActiveRecordInterface
|
||||
$this->ensureConsistency();
|
||||
}
|
||||
|
||||
return $startcol + 10; // 10 = CategoryVersionTableMap::NUM_HYDRATE_COLUMNS.
|
||||
return $startcol + 9; // 9 = CategoryVersionTableMap::NUM_HYDRATE_COLUMNS.
|
||||
|
||||
} catch (Exception $e) {
|
||||
throw new PropelException("Error populating \Thelia\Model\CategoryVersion object", 0, $e);
|
||||
@@ -1061,9 +1020,6 @@ abstract class CategoryVersion implements ActiveRecordInterface
|
||||
if ($this->isColumnModified(CategoryVersionTableMap::PARENT)) {
|
||||
$modifiedColumns[':p' . $index++] = 'PARENT';
|
||||
}
|
||||
if ($this->isColumnModified(CategoryVersionTableMap::LINK)) {
|
||||
$modifiedColumns[':p' . $index++] = 'LINK';
|
||||
}
|
||||
if ($this->isColumnModified(CategoryVersionTableMap::VISIBLE)) {
|
||||
$modifiedColumns[':p' . $index++] = 'VISIBLE';
|
||||
}
|
||||
@@ -1102,9 +1058,6 @@ abstract class CategoryVersion implements ActiveRecordInterface
|
||||
case 'PARENT':
|
||||
$stmt->bindValue($identifier, $this->parent, PDO::PARAM_INT);
|
||||
break;
|
||||
case 'LINK':
|
||||
$stmt->bindValue($identifier, $this->link, PDO::PARAM_STR);
|
||||
break;
|
||||
case 'VISIBLE':
|
||||
$stmt->bindValue($identifier, $this->visible, PDO::PARAM_INT);
|
||||
break;
|
||||
@@ -1188,27 +1141,24 @@ abstract class CategoryVersion implements ActiveRecordInterface
|
||||
return $this->getParent();
|
||||
break;
|
||||
case 2:
|
||||
return $this->getLink();
|
||||
break;
|
||||
case 3:
|
||||
return $this->getVisible();
|
||||
break;
|
||||
case 4:
|
||||
case 3:
|
||||
return $this->getPosition();
|
||||
break;
|
||||
case 5:
|
||||
case 4:
|
||||
return $this->getCreatedAt();
|
||||
break;
|
||||
case 6:
|
||||
case 5:
|
||||
return $this->getUpdatedAt();
|
||||
break;
|
||||
case 7:
|
||||
case 6:
|
||||
return $this->getVersion();
|
||||
break;
|
||||
case 8:
|
||||
case 7:
|
||||
return $this->getVersionCreatedAt();
|
||||
break;
|
||||
case 9:
|
||||
case 8:
|
||||
return $this->getVersionCreatedBy();
|
||||
break;
|
||||
default:
|
||||
@@ -1242,14 +1192,13 @@ abstract class CategoryVersion implements ActiveRecordInterface
|
||||
$result = array(
|
||||
$keys[0] => $this->getId(),
|
||||
$keys[1] => $this->getParent(),
|
||||
$keys[2] => $this->getLink(),
|
||||
$keys[3] => $this->getVisible(),
|
||||
$keys[4] => $this->getPosition(),
|
||||
$keys[5] => $this->getCreatedAt(),
|
||||
$keys[6] => $this->getUpdatedAt(),
|
||||
$keys[7] => $this->getVersion(),
|
||||
$keys[8] => $this->getVersionCreatedAt(),
|
||||
$keys[9] => $this->getVersionCreatedBy(),
|
||||
$keys[2] => $this->getVisible(),
|
||||
$keys[3] => $this->getPosition(),
|
||||
$keys[4] => $this->getCreatedAt(),
|
||||
$keys[5] => $this->getUpdatedAt(),
|
||||
$keys[6] => $this->getVersion(),
|
||||
$keys[7] => $this->getVersionCreatedAt(),
|
||||
$keys[8] => $this->getVersionCreatedBy(),
|
||||
);
|
||||
$virtualColumns = $this->virtualColumns;
|
||||
foreach($virtualColumns as $key => $virtualColumn)
|
||||
@@ -1302,27 +1251,24 @@ abstract class CategoryVersion implements ActiveRecordInterface
|
||||
$this->setParent($value);
|
||||
break;
|
||||
case 2:
|
||||
$this->setLink($value);
|
||||
break;
|
||||
case 3:
|
||||
$this->setVisible($value);
|
||||
break;
|
||||
case 4:
|
||||
case 3:
|
||||
$this->setPosition($value);
|
||||
break;
|
||||
case 5:
|
||||
case 4:
|
||||
$this->setCreatedAt($value);
|
||||
break;
|
||||
case 6:
|
||||
case 5:
|
||||
$this->setUpdatedAt($value);
|
||||
break;
|
||||
case 7:
|
||||
case 6:
|
||||
$this->setVersion($value);
|
||||
break;
|
||||
case 8:
|
||||
case 7:
|
||||
$this->setVersionCreatedAt($value);
|
||||
break;
|
||||
case 9:
|
||||
case 8:
|
||||
$this->setVersionCreatedBy($value);
|
||||
break;
|
||||
} // switch()
|
||||
@@ -1351,14 +1297,13 @@ abstract class CategoryVersion implements ActiveRecordInterface
|
||||
|
||||
if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]);
|
||||
if (array_key_exists($keys[1], $arr)) $this->setParent($arr[$keys[1]]);
|
||||
if (array_key_exists($keys[2], $arr)) $this->setLink($arr[$keys[2]]);
|
||||
if (array_key_exists($keys[3], $arr)) $this->setVisible($arr[$keys[3]]);
|
||||
if (array_key_exists($keys[4], $arr)) $this->setPosition($arr[$keys[4]]);
|
||||
if (array_key_exists($keys[5], $arr)) $this->setCreatedAt($arr[$keys[5]]);
|
||||
if (array_key_exists($keys[6], $arr)) $this->setUpdatedAt($arr[$keys[6]]);
|
||||
if (array_key_exists($keys[7], $arr)) $this->setVersion($arr[$keys[7]]);
|
||||
if (array_key_exists($keys[8], $arr)) $this->setVersionCreatedAt($arr[$keys[8]]);
|
||||
if (array_key_exists($keys[9], $arr)) $this->setVersionCreatedBy($arr[$keys[9]]);
|
||||
if (array_key_exists($keys[2], $arr)) $this->setVisible($arr[$keys[2]]);
|
||||
if (array_key_exists($keys[3], $arr)) $this->setPosition($arr[$keys[3]]);
|
||||
if (array_key_exists($keys[4], $arr)) $this->setCreatedAt($arr[$keys[4]]);
|
||||
if (array_key_exists($keys[5], $arr)) $this->setUpdatedAt($arr[$keys[5]]);
|
||||
if (array_key_exists($keys[6], $arr)) $this->setVersion($arr[$keys[6]]);
|
||||
if (array_key_exists($keys[7], $arr)) $this->setVersionCreatedAt($arr[$keys[7]]);
|
||||
if (array_key_exists($keys[8], $arr)) $this->setVersionCreatedBy($arr[$keys[8]]);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1372,7 +1317,6 @@ abstract class CategoryVersion implements ActiveRecordInterface
|
||||
|
||||
if ($this->isColumnModified(CategoryVersionTableMap::ID)) $criteria->add(CategoryVersionTableMap::ID, $this->id);
|
||||
if ($this->isColumnModified(CategoryVersionTableMap::PARENT)) $criteria->add(CategoryVersionTableMap::PARENT, $this->parent);
|
||||
if ($this->isColumnModified(CategoryVersionTableMap::LINK)) $criteria->add(CategoryVersionTableMap::LINK, $this->link);
|
||||
if ($this->isColumnModified(CategoryVersionTableMap::VISIBLE)) $criteria->add(CategoryVersionTableMap::VISIBLE, $this->visible);
|
||||
if ($this->isColumnModified(CategoryVersionTableMap::POSITION)) $criteria->add(CategoryVersionTableMap::POSITION, $this->position);
|
||||
if ($this->isColumnModified(CategoryVersionTableMap::CREATED_AT)) $criteria->add(CategoryVersionTableMap::CREATED_AT, $this->created_at);
|
||||
@@ -1452,7 +1396,6 @@ abstract class CategoryVersion implements ActiveRecordInterface
|
||||
{
|
||||
$copyObj->setId($this->getId());
|
||||
$copyObj->setParent($this->getParent());
|
||||
$copyObj->setLink($this->getLink());
|
||||
$copyObj->setVisible($this->getVisible());
|
||||
$copyObj->setPosition($this->getPosition());
|
||||
$copyObj->setCreatedAt($this->getCreatedAt());
|
||||
@@ -1545,7 +1488,6 @@ abstract class CategoryVersion implements ActiveRecordInterface
|
||||
{
|
||||
$this->id = null;
|
||||
$this->parent = null;
|
||||
$this->link = null;
|
||||
$this->visible = null;
|
||||
$this->position = null;
|
||||
$this->created_at = null;
|
||||
|
||||
@@ -23,7 +23,6 @@ use Thelia\Model\Map\CategoryVersionTableMap;
|
||||
*
|
||||
* @method ChildCategoryVersionQuery orderById($order = Criteria::ASC) Order by the id column
|
||||
* @method ChildCategoryVersionQuery orderByParent($order = Criteria::ASC) Order by the parent column
|
||||
* @method ChildCategoryVersionQuery orderByLink($order = Criteria::ASC) Order by the link column
|
||||
* @method ChildCategoryVersionQuery orderByVisible($order = Criteria::ASC) Order by the visible column
|
||||
* @method ChildCategoryVersionQuery orderByPosition($order = Criteria::ASC) Order by the position column
|
||||
* @method ChildCategoryVersionQuery orderByCreatedAt($order = Criteria::ASC) Order by the created_at column
|
||||
@@ -34,7 +33,6 @@ use Thelia\Model\Map\CategoryVersionTableMap;
|
||||
*
|
||||
* @method ChildCategoryVersionQuery groupById() Group by the id column
|
||||
* @method ChildCategoryVersionQuery groupByParent() Group by the parent column
|
||||
* @method ChildCategoryVersionQuery groupByLink() Group by the link column
|
||||
* @method ChildCategoryVersionQuery groupByVisible() Group by the visible column
|
||||
* @method ChildCategoryVersionQuery groupByPosition() Group by the position column
|
||||
* @method ChildCategoryVersionQuery groupByCreatedAt() Group by the created_at column
|
||||
@@ -56,7 +54,6 @@ use Thelia\Model\Map\CategoryVersionTableMap;
|
||||
*
|
||||
* @method ChildCategoryVersion findOneById(int $id) Return the first ChildCategoryVersion filtered by the id column
|
||||
* @method ChildCategoryVersion findOneByParent(int $parent) Return the first ChildCategoryVersion filtered by the parent column
|
||||
* @method ChildCategoryVersion findOneByLink(string $link) Return the first ChildCategoryVersion filtered by the link column
|
||||
* @method ChildCategoryVersion findOneByVisible(int $visible) Return the first ChildCategoryVersion filtered by the visible column
|
||||
* @method ChildCategoryVersion findOneByPosition(int $position) Return the first ChildCategoryVersion filtered by the position column
|
||||
* @method ChildCategoryVersion findOneByCreatedAt(string $created_at) Return the first ChildCategoryVersion filtered by the created_at column
|
||||
@@ -67,7 +64,6 @@ use Thelia\Model\Map\CategoryVersionTableMap;
|
||||
*
|
||||
* @method array findById(int $id) Return ChildCategoryVersion objects filtered by the id column
|
||||
* @method array findByParent(int $parent) Return ChildCategoryVersion objects filtered by the parent column
|
||||
* @method array findByLink(string $link) Return ChildCategoryVersion objects filtered by the link column
|
||||
* @method array findByVisible(int $visible) Return ChildCategoryVersion objects filtered by the visible column
|
||||
* @method array findByPosition(int $position) Return ChildCategoryVersion objects filtered by the position column
|
||||
* @method array findByCreatedAt(string $created_at) Return ChildCategoryVersion objects filtered by the created_at column
|
||||
@@ -163,7 +159,7 @@ abstract class CategoryVersionQuery extends ModelCriteria
|
||||
*/
|
||||
protected function findPkSimple($key, $con)
|
||||
{
|
||||
$sql = 'SELECT ID, PARENT, LINK, VISIBLE, POSITION, CREATED_AT, UPDATED_AT, VERSION, VERSION_CREATED_AT, VERSION_CREATED_BY FROM category_version WHERE ID = :p0 AND VERSION = :p1';
|
||||
$sql = 'SELECT ID, PARENT, VISIBLE, POSITION, CREATED_AT, UPDATED_AT, VERSION, VERSION_CREATED_AT, VERSION_CREATED_BY FROM category_version WHERE ID = :p0 AND VERSION = :p1';
|
||||
try {
|
||||
$stmt = $con->prepare($sql);
|
||||
$stmt->bindValue(':p0', $key[0], PDO::PARAM_INT);
|
||||
@@ -348,35 +344,6 @@ abstract class CategoryVersionQuery extends ModelCriteria
|
||||
return $this->addUsingAlias(CategoryVersionTableMap::PARENT, $parent, $comparison);
|
||||
}
|
||||
|
||||
/**
|
||||
* Filter the query on the link column
|
||||
*
|
||||
* Example usage:
|
||||
* <code>
|
||||
* $query->filterByLink('fooValue'); // WHERE link = 'fooValue'
|
||||
* $query->filterByLink('%fooValue%'); // WHERE link LIKE '%fooValue%'
|
||||
* </code>
|
||||
*
|
||||
* @param string $link The value to use as filter.
|
||||
* Accepts wildcards (* and % trigger a LIKE)
|
||||
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
|
||||
*
|
||||
* @return ChildCategoryVersionQuery The current query, for fluid interface
|
||||
*/
|
||||
public function filterByLink($link = null, $comparison = null)
|
||||
{
|
||||
if (null === $comparison) {
|
||||
if (is_array($link)) {
|
||||
$comparison = Criteria::IN;
|
||||
} elseif (preg_match('/[\%\*]/', $link)) {
|
||||
$link = str_replace('*', '%', $link);
|
||||
$comparison = Criteria::LIKE;
|
||||
}
|
||||
}
|
||||
|
||||
return $this->addUsingAlias(CategoryVersionTableMap::LINK, $link, $comparison);
|
||||
}
|
||||
|
||||
/**
|
||||
* Filter the query on the visible column
|
||||
*
|
||||
|
||||
@@ -57,7 +57,7 @@ class CategoryTableMap extends TableMap
|
||||
/**
|
||||
* The total number of columns
|
||||
*/
|
||||
const NUM_COLUMNS = 10;
|
||||
const NUM_COLUMNS = 9;
|
||||
|
||||
/**
|
||||
* The number of lazy-loaded columns
|
||||
@@ -67,7 +67,7 @@ class CategoryTableMap extends TableMap
|
||||
/**
|
||||
* The number of columns to hydrate (NUM_COLUMNS - NUM_LAZY_LOAD_COLUMNS)
|
||||
*/
|
||||
const NUM_HYDRATE_COLUMNS = 10;
|
||||
const NUM_HYDRATE_COLUMNS = 9;
|
||||
|
||||
/**
|
||||
* the column name for the ID field
|
||||
@@ -79,11 +79,6 @@ class CategoryTableMap extends TableMap
|
||||
*/
|
||||
const PARENT = 'category.PARENT';
|
||||
|
||||
/**
|
||||
* the column name for the LINK field
|
||||
*/
|
||||
const LINK = 'category.LINK';
|
||||
|
||||
/**
|
||||
* the column name for the VISIBLE field
|
||||
*/
|
||||
@@ -140,12 +135,12 @@ class CategoryTableMap extends TableMap
|
||||
* e.g. self::$fieldNames[self::TYPE_PHPNAME][0] = 'Id'
|
||||
*/
|
||||
protected static $fieldNames = array (
|
||||
self::TYPE_PHPNAME => array('Id', 'Parent', 'Link', 'Visible', 'Position', 'CreatedAt', 'UpdatedAt', 'Version', 'VersionCreatedAt', 'VersionCreatedBy', ),
|
||||
self::TYPE_STUDLYPHPNAME => array('id', 'parent', 'link', 'visible', 'position', 'createdAt', 'updatedAt', 'version', 'versionCreatedAt', 'versionCreatedBy', ),
|
||||
self::TYPE_COLNAME => array(CategoryTableMap::ID, CategoryTableMap::PARENT, CategoryTableMap::LINK, CategoryTableMap::VISIBLE, CategoryTableMap::POSITION, CategoryTableMap::CREATED_AT, CategoryTableMap::UPDATED_AT, CategoryTableMap::VERSION, CategoryTableMap::VERSION_CREATED_AT, CategoryTableMap::VERSION_CREATED_BY, ),
|
||||
self::TYPE_RAW_COLNAME => array('ID', 'PARENT', 'LINK', 'VISIBLE', 'POSITION', 'CREATED_AT', 'UPDATED_AT', 'VERSION', 'VERSION_CREATED_AT', 'VERSION_CREATED_BY', ),
|
||||
self::TYPE_FIELDNAME => array('id', 'parent', 'link', 'visible', 'position', 'created_at', 'updated_at', 'version', 'version_created_at', 'version_created_by', ),
|
||||
self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, )
|
||||
self::TYPE_PHPNAME => array('Id', 'Parent', 'Visible', 'Position', 'CreatedAt', 'UpdatedAt', 'Version', 'VersionCreatedAt', 'VersionCreatedBy', ),
|
||||
self::TYPE_STUDLYPHPNAME => array('id', 'parent', 'visible', 'position', 'createdAt', 'updatedAt', 'version', 'versionCreatedAt', 'versionCreatedBy', ),
|
||||
self::TYPE_COLNAME => array(CategoryTableMap::ID, CategoryTableMap::PARENT, CategoryTableMap::VISIBLE, CategoryTableMap::POSITION, CategoryTableMap::CREATED_AT, CategoryTableMap::UPDATED_AT, CategoryTableMap::VERSION, CategoryTableMap::VERSION_CREATED_AT, CategoryTableMap::VERSION_CREATED_BY, ),
|
||||
self::TYPE_RAW_COLNAME => array('ID', 'PARENT', 'VISIBLE', 'POSITION', 'CREATED_AT', 'UPDATED_AT', 'VERSION', 'VERSION_CREATED_AT', 'VERSION_CREATED_BY', ),
|
||||
self::TYPE_FIELDNAME => array('id', 'parent', 'visible', 'position', 'created_at', 'updated_at', 'version', 'version_created_at', 'version_created_by', ),
|
||||
self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, 7, 8, )
|
||||
);
|
||||
|
||||
/**
|
||||
@@ -155,12 +150,12 @@ class CategoryTableMap extends TableMap
|
||||
* e.g. self::$fieldKeys[self::TYPE_PHPNAME]['Id'] = 0
|
||||
*/
|
||||
protected static $fieldKeys = array (
|
||||
self::TYPE_PHPNAME => array('Id' => 0, 'Parent' => 1, 'Link' => 2, 'Visible' => 3, 'Position' => 4, 'CreatedAt' => 5, 'UpdatedAt' => 6, 'Version' => 7, 'VersionCreatedAt' => 8, 'VersionCreatedBy' => 9, ),
|
||||
self::TYPE_STUDLYPHPNAME => array('id' => 0, 'parent' => 1, 'link' => 2, 'visible' => 3, 'position' => 4, 'createdAt' => 5, 'updatedAt' => 6, 'version' => 7, 'versionCreatedAt' => 8, 'versionCreatedBy' => 9, ),
|
||||
self::TYPE_COLNAME => array(CategoryTableMap::ID => 0, CategoryTableMap::PARENT => 1, CategoryTableMap::LINK => 2, CategoryTableMap::VISIBLE => 3, CategoryTableMap::POSITION => 4, CategoryTableMap::CREATED_AT => 5, CategoryTableMap::UPDATED_AT => 6, CategoryTableMap::VERSION => 7, CategoryTableMap::VERSION_CREATED_AT => 8, CategoryTableMap::VERSION_CREATED_BY => 9, ),
|
||||
self::TYPE_RAW_COLNAME => array('ID' => 0, 'PARENT' => 1, 'LINK' => 2, 'VISIBLE' => 3, 'POSITION' => 4, 'CREATED_AT' => 5, 'UPDATED_AT' => 6, 'VERSION' => 7, 'VERSION_CREATED_AT' => 8, 'VERSION_CREATED_BY' => 9, ),
|
||||
self::TYPE_FIELDNAME => array('id' => 0, 'parent' => 1, 'link' => 2, 'visible' => 3, 'position' => 4, 'created_at' => 5, 'updated_at' => 6, 'version' => 7, 'version_created_at' => 8, 'version_created_by' => 9, ),
|
||||
self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, )
|
||||
self::TYPE_PHPNAME => array('Id' => 0, 'Parent' => 1, 'Visible' => 2, 'Position' => 3, 'CreatedAt' => 4, 'UpdatedAt' => 5, 'Version' => 6, 'VersionCreatedAt' => 7, 'VersionCreatedBy' => 8, ),
|
||||
self::TYPE_STUDLYPHPNAME => array('id' => 0, 'parent' => 1, 'visible' => 2, 'position' => 3, 'createdAt' => 4, 'updatedAt' => 5, 'version' => 6, 'versionCreatedAt' => 7, 'versionCreatedBy' => 8, ),
|
||||
self::TYPE_COLNAME => array(CategoryTableMap::ID => 0, CategoryTableMap::PARENT => 1, CategoryTableMap::VISIBLE => 2, CategoryTableMap::POSITION => 3, CategoryTableMap::CREATED_AT => 4, CategoryTableMap::UPDATED_AT => 5, CategoryTableMap::VERSION => 6, CategoryTableMap::VERSION_CREATED_AT => 7, CategoryTableMap::VERSION_CREATED_BY => 8, ),
|
||||
self::TYPE_RAW_COLNAME => array('ID' => 0, 'PARENT' => 1, 'VISIBLE' => 2, 'POSITION' => 3, 'CREATED_AT' => 4, 'UPDATED_AT' => 5, 'VERSION' => 6, 'VERSION_CREATED_AT' => 7, 'VERSION_CREATED_BY' => 8, ),
|
||||
self::TYPE_FIELDNAME => array('id' => 0, 'parent' => 1, 'visible' => 2, 'position' => 3, 'created_at' => 4, 'updated_at' => 5, 'version' => 6, 'version_created_at' => 7, 'version_created_by' => 8, ),
|
||||
self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, 7, 8, )
|
||||
);
|
||||
|
||||
/**
|
||||
@@ -181,7 +176,6 @@ class CategoryTableMap extends TableMap
|
||||
// columns
|
||||
$this->addPrimaryKey('ID', 'Id', 'INTEGER', true, null, null);
|
||||
$this->addColumn('PARENT', 'Parent', 'INTEGER', false, null, null);
|
||||
$this->addColumn('LINK', 'Link', 'VARCHAR', false, 255, null);
|
||||
$this->addColumn('VISIBLE', 'Visible', 'TINYINT', true, null, null);
|
||||
$this->addColumn('POSITION', 'Position', 'INTEGER', true, null, null);
|
||||
$this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', false, null, null);
|
||||
@@ -382,7 +376,6 @@ class CategoryTableMap extends TableMap
|
||||
if (null === $alias) {
|
||||
$criteria->addSelectColumn(CategoryTableMap::ID);
|
||||
$criteria->addSelectColumn(CategoryTableMap::PARENT);
|
||||
$criteria->addSelectColumn(CategoryTableMap::LINK);
|
||||
$criteria->addSelectColumn(CategoryTableMap::VISIBLE);
|
||||
$criteria->addSelectColumn(CategoryTableMap::POSITION);
|
||||
$criteria->addSelectColumn(CategoryTableMap::CREATED_AT);
|
||||
@@ -393,7 +386,6 @@ class CategoryTableMap extends TableMap
|
||||
} else {
|
||||
$criteria->addSelectColumn($alias . '.ID');
|
||||
$criteria->addSelectColumn($alias . '.PARENT');
|
||||
$criteria->addSelectColumn($alias . '.LINK');
|
||||
$criteria->addSelectColumn($alias . '.VISIBLE');
|
||||
$criteria->addSelectColumn($alias . '.POSITION');
|
||||
$criteria->addSelectColumn($alias . '.CREATED_AT');
|
||||
|
||||
@@ -57,7 +57,7 @@ class CategoryVersionTableMap extends TableMap
|
||||
/**
|
||||
* The total number of columns
|
||||
*/
|
||||
const NUM_COLUMNS = 10;
|
||||
const NUM_COLUMNS = 9;
|
||||
|
||||
/**
|
||||
* The number of lazy-loaded columns
|
||||
@@ -67,7 +67,7 @@ class CategoryVersionTableMap extends TableMap
|
||||
/**
|
||||
* The number of columns to hydrate (NUM_COLUMNS - NUM_LAZY_LOAD_COLUMNS)
|
||||
*/
|
||||
const NUM_HYDRATE_COLUMNS = 10;
|
||||
const NUM_HYDRATE_COLUMNS = 9;
|
||||
|
||||
/**
|
||||
* the column name for the ID field
|
||||
@@ -79,11 +79,6 @@ class CategoryVersionTableMap extends TableMap
|
||||
*/
|
||||
const PARENT = 'category_version.PARENT';
|
||||
|
||||
/**
|
||||
* the column name for the LINK field
|
||||
*/
|
||||
const LINK = 'category_version.LINK';
|
||||
|
||||
/**
|
||||
* the column name for the VISIBLE field
|
||||
*/
|
||||
@@ -131,12 +126,12 @@ class CategoryVersionTableMap extends TableMap
|
||||
* e.g. self::$fieldNames[self::TYPE_PHPNAME][0] = 'Id'
|
||||
*/
|
||||
protected static $fieldNames = array (
|
||||
self::TYPE_PHPNAME => array('Id', 'Parent', 'Link', 'Visible', 'Position', 'CreatedAt', 'UpdatedAt', 'Version', 'VersionCreatedAt', 'VersionCreatedBy', ),
|
||||
self::TYPE_STUDLYPHPNAME => array('id', 'parent', 'link', 'visible', 'position', 'createdAt', 'updatedAt', 'version', 'versionCreatedAt', 'versionCreatedBy', ),
|
||||
self::TYPE_COLNAME => array(CategoryVersionTableMap::ID, CategoryVersionTableMap::PARENT, CategoryVersionTableMap::LINK, CategoryVersionTableMap::VISIBLE, CategoryVersionTableMap::POSITION, CategoryVersionTableMap::CREATED_AT, CategoryVersionTableMap::UPDATED_AT, CategoryVersionTableMap::VERSION, CategoryVersionTableMap::VERSION_CREATED_AT, CategoryVersionTableMap::VERSION_CREATED_BY, ),
|
||||
self::TYPE_RAW_COLNAME => array('ID', 'PARENT', 'LINK', 'VISIBLE', 'POSITION', 'CREATED_AT', 'UPDATED_AT', 'VERSION', 'VERSION_CREATED_AT', 'VERSION_CREATED_BY', ),
|
||||
self::TYPE_FIELDNAME => array('id', 'parent', 'link', 'visible', 'position', 'created_at', 'updated_at', 'version', 'version_created_at', 'version_created_by', ),
|
||||
self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, )
|
||||
self::TYPE_PHPNAME => array('Id', 'Parent', 'Visible', 'Position', 'CreatedAt', 'UpdatedAt', 'Version', 'VersionCreatedAt', 'VersionCreatedBy', ),
|
||||
self::TYPE_STUDLYPHPNAME => array('id', 'parent', 'visible', 'position', 'createdAt', 'updatedAt', 'version', 'versionCreatedAt', 'versionCreatedBy', ),
|
||||
self::TYPE_COLNAME => array(CategoryVersionTableMap::ID, CategoryVersionTableMap::PARENT, CategoryVersionTableMap::VISIBLE, CategoryVersionTableMap::POSITION, CategoryVersionTableMap::CREATED_AT, CategoryVersionTableMap::UPDATED_AT, CategoryVersionTableMap::VERSION, CategoryVersionTableMap::VERSION_CREATED_AT, CategoryVersionTableMap::VERSION_CREATED_BY, ),
|
||||
self::TYPE_RAW_COLNAME => array('ID', 'PARENT', 'VISIBLE', 'POSITION', 'CREATED_AT', 'UPDATED_AT', 'VERSION', 'VERSION_CREATED_AT', 'VERSION_CREATED_BY', ),
|
||||
self::TYPE_FIELDNAME => array('id', 'parent', 'visible', 'position', 'created_at', 'updated_at', 'version', 'version_created_at', 'version_created_by', ),
|
||||
self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, 7, 8, )
|
||||
);
|
||||
|
||||
/**
|
||||
@@ -146,12 +141,12 @@ class CategoryVersionTableMap extends TableMap
|
||||
* e.g. self::$fieldKeys[self::TYPE_PHPNAME]['Id'] = 0
|
||||
*/
|
||||
protected static $fieldKeys = array (
|
||||
self::TYPE_PHPNAME => array('Id' => 0, 'Parent' => 1, 'Link' => 2, 'Visible' => 3, 'Position' => 4, 'CreatedAt' => 5, 'UpdatedAt' => 6, 'Version' => 7, 'VersionCreatedAt' => 8, 'VersionCreatedBy' => 9, ),
|
||||
self::TYPE_STUDLYPHPNAME => array('id' => 0, 'parent' => 1, 'link' => 2, 'visible' => 3, 'position' => 4, 'createdAt' => 5, 'updatedAt' => 6, 'version' => 7, 'versionCreatedAt' => 8, 'versionCreatedBy' => 9, ),
|
||||
self::TYPE_COLNAME => array(CategoryVersionTableMap::ID => 0, CategoryVersionTableMap::PARENT => 1, CategoryVersionTableMap::LINK => 2, CategoryVersionTableMap::VISIBLE => 3, CategoryVersionTableMap::POSITION => 4, CategoryVersionTableMap::CREATED_AT => 5, CategoryVersionTableMap::UPDATED_AT => 6, CategoryVersionTableMap::VERSION => 7, CategoryVersionTableMap::VERSION_CREATED_AT => 8, CategoryVersionTableMap::VERSION_CREATED_BY => 9, ),
|
||||
self::TYPE_RAW_COLNAME => array('ID' => 0, 'PARENT' => 1, 'LINK' => 2, 'VISIBLE' => 3, 'POSITION' => 4, 'CREATED_AT' => 5, 'UPDATED_AT' => 6, 'VERSION' => 7, 'VERSION_CREATED_AT' => 8, 'VERSION_CREATED_BY' => 9, ),
|
||||
self::TYPE_FIELDNAME => array('id' => 0, 'parent' => 1, 'link' => 2, 'visible' => 3, 'position' => 4, 'created_at' => 5, 'updated_at' => 6, 'version' => 7, 'version_created_at' => 8, 'version_created_by' => 9, ),
|
||||
self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, )
|
||||
self::TYPE_PHPNAME => array('Id' => 0, 'Parent' => 1, 'Visible' => 2, 'Position' => 3, 'CreatedAt' => 4, 'UpdatedAt' => 5, 'Version' => 6, 'VersionCreatedAt' => 7, 'VersionCreatedBy' => 8, ),
|
||||
self::TYPE_STUDLYPHPNAME => array('id' => 0, 'parent' => 1, 'visible' => 2, 'position' => 3, 'createdAt' => 4, 'updatedAt' => 5, 'version' => 6, 'versionCreatedAt' => 7, 'versionCreatedBy' => 8, ),
|
||||
self::TYPE_COLNAME => array(CategoryVersionTableMap::ID => 0, CategoryVersionTableMap::PARENT => 1, CategoryVersionTableMap::VISIBLE => 2, CategoryVersionTableMap::POSITION => 3, CategoryVersionTableMap::CREATED_AT => 4, CategoryVersionTableMap::UPDATED_AT => 5, CategoryVersionTableMap::VERSION => 6, CategoryVersionTableMap::VERSION_CREATED_AT => 7, CategoryVersionTableMap::VERSION_CREATED_BY => 8, ),
|
||||
self::TYPE_RAW_COLNAME => array('ID' => 0, 'PARENT' => 1, 'VISIBLE' => 2, 'POSITION' => 3, 'CREATED_AT' => 4, 'UPDATED_AT' => 5, 'VERSION' => 6, 'VERSION_CREATED_AT' => 7, 'VERSION_CREATED_BY' => 8, ),
|
||||
self::TYPE_FIELDNAME => array('id' => 0, 'parent' => 1, 'visible' => 2, 'position' => 3, 'created_at' => 4, 'updated_at' => 5, 'version' => 6, 'version_created_at' => 7, 'version_created_by' => 8, ),
|
||||
self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, 7, 8, )
|
||||
);
|
||||
|
||||
/**
|
||||
@@ -172,7 +167,6 @@ class CategoryVersionTableMap extends TableMap
|
||||
// columns
|
||||
$this->addForeignPrimaryKey('ID', 'Id', 'INTEGER' , 'category', 'ID', true, null, null);
|
||||
$this->addColumn('PARENT', 'Parent', 'INTEGER', false, null, null);
|
||||
$this->addColumn('LINK', 'Link', 'VARCHAR', false, 255, null);
|
||||
$this->addColumn('VISIBLE', 'Visible', 'TINYINT', true, null, null);
|
||||
$this->addColumn('POSITION', 'Position', 'INTEGER', true, null, null);
|
||||
$this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', false, null, null);
|
||||
@@ -257,11 +251,11 @@ class CategoryVersionTableMap extends TableMap
|
||||
public static function getPrimaryKeyHashFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM)
|
||||
{
|
||||
// If the PK cannot be derived from the row, return NULL.
|
||||
if ($row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)] === null && $row[TableMap::TYPE_NUM == $indexType ? 7 + $offset : static::translateFieldName('Version', TableMap::TYPE_PHPNAME, $indexType)] === null) {
|
||||
if ($row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)] === null && $row[TableMap::TYPE_NUM == $indexType ? 6 + $offset : static::translateFieldName('Version', TableMap::TYPE_PHPNAME, $indexType)] === null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return serialize(array((string) $row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)], (string) $row[TableMap::TYPE_NUM == $indexType ? 7 + $offset : static::translateFieldName('Version', TableMap::TYPE_PHPNAME, $indexType)]));
|
||||
return serialize(array((string) $row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)], (string) $row[TableMap::TYPE_NUM == $indexType ? 6 + $offset : static::translateFieldName('Version', TableMap::TYPE_PHPNAME, $indexType)]));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -379,7 +373,6 @@ class CategoryVersionTableMap extends TableMap
|
||||
if (null === $alias) {
|
||||
$criteria->addSelectColumn(CategoryVersionTableMap::ID);
|
||||
$criteria->addSelectColumn(CategoryVersionTableMap::PARENT);
|
||||
$criteria->addSelectColumn(CategoryVersionTableMap::LINK);
|
||||
$criteria->addSelectColumn(CategoryVersionTableMap::VISIBLE);
|
||||
$criteria->addSelectColumn(CategoryVersionTableMap::POSITION);
|
||||
$criteria->addSelectColumn(CategoryVersionTableMap::CREATED_AT);
|
||||
@@ -390,7 +383,6 @@ class CategoryVersionTableMap extends TableMap
|
||||
} else {
|
||||
$criteria->addSelectColumn($alias . '.ID');
|
||||
$criteria->addSelectColumn($alias . '.PARENT');
|
||||
$criteria->addSelectColumn($alias . '.LINK');
|
||||
$criteria->addSelectColumn($alias . '.VISIBLE');
|
||||
$criteria->addSelectColumn($alias . '.POSITION');
|
||||
$criteria->addSelectColumn($alias . '.CREATED_AT');
|
||||
|
||||
@@ -35,21 +35,23 @@ class BooleanTypeTest extends \PHPUnit_Framework_TestCase
|
||||
public function testBooleanType()
|
||||
{
|
||||
$booleanType = new BooleanType();
|
||||
$this->assertTrue($booleanType->isValid('y'));
|
||||
$this->assertTrue($booleanType->isValid('1'));
|
||||
$this->assertTrue($booleanType->isValid('yes'));
|
||||
$this->assertTrue($booleanType->isValid('true'));
|
||||
$this->assertTrue($booleanType->isValid('no'));
|
||||
$this->assertTrue($booleanType->isValid('n'));
|
||||
$this->assertTrue($booleanType->isValid('off'));
|
||||
$this->assertTrue($booleanType->isValid(1));
|
||||
$this->assertTrue($booleanType->isValid('false'));
|
||||
$this->assertFalse($booleanType->isValid('foo'));
|
||||
$this->assertFalse($booleanType->isValid(5));
|
||||
$this->assertFalse($booleanType->isValid(2));
|
||||
}
|
||||
|
||||
public function testFormatBooleanType()
|
||||
{
|
||||
$booleanType = new BooleanType();
|
||||
$this->assertTrue($booleanType->getFormattedValue('yes'));
|
||||
$this->assertFalse($booleanType->getFormattedValue('no'));
|
||||
$this->assertNull($booleanType->getFormattedValue('foo'));
|
||||
$this->assertTrue($booleanType->getFormattedValue('on'));
|
||||
$this->assertFalse($booleanType->getFormattedValue('0'));
|
||||
$this->assertFalse($booleanType->getFormattedValue(0));
|
||||
$this->assertNull($booleanType->getFormattedValue(3));
|
||||
}
|
||||
}
|
||||
|
||||
64
core/lib/Thelia/Tests/Type/IntToCombinedIntsListTypeTest.php
Executable file
64
core/lib/Thelia/Tests/Type/IntToCombinedIntsListTypeTest.php
Executable file
@@ -0,0 +1,64 @@
|
||||
<?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\Tests\Type;
|
||||
|
||||
use Thelia\Type\IntToCombinedIntsListType;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Etienne Roudeix <eroudeix@openstudio.fr>
|
||||
*
|
||||
*/
|
||||
class IntToCombinedIntsListTypeTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
public function testIntToCombinedIntsListType()
|
||||
{
|
||||
$type = new IntToCombinedIntsListType();
|
||||
$this->assertTrue($type->isValid('1: 2 & 5 | (6 &7), 4: *, 67: (1 & 9)'));
|
||||
$this->assertFalse($type->isValid('1,2,3'));
|
||||
}
|
||||
|
||||
public function testFormatJsonType()
|
||||
{
|
||||
$type = new IntToCombinedIntsListType();
|
||||
$this->assertEquals(
|
||||
$type->getFormattedValue('1: 2 & 5 | (6 &7), 4: *, 67: (1 & 9)'),
|
||||
array(
|
||||
1 => array(
|
||||
"values" => array(2,5,6,7),
|
||||
"expression" => '2&5|(6&7)',
|
||||
),
|
||||
4 => array(
|
||||
"values" => array('*'),
|
||||
"expression" => '*',
|
||||
),
|
||||
67 => array(
|
||||
"values" => array(1,9),
|
||||
"expression" => '(1&9)',
|
||||
),
|
||||
)
|
||||
);
|
||||
$this->assertNull($type->getFormattedValue('foo'));
|
||||
}
|
||||
}
|
||||
64
core/lib/Thelia/Tests/Type/IntToCombinedStringsListTypeTest.php
Executable file
64
core/lib/Thelia/Tests/Type/IntToCombinedStringsListTypeTest.php
Executable file
@@ -0,0 +1,64 @@
|
||||
<?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\Tests\Type;
|
||||
|
||||
use Thelia\Type\IntToCombinedStringsListType;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Etienne Roudeix <eroudeix@openstudio.fr>
|
||||
*
|
||||
*/
|
||||
class IntToCombinedStringsListTypeTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
public function testIntToCombinedStringsListType()
|
||||
{
|
||||
$type = new IntToCombinedStringsListType();
|
||||
$this->assertTrue($type->isValid('1: foo & bar | (fooo &baar), 4: *, 67: (foooo & baaar)'));
|
||||
$this->assertFalse($type->isValid('1,2,3'));
|
||||
}
|
||||
|
||||
public function testFormatJsonType()
|
||||
{
|
||||
$type = new IntToCombinedStringsListType();
|
||||
$this->assertEquals(
|
||||
$type->getFormattedValue('1: foo & bar | (fooo &baar), 4: *, 67: (foooo & baaar)'),
|
||||
array(
|
||||
1 => array(
|
||||
"values" => array('foo','bar','fooo','baar'),
|
||||
"expression" => 'foo&bar|(fooo&baar)',
|
||||
),
|
||||
4 => array(
|
||||
"values" => array('*'),
|
||||
"expression" => '*',
|
||||
),
|
||||
67 => array(
|
||||
"values" => array('foooo','baaar'),
|
||||
"expression" => '(foooo&baaar)',
|
||||
),
|
||||
)
|
||||
);
|
||||
$this->assertNull($type->getFormattedValue('foo'));
|
||||
}
|
||||
}
|
||||
@@ -30,19 +30,6 @@ namespace Thelia\Type;
|
||||
|
||||
class BooleanType implements TypeInterface
|
||||
{
|
||||
protected $trueValuesArray = array(
|
||||
'1',
|
||||
'true',
|
||||
'yes',
|
||||
'y',
|
||||
);
|
||||
protected $falseValuesArray = array(
|
||||
'0',
|
||||
'false',
|
||||
'no',
|
||||
'n',
|
||||
);
|
||||
|
||||
public function getType()
|
||||
{
|
||||
return 'Boolean type';
|
||||
@@ -50,11 +37,11 @@ class BooleanType implements TypeInterface
|
||||
|
||||
public function isValid($value)
|
||||
{
|
||||
return in_array($value, $this->trueValuesArray) || in_array($value, $this->falseValuesArray);
|
||||
return filter_var($value, FILTER_VALIDATE_BOOLEAN, FILTER_NULL_ON_FAILURE) !== null;
|
||||
}
|
||||
|
||||
public function getFormattedValue($value)
|
||||
{
|
||||
return $this->isValid($value) ? ( in_array($value, $this->trueValuesArray) ) : null;
|
||||
return $value === null ? null : filter_var($value, FILTER_VALIDATE_BOOLEAN, FILTER_NULL_ON_FAILURE);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -38,6 +38,12 @@ class EnumListType implements TypeInterface
|
||||
$this->values = $values;
|
||||
}
|
||||
|
||||
public function addValue($value)
|
||||
{
|
||||
if(!in_array($value, $this->values))
|
||||
$this->values[] = $value;
|
||||
}
|
||||
|
||||
public function getType()
|
||||
{
|
||||
return 'Enum list type';
|
||||
|
||||
122
core/lib/Thelia/Type/IntToCombinedIntsListType.php
Executable file
122
core/lib/Thelia/Type/IntToCombinedIntsListType.php
Executable file
@@ -0,0 +1,122 @@
|
||||
<?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\Type;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Etienne Roudeix <eroudeix@openstudio.fr>
|
||||
*
|
||||
*/
|
||||
|
||||
class IntToCombinedIntsListType implements TypeInterface
|
||||
{
|
||||
public function getType()
|
||||
{
|
||||
return 'Int to combined ints list type';
|
||||
}
|
||||
|
||||
public function isValid($values)
|
||||
{
|
||||
foreach(explode(',', $values) as $intToCombinedInts) {
|
||||
$parts = explode(':', $intToCombinedInts);
|
||||
if(count($parts) != 2)
|
||||
return false;
|
||||
if(filter_var($parts[0], FILTER_VALIDATE_INT) === false)
|
||||
return false;
|
||||
|
||||
if(false === $this->checkLogicalFormat($parts[1]))
|
||||
return false;
|
||||
}
|
||||
$x = 3;
|
||||
return true;
|
||||
}
|
||||
|
||||
public function getFormattedValue($values)
|
||||
{
|
||||
if( $this->isValid($values) ) {
|
||||
$return = '';
|
||||
|
||||
$values = preg_replace('#[\s]#', '', $values);
|
||||
foreach(explode(',', $values) as $intToCombinedInts) {
|
||||
$parts = explode(':', $intToCombinedInts);
|
||||
|
||||
$return[trim($parts[0])] = array(
|
||||
"values" => preg_split( "#(&|\|)#", preg_replace('#[\(\)]#', '', $parts[1])),
|
||||
"expression" => $parts[1],
|
||||
);
|
||||
}
|
||||
|
||||
return $return;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
protected function checkLogicalFormat($string)
|
||||
{
|
||||
/* delete all spaces and parentheses */
|
||||
$noSpaceString = preg_replace('#[\s]#', '', $string);
|
||||
$noParentheseString = preg_replace('#[\(\)]#', '', $noSpaceString);
|
||||
|
||||
if(!preg_match('#^([0-9]+([\&\|][0-9]+)*|\*)$#', $noParentheseString))
|
||||
return false;
|
||||
|
||||
/* check parenteses use */
|
||||
$openingParenthesesCount = 0;
|
||||
$closingParenthesesCount = 0;
|
||||
|
||||
for($i=0; $i<strlen($noSpaceString); $i++) {
|
||||
$char = $noSpaceString[$i];
|
||||
if($char == '(') {
|
||||
/* must be :
|
||||
* - after a &| or () or at the begining of expression
|
||||
* - before a number or ()
|
||||
* must not be :
|
||||
* - at the end of expression
|
||||
*/
|
||||
if(($i!=0 && !preg_match('#[\(\)\&\|]#', $noSpaceString[$i-1])) || !isset($noSpaceString[$i+1]) || !preg_match('#[\(\)0-9]#', $noSpaceString[$i+1])) {
|
||||
return false;
|
||||
}
|
||||
$openingParenthesesCount++;
|
||||
} elseif($char == ')') {
|
||||
/* must be :
|
||||
* - after a number or ()
|
||||
* - before a &| or () or at the end of expression
|
||||
* must not be :
|
||||
* - at the begining of expression
|
||||
* - if no ( remain unclose
|
||||
*/
|
||||
if($i == 0 || !preg_match('#[\(\)0-9]#', $noSpaceString[$i-1]) || (isset($noSpaceString[$i+1]) && !preg_match('#[\(\)\&\|]#', $noSpaceString[$i+1])) || $openingParenthesesCount-$closingParenthesesCount==0) {
|
||||
return false;
|
||||
}
|
||||
$closingParenthesesCount++;
|
||||
}
|
||||
}
|
||||
|
||||
if($openingParenthesesCount != $closingParenthesesCount) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
122
core/lib/Thelia/Type/IntToCombinedStringsListType.php
Executable file
122
core/lib/Thelia/Type/IntToCombinedStringsListType.php
Executable file
@@ -0,0 +1,122 @@
|
||||
<?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\Type;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Etienne Roudeix <eroudeix@openstudio.fr>
|
||||
*
|
||||
*/
|
||||
|
||||
class IntToCombinedStringsListType implements TypeInterface
|
||||
{
|
||||
public function getType()
|
||||
{
|
||||
return 'Int to combined strings list type';
|
||||
}
|
||||
|
||||
public function isValid($values)
|
||||
{
|
||||
foreach(explode(',', $values) as $intToCombinedStrings) {
|
||||
$parts = explode(':', $intToCombinedStrings);
|
||||
if(count($parts) != 2)
|
||||
return false;
|
||||
if(filter_var($parts[0], FILTER_VALIDATE_INT) === false)
|
||||
return false;
|
||||
|
||||
if(false === $this->checkLogicalFormat($parts[1]))
|
||||
return false;
|
||||
}
|
||||
$x = 3;
|
||||
return true;
|
||||
}
|
||||
|
||||
public function getFormattedValue($values)
|
||||
{
|
||||
if( $this->isValid($values) ) {
|
||||
$return = '';
|
||||
|
||||
$values = preg_replace('#[\s]#', '', $values);
|
||||
foreach(explode(',', $values) as $intToCombinedStrings) {
|
||||
$parts = explode(':', $intToCombinedStrings);
|
||||
|
||||
$return[trim($parts[0])] = array(
|
||||
"values" => preg_split( "#(&|\|)#", preg_replace('#[\(\)]#', '', $parts[1])),
|
||||
"expression" => $parts[1],
|
||||
);
|
||||
}
|
||||
|
||||
return $return;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
protected function checkLogicalFormat($string)
|
||||
{
|
||||
/* delete all spaces and parentheses */
|
||||
$noSpaceString = preg_replace('#[\s]#', '', $string);
|
||||
$noParentheseString = preg_replace('#[\(\)]#', '', $noSpaceString);
|
||||
|
||||
if(!preg_match('#^([a-zA-Z0-9_\-]+([\&\|][a-zA-Z0-9_\-]+)*|\*)$#', $noParentheseString))
|
||||
return false;
|
||||
|
||||
/* check parenteses use */
|
||||
$openingParenthesesCount = 0;
|
||||
$closingParenthesesCount = 0;
|
||||
|
||||
for($i=0; $i<strlen($noSpaceString); $i++) {
|
||||
$char = $noSpaceString[$i];
|
||||
if($char == '(') {
|
||||
/* must be :
|
||||
* - after a &| or () or at the begining of expression
|
||||
* - before a number or ()
|
||||
* must not be :
|
||||
* - at the end of expression
|
||||
*/
|
||||
if(($i!=0 && !preg_match('#[\(\)\&\|]#', $noSpaceString[$i-1])) || !isset($noSpaceString[$i+1]) || !preg_match('#[\(\)a-zA-Z0-9_\-]#', $noSpaceString[$i+1])) {
|
||||
return false;
|
||||
}
|
||||
$openingParenthesesCount++;
|
||||
} elseif($char == ')') {
|
||||
/* must be :
|
||||
* - after a number or ()
|
||||
* - before a &| or () or at the end of expression
|
||||
* must not be :
|
||||
* - at the begining of expression
|
||||
* - if no ( remain unclose
|
||||
*/
|
||||
if($i == 0 || !preg_match('#[\(\)a-zA-Z0-9_\-]#', $noSpaceString[$i-1]) || (isset($noSpaceString[$i+1]) && !preg_match('#[\(\)\&\|]#', $noSpaceString[$i+1])) || $openingParenthesesCount-$closingParenthesesCount==0) {
|
||||
return false;
|
||||
}
|
||||
$closingParenthesesCount++;
|
||||
}
|
||||
}
|
||||
|
||||
if($openingParenthesesCount != $closingParenthesesCount) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -142,4 +142,9 @@ class TypeCollection implements \Iterator
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public function getKey($key)
|
||||
{
|
||||
return isset($this->types[$key]) ? $this->types[$key] : null;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user