2 /***************************************************************
5 * (c) 2001-2011 Christian Jul Jensen (christian@typo3.com)
8 * This script is part of the TYPO3 project. The TYPO3 project is
9 * free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
14 * The GNU General Public License can be found at
15 * http://www.gnu.org/copyleft/gpl.html.
16 * A copy is found in the textfile GPL.txt and important notices to the license
17 * from the author is found in LICENSE.txt distributed with these scripts.
20 * This script is distributed in the hope that it will be useful,
21 * but WITHOUT ANY WARRANTY; without even the implied warranty of
22 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 * GNU General Public License for more details.
25 * This copyright notice MUST APPEAR in all copies of the script!
26 ***************************************************************/
28 * Class for generating front end for building queries
32 * @author Christian Jul Jensen <christian@typo3.com>
33 * @author Kasper Skårhøj <kasperYYYY@typo3.com>
34 * @coauthor Jo Hasenau <info@cybercraft.de>
37 * [CLASS/FUNCTION INDEX of SCRIPT]
41 * 98: class t3lib_queryGenerator
42 * 245: function makeFieldList()
43 * 273: function init($name,$table,$fieldList='')
44 * 410: function setAndCleanUpExternalLists($name,$list,$force='')
45 * 426: function procesData($qC='')
46 * 529: function cleanUpQueryConfig($queryConfig)
47 * 586: function getFormElements($subLevel=0,$queryConfig='',$parent='')
48 * 744: function makeOptionList($fN, $conf, $table)
49 * 953: function printCodeArray($codeArr,$l=0)
50 * 976: function formatQ($str)
51 * 989: function mkOperatorSelect($name,$op,$draw,$submit)
52 * 1011: function mkTypeSelect($name,$fieldName,$prepend='FIELD_')
53 * 1032: function verifyType($fieldName)
54 * 1049: function verifyComparison($comparison,$neg)
55 * 1068: function mkFieldToInputSelect($name,$fieldName)
56 * 1091: function mkTableSelect($name,$cur)
57 * 1113: function mkCompSelect($name,$comparison,$neg)
58 * 1131: function getSubscript($arr)
59 * 1146: function initUserDef()
60 * 1155: function userDef()
61 * 1164: function userDefCleanUp($queryConfig)
62 * 1175: function getQuery ($queryConfig,$pad='')
63 * 1205: function getQuerySingle($conf,$first)
64 * 1245: function cleanInputVal($conf,$suffix='')
65 * 1270: function getUserDefQuery ($qcArr)
66 * 1278: function updateIcon()
67 * 1287: function getLabelCol()
68 * 1299: function makeSelectorTable($modSettings,$enableList='table,fields,query,group,order,limit')
69 * 1431: function getTreeList($id, $depth, $begin=0, $perms_clause)
70 * 1465: function getSelectQuery($qString = '', $fN = '')
71 * 1504: function JSbottom($formname='forms[0]')
72 * 1510: function typo3FormFieldSet(theField, evallist, is_in, checkbox, checkboxValue)
73 * 1528: function typo3FormFieldGet(theField, evallist, is_in, checkbox, checkboxValue, checkbox_off)
76 * (This index is automatically created/updated by the extension "extdeveval")
82 * Class for generating front end for building queries
84 * @author Christian Jul Jensen <christian@typo3.com>
85 * @author Kasper Skårhøj <kasperYYYY@typo3.com>
89 class t3lib_queryGenerator
{
93 'comparison' => array(
94 // Type = text offset = 0
96 '1_' => 'does not contain',
97 '2_' => 'starts with',
98 '3_' => 'does not start with',
100 '5_' => 'does not end with',
102 '7_' => 'does not equal',
103 // Type = number , offset = 32
105 '33_' => 'does not equal',
106 '34_' => 'is greater than',
107 '35_' => 'is less than',
108 '36_' => 'is between',
109 '37_' => 'is not between',
110 '38_' => 'is in list',
111 '39_' => 'is not in list',
112 '40_' => 'binary AND equals',
113 '41_' => 'binary AND does not equal',
114 '42_' => 'binary OR equals',
115 '43_' => 'binary OR does not equal',
116 // Type = multiple, relation, files , offset = 64
118 '65_' => 'does not equal',
120 '67_' => 'does not contain',
121 '68_' => 'is in list',
122 '69_' => 'is not in list',
123 '70_' => 'binary AND equals',
124 '71_' => 'binary AND does not equal',
125 '72_' => 'binary OR equals',
126 '73_' => 'binary OR does not equal',
127 // Type = date,time offset = 96
129 '97_' => 'does not equal',
130 '98_' => 'is greater than',
131 '99_' => 'is less than',
132 '100_' => 'is between',
133 '101_' => 'is not between',
134 '102_' => 'binary AND equals',
135 '103_' => 'binary AND does not equal',
136 '104_' => 'binary OR equals',
137 '105_' => 'binary OR does not equal',
138 // Type = boolean, offset = 128
140 '129_' => 'is False',
141 // Type = binary , offset = 160
143 '161_' => 'does not equal',
144 '162_' => 'contains',
145 '163_' => 'does not contain'
149 var $compSQL = array(
150 // Type = text offset = 0
151 '0' => "#FIELD# LIKE '%#VALUE#%'",
152 '1' => "#FIELD# NOT LIKE '%#VALUE#%'",
153 '2' => "#FIELD# LIKE '#VALUE#%'",
154 '3' => "#FIELD# NOT LIKE '#VALUE#%'",
155 '4' => "#FIELD# LIKE '%#VALUE#'",
156 '5' => "#FIELD# NOT LIKE '%#VALUE#'",
157 '6' => "#FIELD# = '#VALUE#'",
158 '7' => "#FIELD# != '#VALUE#'",
159 // Type = number, offset = 32
160 '32' => "#FIELD# = '#VALUE#'",
161 '33' => "#FIELD# != '#VALUE#'",
162 '34' => '#FIELD# > #VALUE#',
163 '35' => '#FIELD# < #VALUE#',
164 '36' => '#FIELD# >= #VALUE# AND #FIELD# <= #VALUE1#',
165 '37' => 'NOT (#FIELD# >= #VALUE# AND #FIELD# <= #VALUE1#)',
166 '38' => '#FIELD# IN (#VALUE#)',
167 '39' => '#FIELD# NOT IN (#VALUE#)',
168 '40' => '(#FIELD# & #VALUE#)=#VALUE#',
169 '41' => '(#FIELD# & #VALUE#)!=#VALUE#',
170 '42' => '(#FIELD# | #VALUE#)=#VALUE#',
171 '43' => '(#FIELD# | #VALUE#)!=#VALUE#',
172 // Type = multiple, relation, files , offset = 64
173 '64' => "#FIELD# = '#VALUE#'",
174 '65' => "#FIELD# != '#VALUE#'",
175 '66' => "#FIELD# LIKE '%#VALUE#%' AND #FIELD# LIKE '%#VALUE1#%'",
176 '67' => "(#FIELD# NOT LIKE '%#VALUE#%' OR #FIELD# NOT LIKE '%#VALUE1#%')",
177 '68' => '#FIELD# IN (#VALUE#)',
178 '69' => '#FIELD# NOT IN (#VALUE#)',
179 '70' => '(#FIELD# & #VALUE#)=#VALUE#',
180 '71' => '(#FIELD# & #VALUE#)!=#VALUE#',
181 '72' => '(#FIELD# | #VALUE#)=#VALUE#',
182 '73' => '(#FIELD# | #VALUE#)!=#VALUE#',
183 // Type = date, offset = 32
184 '96' => "#FIELD# = '#VALUE#'",
185 '97' => "#FIELD# != '#VALUE#'",
186 '98' => '#FIELD# > #VALUE#',
187 '99' => '#FIELD# < #VALUE#',
188 '100' => '#FIELD# >= #VALUE# AND #FIELD# <= #VALUE1#',
189 '101' => 'NOT (#FIELD# >= #VALUE# AND #FIELD# <= #VALUE1#)',
190 '102' => '(#FIELD# & #VALUE#)=#VALUE#',
191 '103' => '(#FIELD# & #VALUE#)!=#VALUE#',
192 '104' => '(#FIELD# | #VALUE#)=#VALUE#',
193 '105' => '(#FIELD# | #VALUE#)!=#VALUE#',
194 // Type = boolean, offset = 128
195 '128' => "#FIELD# = '1'",
196 '129' => "#FIELD# != '1'",
197 // Type = binary = 160
198 '160' => "#FIELD# = '#VALUE#'",
199 '161' => "#FIELD# != '#VALUE#'",
200 '162' => '(#FIELD# & #VALUE#)=#VALUE#',
201 '163' => '(#FIELD# & #VALUE#)=0'
204 var $comp_offsets = array(
215 var $noWrap = ' nowrap';
217 var $name; // Form data name prefix
218 var $table; // table for the query
219 var $fieldList; // field list
220 var $fields = array(); // Array of the fields possible
221 var $extFieldLists = array();
222 var $queryConfig = array(); // The query config
223 var $enablePrefix = 0;
224 var $enableQueryParts = 0;
227 protected $formName = '';
233 function makeFieldList() {
235 $fieldListArr = array();
236 if (is_array($TCA[$this->table
])) {
237 t3lib_div
::loadTCA($this->table
);
238 foreach ($TCA[$this->table
]['columns'] as $fN => $value) {
239 $fieldListArr[] = $fN;
241 $fieldListArr[] = 'uid';
242 $fieldListArr[] = 'pid';
243 $fieldListArr[] = 'deleted';
244 if ($TCA[$this->table
]['ctrl']['tstamp']) {
245 $fieldListArr[] = $TCA[$this->table
]['ctrl']['tstamp'];
247 if ($TCA[$this->table
]['ctrl']['crdate']) {
248 $fieldListArr[] = $TCA[$this->table
]['ctrl']['crdate'];
250 if ($TCA[$this->table
]['ctrl']['cruser_id']) {
251 $fieldListArr[] = $TCA[$this->table
]['ctrl']['cruser_id'];
253 if ($TCA[$this->table
]['ctrl']['sortby']) {
254 $fieldListArr[] = $TCA[$this->table
]['ctrl']['sortby'];
257 return implode(',', $fieldListArr);
261 * [Describe function...]
263 * @param [type] $name: ...
264 * @param [type] $table: ...
265 * @param [type] $fieldList: ...
268 function init($name, $table, $fieldList = '') {
271 // Analysing the fields in the table.
272 if (is_array($TCA[$table])) {
273 t3lib_div
::loadTCA($table);
275 $this->table
= $table;
276 $this->fieldList
= $fieldList ?
$fieldList : $this->makeFieldList();
278 $fieldArr = t3lib_div
::trimExplode(',', $this->fieldList
, 1);
279 foreach ($fieldArr as $fN) {
280 $fC = $TCA[$this->table
]['columns'][$fN];
281 $this->fields
[$fN] = $fC['config'];
282 $this->fields
[$fN]['exclude'] = $fC['exclude'];
283 if (is_array($fC) && $fC['label']) {
284 $this->fields
[$fN]['label'] = rtrim(trim($GLOBALS['LANG']->sL($fC['label'])), ':');
285 switch ($this->fields
[$fN]['type']) {
287 if (preg_match('/int|year/i', $this->fields
[$fN]['eval'])) {
288 $this->fields
[$fN]['type'] = 'number';
289 } elseif (preg_match('/time/i', $this->fields
[$fN]['eval'])) {
290 $this->fields
[$fN]['type'] = 'time';
291 } elseif (preg_match('/date/i', $this->fields
[$fN]['eval'])) {
292 $this->fields
[$fN]['type'] = 'date';
294 $this->fields
[$fN]['type'] = 'text';
298 if (!$this->fields
[$fN]['items']) {
299 $this->fields
[$fN]['type'] = 'boolean';
301 $this->fields
[$fN]['type'] = 'binary';
305 $this->fields
[$fN]['type'] = 'multiple';
308 $this->fields
[$fN]['type'] = 'multiple';
309 if ($this->fields
[$fN]['foreign_table']) {
310 $this->fields
[$fN]['type'] = 'relation';
312 if ($this->fields
[$fN]['special']) {
313 $this->fields
[$fN]['type'] = 'text';
317 $this->fields
[$fN]['type'] = 'files';
318 if ($this->fields
[$fN]['internal_type'] == 'db') {
319 $this->fields
[$fN]['type'] = 'relation';
328 $this->fields
[$fN]['type'] = 'text';
333 $this->fields
[$fN]['label'] = '[FIELD: ' . $fN . ']';
336 $this->fields
[$fN]['type'] = 'relation';
337 $this->fields
[$fN]['allowed'] = 'pages';
340 $this->fields
[$fN]['type'] = 'relation';
341 $this->fields
[$fN]['allowed'] = 'be_users';
345 $this->fields
[$fN]['type'] = 'time';
348 $this->fields
[$fN]['type'] = 'boolean';
351 $this->fields
[$fN]['type'] = 'number';
359 $this->queryConfig = array(
362 'type' => 'FIELD_spaceBefore',
366 'type' => 'FIELD_records',
368 'inputValue' => 'foo foo'
371 'type' => 'newlevel',
375 'type' => 'FIELD_spaceBefore',
377 'inputValue' => 'foo foo'
381 'type' => 'FIELD_records',
383 'inputValue' => 'foo foo'
389 'type' => 'FIELD_maillist',
393 $this->initUserDef();
397 * [Describe function...]
399 * @param [type] $name: ...
400 * @param [type] $list: ...
401 * @param [type] $force: ...
404 function setAndCleanUpExternalLists($name, $list, $force = '') {
405 $fields = array_unique(t3lib_div
::trimExplode(',', $list . ',' . $force, 1));
407 foreach ($fields as $fN) {
408 if ($this->fields
[$fN]) {
412 $this->extFieldLists
[$name] = implode(',', $reList);
416 * [Describe function...]
418 * @param [type] $qC: ...
421 function procesData($qC = '') {
422 $this->queryConfig
= $qC;
424 $POST = t3lib_div
::_POST();
427 if ($POST['qG_del']) {
428 //initialize array to work on, save special parameters
429 $ssArr = $this->getSubscript($POST['qG_del']);
430 $workArr =& $this->queryConfig
;
431 for ($i = 0; $i < sizeof($ssArr) - 1; $i++
) {
432 $workArr =& $workArr[$ssArr[$i]];
434 // delete the entry and move the other entries
435 unset($workArr[$ssArr[$i]]);
436 for ($j = $ssArr[$i]; $j < sizeof($workArr); $j++
) {
437 $workArr[$j] = $workArr[$j +
1];
438 unset($workArr[$j +
1]);
443 if ($POST['qG_ins']) {
444 //initialize array to work on, save special parameters
445 $ssArr = $this->getSubscript($POST['qG_ins']);
446 $workArr =& $this->queryConfig
;
447 for ($i = 0; $i < sizeof($ssArr) - 1; $i++
) {
448 $workArr =& $workArr[$ssArr[$i]];
450 // move all entries above position where new entry is to be inserted
451 for ($j = sizeof($workArr); $j > $ssArr[$i]; $j--) {
452 $workArr[$j] = $workArr[$j - 1];
454 //clear new entry position
455 unset($workArr[$ssArr[$i] +
1]);
456 $workArr[$ssArr[$i] +
1]['type'] = 'FIELD_';
460 if ($POST['qG_up']) {
461 //initialize array to work on
462 $ssArr = $this->getSubscript($POST['qG_up']);
463 $workArr =& $this->queryConfig
;
464 for ($i = 0; $i < sizeof($ssArr) - 1; $i++
) {
465 $workArr =& $workArr[$ssArr[$i]];
468 $qG_tmp = $workArr[$ssArr[$i]];
469 $workArr[$ssArr[$i]] = $workArr[$ssArr[$i] - 1];
470 $workArr[$ssArr[$i] - 1] = $qG_tmp;
474 if ($POST['qG_nl']) {
475 //initialize array to work on
476 $ssArr = $this->getSubscript($POST['qG_nl']);
477 $workArr =& $this->queryConfig
;
478 for ($i = 0; $i < sizeof($ssArr) - 1; $i++
) {
479 $workArr =& $workArr[$ssArr[$i]];
482 $tempEl = $workArr[$ssArr[$i]];
483 if (is_array($tempEl)) {
484 if ($tempEl['type'] != 'newlevel') {
485 $workArr[$ssArr[$i]] = array(
486 'type' => 'newlevel',
487 'operator' => $tempEl['operator'],
488 'nl' => array($tempEl)
494 // if collapse level...
495 if ($POST['qG_remnl']) {
496 //initialize array to work on
497 $ssArr = $this->getSubscript($POST['qG_remnl']);
498 $workArr =& $this->queryConfig
;
499 for ($i = 0; $i < sizeof($ssArr) - 1; $i++
) {
500 $workArr =& $workArr[$ssArr[$i]];
504 $tempEl = $workArr[$ssArr[$i]];
505 if (is_array($tempEl)) {
506 if ($tempEl['type'] == 'newlevel') {
507 $a1 = array_slice($workArr, 0, $ssArr[$i]);
508 $a2 = array_slice($workArr, $ssArr[$i]);
511 $a3[0]['operator'] = $tempEl['operator'];
512 $workArr = array_merge($a1, $a3, $a2);
519 * [Describe function...]
521 * @param [type] $queryConfig: ...
524 function cleanUpQueryConfig($queryConfig) {
525 //since we dont traverse the array using numeric keys in the upcoming whileloop make sure it's fresh and clean before displaying
526 if (is_array($queryConfig)) {
529 //queryConfig should never be empty!
530 if (!$queryConfig[0] ||
!$queryConfig[0]['type']) {
531 $queryConfig[0] = array('type' => 'FIELD_');
537 foreach ($queryConfig as $key => $conf) {
538 if (substr($conf['type'], 0, 6) == 'FIELD_') {
539 $fName = substr($conf['type'], 6);
540 $fType = $this->fields
[$fName]['type'];
541 } elseif ($conf['type'] == 'newlevel') {
542 $fType = $conf['type'];
549 if (!$queryConfig[$key]['nl']) {
550 $queryConfig[$key]['nl'][0]['type'] = 'FIELD_';
552 $queryConfig[$key]['nl'] = $this->cleanUpQueryConfig($queryConfig[$key]['nl']);
555 $queryConfig[$key] = $this->userDefCleanUp($queryConfig[$key]);
559 // debug($queryConfig[$key]);
560 $verifiedName = $this->verifyType($fName);
561 $queryConfig[$key]['type'] = 'FIELD_' . $this->verifyType($verifiedName);
563 if ($conf['comparison'] >> 5 != $this->comp_offsets
[$fType]) {
564 $conf['comparison'] = $this->comp_offsets
[$fType] << 5;
566 $queryConfig[$key]['comparison'] = $this->verifyComparison($conf['comparison'], $conf['negate'] ?
1 : 0);
568 $queryConfig[$key]['inputValue'] = $this->cleanInputVal($queryConfig[$key]);
569 $queryConfig[$key]['inputValue1'] = $this->cleanInputVal($queryConfig[$key], 1);
571 // debug($queryConfig[$key]);
579 * [Describe function...]
581 * @param [type] $subLevel: ...
582 * @param [type] $queryConfig: ...
583 * @param [type] $parent: ...
586 function getFormElements($subLevel = 0, $queryConfig = '', $parent = '') {
588 if (!is_array($queryConfig)) {
589 $queryConfig = $this->queryConfig
;
595 foreach ($queryConfig as $key => $conf) {
596 $subscript = $parent . '[' . $key . ']';
598 $lineHTML .= $this->mkOperatorSelect($this->name
. $subscript, $conf['operator'], $c, ($conf['type'] != 'FIELD_'));
599 if (substr($conf['type'], 0, 6) == 'FIELD_') {
600 $fName = substr($conf['type'], 6);
601 $this->fieldName
= $fName;
602 $fType = $this->fields
[$fName]['type'];
603 if ($conf['comparison'] >> 5 != $this->comp_offsets
[$fType]) {
604 $conf['comparison'] = $this->comp_offsets
[$fType] << 5;
608 //make sure queryConfig contains _actual_ comparevalue.
609 //mkCompSelect don't care, but getQuery does.
610 $queryConfig[$key]['comparison'] +
= (isset($conf['negate']) - ($conf['comparison'] %
2));
612 } elseif ($conf['type'] == 'newlevel') {
613 $fType = $conf['type'];
621 if (!$queryConfig[$key]['nl']) {
622 $queryConfig[$key]['nl'][0]['type'] = 'FIELD_';
624 $lineHTML .= '<input type="hidden" name="' . $this->name
. $subscript . '[type]" value="newlevel">';
625 $codeArr[$arrCount]['sub'] = $this->getFormElements($subLevel +
1, $queryConfig[$key]['nl'], $subscript . '[nl]');
628 $lineHTML .= $this->userDef($this->name
. $subscript, $conf, $fName, $fType);
631 $lineHTML .= $this->mkTypeSelect($this->name
. $subscript . '[type]', $fName);
632 $lineHTML .= $this->mkCompSelect($this->name
. $subscript . '[comparison]', $conf['comparison'], $conf['negate'] ?
1 : 0);
633 $lineHTML .= '<input type="checkbox" class="checkbox"' . ($conf['negate'] ?
' checked' : '') . ' name="' . $this->name
. $subscript . '[negate]' . '" onClick="submit();">';
635 if ($conf['comparison'] == 100 ||
$conf['comparison'] == 101) { // between
636 $lineHTML .= '<input type="text" name="' . $this->name
. $subscript . '[inputValue]_hr' . '" value="' . strftime('%e-%m-%Y', $conf['inputValue']) . '" ' . $GLOBALS['TBE_TEMPLATE']->formWidth(10) . ' onChange="typo3form.fieldGet(\'' . $this->name
. $subscript . '[inputValue]\', \'date\', \'\', 0,0);"><input type="hidden" value="' . htmlspecialchars($conf['inputValue']) . '" name="' . $this->name
. $subscript . '[inputValue]' . '">';
637 $lineHTML .= '<input type="text" name="' . $this->name
. $subscript . '[inputValue1]_hr' . '" value="' . strftime('%e-%m-%Y', $conf['inputValue1']) . '" ' . $GLOBALS['TBE_TEMPLATE']->formWidth(10) . ' onChange="typo3form.fieldGet(\'' . $this->name
. $subscript . '[inputValue1]\', \'date\', \'\', 0,0);"><input type="hidden" value="' . htmlspecialchars($conf['inputValue1']) . '" name="' . $this->name
. $subscript . '[inputValue1]' . '">';
638 $this->extJSCODE
.= 'typo3form.fieldSet("' . $this->name
. $subscript . '[inputValue]", "date", "", 0,0);';
639 $this->extJSCODE
.= 'typo3form.fieldSet("' . $this->name
. $subscript . '[inputValue1]", "date", "", 0,0);';
641 $lineHTML .= '<input type="text" name="' . $this->name
. $subscript . '[inputValue]_hr' . '" value="' . strftime('%e-%m-%Y', $conf['inputValue']) . '" ' . $GLOBALS['TBE_TEMPLATE']->formWidth(10) . ' onChange="typo3form.fieldGet(\'' . $this->name
. $subscript . '[inputValue]\', \'date\', \'\', 0,0);"><input type="hidden" value="' . htmlspecialchars($conf['inputValue']) . '" name="' . $this->name
. $subscript . '[inputValue]' . '">';
642 $this->extJSCODE
.= 'typo3form.fieldSet("' . $this->name
. $subscript . '[inputValue]", "date", "", 0,0);';
646 $lineHTML .= $this->mkTypeSelect($this->name
. $subscript . '[type]', $fName);
647 $lineHTML .= $this->mkCompSelect($this->name
. $subscript . '[comparison]', $conf['comparison'], $conf['negate'] ?
1 : 0);
649 $lineHTML .= '<input type="checkbox" class="checkbox"' . ($conf['negate'] ?
' checked' : '') . ' name="' . $this->name
. $subscript . '[negate]' . '" onClick="submit();">';
650 if ($conf['comparison'] == 100 ||
$conf['comparison'] == 101) { // between:
651 $lineHTML .= '<input type="text" name="' . $this->name
. $subscript . '[inputValue]_hr' . '" value="' . strftime('%H:%M %e-%m-%Y', $conf['inputValue']) . '" ' . $GLOBALS['TBE_TEMPLATE']->formWidth(10) . ' onChange="typo3form.fieldGet(\'' . $this->name
. $subscript . '[inputValue]\', \'datetime\', \'\', 0,0);"><input type="hidden" value="' . htmlspecialchars($conf['inputValue']) . '" name="' . $this->name
. $subscript . '[inputValue]' . '">';
652 $lineHTML .= '<input type="text" name="' . $this->name
. $subscript . '[inputValue1]_hr' . '" value="' . strftime('%H:%M %e-%m-%Y', $conf['inputValue1']) . '" ' . $GLOBALS['TBE_TEMPLATE']->formWidth(10) . ' onChange="typo3form.fieldGet(\'' . $this->name
. $subscript . '[inputValue1]\', \'datetime\', \'\', 0,0);"><input type="hidden" value="' . htmlspecialchars($conf['inputValue1']) . '" name="' . $this->name
. $subscript . '[inputValue1]' . '">';
653 $this->extJSCODE
.= 'typo3form.fieldSet("' . $this->name
. $subscript . '[inputValue]", "datetime", "", 0,0);';
654 $this->extJSCODE
.= 'typo3form.fieldSet("' . $this->name
. $subscript . '[inputValue1]", "datetime", "", 0,0);';
656 $lineHTML .= '<input type="text" name="' . $this->name
. $subscript . '[inputValue]_hr' . '" value="' . strftime('%H:%M %e-%m-%Y', intval($conf['inputValue'])) . '" ' . $GLOBALS['TBE_TEMPLATE']->formWidth(10) . ' onChange="typo3form.fieldGet(\'' . $this->name
. $subscript . '[inputValue]\', \'datetime\', \'\', 0,0);"><input type="hidden" value="' . htmlspecialchars($conf['inputValue']) . '" name="' . $this->name
. $subscript . '[inputValue]' . '">';
657 $this->extJSCODE
.= 'typo3form.fieldSet("' . $this->name
. $subscript . '[inputValue]", "datetime", "", 0,0);';
663 $lineHTML .= $this->mkTypeSelect($this->name
. $subscript . '[type]', $fName);
664 $lineHTML .= $this->mkCompSelect($this->name
. $subscript . '[comparison]', $conf['comparison'], $conf['negate'] ?
1 : 0);
665 $lineHTML .= '<input type="checkbox" class="checkbox"' . ($conf['negate'] ?
' checked' : '') . ' name="' . $this->name
. $subscript . '[negate]' . '" onClick="submit();">';
666 if ($conf['comparison'] == 68 ||
$conf['comparison'] == 69 ||
$conf['comparison'] == 162 ||
$conf['comparison'] == 163) {
667 $lineHTML .= '<select name="' . $this->name
. $subscript . '[inputValue]' . '[]" style="vertical-align:top;" size="5" multiple>';
668 } elseif ($conf['comparison'] == 66 ||
$conf['comparison'] == 67) {
669 if (is_array($conf['inputValue'])) {
670 $conf['inputValue'] = implode(',', $conf['inputValue']);
672 $lineHTML .= '<input type="text" value="' . htmlspecialchars($conf['inputValue']) . '" name="' . $this->name
. $subscript . '[inputValue]' . '"' . $GLOBALS['TBE_TEMPLATE']->formWidth(10) . '>';
674 $lineHTML .= '<select name="' . $this->name
. $subscript . '[inputValue]' . '" style="vertical-align:top;" onChange="submit();">';
676 if ($conf['comparison'] != 66 && $conf['comparison'] != 67) {
677 $lineHTML .= $this->makeOptionList($fName, $conf, $this->table
);
678 $lineHTML .= '</select>';
682 $lineHTML .= $this->mkTypeSelect($this->name
. $subscript . '[type]', $fName);
683 $lineHTML .= $this->mkCompSelect($this->name
. $subscript . '[comparison]', $conf['comparison'], $conf['negate'] ?
1 : 0);
684 $lineHTML .= '<input type="checkbox" class="checkbox"' . ($conf['negate'] ?
' checked' : '') . ' name="' . $this->name
. $subscript . '[negate]' . '" onClick="submit();">';
685 if ($conf['comparison'] == 68 ||
$conf['comparison'] == 69) {
686 $lineHTML .= '<select name="' . $this->name
. $subscript . '[inputValue]' . '[]" style="vertical-align:top;" size="5" multiple>';
688 $lineHTML .= '<select name="' . $this->name
. $subscript . '[inputValue]' . '" style="vertical-align:top;" onChange="submit();">';
690 $lineHTML .= '<option value=""></option>' . $this->makeOptionList($fName, $conf, $this->table
);
691 $lineHTML .= '</select>';
692 if ($conf['comparison'] == 66 ||
$conf['comparison'] == 67) {
693 $lineHTML .= ' + <input type="text" value="' . htmlspecialchars($conf['inputValue1']) . '" name="' . $this->name
. $subscript . '[inputValue1]' . '"' . $GLOBALS['TBE_TEMPLATE']->formWidth(10) . '>';
697 $lineHTML .= $this->mkTypeSelect($this->name
. $subscript . '[type]', $fName);
698 $lineHTML .= $this->mkCompSelect($this->name
. $subscript . '[comparison]', $conf['comparison'], $conf['negate'] ?
1 : 0);
699 $lineHTML .= '<input type="checkbox" class="checkbox"' . ($conf['negate'] ?
' checked' : '') . ' name="' . $this->name
. $subscript . '[negate]' . '" onClick="submit();">';
700 $lineHTML .= '<input type="hidden" value="1" name="' . $this->name
. $subscript . '[inputValue]' . '"' . $GLOBALS['TBE_TEMPLATE']->formWidth(10) . '>';
703 $lineHTML .= $this->mkTypeSelect($this->name
. $subscript . '[type]', $fName);
704 $lineHTML .= $this->mkCompSelect($this->name
. $subscript . '[comparison]', $conf['comparison'], $conf['negate'] ?
1 : 0);
705 $lineHTML .= '<input type="checkbox" class="checkbox"' . ($conf['negate'] ?
' checked' : '') . ' name="' . $this->name
. $subscript . '[negate]' . '" onClick="submit();">';
706 if ($conf['comparison'] == 37 ||
$conf['comparison'] == 36) { // between:
707 $lineHTML .= '<input type="text" value="' . htmlspecialchars($conf['inputValue']) . '" name="' . $this->name
. $subscript . '[inputValue]' . '"' . $GLOBALS['TBE_TEMPLATE']->formWidth(5) . '>
708 <input type="text" value="' . htmlspecialchars($conf['inputValue1']) . '" name="' . $this->name
. $subscript . '[inputValue1]' . '"' . $GLOBALS['TBE_TEMPLATE']->formWidth(5) . '>'; // onChange='submit();'
710 $lineHTML .= '<input type="text" value="' . htmlspecialchars($conf['inputValue']) . '" name="' . $this->name
. $subscript . '[inputValue]' . '"' . $GLOBALS['TBE_TEMPLATE']->formWidth(10) . '>'; // onChange="submit();"
714 if ($fType != 'ignore') {
715 $lineHTML .= $this->updateIcon();
717 $lineHTML .= '<input type="image" border="0" ' . t3lib_iconWorks
::skinImg($GLOBALS['BACK_PATH'], 'gfx/garbage.gif', 'width="11" height="12"') . 'title="Remove condition" name="qG_del' . $subscript . '">';
719 $lineHTML .= '<input type="image" border="0" ' . t3lib_iconWorks
::skinImg($GLOBALS['BACK_PATH'], 'gfx/add.gif', 'width="12" height="12"') . ' title="Add condition" name="qG_ins' . $subscript . '">';
721 $lineHTML .= '<input type="image" border="0" ' . t3lib_iconWorks
::skinImg($GLOBALS['BACK_PATH'], 'gfx/pil2up.gif', 'width="12" height="7"') . ' title="Move up" name="qG_up' . $subscript . '">';
724 if ($c != 0 && $fType != 'newlevel') {
725 $lineHTML .= '<input type="image" border="0" ' . t3lib_iconWorks
::skinImg($GLOBALS['BACK_PATH'], 'gfx/pil2right.gif', 'height="12" width="7"') . ' title="New level" name="qG_nl' . $subscript . '">';
727 if ($fType == 'newlevel') {
728 $lineHTML .= '<input type="image" border="0" ' . t3lib_iconWorks
::skinImg($GLOBALS['BACK_PATH'], 'gfx/pil2left.gif', 'height="12" width="7"') . ' title="Collapse new level" name="qG_remnl' . $subscript . '">';
731 $codeArr[$arrCount]['html'] = $lineHTML;
732 $codeArr[$arrCount]['query'] = $this->getQuerySingle($conf, $c > 0 ?
0 : 1);
738 $this->queryConfig
= $queryConfig;
744 * [Describe function...]
746 * @param [type] $codeArr: ...
747 * @param [type] $l: ...
748 * @param [type] $table: ...
751 function makeOptionList($fN, $conf, $table) {
753 $fieldSetup = $this->fields
[$fN];
754 if ($fieldSetup['type'] == 'files') {
755 if ($conf['comparison'] == 66 ||
$conf['comparison'] == 67) {
756 $fileExtArray = explode(',', $fieldSetup['allowed']);
757 natcasesort($fileExtArray);
758 foreach ($fileExtArray as $fileExt) {
759 if (t3lib_div
::inList($conf['inputValue'], $fileExt)) {
760 $out .= '<option value="' . $fileExt . '" selected>.' . $fileExt . '</option>';
762 $out .= '<option value="' . $fileExt . '">.' . $fileExt . '</option>';
766 $d = dir(PATH_site
. $fieldSetup['uploadfolder']);
767 while (false !== ($entry = $d->read())) {
768 if ($entry == '.' ||
$entry == '..') {
771 $fileArray[] = $entry;
774 natcasesort($fileArray);
775 foreach ($fileArray as $fileName) {
776 if (t3lib_div
::inList($conf['inputValue'], $fileName)) {
777 $out .= '<option value="' . $fileName . '" selected>' . $fileName . '</option>';
779 $out .= '<option value="' . $fileName . '">' . $fileName . '</option>';
783 if ($fieldSetup['type'] == 'multiple') {
784 foreach ($fieldSetup['items'] as $key => $val) {
785 if (substr($val[0], 0, 4) == 'LLL:') {
786 $value = $GLOBALS['LANG']->sL($val[0]);
790 if (t3lib_div
::inList($conf['inputValue'], $val[1])) {
791 $out .= '<option value="' . $val[1] . '" selected>' . $value . '</option>';
793 $out .= '<option value="' . $val[1] . '">' . $value . '</option>';
797 if ($fieldSetup['type'] == 'binary') {
798 foreach ($fieldSetup['items'] as $key => $val) {
799 if (substr($val[0], 0, 4) == 'LLL:') {
800 $value = $GLOBALS['LANG']->sL($val[0]);
804 if (t3lib_div
::inList($conf['inputValue'], pow(2, $key))) {
805 $out .= '<option value="' . pow(2, $key) . '" selected>' . $value . '</option>';
807 $out .= '<option value="' . pow(2, $key) . '">' . $value . '</option>';
811 if ($fieldSetup['type'] == 'relation') {
812 if ($fieldSetup['items']) {
813 foreach ($fieldSetup['items'] as $key => $val) {
814 if (substr($val[0], 0, 4) == 'LLL:') {
815 $value = $GLOBALS['LANG']->sL($val[0]);
819 if (t3lib_div
::inList($conf['inputValue'], $val[1])) {
820 $out .= '<option value="' . $val[1] . '" selected>' . $value . '</option>';
822 $out .= '<option value="' . $val[1] . '">' . $value . '</option>';
827 if (stristr($fieldSetup['allowed'], ',')) {
828 $from_table_Arr = explode(',', $fieldSetup['allowed']);
830 if (!$fieldSetup['prepend_tname']) {
831 $checkres = $GLOBALS['TYPO3_DB']->exec_SELECTquery($fN, $table, t3lib_BEfunc
::deleteClause($table), $groupBy = '', $orderBy = '', $limit = '');
833 while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($checkres)) {
834 if (stristr($row[$fN], ',')) {
835 $checkContent = explode(',', $row[$fN]);
836 foreach ($checkContent as $singleValue) {
837 if (!stristr($singleValue, '_')) {
838 $dontPrefixFirstTable = 1;
842 $singleValue = $row[$fN];
843 if (strlen($singleValue) && !stristr($singleValue, '_')) {
844 $dontPrefixFirstTable = 1;
851 $from_table_Arr[0] = $fieldSetup['allowed'];
853 if ($fieldSetup['prepend_tname']) {
856 if ($fieldSetup['foreign_table']) {
857 $from_table_Arr[0] = $fieldSetup['foreign_table'];
860 $webMountPageTree = '';
861 while (list(, $from_table) = each($from_table_Arr)) {
862 if (($useTablePrefix && !$dontPrefixFirstTable && $counter != 1) ||
$counter == 1) {
863 $tablePrefix = $from_table . '_';
866 if (is_array($TCA[$from_table])) {
867 t3lib_div
::loadTCA($from_table);
868 $labelField = $TCA[$from_table]['ctrl']['label'];
869 $altLabelField = $TCA[$from_table]['ctrl']['label_alt'];
870 if ($TCA[$from_table]['columns'][$labelField]['config']['items']) {
871 foreach ($TCA[$from_table]['columns'][$labelField]['config']['items'] as $labelArray) {
872 if (substr($labelArray[0], 0, 4) == 'LLL:') {
873 $labelFieldSelect[$labelArray[1]] = $GLOBALS['LANG']->sL($labelArray[0]);
875 $labelFieldSelect[$labelArray[1]] = $labelArray[0];
878 $useSelectLabels = 1;
880 if ($TCA[$from_table]['columns'][$altLabelField]['config']['items']) {
881 foreach ($TCA[$from_table]['columns'][$altLabelField]['config']['items'] as $altLabelArray) {
882 if (substr($altLabelArray[0], 0, 4) == 'LLL:') {
883 $altLabelFieldSelect[$altLabelArray[1]] = $GLOBALS['LANG']->sL($altLabelArray[0]);
885 $altLabelFieldSelect[$altLabelArray[1]] = $altLabelArray[0];
888 $useAltSelectLabels = 1;
890 $altLabelFieldSelect = $altLabelField ?
',' . $altLabelField : '';
891 $select_fields = 'uid,' . $labelField . $altLabelFieldSelect;
892 if (!$GLOBALS['BE_USER']->isAdmin() && $GLOBALS['TYPO3_CONF_VARS']['BE']['lockBeUserToDBmounts']) {
893 $webMounts = $GLOBALS['BE_USER']->returnWebmounts();
894 $perms_clause = $GLOBALS['BE_USER']->getPagePermsClause(1);
895 foreach ($webMounts as $key => $val) {
896 if ($webMountPageTree) {
897 $webMountPageTreePrefix = ',';
899 $webMountPageTree .= $webMountPageTreePrefix . $this->getTreeList($val, 999, $begin = 0, $perms_clause);
901 if ($from_table == 'pages') {
902 $where_clause = 'uid IN (' . $webMountPageTree . ') ';
903 if (!$GLOBALS['SOBE']->MOD_SETTINGS
['show_deleted']) {
904 $where_clause .= t3lib_BEfunc
::deleteClause($from_table) . ' AND' . $perms_clause;
907 $where_clause = 'pid IN (' . $webMountPageTree . ') ';
908 if (!$GLOBALS['SOBE']->MOD_SETTINGS
['show_deleted']) {
909 $where_clause .= t3lib_BEfunc
::deleteClause($from_table);
913 $where_clause = 'uid';
914 if (!$GLOBALS['SOBE']->MOD_SETTINGS
['show_deleted']) {
915 $where_clause .= t3lib_BEfunc
::deleteClause($from_table);
919 if (!$this->tableArray
[$from_table]) {
920 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery($select_fields, $from_table, $where_clause, $groupBy = '', $orderBy, $limit = '');
923 while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
924 $this->tableArray
[$from_table][] = $row;
927 foreach ($this->tableArray
[$from_table] as $key => $val) {
928 if ($useSelectLabels) {
929 $outArray[$tablePrefix . $val['uid']] = htmlspecialchars($labelFieldSelect[$val[$labelField]]);
930 } elseif ($val[$labelField]) {
931 $outArray[$tablePrefix . $val['uid']] = htmlspecialchars($val[$labelField]);
932 } elseif ($useAltSelectLabels) {
933 $outArray[$tablePrefix . $val['uid']] = htmlspecialchars($altLabelFieldSelect[$val[$altLabelField]]);
935 $outArray[$tablePrefix . $val['uid']] = htmlspecialchars($val[$altLabelField]);
938 if ($GLOBALS['SOBE']->MOD_SETTINGS
['options_sortlabel'] && is_array($outArray)) {
939 natcasesort($outArray);
943 foreach ($outArray as $key2 => $val2) {
944 if (t3lib_div
::inList($conf['inputValue'], $key2)) {
945 $out .= '<option value="' . $key2 . '" selected>[' . $key2 . '] ' . $val2 . '</option>';
947 $out .= '<option value="' . $key2 . '">[' . $key2 . '] ' . $val2 . '</option>';
956 * [Describe function...]
958 * @param [type] $codeArr: ...
959 * @param [type] $l: ...
962 function printCodeArray($codeArr, $l = 0) {
965 $indent = '<td style="vertical-align:top;"><img height="1" width="50"></td>';
968 $bgColor = t3lib_div
::modifyHTMLColor($GLOBALS['TBE_TEMPLATE']->bgColor2
, $lf, $lf, $lf);
969 foreach ($codeArr as $k => $v) {
970 $line .= '<tr>' . $indent . '<td bgcolor="' . $bgColor . '"' . $this->noWrap
. '>' . $v['html'] . '</td></tr>';
971 if ($this->enableQueryParts
) {
972 $line .= '<tr>' . $indent . '<td>' . $this->formatQ($v['query']) . '</td></tr>';
974 if (is_array($v['sub'])) {
975 $line .= '<tr>' . $indent . '<td' . $this->noWrap
. '>' . $this->printCodeArray($v['sub'], $l +
1) . '</td></tr>';
978 $out = '<table border="0" cellpadding="0" cellspacing="1">' . $line . '</table>';
983 * [Describe function...]
985 * @param [type] $str: ...
988 function formatQ($str) {
989 return '<font size="1" face="verdana" color="maroon"><i>' . htmlspecialchars($str) . '</i></font>';
993 * [Describe function...]
995 * @param [type] $name: ...
996 * @param [type] $op: ...
997 * @param [type] $draw: ...
998 * @param [type] $submit: ...
1001 function mkOperatorSelect($name, $op, $draw, $submit) {
1003 $out = '<select name="' . $name . '[operator]"' . ($submit ?
' onChange="submit();"' : '') . '>'; //
1004 $out .= '<option value="AND"' . (!$op ||
$op == "AND" ?
' selected' : '') . '>' . $this->lang
["AND"] . '</option>';
1005 $out .= '<option value="OR"' . ($op == 'OR' ?
' selected' : '') . '>' . $this->lang
['OR'] . '</option>';
1006 $out .= '</select>';
1008 $out = '<input type="hidden" value="' . $op . '" name="' . $name . '[operator]">';
1009 $out .= '<img src="clear.gif" height="1" width="47">';
1016 * [Describe function...]
1018 * @param [type] $name: ...
1019 * @param [type] $fieldName: ...
1020 * @param [type] $prepend: ...
1021 * @return [type] ...
1023 function mkTypeSelect($name, $fieldName, $prepend = 'FIELD_') {
1024 $out = '<select name="' . $name . '" onChange="submit();">';
1025 $out .= '<option value=""></option>';
1026 foreach ($this->fields
as $key => $value) {
1027 if (!$value['exclude'] ||
$GLOBALS['BE_USER']->check('non_exclude_fields', $this->table
. ':' . $key)) {
1028 $label = $this->fields
[$key]['label'];
1029 $label_alt = $this->fields
[$key]['label_alt'];
1030 $out .= '<option value="' . $prepend . $key . '"' . ($key == $fieldName ?
' selected' : '') . '>' . $label . '</option>';
1033 $out .= '</select>';
1038 * [Describe function...]
1040 * @param [type] $fieldName: ...
1041 * @return [type] ...
1043 function verifyType($fieldName) {
1045 foreach ($this->fields
as $key => $value) {
1049 if ($key == $fieldName) {
1057 * [Describe function...]
1059 * @param [type] $comparison: ...
1060 * @param [type] $neg: ...
1061 * @return [type] ...
1063 function verifyComparison($comparison, $neg) {
1064 $compOffSet = $comparison >> 5;
1066 for ($i = 32 * $compOffSet +
$neg; $i < 32 * ($compOffSet +
1); $i +
= 2) {
1070 if (($i >> 1) == ($comparison >> 1)) {
1078 * [Describe function...]
1080 * @param [type] $name: ...
1081 * @param [type] $fieldName: ...
1082 * @return [type] ...
1084 function mkFieldToInputSelect($name, $fieldName) {
1085 $out = '<input type="Text" value="' . htmlspecialchars($fieldName) . '" name="' . $name . '"' . $GLOBALS['TBE_TEMPLATE']->formWidth() . '>' . $this->updateIcon();
1086 $out .= '<a href="#" onClick="document.forms[0][\'' . $name . '\'].value=\'\';return false;">' . t3lib_iconWorks
::getSpriteIcon('actions-edit-delete', array('title' => 'Clear list')) . '</a>';
1087 $out .= '<BR><select name="_fieldListDummy" size="5" onChange="document.forms[0][\'' . $name . '\'].value+=\',\'+this.value">';
1088 foreach ($this->fields
as $key => $value) {
1089 if (!$value['exclude'] ||
$GLOBALS['BE_USER']->check('non_exclude_fields', $this->table
. ':' . $key)) {
1090 $label = $this->fields
[$key]['label'];
1091 $label_alt = $this->fields
[$key]['label_alt'];
1092 $out .= '<option value="' . $key . '"' . ($key == $fieldName ?
' selected' : '') . '>' . $label . '</option>';
1095 $out .= '</select>';
1100 * [Describe function...]
1102 * @param [type] $name: ...
1103 * @param [type] $cur: ...
1104 * @return [type] ...
1106 function mkTableSelect($name, $cur) {
1108 $out = '<select name="' . $name . '" onChange="submit();">';
1109 $out .= '<option value=""></option>';
1110 foreach ($TCA as $tN => $value) {
1111 if ($GLOBALS['BE_USER']->check('tables_select', $tN)) {
1112 $out .= '<option value="' . $tN . '"' . ($tN == $cur ?
' selected' : '') . '>' . $GLOBALS['LANG']->sl($TCA[$tN]['ctrl']['title']) . '</option>';
1115 $out .= '</select>';
1120 * [Describe function...]
1122 * @param [type] $name: ...
1123 * @param [type] $comparison: ...
1124 * @param [type] $neg: ...
1125 * @return [type] ...
1127 function mkCompSelect($name, $comparison, $neg) {
1128 $compOffSet = $comparison >> 5;
1129 $out = '<select name="' . $name . '" onChange="submit();">';
1130 for ($i = 32 * $compOffSet +
$neg; $i < 32 * ($compOffSet +
1); $i +
= 2) {
1131 if ($this->lang
['comparison'][$i . '_']) {
1132 $out .= '<option value="' . $i . '"' . (($i >> 1) == ($comparison >> 1) ?
' selected' : '') . '>' . $this->lang
['comparison'][$i . '_'] . '</option>';
1135 $out .= '</select>';
1140 * [Describe function...]
1142 * @param [type] $arr: ...
1143 * @return [type] ...
1145 function getSubscript($arr) {
1146 while (is_array($arr)) {
1148 list($key,) = each($arr);
1156 * [Describe function...]
1158 * @return [type] ...
1160 function initUserDef() {
1165 * [Describe function...]
1167 * @return [type] ...
1169 function userDef() {
1173 * [Describe function...]
1175 * @param [type] $queryConfig: ...
1176 * @return [type] ...
1178 function userDefCleanUp($queryConfig) {
1179 return $queryConfig;
1183 * [Describe function...]
1185 * @param [type] $queryConfig: ...
1186 * @param [type] $pad: ...
1187 * @return [type] ...
1189 function getQuery($queryConfig, $pad = '') {
1191 // Since we don't traverse the array using numeric keys in the upcoming whileloop make sure it's fresh and clean
1192 ksort($queryConfig);
1194 foreach ($queryConfig as $key => $conf) {
1195 switch ($conf['type']) {
1197 $qs .= LF
. $pad . trim($conf['operator']) . ' (' . $this->getQuery($queryConfig[$key]['nl'], $pad . ' ') . LF
. $pad . ')';
1200 $qs .= LF
. $pad . getUserDefQuery($conf, $first);
1203 $qs .= LF
. $pad . $this->getQuerySingle($conf, $first);
1212 * [Describe function...]
1214 * @param [type] $conf: ...
1215 * @param [type] $first: ...
1216 * @return [type] ...
1218 function getQuerySingle($conf, $first) {
1220 $prefix = $this->enablePrefix ?
$this->table
. '.' : '';
1222 // Is it OK to insert the AND operator if none is set?
1223 $qs .= trim(($conf['operator'] ?
$conf['operator'] : 'AND')) . ' ';
1225 $qsTmp = str_replace('#FIELD#', $prefix . trim(substr($conf['type'], 6)), $this->compSQL
[$conf['comparison']]);
1226 $inputVal = $this->cleanInputVal($conf);
1227 if ($conf['comparison'] == 68 ||
$conf['comparison'] == 69) {
1228 $inputVal = explode(',', $inputVal);
1229 foreach ($inputVal as $key => $fileName) {
1230 $inputVal[$key] = "'" . $fileName . "'";
1232 $inputVal = implode(',', $inputVal);
1233 $qsTmp = str_replace('#VALUE#', $inputVal, $qsTmp);
1234 } elseif ($conf['comparison'] == 162 ||
$conf['comparison'] == 163) {
1235 $inputValArray = explode(',', $inputVal);
1237 foreach ($inputValArray as $key => $fileName) {
1238 $inputVal +
= intval($fileName);
1240 $qsTmp = str_replace('#VALUE#', $inputVal, $qsTmp);
1242 $qsTmp = str_replace('#VALUE#', $GLOBALS['TYPO3_DB']->quoteStr($inputVal, $this->table
), $qsTmp);
1244 if ($conf['comparison'] == 37 ||
$conf['comparison'] == 36 ||
$conf['comparison'] == 66 ||
$conf['comparison'] == 67 ||
$conf['comparison'] == 100 ||
$conf['comparison'] == 101) { // between:
1245 $inputVal = $this->cleanInputVal($conf, '1');
1246 $qsTmp = str_replace('#VALUE1#', $GLOBALS['TYPO3_DB']->quoteStr($inputVal, $this->table
), $qsTmp);
1248 $qs .= trim($qsTmp);
1253 * [Describe function...]
1255 * @param [type] $conf: ...
1256 * @param [type] $suffix: ...
1257 * @return [type] ...
1259 function cleanInputVal($conf, $suffix = '') {
1260 if (($conf['comparison'] >> 5 == 0) ||
($conf['comparison'] == 32 ||
$conf['comparison'] == 33 ||
$conf['comparison'] == 64 ||
$conf['comparison'] == 65 ||
$conf['comparison'] == 66 ||
$conf['comparison'] == 67 ||
$conf['comparison'] == 96 ||
$conf['comparison'] == 97)) {
1261 $inputVal = $conf['inputValue' . $suffix];
1262 } elseif ($conf['comparison'] == 39 ||
$conf['comparison'] == 38) { // in list:
1263 $inputVal = implode(',', t3lib_div
::intExplode(',', $conf['inputValue' . $suffix]));
1264 } elseif ($conf['comparison'] == 68 ||
$conf['comparison'] == 69 ||
$conf['comparison'] == 162 ||
$conf['comparison'] == 163) { // in list:
1265 if (is_array($conf['inputValue' . $suffix])) {
1266 $inputVal = implode(',', $conf['inputValue' . $suffix]);
1267 } elseif ($conf['inputValue' . $suffix]) {
1268 $inputVal = $conf['inputValue' . $suffix];
1273 $inputVal = doubleval($conf['inputValue' . $suffix]);
1279 * [Describe function...]
1281 * @param [type] $qcArr: ...
1282 * @return [type] ...
1284 function getUserDefQuery($qcArr) {
1288 * [Describe function...]
1290 * @return [type] ...
1292 function updateIcon() {
1293 return '<input type="image" border="0" ' . t3lib_iconWorks
::skinImg($GLOBALS['BACK_PATH'], 'gfx/refresh_n.gif', 'width="14" height="14"') . ' title="Update" name="just_update">';
1297 * [Describe function...]
1299 * @return [type] ...
1301 function getLabelCol() {
1303 return $TCA[$this->table
]['ctrl']['label'];
1307 * [Describe function...]
1309 * @param [type] $modSettings: ...
1310 * @param [type] $enableList: ...
1311 * @return [type] ...
1313 function makeSelectorTable($modSettings, $enableList = 'table,fields,query,group,order,limit') {
1314 $enableArr = explode(',', $enableList);
1316 $TDparams = ' class="bgColor5" nowrap';
1318 if (in_array('table', $enableArr) && !$GLOBALS['BE_USER']->userTS
['mod.']['dbint.']['disableSelectATable']) {
1321 <td' . $TDparams . '><strong>Select a table:</strong></td>
1322 <td' . $TDparams . '>' . $this->mkTableSelect('SET[queryTable]', $this->table
) . '</td>
1328 $this->setAndCleanUpExternalLists('queryFields', $modSettings['queryFields'], 'uid,' . $this->getLabelCol());
1329 $this->setAndCleanUpExternalLists('queryGroup', $modSettings['queryGroup']);
1330 $this->setAndCleanUpExternalLists('queryOrder', $modSettings['queryOrder'] . ',' . $modSettings['queryOrder2']);
1333 $this->extFieldLists
['queryLimit'] = $modSettings['queryLimit'];
1334 if (!$this->extFieldLists
['queryLimit']) {
1335 $this->extFieldLists
['queryLimit'] = 100;
1337 $parts = t3lib_div
::intExplode(',', $this->extFieldLists
['queryLimit']);
1339 $this->limitBegin
= $parts[0];
1340 $this->limitLength
= $parts[1];
1342 $this->limitLength
= $this->extFieldLists
['queryLimit'];
1344 $this->extFieldLists
['queryLimit'] = implode(',', array_slice($parts, 0, 2));
1346 // Insert Descending parts
1347 if ($this->extFieldLists
['queryOrder']) {
1348 $descParts = explode(',', $modSettings['queryOrderDesc'] . ',' . $modSettings['queryOrder2Desc']);
1349 $orderParts = explode(',', $this->extFieldLists
['queryOrder']);
1351 foreach ($orderParts as $kk => $vv) {
1352 $reList[] = $vv . ($descParts[$kk] ?
' DESC' : '');
1354 $this->extFieldLists
['queryOrder_SQL'] = implode(',', $reList);
1358 $this->procesData($modSettings['queryConfig'] ?
unserialize($modSettings['queryConfig']) : '');
1359 // debug($this->queryConfig);
1360 $this->queryConfig
= $this->cleanUpQueryConfig($this->queryConfig
);
1361 // debug($this->queryConfig);
1362 $this->enableQueryParts
= $modSettings['search_query_smallparts'];
1364 $codeArr = $this->getFormElements();
1365 $queryCode = $this->printCodeArray($codeArr);
1367 if (in_array('fields', $enableArr) && !$GLOBALS['BE_USER']->userTS
['mod.']['dbint.']['disableSelectFields']) {
1370 <td' . $TDparams . '><strong>Select fields:</strong></td>
1371 <td' . $TDparams . '>' . $this->mkFieldToInputSelect('SET[queryFields]', $this->extFieldLists
['queryFields']) . '</td>
1374 if (in_array('query', $enableArr) && !$GLOBALS['BE_USER']->userTS
['mod.']['dbint.']['disableMakeQuery']) {
1376 <td colspan="2"' . $TDparams . '><strong>Make Query:</strong></td>
1379 <td colspan="2">' . $queryCode . '</td>
1383 if (in_array('group', $enableArr) && !$GLOBALS['BE_USER']->userTS
['mod.']['dbint.']['disableGroupBy']) {
1385 <td' . $TDparams . '><strong>Group By:</strong></td>
1386 <td' . $TDparams . '>' . $this->mkTypeSelect('SET[queryGroup]', $this->extFieldLists
['queryGroup'], '') . '</td>
1389 if (in_array('order', $enableArr) && !$GLOBALS['BE_USER']->userTS
['mod.']['dbint.']['disableOrderBy']) {
1390 $orderByArr = explode(',', $this->extFieldLists
['queryOrder']);
1391 // debug($orderByArr);
1393 $orderBy .= $this->mkTypeSelect('SET[queryOrder]', $orderByArr[0], '') .
1394 ' ' . t3lib_BEfunc
::getFuncCheck($GLOBALS['SOBE']->id
, 'SET[queryOrderDesc]', $modSettings['queryOrderDesc'], '', '', 'id="checkQueryOrderDesc"') . ' <label for="checkQueryOrderDesc">Descending</label>';
1395 if ($orderByArr[0]) {
1396 $orderBy .= '<BR>' . $this->mkTypeSelect('SET[queryOrder2]', $orderByArr[1], '') .
1397 ' ' . t3lib_BEfunc
::getFuncCheck($GLOBALS['SOBE']->id
, 'SET[queryOrder2Desc]', $modSettings['queryOrder2Desc'], '', '', 'id="checkQueryOrder2Desc"') . ' <label for="checkQueryOrder2Desc">Descending</label>';
1400 <td' . $TDparams . '><strong>Order By:</strong></td>
1401 <td' . $TDparams . '>' . $orderBy . '</td>
1404 if (in_array('limit', $enableArr) && !$GLOBALS['BE_USER']->userTS
['mod.']['dbint.']['disableLimit']) {
1405 $limit = '<input type="Text" value="' . htmlspecialchars($this->extFieldLists
['queryLimit']) . '" name="SET[queryLimit]" id="queryLimit"' . $GLOBALS['TBE_TEMPLATE']->formWidth(10) . '>' . $this->updateIcon();
1407 $prevLimit = ($this->limitBegin
- $this->limitLength
) < 0 ?
0 :
1408 $this->limitBegin
- $this->limitLength
;
1409 if ($this->limitBegin
) {
1410 $prevButton = '<input type="button" value="previous ' . $this->limitLength
. '" onclick=\'document.getElementById("queryLimit").value="' . $prevLimit . ',' . $this->limitLength
. '";document.forms[0].submit();\'>';
1412 if (!$this->limitLength
) {
1413 $this->limitLength
= 100;
1415 $nextLimit = $this->limitBegin +
$this->limitLength
;
1416 if ($nextLimit < 0) {
1420 $nextButton = '<input type="button" value="next ' . $this->limitLength
. '" onclick=\'document.getElementById("queryLimit").value="' . $nextLimit . ',' . $this->limitLength
. '";document.forms[0].submit();\'>';
1423 $numberButtons = '<input type="button" value="10" onclick=\'document.getElementById("queryLimit").value="10";document.forms[0].submit();\'>';
1424 $numberButtons .= '<input type="button" value="20" onclick=\'document.getElementById("queryLimit").value="20";document.forms[0].submit();\'>';
1425 $numberButtons .= '<input type="button" value="50" onclick=\'document.getElementById("queryLimit").value="50";document.forms[0].submit();\'>';
1426 $numberButtons .= '<input type="button" value="100" onclick=\'document.getElementById("queryLimit").value="100";document.forms[0].submit();\'>';
1428 <td' . $TDparams . '><strong>Limit:</strong></td>
1429 <td' . $TDparams . '>' . $limit . $prevButton . $nextButton . ' ' . $numberButtons . '</td>
1434 $out = '<table border="0" cellpadding="3" cellspacing="1" class="qg-make-query">' . $out . '</table>';
1435 $out .= $this->JSbottom($this->formName
);
1440 * [Describe function...]
1442 * @param [type] $qString: ...
1443 * @param [type] $depth: ...
1444 * @param [type] $begin: ...
1445 * @param [type] $perms_clause: ...
1446 * @return [type] ...
1448 function getTreeList($id, $depth, $begin = 0, $perms_clause) {
1449 $depth = intval($depth);
1450 $begin = intval($begin);
1457 if ($id && $depth > 0) {
1458 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery(
1461 'pid=' . $id . ' ' . t3lib_BEfunc
::deleteClause('pages') . ' AND ' . $perms_clause
1463 while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
1465 $theList .= ',' . $row['uid'];
1468 $theList .= $this->getTreeList($row['uid'], $depth - 1, $begin - 1, $perms_clause);
1476 * [Describe function...]
1478 * @param [type] $qString: ...
1479 * @param [type] $fN: ...
1480 * @return [type] ...
1482 function getSelectQuery($qString = '', $fN = '') {
1484 $qString = $this->getQuery($this->queryConfig
);
1486 $qString = '(' . $qString . ')';
1487 if (!$GLOBALS['BE_USER']->isAdmin() && $GLOBALS['TYPO3_CONF_VARS']['BE']['lockBeUserToDBmounts']) {
1488 $webMounts = $GLOBALS['BE_USER']->returnWebmounts();
1489 $perms_clause = $GLOBALS['BE_USER']->getPagePermsClause(1);
1490 $webMountPageTree = '';
1491 foreach ($webMounts as $key => $val) {
1492 if ($webMountPageTree) {
1493 $webMountPageTreePrefix = ',';
1495 $webMountPageTree .= $webMountPageTreePrefix . $this->getTreeList($val, 999, $begin = 0, $perms_clause);
1497 if ($this->table
== 'pages') {
1498 $qString .= ' AND uid IN (' . $webMountPageTree . ')';
1500 $qString .= ' AND pid IN (' . $webMountPageTree . ')';
1503 $fieldlist = $this->extFieldLists
['queryFields'] .
1505 ($GLOBALS['TCA'][$this->table
]['ctrl']['delete'] ?
',' . $GLOBALS['TCA'][$this->table
]['ctrl']['delete'] : '');
1506 if (!$GLOBALS['SOBE']->MOD_SETTINGS
['show_deleted']) {
1507 $qString .= t3lib_BEfunc
::deleteClause($this->table
);
1509 $query = $GLOBALS['TYPO3_DB']->SELECTquery(
1513 trim($this->extFieldLists
['queryGroup']),
1514 $this->extFieldLists
['queryOrder'] ?
trim($this->extFieldLists
['queryOrder_SQL']) : '',
1515 $this->extFieldLists
['queryLimit']
1521 * [Describe function...]
1523 * @param [type] $formname: ...
1524 * @return [type] ...
1526 function JSbottom($formname) {
1528 if ($this->extJSCODE
) {
1530 <script language="javascript" type="text/javascript" src="' . $GLOBALS['BACK_PATH'] . '../t3lib/jsfunc.evalfield.js"></script>
1531 <script language="javascript" type="text/javascript" src="' . $GLOBALS['BACK_PATH'] . 'jsfunc.tbe_editor.js"></script>
1532 <script language="javascript" type="text/javascript">
1533 TBE_EDITOR.formname = "' . $formname . '";
1534 TBE_EDITOR.formnameUENC = "' . rawurlencode($formname) . '";
1535 TBE_EDITOR.backend_interface = "' . $GLOBALS['BE_USER']->uc
['interfaceSetup'] . '";
1536 ' . $this->extJSCODE
. '
1543 * Sets the current name of the input form.
1545 * @param string $formName: The name of the form.
1548 public function setFormName($formName) {
1549 $this->formName
= trim($formName);
1554 if (defined('TYPO3_MODE') && isset($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE
]['XCLASS']['t3lib/class.t3lib_querygenerator.php'])) {
1555 include_once($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE
]['XCLASS']['t3lib/class.t3lib_querygenerator.php']);