|
1
|
|
|
<?php |
|
2
|
|
|
/*************************************************************************************/ |
|
3
|
|
|
/* This file is part of the module FeatureType */ |
|
4
|
|
|
/* */ |
|
5
|
|
|
/* For the full copyright and license information, please view the LICENSE.txt */ |
|
6
|
|
|
/* file that was distributed with this source code. */ |
|
7
|
|
|
/*************************************************************************************/ |
|
8
|
|
|
|
|
9
|
|
|
namespace FeatureType\Loop; |
|
10
|
|
|
|
|
11
|
|
|
use FeatureType\Model\FeatureType; |
|
12
|
|
|
use FeatureType\Model\FeatureTypeQuery; |
|
13
|
|
|
use FeatureType\Model\Map\FeatureFeatureTypeTableMap; |
|
14
|
|
|
use FeatureType\Model\Map\FeatureTypeTableMap; |
|
15
|
|
|
use Propel\Runtime\ActiveQuery\Criteria; |
|
16
|
|
|
use Propel\Runtime\ActiveQuery\Join; |
|
17
|
|
|
use Thelia\Core\Template\Element\BaseI18nLoop; |
|
18
|
|
|
use Thelia\Core\Template\Element\LoopResult; |
|
19
|
|
|
use Thelia\Core\Template\Element\LoopResultRow; |
|
20
|
|
|
use Thelia\Core\Template\Element\PropelSearchLoopInterface; |
|
21
|
|
|
use Thelia\Core\Template\Loop\Argument\Argument; |
|
22
|
|
|
use Thelia\Core\Template\Loop\Argument\ArgumentCollection; |
|
23
|
|
|
|
|
24
|
|
|
/** |
|
25
|
|
|
* Class FeatureTypeLoop |
|
26
|
|
|
* @package FeatureType\Loop |
|
27
|
|
|
* @author Gilles Bourgeat <[email protected]> |
|
28
|
|
|
*/ |
|
29
|
|
|
class FeatureTypeLoop extends BaseI18nLoop implements PropelSearchLoopInterface |
|
30
|
|
|
{ |
|
31
|
|
|
/** |
|
32
|
|
|
* Definition of loop arguments |
|
33
|
|
|
* |
|
34
|
|
|
* example : |
|
35
|
|
|
* |
|
36
|
|
|
* public function getArgDefinitions() |
|
37
|
|
|
* { |
|
38
|
|
|
* return new ArgumentCollection( |
|
39
|
|
|
* |
|
40
|
|
|
* Argument::createIntListTypeArgument('id'), |
|
41
|
|
|
* new Argument( |
|
42
|
|
|
* 'ref', |
|
43
|
|
|
* new TypeCollection( |
|
44
|
|
|
* new Type\AlphaNumStringListType() |
|
45
|
|
|
* ) |
|
46
|
|
|
* ), |
|
47
|
|
|
* Argument::createIntListTypeArgument('category'), |
|
48
|
|
|
* Argument::createBooleanTypeArgument('new'), |
|
49
|
|
|
* ... |
|
50
|
|
|
* ); |
|
51
|
|
|
* } |
|
52
|
|
|
* |
|
53
|
|
|
* @return \Thelia\Core\Template\Loop\Argument\ArgumentCollection |
|
54
|
|
|
*/ |
|
55
|
|
|
protected function getArgDefinitions() |
|
56
|
|
|
{ |
|
57
|
|
|
return new ArgumentCollection( |
|
58
|
|
|
Argument::createIntListTypeArgument("id"), |
|
59
|
|
|
Argument::createIntListTypeArgument("exclude_id"), |
|
60
|
|
|
Argument::createAnyTypeArgument('slug'), |
|
61
|
|
|
Argument::createIntListTypeArgument("feature_id"), |
|
62
|
|
|
Argument::createEnumListTypeArgument( |
|
63
|
|
|
"order", |
|
64
|
|
|
[ |
|
65
|
|
|
"id", |
|
66
|
|
|
"id-reverse", |
|
67
|
|
|
"feature_type", |
|
68
|
|
|
"feature_type-reverse", |
|
69
|
|
|
], |
|
70
|
|
|
"id" |
|
71
|
|
|
) |
|
72
|
|
|
); |
|
73
|
|
|
} |
|
74
|
|
|
/** |
|
75
|
|
|
* this method returns a Propel ModelCriteria |
|
76
|
|
|
* |
|
77
|
|
|
* @return \Propel\Runtime\ActiveQuery\ModelCriteria |
|
78
|
|
|
*/ |
|
79
|
|
|
public function buildModelCriteria() |
|
80
|
|
|
{ |
|
81
|
|
|
$query = new FeatureTypeQuery(); |
|
82
|
|
|
|
|
83
|
|
|
/* manage translations */ |
|
84
|
|
|
$this->configureI18nProcessing($query, array('TITLE', 'DESCRIPTION')); |
|
85
|
|
|
|
|
86
|
|
|
if (null !== $id = $this->getId()) { |
|
87
|
|
|
$query->filterById($id); |
|
88
|
|
|
} |
|
89
|
|
|
|
|
90
|
|
|
if (null !== $id = $this->getExcludeId()) { |
|
91
|
|
|
$query->filterById($id, Criteria::NOT_IN); |
|
92
|
|
|
} |
|
93
|
|
|
|
|
94
|
|
|
if (null !== $slug = $this->getSlug()) { |
|
95
|
|
|
$query->filterBySlug($slug); |
|
96
|
|
|
} |
|
97
|
|
|
|
|
98
|
|
|
if (null !== $featureId = $this->getFeatureId()) { |
|
99
|
|
|
$join = new Join(); |
|
100
|
|
|
|
|
101
|
|
|
$join->addExplicitCondition( |
|
102
|
|
|
FeatureTypeTableMap::TABLE_NAME, |
|
103
|
|
|
'ID', |
|
104
|
|
|
null, |
|
105
|
|
|
FeatureFeatureTypeTableMap::TABLE_NAME, |
|
106
|
|
|
'FEATURE_TYPE_ID', |
|
107
|
|
|
null |
|
108
|
|
|
); |
|
109
|
|
|
|
|
110
|
|
|
$join->setJoinType(Criteria::JOIN); |
|
111
|
|
|
|
|
112
|
|
|
$query |
|
113
|
|
|
->addJoinObject($join, 'feature_type_join') |
|
114
|
|
|
->addJoinCondition( |
|
115
|
|
|
'feature_type_join', |
|
116
|
|
|
'`feature_feature_type`.`feature_id` IN (?)', |
|
117
|
|
|
implode(',', $featureId), |
|
118
|
|
|
null, |
|
119
|
|
|
\PDO::PARAM_INT |
|
120
|
|
|
); |
|
121
|
|
|
} |
|
122
|
|
|
|
|
123
|
|
|
foreach ($this->getOrder() as $order) { |
|
124
|
|
|
switch ($order) { |
|
125
|
|
|
case "id": |
|
126
|
|
|
$query->orderById(); |
|
127
|
|
|
break; |
|
128
|
|
|
case "id-reverse": |
|
129
|
|
|
$query->orderById(Criteria::DESC); |
|
130
|
|
|
break; |
|
131
|
|
|
case "slug": |
|
132
|
|
|
$query->orderBySlug(); |
|
133
|
|
|
break; |
|
134
|
|
|
case "slug-reverse": |
|
135
|
|
|
$query->orderBySlug(Criteria::DESC); |
|
136
|
|
|
break; |
|
137
|
|
|
} |
|
138
|
|
|
} |
|
139
|
|
|
return $query; |
|
140
|
|
|
} |
|
141
|
|
|
|
|
142
|
|
|
/** |
|
143
|
|
|
* @param LoopResult $loopResult |
|
144
|
|
|
* |
|
145
|
|
|
* @return LoopResult |
|
146
|
|
|
*/ |
|
147
|
|
|
public function parseResults(LoopResult $loopResult) |
|
148
|
|
|
{ |
|
149
|
|
|
/** @var FeatureType $entry */ |
|
150
|
|
|
foreach ($loopResult->getResultDataCollection() as $entry) { |
|
151
|
|
|
$row = new LoopResultRow($entry); |
|
152
|
|
|
$row |
|
153
|
|
|
->set("ID", $entry->getId()) |
|
154
|
|
|
->set("SLUG", $entry->getSlug()) |
|
155
|
|
|
->set("TITLE", $entry->getVirtualColumn('i18n_TITLE')) |
|
156
|
|
|
->set("DESCRIPTION", $entry->getVirtualColumn('i18n_DESCRIPTION')) |
|
157
|
|
|
->set("CSS_CLASS", $entry->getCssClass()) |
|
158
|
|
|
->set("PATTERN", $entry->getPattern()) |
|
159
|
|
|
->set("INPUT_TYPE", $entry->getInputType()) |
|
160
|
|
|
->set("MIN", $entry->getMin()) |
|
161
|
|
|
->set("MAX", $entry->getMax()) |
|
162
|
|
|
->set("STEP", $entry->getStep()) |
|
163
|
|
|
->set("IMAGE_MAX_WIDTH", $entry->getImageMaxWidth()) |
|
164
|
|
|
->set("IMAGE_MAX_HEIGHT", $entry->getImageMaxHeight()) |
|
165
|
|
|
->set("IMAGE_RATIO", $entry->getImageRatio()) |
|
166
|
|
|
->set("IS_MULTILINGUAL_FEATURE_AV_VALUE", $entry->getIsMultilingualFeatureAvValue()) |
|
167
|
|
|
->set("HAS_FEATURE_AV_VALUE", $entry->getHasFeatureAvValue()) |
|
168
|
|
|
; |
|
169
|
|
|
|
|
170
|
|
|
$this->addOutputFields($row, $entry); |
|
171
|
|
|
|
|
172
|
|
|
$loopResult->addRow($row); |
|
173
|
|
|
} |
|
174
|
|
|
|
|
175
|
|
|
return $loopResult; |
|
176
|
|
|
} |
|
177
|
|
|
} |
|
178
|
|
|
|