Skip to content
This repository
Newer
Older
100755 352 lines (266 sloc) 10.648 kb
7f90fa05 » Alistair Kearney
2008-09-18 Initial commit of Revision 5 code
1 <?php
4ff048c2 » brendo
2010-12-08 Added missing @package to some classes
2 /**
3 * @package toolkit
4 */
f7b3c440 » brendo
2011-04-18 Sanitize Taglist values for displayPublishPanel and displayDatasource…
5
ea14c4af » brendo
2011-01-06 Some basic documentation for the Constants and the core Fields
6 /**
7 * The Tag List field is really a different interface for the Select Box
f7b3c440 » brendo
2011-04-18 Sanitize Taglist values for displayPublishPanel and displayDatasource…
8 * field, offering a tag interface that can have static suggestions,
ea14c4af » brendo
2011-01-06 Some basic documentation for the Constants and the core Fields
9 * suggestions from another field or a dynamic list based on what an Author
10 * has previously used for this field.
11 */
f7b3c440 » brendo
2011-04-18 Sanitize Taglist values for displayPublishPanel and displayDatasource…
12
94d10d2b » Rowan Lewis
2008-12-03 Rewrote buildDSRetrivalSQL on all fields to sanitize input, added bet…
13 Class fieldTagList extends Field {
14 public function __construct(&$parent){
7f90fa05 » Alistair Kearney
2008-09-18 Initial commit of Revision 5 code
15 parent::__construct($parent);
e6a3e493 » nilshoerrmann
2009-02-07 make field titles translatable; always translate 'optional' separately
16 $this->_name = __('Tag List');
7f90fa05 » Alistair Kearney
2008-09-18 Initial commit of Revision 5 code
17 }
f2116e41 » cz
2010-10-31 Merge brendo's changes
18
9bd435a6 » brendo
2011-06-02 Lead by example: core Fields code cleanup
19 /*-------------------------------------------------------------------------
20 Definition:
21 -------------------------------------------------------------------------*/
22
23 public function canFilter() {
24 return true;
b30a6dac » pointybeard
2009-01-02 Can now choose multiple sources for pre-populating tag lists.
25 }
f2116e41 » cz
2010-10-31 Merge brendo's changes
26
9bd435a6 » brendo
2011-06-02 Lead by example: core Fields code cleanup
27 public function canImport(){
d5212827 » Rowan Lewis
2008-12-03 Fixed bug #283.
28 return true;
29 }
f2116e41 » cz
2010-10-31 Merge brendo's changes
30
9bd435a6 » brendo
2011-06-02 Lead by example: core Fields code cleanup
31 public function canPrePopulate(){
7f90fa05 » Alistair Kearney
2008-09-18 Initial commit of Revision 5 code
32 return true;
33 }
f2116e41 » cz
2010-10-31 Merge brendo's changes
34
9bd435a6 » brendo
2011-06-02 Lead by example: core Fields code cleanup
35 public function requiresSQLGrouping() {
7f90fa05 » Alistair Kearney
2008-09-18 Initial commit of Revision 5 code
36 return true;
37 }
f2116e41 » cz
2010-10-31 Merge brendo's changes
38
9bd435a6 » brendo
2011-06-02 Lead by example: core Fields code cleanup
39 public function allowDatasourceParamOutput(){
62017220 » psychoticmeow
2009-01-06 Added functions to aid in writing importer tools.
40 return true;
41 }
f2116e41 » cz
2010-10-31 Merge brendo's changes
42
9bd435a6 » brendo
2011-06-02 Lead by example: core Fields code cleanup
43 /*-------------------------------------------------------------------------
44 Setup:
45 -------------------------------------------------------------------------*/
f2116e41 » cz
2010-10-31 Merge brendo's changes
46
9bd435a6 » brendo
2011-06-02 Lead by example: core Fields code cleanup
47 public function createTable(){
48 return Symphony::Database()->query("
49 CREATE TABLE IF NOT EXISTS `tbl_entries_data_" . $this->get('id') . "` (
50 `id` int(11) unsigned NOT NULL auto_increment,
51 `entry_id` int(11) unsigned NOT NULL,
52 `handle` varchar(255) default NULL,
53 `value` varchar(255) default NULL,
54 PRIMARY KEY (`id`),
55 KEY `entry_id` (`entry_id`),
56 KEY `handle` (`handle`),
57 KEY `value` (`value`)
f5de9aab » brendo
2011-08-22 Set the charset and collation of the core fields. Fixes #743
58 ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
9bd435a6 » brendo
2011-06-02 Lead by example: core Fields code cleanup
59 ");
60 }
f2116e41 » cz
2010-10-31 Merge brendo's changes
61
9bd435a6 » brendo
2011-06-02 Lead by example: core Fields code cleanup
62 /*-------------------------------------------------------------------------
63 Utilities:
64 -------------------------------------------------------------------------*/
f2116e41 » cz
2010-10-31 Merge brendo's changes
65
9bd435a6 » brendo
2011-06-02 Lead by example: core Fields code cleanup
66 public function set($field, $value){
67 if($field == 'pre_populate_source' && !is_array($value)) $value = preg_split('/\s*,\s*/', $value, -1, PREG_SPLIT_NO_EMPTY);
68 $this->_fields[$field] = $value;
69 }
70
71 public function findAllTags(){
72 if(!is_array($this->get('pre_populate_source'))) return;
73
74 $values = array();
75
76 foreach($this->get('pre_populate_source') as $item){
77 $result = Symphony::Database()->fetchCol('value', sprintf(
78 "SELECT DISTINCT `value` FROM tbl_entries_data_%d ORDER BY `value` ASC",
79 ($item == 'existing' ? $this->get('id') : $item)
94d10d2b » Rowan Lewis
2008-12-03 Rewrote buildDSRetrivalSQL on all fields to sanitize input, added bet…
80 ));
9bd435a6 » brendo
2011-06-02 Lead by example: core Fields code cleanup
81
82 if(!is_array($result) || empty($result)) continue;
83
84 $values = array_merge($values, $result);
94d10d2b » Rowan Lewis
2008-12-03 Rewrote buildDSRetrivalSQL on all fields to sanitize input, added bet…
85 }
86
9bd435a6 » brendo
2011-06-02 Lead by example: core Fields code cleanup
87 return array_unique($values);
f2116e41 » cz
2010-10-31 Merge brendo's changes
88 }
7f90fa05 » Alistair Kearney
2008-09-18 Initial commit of Revision 5 code
89
9bd435a6 » brendo
2011-06-02 Lead by example: core Fields code cleanup
90 private static function __tagArrayToString(array $tags){
91 if(empty($tags)) return NULL;
f2116e41 » cz
2010-10-31 Merge brendo's changes
92
9bd435a6 » brendo
2011-06-02 Lead by example: core Fields code cleanup
93 sort($tags);
f2116e41 » cz
2010-10-31 Merge brendo's changes
94
9bd435a6 » brendo
2011-06-02 Lead by example: core Fields code cleanup
95 return implode(', ', $tags);
96 }
f2116e41 » cz
2010-10-31 Merge brendo's changes
97
9bd435a6 » brendo
2011-06-02 Lead by example: core Fields code cleanup
98 /*-------------------------------------------------------------------------
99 Settings:
100 -------------------------------------------------------------------------*/
7f90fa05 » Alistair Kearney
2008-09-18 Initial commit of Revision 5 code
101
9bd435a6 » brendo
2011-06-02 Lead by example: core Fields code cleanup
102 public function findDefaults(&$fields){
103 if(!isset($fields['pre_populate_source'])) $fields['pre_populate_source'] = array('existing');
104 }
f2116e41 » cz
2010-10-31 Merge brendo's changes
105
9bd435a6 » brendo
2011-06-02 Lead by example: core Fields code cleanup
106 public function displaySettingsPanel(&$wrapper, $errors = null) {
107 parent::displaySettingsPanel($wrapper, $errors);
f2116e41 » cz
2010-10-31 Merge brendo's changes
108
9bd435a6 » brendo
2011-06-02 Lead by example: core Fields code cleanup
109 $label = Widget::Label(__('Suggestion List'));
110
26109d90 » brendo
2011-08-22 SectionManager is now static.
111 $sections = SectionManager::fetch(NULL, 'ASC', 'name');
9bd435a6 » brendo
2011-06-02 Lead by example: core Fields code cleanup
112 $field_groups = array();
113
114 if(is_array($sections) && !empty($sections))
115 foreach($sections as $section) $field_groups[$section->get('id')] = array('fields' => $section->fetchFields(), 'section' => $section);
116
117 $options = array(
118 //array('none', false, __('None')),
119 array('existing', (in_array('existing', $this->get('pre_populate_source'))), __('Existing Values')),
120 );
121
122 foreach($field_groups as $group){
123
124 if(!is_array($group['fields'])) continue;
125
126 $fields = array();
127 foreach($group['fields'] as $f){
128 if($f->get('id') != $this->get('id') && $f->canPrePopulate()) $fields[] = array($f->get('id'), (in_array($f->get('id'), $this->get('pre_populate_source'))), $f->get('label'));
7f90fa05 » Alistair Kearney
2008-09-18 Initial commit of Revision 5 code
129 }
9bd435a6 » brendo
2011-06-02 Lead by example: core Fields code cleanup
130
131 if(is_array($fields) && !empty($fields)) $options[] = array('label' => $group['section']->get('name'), 'options' => $fields);
f2116e41 » cz
2010-10-31 Merge brendo's changes
132 }
9bd435a6 » brendo
2011-06-02 Lead by example: core Fields code cleanup
133
134 $label->appendChild(Widget::Select('fields['.$this->get('sortorder').'][pre_populate_source][]', $options, array('multiple' => 'multiple')));
135 $wrapper->appendChild($label);
136
137 $this->buildValidationSelect($wrapper, $this->get('validator'), 'fields['.$this->get('sortorder').'][validator]');
138
139 $this->appendShowColumnCheckbox($wrapper);
140 }
141
142 public function commit(){
143 if(!parent::commit()) return false;
144
145 $id = $this->get('id');
146
147 if($id === false) return false;
148
149 $fields = array();
150
151 $fields['field_id'] = $id;
152 $fields['pre_populate_source'] = (is_null($this->get('pre_populate_source')) ? NULL : implode(',', $this->get('pre_populate_source')));
153 $fields['validator'] = ($fields['validator'] == 'custom' ? NULL : $this->get('validator'));
154
155 Symphony::Database()->query("DELETE FROM `tbl_fields_".$this->handle()."` WHERE `field_id` = '$id' LIMIT 1");
156
157 return Symphony::Database()->insert($fields, 'tbl_fields_' . $this->handle());
7f90fa05 » Alistair Kearney
2008-09-18 Initial commit of Revision 5 code
158 }
159
9bd435a6 » brendo
2011-06-02 Lead by example: core Fields code cleanup
160 /*-------------------------------------------------------------------------
161 Publish:
162 -------------------------------------------------------------------------*/
f2116e41 » cz
2010-10-31 Merge brendo's changes
163
9bd435a6 » brendo
2011-06-02 Lead by example: core Fields code cleanup
164 public function displayPublishPanel(&$wrapper, $data=NULL, $flagWithError=NULL, $fieldnamePrefix=NULL, $fieldnamePostfix=NULL){
c2235c32 » pointybeard
2009-02-10 Fixed truncation issues with Tag List field
165 $value = NULL;
166 if(isset($data['value'])){
167 $value = (is_array($data['value']) ? self::__tagArrayToString($data['value']) : $data['value']);
168 }
f2116e41 » cz
2010-10-31 Merge brendo's changes
169
7f90fa05 » Alistair Kearney
2008-09-18 Initial commit of Revision 5 code
170 $label = Widget::Label($this->get('label'));
f2116e41 » cz
2010-10-31 Merge brendo's changes
171
7f90fa05 » Alistair Kearney
2008-09-18 Initial commit of Revision 5 code
172 $label->appendChild(Widget::Input('fields'.$fieldnamePrefix.'['.$this->get('element_name').']'.$fieldnamePostfix, (strlen($value) != 0 ? $value : NULL)));
f2116e41 » cz
2010-10-31 Merge brendo's changes
173
7f90fa05 » Alistair Kearney
2008-09-18 Initial commit of Revision 5 code
174 if($flagWithError != NULL) $wrapper->appendChild(Widget::wrapFormElementWithError($label, $flagWithError));
175 else $wrapper->appendChild($label);
176
177 if($this->get('pre_populate_source') != NULL){
f2116e41 » cz
2010-10-31 Merge brendo's changes
178
7f90fa05 » Alistair Kearney
2008-09-18 Initial commit of Revision 5 code
179 $existing_tags = $this->findAllTags();
180
181 if(is_array($existing_tags) && !empty($existing_tags)){
182 $taglist = new XMLElement('ul');
183 $taglist->setAttribute('class', 'tags');
f2116e41 » cz
2010-10-31 Merge brendo's changes
184
f7b3c440 » brendo
2011-04-18 Sanitize Taglist values for displayPublishPanel and displayDatasource…
185 foreach($existing_tags as $tag) {
186 $taglist->appendChild(
187 new XMLElement('li', General::sanitize($tag))
188 );
189 }
f2116e41 » cz
2010-10-31 Merge brendo's changes
190
7f90fa05 » Alistair Kearney
2008-09-18 Initial commit of Revision 5 code
191 $wrapper->appendChild($taglist);
192 }
193 }
194 }
f2116e41 » cz
2010-10-31 Merge brendo's changes
195
f22015a5 » Alistair Kearney
2009-05-15 Fixed Field::processRawFieldData() function signature so it does not …
196 public function processRawFieldData($data, &$status, $simulate=false, $entry_id=NULL){
7f90fa05 » Alistair Kearney
2008-09-18 Initial commit of Revision 5 code
197 $status = self::__OK__;
f2116e41 » cz
2010-10-31 Merge brendo's changes
198
7f90fa05 » Alistair Kearney
2008-09-18 Initial commit of Revision 5 code
199 $data = preg_split('/\,\s*/i', $data, -1, PREG_SPLIT_NO_EMPTY);
200 $data = array_map('trim', $data);
f2116e41 » cz
2010-10-31 Merge brendo's changes
201
7f90fa05 » Alistair Kearney
2008-09-18 Initial commit of Revision 5 code
202 if(empty($data)) return;
f2116e41 » cz
2010-10-31 Merge brendo's changes
203
3f26fac2 » Alistair Kearney
2009-12-23 Taglist field will do a case insensitive removal of duplicates.
204 // Do a case insensitive removal of duplicates
205 $data = General::array_remove_duplicates($data, true);
f2116e41 » cz
2010-10-31 Merge brendo's changes
206
7f90fa05 » Alistair Kearney
2008-09-18 Initial commit of Revision 5 code
207 sort($data);
f2116e41 » cz
2010-10-31 Merge brendo's changes
208
7f90fa05 » Alistair Kearney
2008-09-18 Initial commit of Revision 5 code
209 $result = array();
210 foreach($data as $value){
211 $result['value'][] = $value;
212 $result['handle'][] = Lang::createHandle($value);
213 }
f2116e41 » cz
2010-10-31 Merge brendo's changes
214
7f90fa05 » Alistair Kearney
2008-09-18 Initial commit of Revision 5 code
215 return $result;
216 }
f2116e41 » cz
2010-10-31 Merge brendo's changes
217
9bd435a6 » brendo
2011-06-02 Lead by example: core Fields code cleanup
218 /*-------------------------------------------------------------------------
219 Output:
220 -------------------------------------------------------------------------*/
f2116e41 » cz
2010-10-31 Merge brendo's changes
221
9bd435a6 » brendo
2011-06-02 Lead by example: core Fields code cleanup
222 public function appendFormattedElement(&$wrapper, $data, $encode = false) {
223 if (!is_array($data) or empty($data)) return;
f2116e41 » cz
2010-10-31 Merge brendo's changes
224
9bd435a6 » brendo
2011-06-02 Lead by example: core Fields code cleanup
225 $list = new XMLElement($this->get('element_name'));
f2116e41 » cz
2010-10-31 Merge brendo's changes
226
9bd435a6 » brendo
2011-06-02 Lead by example: core Fields code cleanup
227 if (!is_array($data['handle']) and !is_array($data['value'])) {
228 $data = array(
229 'handle' => array($data['handle']),
230 'value' => array($data['value'])
231 );
232 }
f2116e41 » cz
2010-10-31 Merge brendo's changes
233
9bd435a6 » brendo
2011-06-02 Lead by example: core Fields code cleanup
234 foreach ($data['value'] as $index => $value) {
235 $list->appendChild(new XMLElement(
236 'item', General::sanitize($value), array(
237 'handle' => $data['handle'][$index]
238 )
239 ));
240 }
f2116e41 » cz
2010-10-31 Merge brendo's changes
241
9bd435a6 » brendo
2011-06-02 Lead by example: core Fields code cleanup
242 $wrapper->appendChild($list);
243 }
f2116e41 » cz
2010-10-31 Merge brendo's changes
244
89c1a5d7 » brendo
2011-06-21 Add `` parameter to `Field->prepareTableValue`. Add missing `` parame…
245 public function prepareTableValue($data, XMLElement $link=NULL, $entry_id = null){
7f90fa05 » Alistair Kearney
2008-09-18 Initial commit of Revision 5 code
246 if(!is_array($data) || empty($data)) return;
f2116e41 » cz
2010-10-31 Merge brendo's changes
247
c2235c32 » pointybeard
2009-02-10 Fixed truncation issues with Tag List field
248 $value = NULL;
249 if(isset($data['value'])){
250 $value = (is_array($data['value']) ? self::__tagArrayToString($data['value']) : $data['value']);
251 }
7f90fa05 » Alistair Kearney
2008-09-18 Initial commit of Revision 5 code
252
89c1a5d7 » brendo
2011-06-21 Add `` parameter to `Field->prepareTableValue`. Add missing `` parame…
253 return parent::prepareTableValue(array('value' => General::sanitize($value)), $link, $entry_id = null);
7f90fa05 » Alistair Kearney
2008-09-18 Initial commit of Revision 5 code
254 }
f2116e41 » cz
2010-10-31 Merge brendo's changes
255
9bd435a6 » brendo
2011-06-02 Lead by example: core Fields code cleanup
256 /*-------------------------------------------------------------------------
257 Filtering:
258 -------------------------------------------------------------------------*/
f2116e41 » cz
2010-10-31 Merge brendo's changes
259
9bd435a6 » brendo
2011-06-02 Lead by example: core Fields code cleanup
260 public function displayDatasourceFilterPanel(&$wrapper, $data=NULL, $errors=NULL, $fieldnamePrefix=NULL, $fieldnamePostfix=NULL){
261 parent::displayDatasourceFilterPanel($wrapper, $data, $errors, $fieldnamePrefix, $fieldnamePostfix);
7f90fa05 » Alistair Kearney
2008-09-18 Initial commit of Revision 5 code
262
9bd435a6 » brendo
2011-06-02 Lead by example: core Fields code cleanup
263 if($this->get('pre_populate_source') != NULL){
f2116e41 » cz
2010-10-31 Merge brendo's changes
264
9bd435a6 » brendo
2011-06-02 Lead by example: core Fields code cleanup
265 $existing_tags = $this->findAllTags();
f2116e41 » cz
2010-10-31 Merge brendo's changes
266
9bd435a6 » brendo
2011-06-02 Lead by example: core Fields code cleanup
267 if(is_array($existing_tags) && !empty($existing_tags)){
268 $taglist = new XMLElement('ul');
269 $taglist->setAttribute('class', 'tags');
f2116e41 » cz
2010-10-31 Merge brendo's changes
270
9bd435a6 » brendo
2011-06-02 Lead by example: core Fields code cleanup
271 foreach($existing_tags as $tag) {
272 $taglist->appendChild(
273 new XMLElement('li', General::sanitize($tag))
274 );
275 }
f2116e41 » cz
2010-10-31 Merge brendo's changes
276
9bd435a6 » brendo
2011-06-02 Lead by example: core Fields code cleanup
277 $wrapper->appendChild($taglist);
7f90fa05 » Alistair Kearney
2008-09-18 Initial commit of Revision 5 code
278 }
279 }
94d10d2b » Rowan Lewis
2008-12-03 Rewrote buildDSRetrivalSQL on all fields to sanitize input, added bet…
280 }
7f90fa05 » Alistair Kearney
2008-09-18 Initial commit of Revision 5 code
281
c48583be » brendo
2011-03-27 Fix a long standing typo, buildDSRetrivalSQL is now correctly buildDS…
282 public function buildDSRetrievalSQL($data, &$joins, &$where, $andOperation = false) {
53bfa6c5 » Alistair Kearney
2008-10-07 Tag field can now be filtered by the handle, instead of just the value.
283 $field_id = $this->get('id');
f2116e41 » cz
2010-10-31 Merge brendo's changes
284
373357fb » Rowan Lewis
2008-12-03 Fixed bug #250 and rewrote buildDSRetrivalSQL to sanitize user input.
285 if (self::isFilterRegex($data[0])) {
286 $this->_key++;
f2116e41 » cz
2010-10-31 Merge brendo's changes
287
288 if (preg_match('/^regexp:/i', $data[0])) {
a6134276 » brendo
2011-07-09 Strip spaces from the regexp filters, RE #710
289 $pattern = preg_replace('/^regexp:\s*/i', null, $this->cleanValue($data[0]));
f2116e41 » cz
2010-10-31 Merge brendo's changes
290 $regex = 'REGEXP';
291 } else {
a6134276 » brendo
2011-07-09 Strip spaces from the regexp filters, RE #710
292 $pattern = preg_replace('/^not-?regexp:\s*/i', null, $this->cleanValue($data[0]));
f2116e41 » cz
2010-10-31 Merge brendo's changes
293 $regex = 'NOT REGEXP';
294 }
295
a6134276 » brendo
2011-07-09 Strip spaces from the regexp filters, RE #710
296 if(strlen($pattern) == 0) return;
297
373357fb » Rowan Lewis
2008-12-03 Fixed bug #250 and rewrote buildDSRetrivalSQL to sanitize user input.
298 $joins .= "
299 LEFT JOIN
94d10d2b » Rowan Lewis
2008-12-03 Rewrote buildDSRetrivalSQL on all fields to sanitize input, added bet…
300 `tbl_entries_data_{$field_id}` AS t{$field_id}_{$this->_key}
301 ON (e.id = t{$field_id}_{$this->_key}.entry_id)
373357fb » Rowan Lewis
2008-12-03 Fixed bug #250 and rewrote buildDSRetrivalSQL to sanitize user input.
302 ";
303 $where .= "
304 AND (
f2116e41 » cz
2010-10-31 Merge brendo's changes
305 t{$field_id}_{$this->_key}.value {$regex} '{$pattern}'
306 OR t{$field_id}_{$this->_key}.handle {$regex} '{$pattern}'
94d10d2b » Rowan Lewis
2008-12-03 Rewrote buildDSRetrivalSQL on all fields to sanitize input, added bet…
307 )
373357fb » Rowan Lewis
2008-12-03 Fixed bug #250 and rewrote buildDSRetrivalSQL to sanitize user input.
308 ";
f2116e41 » cz
2010-10-31 Merge brendo's changes
309
373357fb » Rowan Lewis
2008-12-03 Fixed bug #250 and rewrote buildDSRetrivalSQL to sanitize user input.
310 } elseif ($andOperation) {
311 foreach ($data as $value) {
312 $this->_key++;
94d10d2b » Rowan Lewis
2008-12-03 Rewrote buildDSRetrivalSQL on all fields to sanitize input, added bet…
313 $value = $this->cleanValue($value);
373357fb » Rowan Lewis
2008-12-03 Fixed bug #250 and rewrote buildDSRetrivalSQL to sanitize user input.
314 $joins .= "
315 LEFT JOIN
94d10d2b » Rowan Lewis
2008-12-03 Rewrote buildDSRetrivalSQL on all fields to sanitize input, added bet…
316 `tbl_entries_data_{$field_id}` AS t{$field_id}_{$this->_key}
317 ON (e.id = t{$field_id}_{$this->_key}.entry_id)
373357fb » Rowan Lewis
2008-12-03 Fixed bug #250 and rewrote buildDSRetrivalSQL to sanitize user input.
318 ";
319 $where .= "
320 AND (
94d10d2b » Rowan Lewis
2008-12-03 Rewrote buildDSRetrivalSQL on all fields to sanitize input, added bet…
321 t{$field_id}_{$this->_key}.value = '{$value}'
322 OR t{$field_id}_{$this->_key}.handle = '{$value}'
323 )
373357fb » Rowan Lewis
2008-12-03 Fixed bug #250 and rewrote buildDSRetrivalSQL to sanitize user input.
324 ";
53bfa6c5 » Alistair Kearney
2008-10-07 Tag field can now be filtered by the handle, instead of just the value.
325 }
f2116e41 » cz
2010-10-31 Merge brendo's changes
326
373357fb » Rowan Lewis
2008-12-03 Fixed bug #250 and rewrote buildDSRetrivalSQL to sanitize user input.
327 } else {
328 if (!is_array($data)) $data = array($data);
f2116e41 » cz
2010-10-31 Merge brendo's changes
329
373357fb » Rowan Lewis
2008-12-03 Fixed bug #250 and rewrote buildDSRetrivalSQL to sanitize user input.
330 foreach ($data as &$value) {
94d10d2b » Rowan Lewis
2008-12-03 Rewrote buildDSRetrivalSQL on all fields to sanitize input, added bet…
331 $value = $this->cleanValue($value);
373357fb » Rowan Lewis
2008-12-03 Fixed bug #250 and rewrote buildDSRetrivalSQL to sanitize user input.
332 }
f2116e41 » cz
2010-10-31 Merge brendo's changes
333
373357fb » Rowan Lewis
2008-12-03 Fixed bug #250 and rewrote buildDSRetrivalSQL to sanitize user input.
334 $this->_key++;
335 $data = implode("', '", $data);
336 $joins .= "
337 LEFT JOIN
94d10d2b » Rowan Lewis
2008-12-03 Rewrote buildDSRetrivalSQL on all fields to sanitize input, added bet…
338 `tbl_entries_data_{$field_id}` AS t{$field_id}_{$this->_key}
339 ON (e.id = t{$field_id}_{$this->_key}.entry_id)
373357fb » Rowan Lewis
2008-12-03 Fixed bug #250 and rewrote buildDSRetrivalSQL to sanitize user input.
340 ";
341 $where .= "
342 AND (
94d10d2b » Rowan Lewis
2008-12-03 Rewrote buildDSRetrivalSQL on all fields to sanitize input, added bet…
343 t{$field_id}_{$this->_key}.value IN ('{$data}')
344 OR t{$field_id}_{$this->_key}.handle IN ('{$data}')
345 )
373357fb » Rowan Lewis
2008-12-03 Fixed bug #250 and rewrote buildDSRetrivalSQL to sanitize user input.
346 ";
347 }
f2116e41 » cz
2010-10-31 Merge brendo's changes
348
53bfa6c5 » Alistair Kearney
2008-10-07 Tag field can now be filtered by the handle, instead of just the value.
349 return true;
350 }
7f90fa05 » Alistair Kearney
2008-09-18 Initial commit of Revision 5 code
351
9bd435a6 » brendo
2011-06-02 Lead by example: core Fields code cleanup
352 }
Something went wrong with that request. Please try again.