2 namespace TYPO3\CMS\Core\Database
;
4 /***************************************************************
7 * (c) 2001-2011 Christian Jul Jensen (christian@typo3.com)
10 * This script is part of the TYPO3 project. The TYPO3 project is
11 * free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
16 * The GNU General Public License can be found at
17 * http://www.gnu.org/copyleft/gpl.html.
18 * A copy is found in the textfile GPL.txt and important notices to the license
19 * from the author is found in LICENSE.txt distributed with these scripts.
22 * This script is distributed in the hope that it will be useful,
23 * but WITHOUT ANY WARRANTY; without even the implied warranty of
24 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
25 * GNU General Public License for more details.
27 * This copyright notice MUST APPEAR in all copies of the script!
28 ***************************************************************/
30 * 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 for generating front end for building queries
39 * @author Christian Jul Jensen <christian@typo3.com>
40 * @author Kasper Skårhøj <kasperYYYY@typo3.com>
42 class QueryGenerator
{
45 * @todo Define visibility
50 'comparison' => array(
51 // Type = text offset = 0
53 '1_' => 'does not contain',
54 '2_' => 'starts with',
55 '3_' => 'does not start with',
57 '5_' => 'does not end with',
59 '7_' => 'does not equal',
60 // Type = number , offset = 32
62 '33_' => 'does not equal',
63 '34_' => 'is greater than',
64 '35_' => 'is less than',
65 '36_' => 'is between',
66 '37_' => 'is not between',
67 '38_' => 'is in list',
68 '39_' => 'is not in list',
69 '40_' => 'binary AND equals',
70 '41_' => 'binary AND does not equal',
71 '42_' => 'binary OR equals',
72 '43_' => 'binary OR does not equal',
73 // Type = multiple, relation, files , offset = 64
75 '65_' => 'does not equal',
77 '67_' => 'does not contain',
78 '68_' => 'is in list',
79 '69_' => 'is not in list',
80 '70_' => 'binary AND equals',
81 '71_' => 'binary AND does not equal',
82 '72_' => 'binary OR equals',
83 '73_' => 'binary OR does not equal',
84 // Type = date,time offset = 96
86 '97_' => 'does not equal',
87 '98_' => 'is greater than',
88 '99_' => 'is less than',
89 '100_' => 'is between',
90 '101_' => 'is not between',
91 '102_' => 'binary AND equals',
92 '103_' => 'binary AND does not equal',
93 '104_' => 'binary OR equals',
94 '105_' => 'binary OR does not equal',
95 // Type = boolean, offset = 128
98 // Type = binary , offset = 160
100 '161_' => 'does not equal',
101 '162_' => 'contains',
102 '163_' => 'does not contain'
107 * @todo Define visibility
109 public $compSQL = array(
110 // Type = text offset = 0
111 '0' => '#FIELD# LIKE \'%#VALUE#%\'',
112 '1' => '#FIELD# NOT LIKE \'%#VALUE#%\'',
113 '2' => '#FIELD# LIKE \'#VALUE#%\'',
114 '3' => '#FIELD# NOT LIKE \'#VALUE#%\'',
115 '4' => '#FIELD# LIKE \'%#VALUE#\'',
116 '5' => '#FIELD# NOT LIKE \'%#VALUE#\'',
117 '6' => '#FIELD# = \'#VALUE#\'',
118 '7' => '#FIELD# != \'#VALUE#\'',
119 // Type = number, offset = 32
120 '32' => '#FIELD# = \'#VALUE#\'',
121 '33' => '#FIELD# != \'#VALUE#\'',
122 '34' => '#FIELD# > #VALUE#',
123 '35' => '#FIELD# < #VALUE#',
124 '36' => '#FIELD# >= #VALUE# AND #FIELD# <= #VALUE1#',
125 '37' => 'NOT (#FIELD# >= #VALUE# AND #FIELD# <= #VALUE1#)',
126 '38' => '#FIELD# IN (#VALUE#)',
127 '39' => '#FIELD# NOT IN (#VALUE#)',
128 '40' => '(#FIELD# & #VALUE#)=#VALUE#',
129 '41' => '(#FIELD# & #VALUE#)!=#VALUE#',
130 '42' => '(#FIELD# | #VALUE#)=#VALUE#',
131 '43' => '(#FIELD# | #VALUE#)!=#VALUE#',
132 // Type = multiple, relation, files , offset = 64
133 '64' => '#FIELD# = \'#VALUE#\'',
134 '65' => '#FIELD# != \'#VALUE#\'',
135 '66' => '#FIELD# LIKE \'%#VALUE#%\' AND #FIELD# LIKE \'%#VALUE1#%\'',
136 '67' => '(#FIELD# NOT LIKE \'%#VALUE#%\' OR #FIELD# NOT LIKE \'%#VALUE1#%\')',
137 '68' => '#FIELD# IN (#VALUE#)',
138 '69' => '#FIELD# NOT IN (#VALUE#)',
139 '70' => '(#FIELD# & #VALUE#)=#VALUE#',
140 '71' => '(#FIELD# & #VALUE#)!=#VALUE#',
141 '72' => '(#FIELD# | #VALUE#)=#VALUE#',
142 '73' => '(#FIELD# | #VALUE#)!=#VALUE#',
143 // Type = date, offset = 32
144 '96' => '#FIELD# = \'#VALUE#\'',
145 '97' => '#FIELD# != \'#VALUE#\'',
146 '98' => '#FIELD# > #VALUE#',
147 '99' => '#FIELD# < #VALUE#',
148 '100' => '#FIELD# >= #VALUE# AND #FIELD# <= #VALUE1#',
149 '101' => 'NOT (#FIELD# >= #VALUE# AND #FIELD# <= #VALUE1#)',
150 '102' => '(#FIELD# & #VALUE#)=#VALUE#',
151 '103' => '(#FIELD# & #VALUE#)!=#VALUE#',
152 '104' => '(#FIELD# | #VALUE#)=#VALUE#',
153 '105' => '(#FIELD# | #VALUE#)!=#VALUE#',
154 // Type = boolean, offset = 128
155 '128' => '#FIELD# = \'1\'',
156 '129' => '#FIELD# != \'1\'',
157 // Type = binary = 160
158 '160' => '#FIELD# = \'#VALUE#\'',
159 '161' => '#FIELD# != \'#VALUE#\'',
160 '162' => '(#FIELD# & #VALUE#)=#VALUE#',
161 '163' => '(#FIELD# & #VALUE#)=0'
165 * @todo Define visibility
167 public $comp_offsets = array(
180 * @todo Define visibility
182 public $noWrap = ' nowrap';
184 // Form data name prefix
186 * @todo Define visibility
190 // Table for the query
192 * @todo Define visibility
198 * @todo Define visibility
202 // Array of the fields possible
204 * @todo Define visibility
206 public $fields = array();
209 * @todo Define visibility
211 public $extFieldLists = array();
215 * @todo Define visibility
217 public $queryConfig = array();
220 * @todo Define visibility
222 public $enablePrefix = 0;
225 * @todo Define visibility
227 public $enableQueryParts = 0;
230 * @todo Define visibility
232 public $extJSCODE = '';
234 protected $formName = '';
237 * Make a list of fields for current table
239 * @return string Separated list of fields
240 * @todo Define visibility
242 public function makeFieldList() {
243 $fieldListArr = array();
244 if (is_array($GLOBALS['TCA'][$this->table
])) {
245 \TYPO3\CMS\Core\Utility\GeneralUtility
::loadTCA($this->table
);
246 foreach ($GLOBALS['TCA'][$this->table
]['columns'] as $fN => $value) {
247 $fieldListArr[] = $fN;
249 $fieldListArr[] = 'uid';
250 $fieldListArr[] = 'pid';
251 $fieldListArr[] = 'deleted';
252 if ($GLOBALS['TCA'][$this->table
]['ctrl']['tstamp']) {
253 $fieldListArr[] = $GLOBALS['TCA'][$this->table
]['ctrl']['tstamp'];
255 if ($GLOBALS['TCA'][$this->table
]['ctrl']['crdate']) {
256 $fieldListArr[] = $GLOBALS['TCA'][$this->table
]['ctrl']['crdate'];
258 if ($GLOBALS['TCA'][$this->table
]['ctrl']['cruser_id']) {
259 $fieldListArr[] = $GLOBALS['TCA'][$this->table
]['ctrl']['cruser_id'];
261 if ($GLOBALS['TCA'][$this->table
]['ctrl']['sortby']) {
262 $fieldListArr[] = $GLOBALS['TCA'][$this->table
]['ctrl']['sortby'];
265 return implode(',', $fieldListArr);
269 * [Describe function...]
271 * @param [type] $name: ...
272 * @param [type] $table: ...
273 * @param [type] $fieldList: ...
275 * @todo Define visibility
277 public function init($name, $table, $fieldList = '') {
278 // Analysing the fields in the table.
279 if (is_array($GLOBALS['TCA'][$table])) {
280 \TYPO3\CMS\Core\Utility\GeneralUtility
::loadTCA($table);
282 $this->table
= $table;
283 $this->fieldList
= $fieldList ?
$fieldList : $this->makeFieldList();
284 $fieldArr = \TYPO3\CMS\Core\Utility\GeneralUtility
::trimExplode(',', $this->fieldList
, 1);
285 foreach ($fieldArr as $fN) {
286 $fC = $GLOBALS['TCA'][$this->table
]['columns'][$fN];
287 $this->fields
[$fN] = $fC['config'];
288 $this->fields
[$fN]['exclude'] = $fC['exclude'];
289 if (is_array($fC) && $fC['label']) {
290 $this->fields
[$fN]['label'] = rtrim(trim($GLOBALS['LANG']->sL($fC['label'])), ':');
291 switch ($this->fields
[$fN]['type']) {
293 if (preg_match('/int|year/i', $this->fields
[$fN]['eval'])) {
294 $this->fields
[$fN]['type'] = 'number';
295 } elseif (preg_match('/time/i', $this->fields
[$fN]['eval'])) {
296 $this->fields
[$fN]['type'] = 'time';
297 } elseif (preg_match('/date/i', $this->fields
[$fN]['eval'])) {
298 $this->fields
[$fN]['type'] = 'date';
300 $this->fields
[$fN]['type'] = 'text';
304 if (!$this->fields
[$fN]['items']) {
305 $this->fields
[$fN]['type'] = 'boolean';
307 $this->fields
[$fN]['type'] = 'binary';
311 $this->fields
[$fN]['type'] = 'multiple';
314 $this->fields
[$fN]['type'] = 'multiple';
315 if ($this->fields
[$fN]['foreign_table']) {
316 $this->fields
[$fN]['type'] = 'relation';
318 if ($this->fields
[$fN]['special']) {
319 $this->fields
[$fN]['type'] = 'text';
323 $this->fields
[$fN]['type'] = 'files';
324 if ($this->fields
[$fN]['internal_type'] == 'db') {
325 $this->fields
[$fN]['type'] = 'relation';
339 $this->fields
[$fN]['type'] = 'text';
343 $this->fields
[$fN]['label'] = '[FIELD: ' . $fN . ']';
346 $this->fields
[$fN]['type'] = 'relation';
347 $this->fields
[$fN]['allowed'] = 'pages';
350 $this->fields
[$fN]['type'] = 'relation';
351 $this->fields
[$fN]['allowed'] = 'be_users';
356 $this->fields
[$fN]['type'] = 'time';
359 $this->fields
[$fN]['type'] = 'boolean';
362 $this->fields
[$fN]['type'] = 'number';
369 $this->queryConfig = array(
372 'type' => 'FIELD_spaceBefore',
376 'type' => 'FIELD_records',
378 'inputValue' => 'foo foo'
381 'type' => 'newlevel',
385 'type' => 'FIELD_spaceBefore',
387 'inputValue' => 'foo foo'
391 'type' => 'FIELD_records',
393 'inputValue' => 'foo foo'
399 'type' => 'FIELD_maillist',
403 $this->initUserDef();
407 * [Describe function...]
409 * @param [type] $name: ...
410 * @param [type] $list: ...
411 * @param [type] $force: ...
413 * @todo Define visibility
415 public function setAndCleanUpExternalLists($name, $list, $force = '') {
416 $fields = array_unique(\TYPO3\CMS\Core\Utility\GeneralUtility
::trimExplode(',', $list . ',' . $force, 1));
418 foreach ($fields as $fN) {
419 if ($this->fields
[$fN]) {
423 $this->extFieldLists
[$name] = implode(',', $reList);
427 * [Describe function...]
429 * @param [type] $qC: ...
431 * @todo Define visibility
433 public function procesData($qC = '') {
434 $this->queryConfig
= $qC;
435 $POST = \TYPO3\CMS\Core\Utility\GeneralUtility
::_POST();
437 if ($POST['qG_del']) {
438 // Initialize array to work on, save special parameters
439 $ssArr = $this->getSubscript($POST['qG_del']);
440 $workArr = &$this->queryConfig
;
441 $ssArrSize = sizeof($ssArr) - 1;
442 for ($i = 0; $i < $ssArrSize; $i++
) {
443 $workArr = &$workArr[$ssArr[$i]];
445 // Delete the entry and move the other entries
446 unset($workArr[$ssArr[$i]]);
447 $workArrSize = sizeof($workArr);
448 for ($j = $ssArr[$i]; $j < $workArrSize; $j++
) {
449 $workArr[$j] = $workArr[$j +
1];
450 unset($workArr[$j +
1]);
454 if ($POST['qG_ins']) {
455 // Initialize array to work on, save special parameters
456 $ssArr = $this->getSubscript($POST['qG_ins']);
457 $workArr = &$this->queryConfig
;
458 $ssArrSize = sizeof($ssArr) - 1;
459 for ($i = 0; $i < $ssArrSize; $i++
) {
460 $workArr = &$workArr[$ssArr[$i]];
462 // Move all entries above position where new entry is to be inserted
463 $workArrSize = sizeof($workArr);
464 for ($j = $workArrSize; $j > $ssArr[$i]; $j--) {
465 $workArr[$j] = $workArr[$j - 1];
467 // Clear new entry position
468 unset($workArr[$ssArr[$i] +
1]);
469 $workArr[$ssArr[$i] +
1]['type'] = 'FIELD_';
472 if ($POST['qG_up']) {
473 // Initialize array to work on
474 $ssArr = $this->getSubscript($POST['qG_up']);
475 $workArr = &$this->queryConfig
;
476 $ssArrSize = sizeof($ssArr) - 1;
477 for ($i = 0; $i < $ssArrSize; $i++
) {
478 $workArr = &$workArr[$ssArr[$i]];
481 $qG_tmp = $workArr[$ssArr[$i]];
482 $workArr[$ssArr[$i]] = $workArr[$ssArr[$i] - 1];
483 $workArr[$ssArr[$i] - 1] = $qG_tmp;
486 if ($POST['qG_nl']) {
487 // Initialize array to work on
488 $ssArr = $this->getSubscript($POST['qG_nl']);
489 $workArr = &$this->queryConfig
;
490 $ssArraySize = sizeof($ssArr) - 1;
491 for ($i = 0; $i < $ssArraySize; $i++
) {
492 $workArr = &$workArr[$ssArr[$i]];
495 $tempEl = $workArr[$ssArr[$i]];
496 if (is_array($tempEl)) {
497 if ($tempEl['type'] != 'newlevel') {
498 $workArr[$ssArr[$i]] = array(
499 'type' => 'newlevel',
500 'operator' => $tempEl['operator'],
501 'nl' => array($tempEl)
506 // If collapse level...
507 if ($POST['qG_remnl']) {
508 // Initialize array to work on
509 $ssArr = $this->getSubscript($POST['qG_remnl']);
510 $workArr = &$this->queryConfig
;
511 $ssArrSize = sizeof($ssArr) - 1;
512 for ($i = 0; $i < $ssArrSize; $i++
) {
513 $workArr = &$workArr[$ssArr[$i]];
516 $tempEl = $workArr[$ssArr[$i]];
517 if (is_array($tempEl)) {
518 if ($tempEl['type'] == 'newlevel') {
519 $a1 = array_slice($workArr, 0, $ssArr[$i]);
520 $a2 = array_slice($workArr, $ssArr[$i]);
523 $a3[0]['operator'] = $tempEl['operator'];
524 $workArr = array_merge($a1, $a3, $a2);
531 * [Describe function...]
533 * @param [type] $queryConfig: ...
535 * @todo Define visibility
537 public function cleanUpQueryConfig($queryConfig) {
538 // Since we dont traverse the array using numeric keys in the upcoming whileloop make sure it's fresh and clean before displaying
539 if (is_array($queryConfig)) {
542 // queryConfig should never be empty!
543 if (!$queryConfig[0] ||
!$queryConfig[0]['type']) {
544 $queryConfig[0] = array('type' => 'FIELD_');
550 foreach ($queryConfig as $key => $conf) {
551 if (substr($conf['type'], 0, 6) == 'FIELD_') {
552 $fName = substr($conf['type'], 6);
553 $fType = $this->fields
[$fName]['type'];
554 } elseif ($conf['type'] == 'newlevel') {
555 $fType = $conf['type'];
561 if (!$queryConfig[$key]['nl']) {
562 $queryConfig[$key]['nl'][0]['type'] = 'FIELD_';
564 $queryConfig[$key]['nl'] = $this->cleanUpQueryConfig($queryConfig[$key]['nl']);
567 $queryConfig[$key] = $this->userDefCleanUp($queryConfig[$key]);
572 $verifiedName = $this->verifyType($fName);
573 $queryConfig[$key]['type'] = 'FIELD_' . $this->verifyType($verifiedName);
574 if ($conf['comparison'] >> 5 != $this->comp_offsets
[$fType]) {
575 $conf['comparison'] = $this->comp_offsets
[$fType] << 5;
577 $queryConfig[$key]['comparison'] = $this->verifyComparison($conf['comparison'], $conf['negate'] ?
1 : 0);
578 $queryConfig[$key]['inputValue'] = $this->cleanInputVal($queryConfig[$key]);
579 $queryConfig[$key]['inputValue1'] = $this->cleanInputVal($queryConfig[$key], 1);
587 * [Describe function...]
589 * @param [type] $subLevel: ...
590 * @param [type] $queryConfig: ...
591 * @param [type] $parent: ...
593 * @todo Define visibility
595 public function getFormElements($subLevel = 0, $queryConfig = '', $parent = '') {
597 if (!is_array($queryConfig)) {
598 $queryConfig = $this->queryConfig
;
603 foreach ($queryConfig as $key => $conf) {
604 $subscript = $parent . '[' . $key . ']';
606 $lineHTML .= $this->mkOperatorSelect($this->name
. $subscript, $conf['operator'], $c, $conf['type'] != 'FIELD_');
607 if (substr($conf['type'], 0, 6) == 'FIELD_') {
608 $fName = substr($conf['type'], 6);
609 $this->fieldName
= $fName;
610 $fType = $this->fields
[$fName]['type'];
611 if ($conf['comparison'] >> 5 != $this->comp_offsets
[$fType]) {
612 $conf['comparison'] = $this->comp_offsets
[$fType] << 5;
615 //make sure queryConfig contains _actual_ comparevalue.
616 //mkCompSelect don't care, but getQuery does.
617 $queryConfig[$key]['comparison'] +
= isset($conf['negate']) - $conf['comparison'] %
2;
618 } elseif ($conf['type'] == 'newlevel') {
619 $fType = $conf['type'];
627 if (!$queryConfig[$key]['nl']) {
628 $queryConfig[$key]['nl'][0]['type'] = 'FIELD_';
630 $lineHTML .= '<input type="hidden" name="' . $this->name
. $subscript . '[type]" value="newlevel">';
631 $codeArr[$arrCount]['sub'] = $this->getFormElements($subLevel +
1, $queryConfig[$key]['nl'], $subscript . '[nl]');
634 $lineHTML .= $this->userDef($this->name
. $subscript, $conf, $fName, $fType);
637 $lineHTML .= $this->mkTypeSelect($this->name
. $subscript . '[type]', $fName);
638 $lineHTML .= $this->mkCompSelect($this->name
. $subscript . '[comparison]', $conf['comparison'], $conf['negate'] ?
1 : 0);
639 $lineHTML .= '<input type="checkbox" class="checkbox"' . ($conf['negate'] ?
' checked' : '') . ' name="' . $this->name
. $subscript . '[negate]' . '" onClick="submit();">';
640 if ($conf['comparison'] == 100 ||
$conf['comparison'] == 101) {
642 $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]' . '">';
643 $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]' . '">';
644 $this->extJSCODE
.= 'typo3form.fieldSet("' . $this->name
. $subscript . '[inputValue]", "date", "", 0,0);';
645 $this->extJSCODE
.= 'typo3form.fieldSet("' . $this->name
. $subscript . '[inputValue1]", "date", "", 0,0);';
647 $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]' . '">';
648 $this->extJSCODE
.= 'typo3form.fieldSet("' . $this->name
. $subscript . '[inputValue]", "date", "", 0,0);';
652 $lineHTML .= $this->mkTypeSelect($this->name
. $subscript . '[type]', $fName);
653 $lineHTML .= $this->mkCompSelect($this->name
. $subscript . '[comparison]', $conf['comparison'], $conf['negate'] ?
1 : 0);
654 $lineHTML .= '<input type="checkbox" class="checkbox"' . ($conf['negate'] ?
' checked' : '') . ' name="' . $this->name
. $subscript . '[negate]' . '" onClick="submit();">';
655 if ($conf['comparison'] == 100 ||
$conf['comparison'] == 101) {
657 $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]' . '">';
658 $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]' . '">';
659 $this->extJSCODE
.= 'typo3form.fieldSet("' . $this->name
. $subscript . '[inputValue]", "datetime", "", 0,0);';
660 $this->extJSCODE
.= 'typo3form.fieldSet("' . $this->name
. $subscript . '[inputValue1]", "datetime", "", 0,0);';
662 $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]' . '">';
663 $this->extJSCODE
.= 'typo3form.fieldSet("' . $this->name
. $subscript . '[inputValue]", "datetime", "", 0,0);';
671 $lineHTML .= $this->mkTypeSelect($this->name
. $subscript . '[type]', $fName);
672 $lineHTML .= $this->mkCompSelect($this->name
. $subscript . '[comparison]', $conf['comparison'], $conf['negate'] ?
1 : 0);
673 $lineHTML .= '<input type="checkbox" class="checkbox"' . ($conf['negate'] ?
' checked' : '') . ' name="' . $this->name
. $subscript . '[negate]' . '" onClick="submit();">';
674 if ($conf['comparison'] == 68 ||
$conf['comparison'] == 69 ||
$conf['comparison'] == 162 ||
$conf['comparison'] == 163) {
675 $lineHTML .= '<select name="' . $this->name
. $subscript . '[inputValue]' . '[]" style="vertical-align:top;" size="5" multiple>';
676 } elseif ($conf['comparison'] == 66 ||
$conf['comparison'] == 67) {
677 if (is_array($conf['inputValue'])) {
678 $conf['inputValue'] = implode(',', $conf['inputValue']);
680 $lineHTML .= '<input type="text" value="' . htmlspecialchars($conf['inputValue']) . '" name="' . $this->name
. $subscript . '[inputValue]' . '"' . $GLOBALS['TBE_TEMPLATE']->formWidth(10) . '>';
682 $lineHTML .= '<select name="' . $this->name
. $subscript . '[inputValue]' . '" style="vertical-align:top;" onChange="submit();">';
684 if ($conf['comparison'] != 66 && $conf['comparison'] != 67) {
685 $lineHTML .= $this->makeOptionList($fName, $conf, $this->table
);
686 $lineHTML .= '</select>';
690 $lineHTML .= $this->mkTypeSelect($this->name
. $subscript . '[type]', $fName);
691 $lineHTML .= $this->mkCompSelect($this->name
. $subscript . '[comparison]', $conf['comparison'], $conf['negate'] ?
1 : 0);
692 $lineHTML .= '<input type="checkbox" class="checkbox"' . ($conf['negate'] ?
' checked' : '') . ' name="' . $this->name
. $subscript . '[negate]' . '" onClick="submit();">';
693 if ($conf['comparison'] == 68 ||
$conf['comparison'] == 69) {
694 $lineHTML .= '<select name="' . $this->name
. $subscript . '[inputValue]' . '[]" style="vertical-align:top;" size="5" multiple>';
696 $lineHTML .= '<select name="' . $this->name
. $subscript . '[inputValue]' . '" style="vertical-align:top;" onChange="submit();">';
698 $lineHTML .= '<option value=""></option>' . $this->makeOptionList($fName, $conf, $this->table
);
699 $lineHTML .= '</select>';
700 if ($conf['comparison'] == 66 ||
$conf['comparison'] == 67) {
701 $lineHTML .= ' + <input type="text" value="' . htmlspecialchars($conf['inputValue1']) . '" name="' . $this->name
. $subscript . '[inputValue1]' . '"' . $GLOBALS['TBE_TEMPLATE']->formWidth(10) . '>';
705 $lineHTML .= $this->mkTypeSelect($this->name
. $subscript . '[type]', $fName);
706 $lineHTML .= $this->mkCompSelect($this->name
. $subscript . '[comparison]', $conf['comparison'], $conf['negate'] ?
1 : 0);
707 $lineHTML .= '<input type="checkbox" class="checkbox"' . ($conf['negate'] ?
' checked' : '') . ' name="' . $this->name
. $subscript . '[negate]' . '" onClick="submit();">';
708 $lineHTML .= '<input type="hidden" value="1" name="' . $this->name
. $subscript . '[inputValue]' . '"' . $GLOBALS['TBE_TEMPLATE']->formWidth(10) . '>';
711 $lineHTML .= $this->mkTypeSelect($this->name
. $subscript . '[type]', $fName);
712 $lineHTML .= $this->mkCompSelect($this->name
. $subscript . '[comparison]', $conf['comparison'], $conf['negate'] ?
1 : 0);
713 $lineHTML .= '<input type="checkbox" class="checkbox"' . ($conf['negate'] ?
' checked' : '') . ' name="' . $this->name
. $subscript . '[negate]' . '" onClick="submit();">';
714 if ($conf['comparison'] == 37 ||
$conf['comparison'] == 36) {
716 $lineHTML .= '<input type="text" value="' . htmlspecialchars($conf['inputValue']) . '" name="' . $this->name
. $subscript . '[inputValue]' . '"' . $GLOBALS['TBE_TEMPLATE']->formWidth(5) . '>
717 <input type="text" value="' . htmlspecialchars($conf['inputValue1']) . '" name="' . $this->name
. $subscript . '[inputValue1]' . '"' . $GLOBALS['TBE_TEMPLATE']->formWidth(5) . '>';
719 $lineHTML .= '<input type="text" value="' . htmlspecialchars($conf['inputValue']) . '" name="' . $this->name
. $subscript . '[inputValue]' . '"' . $GLOBALS['TBE_TEMPLATE']->formWidth(10) . '>';
723 if ($fType != 'ignore') {
724 $lineHTML .= $this->updateIcon();
726 $lineHTML .= '<input type="image" border="0" ' . \TYPO3\CMS\Backend\Utility\IconUtility
::skinImg($GLOBALS['BACK_PATH'], 'gfx/garbage.gif', 'width="11" height="12"') . 'title="Remove condition" name="qG_del' . $subscript . '">';
728 $lineHTML .= '<input type="image" border="0" ' . \TYPO3\CMS\Backend\Utility\IconUtility
::skinImg($GLOBALS['BACK_PATH'], 'gfx/add.gif', 'width="12" height="12"') . ' title="Add condition" name="qG_ins' . $subscript . '">';
730 $lineHTML .= '<input type="image" border="0" ' . \TYPO3\CMS\Backend\Utility\IconUtility
::skinImg($GLOBALS['BACK_PATH'], 'gfx/pil2up.gif', 'width="12" height="7"') . ' title="Move up" name="qG_up' . $subscript . '">';
732 if ($c != 0 && $fType != 'newlevel') {
733 $lineHTML .= '<input type="image" border="0" ' . \TYPO3\CMS\Backend\Utility\IconUtility
::skinImg($GLOBALS['BACK_PATH'], 'gfx/pil2right.gif', 'height="12" width="7"') . ' title="New level" name="qG_nl' . $subscript . '">';
735 if ($fType == 'newlevel') {
736 $lineHTML .= '<input type="image" border="0" ' . \TYPO3\CMS\Backend\Utility\IconUtility
::skinImg($GLOBALS['BACK_PATH'], 'gfx/pil2left.gif', 'height="12" width="7"') . ' title="Collapse new level" name="qG_remnl' . $subscript . '">';
738 $codeArr[$arrCount]['html'] = $lineHTML;
739 $codeArr[$arrCount]['query'] = $this->getQuerySingle($conf, $c > 0 ?
0 : 1);
745 $this->queryConfig
= $queryConfig;
750 * [Describe function...]
752 * @param [type] $codeArr: ...
753 * @param [type] $l: ...
754 * @param [type] $table: ...
756 * @todo Define visibility
758 public function makeOptionList($fN, $conf, $table) {
760 $fieldSetup = $this->fields
[$fN];
761 if ($fieldSetup['type'] == 'files') {
762 if ($conf['comparison'] == 66 ||
$conf['comparison'] == 67) {
763 $fileExtArray = explode(',', $fieldSetup['allowed']);
764 natcasesort($fileExtArray);
765 foreach ($fileExtArray as $fileExt) {
766 if (\TYPO3\CMS\Core\Utility\GeneralUtility
::inList($conf['inputValue'], $fileExt)) {
767 $out .= '<option value="' . $fileExt . '" selected>.' . $fileExt . '</option>';
769 $out .= '<option value="' . $fileExt . '">.' . $fileExt . '</option>';
773 $d = dir(PATH_site
. $fieldSetup['uploadfolder']);
774 while (FALSE
!== ($entry = $d->read())) {
775 if ($entry == '.' ||
$entry == '..') {
778 $fileArray[] = $entry;
781 natcasesort($fileArray);
782 foreach ($fileArray as $fileName) {
783 if (\TYPO3\CMS\Core\Utility\GeneralUtility
::inList($conf['inputValue'], $fileName)) {
784 $out .= '<option value="' . $fileName . '" selected>' . $fileName . '</option>';
786 $out .= '<option value="' . $fileName . '">' . $fileName . '</option>';
790 if ($fieldSetup['type'] == 'multiple') {
791 foreach ($fieldSetup['items'] as $key => $val) {
792 if (substr($val[0], 0, 4) == 'LLL:') {
793 $value = $GLOBALS['LANG']->sL($val[0]);
797 if (\TYPO3\CMS\Core\Utility\GeneralUtility
::inList($conf['inputValue'], $val[1])) {
798 $out .= '<option value="' . $val[1] . '" selected>' . $value . '</option>';
800 $out .= '<option value="' . $val[1] . '">' . $value . '</option>';
804 if ($fieldSetup['type'] == 'binary') {
805 foreach ($fieldSetup['items'] as $key => $val) {
806 if (substr($val[0], 0, 4) == 'LLL:') {
807 $value = $GLOBALS['LANG']->sL($val[0]);
811 if (\TYPO3\CMS\Core\Utility\GeneralUtility
::inList($conf['inputValue'], pow(2, $key))) {
812 $out .= '<option value="' . pow(2, $key) . '" selected>' . $value . '</option>';
814 $out .= '<option value="' . pow(2, $key) . '">' . $value . '</option>';
818 if ($fieldSetup['type'] == 'relation') {
819 if ($fieldSetup['items']) {
820 foreach ($fieldSetup['items'] as $key => $val) {
821 if (substr($val[0], 0, 4) == 'LLL:') {
822 $value = $GLOBALS['LANG']->sL($val[0]);
826 if (\TYPO3\CMS\Core\Utility\GeneralUtility
::inList($conf['inputValue'], $val[1])) {
827 $out .= '<option value="' . $val[1] . '" selected>' . $value . '</option>';
829 $out .= '<option value="' . $val[1] . '">' . $value . '</option>';
833 if (stristr($fieldSetup['allowed'], ',')) {
834 $from_table_Arr = explode(',', $fieldSetup['allowed']);
836 if (!$fieldSetup['prepend_tname']) {
837 $checkres = $GLOBALS['TYPO3_DB']->exec_SELECTquery($fN, $table, \TYPO3\CMS\Backend\Utility\BackendUtility
::deleteClause($table), ($groupBy = ''), ($orderBy = ''), ($limit = ''));
839 while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($checkres)) {
840 if (stristr($row[$fN], ',')) {
841 $checkContent = explode(',', $row[$fN]);
842 foreach ($checkContent as $singleValue) {
843 if (!stristr($singleValue, '_')) {
844 $dontPrefixFirstTable = 1;
848 $singleValue = $row[$fN];
849 if (strlen($singleValue) && !stristr($singleValue, '_')) {
850 $dontPrefixFirstTable = 1;
854 $GLOBALS['TYPO3_DB']->sql_free_result($checkres);
858 $from_table_Arr[0] = $fieldSetup['allowed'];
860 if ($fieldSetup['prepend_tname']) {
863 if ($fieldSetup['foreign_table']) {
864 $from_table_Arr[0] = $fieldSetup['foreign_table'];
867 $webMountPageTree = '';
868 while (list(, $from_table) = each($from_table_Arr)) {
869 if ($useTablePrefix && !$dontPrefixFirstTable && $counter != 1 ||
$counter == 1) {
870 $tablePrefix = $from_table . '_';
873 if (is_array($GLOBALS['TCA'][$from_table])) {
874 \TYPO3\CMS\Core\Utility\GeneralUtility
::loadTCA($from_table);
875 $labelField = $GLOBALS['TCA'][$from_table]['ctrl']['label'];
876 $altLabelField = $GLOBALS['TCA'][$from_table]['ctrl']['label_alt'];
877 if ($GLOBALS['TCA'][$from_table]['columns'][$labelField]['config']['items']) {
878 foreach ($GLOBALS['TCA'][$from_table]['columns'][$labelField]['config']['items'] as $labelArray) {
879 if (substr($labelArray[0], 0, 4) == 'LLL:') {
880 $labelFieldSelect[$labelArray[1]] = $GLOBALS['LANG']->sL($labelArray[0]);
882 $labelFieldSelect[$labelArray[1]] = $labelArray[0];
885 $useSelectLabels = 1;
887 if ($GLOBALS['TCA'][$from_table]['columns'][$altLabelField]['config']['items']) {
888 foreach ($GLOBALS['TCA'][$from_table]['columns'][$altLabelField]['config']['items'] as $altLabelArray) {
889 if (substr($altLabelArray[0], 0, 4) == 'LLL:') {
890 $altLabelFieldSelect[$altLabelArray[1]] = $GLOBALS['LANG']->sL($altLabelArray[0]);
892 $altLabelFieldSelect[$altLabelArray[1]] = $altLabelArray[0];
895 $useAltSelectLabels = 1;
897 $altLabelFieldSelect = $altLabelField ?
',' . $altLabelField : '';
898 $select_fields = 'uid,' . $labelField . $altLabelFieldSelect;
899 if (!$GLOBALS['BE_USER']->isAdmin() && $GLOBALS['TYPO3_CONF_VARS']['BE']['lockBeUserToDBmounts']) {
900 $webMounts = $GLOBALS['BE_USER']->returnWebmounts();
901 $perms_clause = $GLOBALS['BE_USER']->getPagePermsClause(1);
902 foreach ($webMounts as $key => $val) {
903 if ($webMountPageTree) {
904 $webMountPageTreePrefix = ',';
906 $webMountPageTree .= $webMountPageTreePrefix . $this->getTreeList($val, 999, ($begin = 0), $perms_clause);
908 if ($from_table == 'pages') {
909 $where_clause = 'uid IN (' . $webMountPageTree . ') ';
910 if (!$GLOBALS['SOBE']->MOD_SETTINGS
['show_deleted']) {
911 $where_clause .= \TYPO3\CMS\Backend\Utility\BackendUtility
::deleteClause($from_table) . ' AND' . $perms_clause;
914 $where_clause = 'pid IN (' . $webMountPageTree . ') ';
915 if (!$GLOBALS['SOBE']->MOD_SETTINGS
['show_deleted']) {
916 $where_clause .= \TYPO3\CMS\Backend\Utility\BackendUtility
::deleteClause($from_table);
920 $where_clause = 'uid';
921 if (!$GLOBALS['SOBE']->MOD_SETTINGS
['show_deleted']) {
922 $where_clause .= \TYPO3\CMS\Backend\Utility\BackendUtility
::deleteClause($from_table);
926 if (!$this->tableArray
[$from_table]) {
927 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery($select_fields, $from_table, $where_clause, ($groupBy = ''), $orderBy, ($limit = ''));
930 while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
931 $this->tableArray
[$from_table][] = $row;
933 $GLOBALS['TYPO3_DB']->sql_free_result($res);
935 foreach ($this->tableArray
[$from_table] as $key => $val) {
936 if ($useSelectLabels) {
937 $outArray[$tablePrefix . $val['uid']] = htmlspecialchars($labelFieldSelect[$val[$labelField]]);
938 } elseif ($val[$labelField]) {
939 $outArray[$tablePrefix . $val['uid']] = htmlspecialchars($val[$labelField]);
940 } elseif ($useAltSelectLabels) {
941 $outArray[$tablePrefix . $val['uid']] = htmlspecialchars($altLabelFieldSelect[$val[$altLabelField]]);
943 $outArray[$tablePrefix . $val['uid']] = htmlspecialchars($val[$altLabelField]);
946 if ($GLOBALS['SOBE']->MOD_SETTINGS
['options_sortlabel'] && is_array($outArray)) {
947 natcasesort($outArray);
951 foreach ($outArray as $key2 => $val2) {
952 if (\TYPO3\CMS\Core\Utility\GeneralUtility
::inList($conf['inputValue'], $key2)) {
953 $out .= '<option value="' . $key2 . '" selected>[' . $key2 . '] ' . $val2 . '</option>';
955 $out .= '<option value="' . $key2 . '">[' . $key2 . '] ' . $val2 . '</option>';
963 * [Describe function...]
965 * @param [type] $codeArr: ...
966 * @param [type] $l: ...
968 * @todo Define visibility
970 public function printCodeArray($codeArr, $l = 0) {
973 $indent = '<td style="vertical-align:top;"><img height="1" width="50"></td>';
976 $bgColor = \TYPO3\CMS\Core\Utility\GeneralUtility
::modifyHTMLColor($GLOBALS['TBE_TEMPLATE']->bgColor2
, $lf, $lf, $lf);
977 foreach ($codeArr as $k => $v) {
978 $line .= '<tr>' . $indent . '<td bgcolor="' . $bgColor . '"' . $this->noWrap
. '>' . $v['html'] . '</td></tr>';
979 if ($this->enableQueryParts
) {
980 $line .= '<tr>' . $indent . '<td>' . $this->formatQ($v['query']) . '</td></tr>';
982 if (is_array($v['sub'])) {
983 $line .= '<tr>' . $indent . '<td' . $this->noWrap
. '>' . $this->printCodeArray($v['sub'], ($l +
1)) . '</td></tr>';
986 $out = '<table border="0" cellpadding="0" cellspacing="1">' . $line . '</table>';
991 * [Describe function...]
993 * @param [type] $str: ...
995 * @todo Define visibility
997 public function formatQ($str) {
998 return '<font size="1" face="verdana" color="maroon"><i>' . htmlspecialchars($str) . '</i></font>';
1002 * [Describe function...]
1004 * @param [type] $name: ...
1005 * @param [type] $op: ...
1006 * @param [type] $draw: ...
1007 * @param [type] $submit: ...
1008 * @return [type] ...
1009 * @todo Define visibility
1011 public function mkOperatorSelect($name, $op, $draw, $submit) {
1013 $out = '<select name="' . $name . '[operator]"' . ($submit ?
' onChange="submit();"' : '') . '>';
1015 $out .= '<option value="AND"' . (!$op ||
$op == 'AND' ?
' selected' : '') . '>' . $this->lang
['AND'] . '</option>';
1016 $out .= '<option value="OR"' . ($op == 'OR' ?
' selected' : '') . '>' . $this->lang
['OR'] . '</option>';
1017 $out .= '</select>';
1019 $out = '<input type="hidden" value="' . $op . '" name="' . $name . '[operator]">';
1020 $out .= '<img src="clear.gif" height="1" width="47">';
1026 * [Describe function...]
1028 * @param [type] $name: ...
1029 * @param [type] $fieldName: ...
1030 * @param [type] $prepend: ...
1031 * @return [type] ...
1032 * @todo Define visibility
1034 public function mkTypeSelect($name, $fieldName, $prepend = 'FIELD_') {
1035 $out = '<select name="' . $name . '" onChange="submit();">';
1036 $out .= '<option value=""></option>';
1037 foreach ($this->fields
as $key => $value) {
1038 if (!$value['exclude'] ||
$GLOBALS['BE_USER']->check('non_exclude_fields', $this->table
. ':' . $key)) {
1039 $label = $this->fields
[$key]['label'];
1040 $label_alt = $this->fields
[$key]['label_alt'];
1041 $out .= '<option value="' . $prepend . $key . '"' . ($key == $fieldName ?
' selected' : '') . '>' . $label . '</option>';
1044 $out .= '</select>';
1049 * [Describe function...]
1051 * @param [type] $fieldName: ...
1052 * @return [type] ...
1053 * @todo Define visibility
1055 public function verifyType($fieldName) {
1057 foreach ($this->fields
as $key => $value) {
1061 if ($key == $fieldName) {
1069 * [Describe function...]
1071 * @param [type] $comparison: ...
1072 * @param [type] $neg: ...
1073 * @return [type] ...
1074 * @todo Define visibility
1076 public function verifyComparison($comparison, $neg) {
1077 $compOffSet = $comparison >> 5;
1079 for ($i = 32 * $compOffSet +
$neg; $i < 32 * ($compOffSet +
1); $i +
= 2) {
1083 if ($i >> 1 == $comparison >> 1) {
1091 * [Describe function...]
1093 * @param [type] $name: ...
1094 * @param [type] $fieldName: ...
1095 * @return [type] ...
1096 * @todo Define visibility
1098 public function mkFieldToInputSelect($name, $fieldName) {
1099 $out = '<input type="Text" value="' . htmlspecialchars($fieldName) . '" name="' . $name . '"' . $GLOBALS['TBE_TEMPLATE']->formWidth() . '>' . $this->updateIcon();
1100 $out .= '<a href="#" onClick="document.forms[0][\'' . $name . '\'].value=\'\';return false;">' . \TYPO3\CMS\Backend\Utility\IconUtility
::getSpriteIcon('actions-edit-delete', array('title' => 'Clear list')) . '</a>';
1101 $out .= '<BR><select name="_fieldListDummy" size="5" onChange="document.forms[0][\'' . $name . '\'].value+=\',\'+this.value">';
1102 foreach ($this->fields
as $key => $value) {
1103 if (!$value['exclude'] ||
$GLOBALS['BE_USER']->check('non_exclude_fields', $this->table
. ':' . $key)) {
1104 $label = $this->fields
[$key]['label'];
1105 $label_alt = $this->fields
[$key]['label_alt'];
1106 $out .= '<option value="' . $key . '"' . ($key == $fieldName ?
' selected' : '') . '>' . $label . '</option>';
1109 $out .= '</select>';
1114 * [Describe function...]
1116 * @param [type] $name: ...
1117 * @param [type] $cur: ...
1118 * @return [type] ...
1119 * @todo Define visibility
1121 public function mkTableSelect($name, $cur) {
1122 $out = '<select name="' . $name . '" onChange="submit();">';
1123 $out .= '<option value=""></option>';
1124 foreach ($GLOBALS['TCA'] as $tN => $value) {
1125 if ($GLOBALS['BE_USER']->check('tables_select', $tN)) {
1126 $out .= '<option value="' . $tN . '"' . ($tN == $cur ?
' selected' : '') . '>' . $GLOBALS['LANG']->sl($GLOBALS['TCA'][$tN]['ctrl']['title']) . '</option>';
1129 $out .= '</select>';
1134 * [Describe function...]
1136 * @param [type] $name: ...
1137 * @param [type] $comparison: ...
1138 * @param [type] $neg: ...
1139 * @return [type] ...
1140 * @todo Define visibility
1142 public function mkCompSelect($name, $comparison, $neg) {
1143 $compOffSet = $comparison >> 5;
1144 $out = '<select name="' . $name . '" onChange="submit();">';
1145 for ($i = 32 * $compOffSet +
$neg; $i < 32 * ($compOffSet +
1); $i +
= 2) {
1146 if ($this->lang
['comparison'][$i . '_']) {
1147 $out .= '<option value="' . $i . '"' . ($i >> 1 == $comparison >> 1 ?
' selected' : '') . '>' . $this->lang
['comparison'][($i . '_')] . '</option>';
1150 $out .= '</select>';
1155 * [Describe function...]
1157 * @param [type] $arr: ...
1158 * @return [type] ...
1159 * @todo Define visibility
1161 public function getSubscript($arr) {
1162 while (is_array($arr)) {
1164 list($key, ) = each($arr);
1172 * [Describe function...]
1174 * @return [type] ...
1175 * @todo Define visibility
1177 public function initUserDef() {
1182 * [Describe function...]
1184 * @return [type] ...
1185 * @todo Define visibility
1187 public function userDef() {
1192 * [Describe function...]
1194 * @param [type] $queryConfig: ...
1195 * @return [type] ...
1196 * @todo Define visibility
1198 public function userDefCleanUp($queryConfig) {
1199 return $queryConfig;
1203 * [Describe function...]
1205 * @param [type] $queryConfig: ...
1206 * @param [type] $pad: ...
1207 * @return [type] ...
1208 * @todo Define visibility
1210 public function getQuery($queryConfig, $pad = '') {
1212 // Since we don't traverse the array using numeric keys in the upcoming whileloop make sure it's fresh and clean
1213 ksort($queryConfig);
1215 foreach ($queryConfig as $key => $conf) {
1216 switch ($conf['type']) {
1218 $qs .= LF
. $pad . trim($conf['operator']) . ' (' . $this->getQuery($queryConfig[$key]['nl'], ($pad . ' ')) . LF
. $pad . ')';
1221 $qs .= LF
. $pad . getUserDefQuery($conf, $first);
1224 $qs .= LF
. $pad . $this->getQuerySingle($conf, $first);
1233 * [Describe function...]
1235 * @param [type] $conf: ...
1236 * @param [type] $first: ...
1237 * @return [type] ...
1238 * @todo Define visibility
1240 public function getQuerySingle($conf, $first) {
1242 $prefix = $this->enablePrefix ?
$this->table
. '.' : '';
1244 // Is it OK to insert the AND operator if none is set?
1245 $qs .= trim(($conf['operator'] ?
$conf['operator'] : 'AND')) . ' ';
1247 $qsTmp = str_replace('#FIELD#', $prefix . trim(substr($conf['type'], 6)), $this->compSQL
[$conf['comparison']]);
1248 $inputVal = $this->cleanInputVal($conf);
1249 if ($conf['comparison'] == 68 ||
$conf['comparison'] == 69) {
1250 $inputVal = explode(',', $inputVal);
1251 foreach ($inputVal as $key => $fileName) {
1252 $inputVal[$key] = '\'' . $fileName . '\'';
1254 $inputVal = implode(',', $inputVal);
1255 $qsTmp = str_replace('#VALUE#', $inputVal, $qsTmp);
1256 } elseif ($conf['comparison'] == 162 ||
$conf['comparison'] == 163) {
1257 $inputValArray = explode(',', $inputVal);
1259 foreach ($inputValArray as $key => $fileName) {
1260 $inputVal +
= intval($fileName);
1262 $qsTmp = str_replace('#VALUE#', $inputVal, $qsTmp);
1264 $qsTmp = str_replace('#VALUE#', $GLOBALS['TYPO3_DB']->quoteStr($inputVal, $this->table
), $qsTmp);
1266 if ($conf['comparison'] == 37 ||
$conf['comparison'] == 36 ||
$conf['comparison'] == 66 ||
$conf['comparison'] == 67 ||
$conf['comparison'] == 100 ||
$conf['comparison'] == 101) {
1268 $inputVal = $this->cleanInputVal($conf, '1');
1269 $qsTmp = str_replace('#VALUE1#', $GLOBALS['TYPO3_DB']->quoteStr($inputVal, $this->table
), $qsTmp);
1271 $qs .= trim($qsTmp);
1276 * [Describe function...]
1278 * @param [type] $conf: ...
1279 * @param [type] $suffix: ...
1280 * @return [type] ...
1281 * @todo Define visibility
1283 public function cleanInputVal($conf, $suffix = '') {
1284 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)) {
1285 $inputVal = $conf['inputValue' . $suffix];
1286 } elseif ($conf['comparison'] == 39 ||
$conf['comparison'] == 38) {
1288 $inputVal = implode(',', \TYPO3\CMS\Core\Utility\GeneralUtility
::intExplode(',', $conf['inputValue' . $suffix]));
1289 } elseif ($conf['comparison'] == 68 ||
$conf['comparison'] == 69 ||
$conf['comparison'] == 162 ||
$conf['comparison'] == 163) {
1291 if (is_array($conf['inputValue' . $suffix])) {
1292 $inputVal = implode(',', $conf['inputValue' . $suffix]);
1293 } elseif ($conf['inputValue' . $suffix]) {
1294 $inputVal = $conf['inputValue' . $suffix];
1299 $inputVal = doubleval($conf['inputValue' . $suffix]);
1305 * [Describe function...]
1307 * @param [type] $qcArr: ...
1308 * @return [type] ...
1309 * @todo Define visibility
1311 public function getUserDefQuery($qcArr) {
1316 * [Describe function...]
1318 * @return [type] ...
1319 * @todo Define visibility
1321 public function updateIcon() {
1322 return '<input type="image" border="0" ' . \TYPO3\CMS\Backend\Utility\IconUtility
::skinImg($GLOBALS['BACK_PATH'], 'gfx/refresh_n.gif', 'width="14" height="14"') . ' title="Update" name="just_update">';
1326 * [Describe function...]
1328 * @return [type] ...
1329 * @todo Define visibility
1331 public function getLabelCol() {
1332 return $GLOBALS['TCA'][$this->table
]['ctrl']['label'];
1336 * [Describe function...]
1338 * @param [type] $modSettings: ...
1339 * @param [type] $enableList: ...
1340 * @return [type] ...
1341 * @todo Define visibility
1343 public function makeSelectorTable($modSettings, $enableList = 'table,fields,query,group,order,limit') {
1344 $enableArr = explode(',', $enableList);
1346 $TDparams = ' class="bgColor5" nowrap';
1347 if (in_array('table', $enableArr) && !$GLOBALS['BE_USER']->userTS
['mod.']['dbint.']['disableSelectATable']) {
1350 <td' . $TDparams . '><strong>Select a table:</strong></td>
1351 <td' . $TDparams . '>' . $this->mkTableSelect('SET[queryTable]', $this->table
) . '</td>
1356 $this->setAndCleanUpExternalLists('queryFields', $modSettings['queryFields'], 'uid,' . $this->getLabelCol());
1357 $this->setAndCleanUpExternalLists('queryGroup', $modSettings['queryGroup']);
1358 $this->setAndCleanUpExternalLists('queryOrder', $modSettings['queryOrder'] . ',' . $modSettings['queryOrder2']);
1360 $this->extFieldLists
['queryLimit'] = $modSettings['queryLimit'];
1361 if (!$this->extFieldLists
['queryLimit']) {
1362 $this->extFieldLists
['queryLimit'] = 100;
1364 $parts = \TYPO3\CMS\Core\Utility\GeneralUtility
::intExplode(',', $this->extFieldLists
['queryLimit']);
1366 $this->limitBegin
= $parts[0];
1367 $this->limitLength
= $parts[1];
1369 $this->limitLength
= $this->extFieldLists
['queryLimit'];
1371 $this->extFieldLists
['queryLimit'] = implode(',', array_slice($parts, 0, 2));
1372 // Insert Descending parts
1373 if ($this->extFieldLists
['queryOrder']) {
1374 $descParts = explode(',', $modSettings['queryOrderDesc'] . ',' . $modSettings['queryOrder2Desc']);
1375 $orderParts = explode(',', $this->extFieldLists
['queryOrder']);
1377 foreach ($orderParts as $kk => $vv) {
1378 $reList[] = $vv . ($descParts[$kk] ?
' DESC' : '');
1380 $this->extFieldLists
['queryOrder_SQL'] = implode(',', $reList);
1383 $this->procesData($modSettings['queryConfig'] ?
unserialize($modSettings['queryConfig']) : '');
1384 $this->queryConfig
= $this->cleanUpQueryConfig($this->queryConfig
);
1385 $this->enableQueryParts
= $modSettings['search_query_smallparts'];
1386 $codeArr = $this->getFormElements();
1387 $queryCode = $this->printCodeArray($codeArr);
1388 if (in_array('fields', $enableArr) && !$GLOBALS['BE_USER']->userTS
['mod.']['dbint.']['disableSelectFields']) {
1391 <td' . $TDparams . '><strong>Select fields:</strong></td>
1392 <td' . $TDparams . '>' . $this->mkFieldToInputSelect('SET[queryFields]', $this->extFieldLists
['queryFields']) . '</td>
1395 if (in_array('query', $enableArr) && !$GLOBALS['BE_USER']->userTS
['mod.']['dbint.']['disableMakeQuery']) {
1397 <td colspan="2"' . $TDparams . '><strong>Make Query:</strong></td>
1400 <td colspan="2">' . $queryCode . '</td>
1404 if (in_array('group', $enableArr) && !$GLOBALS['BE_USER']->userTS
['mod.']['dbint.']['disableGroupBy']) {
1406 <td' . $TDparams . '><strong>Group By:</strong></td>
1407 <td' . $TDparams . '>' . $this->mkTypeSelect('SET[queryGroup]', $this->extFieldLists
['queryGroup'], '') . '</td>
1410 if (in_array('order', $enableArr) && !$GLOBALS['BE_USER']->userTS
['mod.']['dbint.']['disableOrderBy']) {
1411 $orderByArr = explode(',', $this->extFieldLists
['queryOrder']);
1413 $orderBy .= $this->mkTypeSelect('SET[queryOrder]', $orderByArr[0], '') . ' ' . \TYPO3\CMS\Backend\Utility\BackendUtility
::getFuncCheck($GLOBALS['SOBE']->id
, 'SET[queryOrderDesc]', $modSettings['queryOrderDesc'], '', '', 'id="checkQueryOrderDesc"') . ' <label for="checkQueryOrderDesc">Descending</label>';
1414 if ($orderByArr[0]) {
1415 $orderBy .= '<BR>' . $this->mkTypeSelect('SET[queryOrder2]', $orderByArr[1], '') . ' ' . \TYPO3\CMS\Backend\Utility\BackendUtility
::getFuncCheck($GLOBALS['SOBE']->id
, 'SET[queryOrder2Desc]', $modSettings['queryOrder2Desc'], '', '', 'id="checkQueryOrder2Desc"') . ' <label for="checkQueryOrder2Desc">Descending</label>';
1418 <td' . $TDparams . '><strong>Order By:</strong></td>
1419 <td' . $TDparams . '>' . $orderBy . '</td>
1422 if (in_array('limit', $enableArr) && !$GLOBALS['BE_USER']->userTS
['mod.']['dbint.']['disableLimit']) {
1423 $limit = '<input type="Text" value="' . htmlspecialchars($this->extFieldLists
['queryLimit']) . '" name="SET[queryLimit]" id="queryLimit"' . $GLOBALS['TBE_TEMPLATE']->formWidth(10) . '>' . $this->updateIcon();
1424 $prevLimit = $this->limitBegin
- $this->limitLength
< 0 ?
0 : $this->limitBegin
- $this->limitLength
;
1425 if ($this->limitBegin
) {
1426 $prevButton = '<input type="button" value="previous ' . $this->limitLength
. '" onclick=\'document.getElementById("queryLimit").value="' . $prevLimit . ',' . $this->limitLength
. '";document.forms[0].submit();\'>';
1428 if (!$this->limitLength
) {
1429 $this->limitLength
= 100;
1431 $nextLimit = $this->limitBegin +
$this->limitLength
;
1432 if ($nextLimit < 0) {
1436 $nextButton = '<input type="button" value="next ' . $this->limitLength
. '" onclick=\'document.getElementById("queryLimit").value="' . $nextLimit . ',' . $this->limitLength
. '";document.forms[0].submit();\'>';
1438 $numberButtons = '<input type="button" value="10" onclick=\'document.getElementById("queryLimit").value="10";document.forms[0].submit();\'>';
1439 $numberButtons .= '<input type="button" value="20" onclick=\'document.getElementById("queryLimit").value="20";document.forms[0].submit();\'>';
1440 $numberButtons .= '<input type="button" value="50" onclick=\'document.getElementById("queryLimit").value="50";document.forms[0].submit();\'>';
1441 $numberButtons .= '<input type="button" value="100" onclick=\'document.getElementById("queryLimit").value="100";document.forms[0].submit();\'>';
1443 <td' . $TDparams . '><strong>Limit:</strong></td>
1444 <td' . $TDparams . '>' . $limit . $prevButton . $nextButton . ' ' . $numberButtons . '</td>
1449 $out = '<table border="0" cellpadding="3" cellspacing="1" class="qg-make-query">' . $out . '</table>';
1450 $out .= $this->JSbottom($this->formName
);
1455 * [Describe function...]
1457 * @param [type] $qString: ...
1458 * @param [type] $depth: ...
1459 * @param [type] $begin: ...
1460 * @param [type] $perms_clause: ...
1461 * @return [type] ...
1462 * @todo Define visibility
1464 public function getTreeList($id, $depth, $begin = 0, $perms_clause) {
1465 $depth = intval($depth);
1466 $begin = intval($begin);
1473 if ($id && $depth > 0) {
1474 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('uid', 'pages', 'pid=' . $id . ' ' . \TYPO3\CMS\Backend\Utility\BackendUtility
::deleteClause('pages') . ' AND ' . $perms_clause);
1475 while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
1477 $theList .= ',' . $row['uid'];
1480 $theList .= $this->getTreeList($row['uid'], $depth - 1, $begin - 1, $perms_clause);
1483 $GLOBALS['TYPO3_DB']->sql_free_result($res);
1489 * [Describe function...]
1491 * @param [type] $qString: ...
1492 * @param [type] $fN: ...
1493 * @return [type] ...
1494 * @todo Define visibility
1496 public function getSelectQuery($qString = '', $fN = '') {
1498 $qString = $this->getQuery($this->queryConfig
);
1500 $qString = '(' . $qString . ')';
1501 if (!$GLOBALS['BE_USER']->isAdmin() && $GLOBALS['TYPO3_CONF_VARS']['BE']['lockBeUserToDBmounts']) {
1502 $webMounts = $GLOBALS['BE_USER']->returnWebmounts();
1503 $perms_clause = $GLOBALS['BE_USER']->getPagePermsClause(1);
1504 $webMountPageTree = '';
1505 foreach ($webMounts as $key => $val) {
1506 if ($webMountPageTree) {
1507 $webMountPageTreePrefix = ',';
1509 $webMountPageTree .= $webMountPageTreePrefix . $this->getTreeList($val, 999, ($begin = 0), $perms_clause);
1511 if ($this->table
== 'pages') {
1512 $qString .= ' AND uid IN (' . $webMountPageTree . ')';
1514 $qString .= ' AND pid IN (' . $webMountPageTree . ')';
1517 $fieldlist = $this->extFieldLists
['queryFields'] . ',pid' . ($GLOBALS['TCA'][$this->table
]['ctrl']['delete'] ?
',' . $GLOBALS['TCA'][$this->table
]['ctrl']['delete'] : '');
1518 if (!$GLOBALS['SOBE']->MOD_SETTINGS
['show_deleted']) {
1519 $qString .= \TYPO3\CMS\Backend\Utility\BackendUtility
::deleteClause($this->table
);
1521 $query = $GLOBALS['TYPO3_DB']->SELECTquery($fieldlist, $this->table
, $qString, trim($this->extFieldLists
['queryGroup']), $this->extFieldLists
['queryOrder'] ?
trim($this->extFieldLists
['queryOrder_SQL']) : '', $this->extFieldLists
['queryLimit']);
1526 * [Describe function...]
1528 * @param string $formname
1530 * @todo Define visibility
1532 public function JSbottom($formname) {
1534 if ($this->extJSCODE
) {
1536 <script language="javascript" type="text/javascript" src="' . $GLOBALS['BACK_PATH'] . '../t3lib/jsfunc.evalfield.js"></script>
1537 <script language="javascript" type="text/javascript" src="' . $GLOBALS['BACK_PATH'] . 'jsfunc.tbe_editor.js"></script>
1538 <script language="javascript" type="text/javascript">
1539 TBE_EDITOR.formname = "' . $formname . '";
1540 TBE_EDITOR.formnameUENC = "' . rawurlencode($formname) . '";
1541 TBE_EDITOR.backend_interface = "' . $GLOBALS['BE_USER']->uc
['interfaceSetup'] . '";
1542 ' . $this->extJSCODE
. '
1549 * Sets the current name of the input form.
1551 * @param string $formName The name of the form.
1554 public function setFormName($formName) {
1555 $this->formName
= trim($formName);