2 namespace TYPO3\CMS\Core\Database;
35 'comparison' => array(
38 '1_' =>
'does not contain',
39 '2_' =>
'starts with',
40 '3_' =>
'does not start with',
42 '5_' =>
'does not end with',
44 '7_' =>
'does not equal',
47 '33_' =>
'does not equal',
48 '34_' =>
'is greater than',
49 '35_' =>
'is less than',
50 '36_' =>
'is between',
51 '37_' =>
'is not between',
52 '38_' =>
'is in list',
53 '39_' =>
'is not in list',
54 '40_' =>
'binary AND equals',
55 '41_' =>
'binary AND does not equal',
56 '42_' =>
'binary OR equals',
57 '43_' =>
'binary OR does not equal',
60 '65_' =>
'does not equal',
62 '67_' =>
'does not contain',
63 '68_' =>
'is in list',
64 '69_' =>
'is not in list',
65 '70_' =>
'binary AND equals',
66 '71_' =>
'binary AND does not equal',
67 '72_' =>
'binary OR equals',
68 '73_' =>
'binary OR does not equal',
71 '97_' =>
'does not equal',
72 '98_' =>
'is greater than',
73 '99_' =>
'is less than',
74 '100_' =>
'is between',
75 '101_' =>
'is not between',
76 '102_' =>
'binary AND equals',
77 '103_' =>
'binary AND does not equal',
78 '104_' =>
'binary OR equals',
79 '105_' =>
'binary OR does not equal',
85 '161_' =>
'does not equal',
87 '163_' =>
'does not contain'
96 '0' =>
'#FIELD# LIKE \'%#VALUE#%\'',
97 '1' =>
'#FIELD# NOT LIKE \'%#VALUE#%\'',
98 '2' =>
'#FIELD# LIKE \'#VALUE#%\'',
99 '3' =>
'#FIELD# NOT LIKE \'#VALUE#%\'',
100 '4' =>
'#FIELD# LIKE \'%#VALUE#\'',
101 '5' =>
'#FIELD# NOT LIKE \'%#VALUE#\'',
102 '6' =>
'#FIELD# = \'#VALUE#\'',
103 '7' =>
'#FIELD# != \'#VALUE#\'',
105 '32' =>
'#FIELD# = \'#VALUE#\'',
106 '33' =>
'#FIELD# != \'#VALUE#\'',
107 '34' =>
'#FIELD# > #VALUE#',
108 '35' =>
'#FIELD# < #VALUE#',
109 '36' =>
'#FIELD# >= #VALUE# AND #FIELD# <= #VALUE1#',
110 '37' =>
'NOT (#FIELD# >= #VALUE# AND #FIELD# <= #VALUE1#)',
111 '38' =>
'#FIELD# IN (#VALUE#)',
112 '39' =>
'#FIELD# NOT IN (#VALUE#)',
113 '40' =>
'(#FIELD# & #VALUE#)=#VALUE#',
114 '41' =>
'(#FIELD# & #VALUE#)!=#VALUE#',
115 '42' =>
'(#FIELD# | #VALUE#)=#VALUE#',
116 '43' =>
'(#FIELD# | #VALUE#)!=#VALUE#',
118 '64' =>
'#FIELD# = \'#VALUE#\'',
119 '65' =>
'#FIELD# != \'#VALUE#\'',
120 '66' =>
'#FIELD# LIKE \'%#VALUE#%\' AND #FIELD# LIKE \'%#VALUE1#%\'',
121 '67' =>
'(#FIELD# NOT LIKE \'%#VALUE#%\' OR #FIELD# NOT LIKE \'%#VALUE1#%\')',
122 '68' =>
'#FIELD# IN (#VALUE#)',
123 '69' =>
'#FIELD# NOT IN (#VALUE#)',
124 '70' =>
'(#FIELD# & #VALUE#)=#VALUE#',
125 '71' =>
'(#FIELD# & #VALUE#)!=#VALUE#',
126 '72' =>
'(#FIELD# | #VALUE#)=#VALUE#',
127 '73' =>
'(#FIELD# | #VALUE#)!=#VALUE#',
129 '96' =>
'#FIELD# = \'#VALUE#\'',
130 '97' =>
'#FIELD# != \'#VALUE#\'',
131 '98' =>
'#FIELD# > #VALUE#',
132 '99' =>
'#FIELD# < #VALUE#',
133 '100' =>
'#FIELD# >= #VALUE# AND #FIELD# <= #VALUE1#',
134 '101' =>
'NOT (#FIELD# >= #VALUE# AND #FIELD# <= #VALUE1#)',
135 '102' =>
'(#FIELD# & #VALUE#)=#VALUE#',
136 '103' =>
'(#FIELD# & #VALUE#)!=#VALUE#',
137 '104' =>
'(#FIELD# | #VALUE#)=#VALUE#',
138 '105' =>
'(#FIELD# | #VALUE#)!=#VALUE#',
140 '128' =>
'#FIELD# = \'1\'',
141 '129' =>
'#FIELD# != \'1\'',
143 '160' =>
'#FIELD# = \'#VALUE#\'',
144 '161' =>
'#FIELD# != \'#VALUE#\'',
145 '162' =>
'(#FIELD# & #VALUE#)=#VALUE#',
146 '163' =>
'(#FIELD# & #VALUE#)=0'
257 $fieldListArr = array();
258 if (is_array(
$GLOBALS[
'TCA'][$this->table])) {
259 $fieldListArr = array_keys(
$GLOBALS[
'TCA'][$this->table][
'columns']);
260 $fieldListArr[] =
'uid';
261 $fieldListArr[] =
'pid';
262 $fieldListArr[] =
'deleted';
263 if (
$GLOBALS[
'TCA'][$this->table][
'ctrl'][
'tstamp']) {
266 if (
$GLOBALS[
'TCA'][$this->table][
'ctrl'][
'crdate']) {
269 if (
$GLOBALS[
'TCA'][$this->table][
'ctrl'][
'cruser_id']) {
272 if (
$GLOBALS[
'TCA'][$this->table][
'ctrl'][
'sortby']) {
276 return implode(
',', $fieldListArr);
298 $this->fields[
$fieldName][
'exclude'] = $fC[
'exclude'];
299 if (is_array($fC) && $fC[
'label']) {
301 switch ($this->fields[$fieldName][
'type']) {
303 if (preg_match(
'/int|year/i', $this->fields[$fieldName][
'eval'])) {
305 }
elseif (preg_match(
'/time/i', $this->fields[$fieldName][
'eval'])) {
307 }
elseif (preg_match(
'/date/i', $this->fields[$fieldName][
'eval'])) {
314 if (!$this->fields[$fieldName][
'items'] || count($this->fields[$fieldName][
'items']) <= 1) {
315 $this->fields[
$fieldName][
'type'] =
'boolean';
321 $this->fields[
$fieldName][
'type'] =
'multiple';
324 $this->fields[
$fieldName][
'type'] =
'multiple';
325 if ($this->fields[$fieldName][
'foreign_table']) {
326 $this->fields[
$fieldName][
'type'] =
'relation';
328 if ($this->fields[$fieldName][
'special']) {
334 if ($this->fields[$fieldName][
'internal_type'] ===
'db') {
335 $this->fields[
$fieldName][
'type'] =
'relation';
347 $this->fields[
$fieldName][
'label'] =
'[FIELD: ' . $fieldName .
']';
348 switch ($fieldName) {
350 $this->fields[
$fieldName][
'type'] =
'relation';
351 $this->fields[
$fieldName][
'allowed'] =
'pages';
354 $this->fields[
$fieldName][
'type'] =
'relation';
355 $this->fields[
$fieldName][
'allowed'] =
'be_users';
362 $this->fields[
$fieldName][
'type'] =
'boolean';
421 if ($this->fields[$fieldName]) {
425 $this->extFieldLists[
$name] = implode(
',', $reList);
436 $this->queryConfig = $qC;
439 if ($POST[
'qG_del']) {
443 $ssArrSize =
sizeof($ssArr) - 1;
444 for ($i = 0; $i < $ssArrSize; $i++) {
445 $workArr = &$workArr[$ssArr[$i]];
448 unset($workArr[$ssArr[$i]]);
449 $workArrSize =
sizeof($workArr);
450 for ($j = $ssArr[$i]; $j < $workArrSize; $j++) {
451 $workArr[$j] = $workArr[$j + 1];
452 unset($workArr[$j + 1]);
456 if ($POST[
'qG_ins']) {
460 $ssArrSize =
sizeof($ssArr) - 1;
461 for ($i = 0; $i < $ssArrSize; $i++) {
462 $workArr = &$workArr[$ssArr[$i]];
465 $workArrSize =
sizeof($workArr);
466 for ($j = $workArrSize; $j > $ssArr[$i]; $j--) {
467 $workArr[$j] = $workArr[$j - 1];
470 unset($workArr[$ssArr[$i] + 1]);
471 $workArr[$ssArr[$i] + 1][
'type'] =
'FIELD_';
474 if ($POST[
'qG_up']) {
478 $ssArrSize =
sizeof($ssArr) - 1;
479 for ($i = 0; $i < $ssArrSize; $i++) {
480 $workArr = &$workArr[$ssArr[$i]];
483 $qG_tmp = $workArr[$ssArr[$i]];
484 $workArr[$ssArr[$i]] = $workArr[$ssArr[$i] - 1];
485 $workArr[$ssArr[$i] - 1] = $qG_tmp;
488 if ($POST[
'qG_nl']) {
492 $ssArraySize =
sizeof($ssArr) - 1;
493 for ($i = 0; $i < $ssArraySize; $i++) {
494 $workArr = &$workArr[$ssArr[$i]];
497 $tempEl = $workArr[$ssArr[$i]];
498 if (is_array($tempEl)) {
499 if ($tempEl[
'type'] !=
'newlevel') {
500 $workArr[$ssArr[$i]] = array(
501 'type' =>
'newlevel',
502 'operator' => $tempEl[
'operator'],
503 'nl' => array($tempEl)
509 if ($POST[
'qG_remnl']) {
513 $ssArrSize =
sizeof($ssArr) - 1;
514 for ($i = 0; $i < $ssArrSize; $i++) {
515 $workArr = &$workArr[$ssArr[$i]];
518 $tempEl = $workArr[$ssArr[$i]];
519 if (is_array($tempEl)) {
520 if ($tempEl[
'type'] ===
'newlevel') {
521 $a1 = array_slice($workArr, 0, $ssArr[$i]);
522 $a2 = array_slice($workArr, $ssArr[$i]);
525 $a3[0][
'operator'] = $tempEl[
'operator'];
526 $workArr = array_merge($a1, $a3, $a2);
552 if (substr($conf[
'type'], 0, 6) ===
'FIELD_') {
554 $fieldType = $this->fields[
$fieldName][
'type'];
555 }
elseif ($conf[
'type'] ===
'newlevel') {
556 $fieldType = $conf[
'type'];
558 $fieldType =
'ignore';
560 switch ($fieldType) {
574 if ($conf[
'comparison'] >> 5 != $this->comp_offsets[$fieldType]) {
575 $conf[
'comparison'] = $this->comp_offsets[$fieldType] << 5;
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_') {
610 $fieldType = $this->fields[
$fieldName][
'type'];
611 if ($conf[
'comparison'] >> 5 != $this->comp_offsets[$fieldType]) {
612 $conf[
'comparison'] = $this->comp_offsets[$fieldType] << 5;
617 $queryConfig[$key][
'comparison'] += isset($conf[
'negate']) - $conf[
'comparison'] % 2;
618 }
elseif ($conf[
'type'] ===
'newlevel') {
619 $fieldType = $conf[
'type'];
621 $fieldType =
'ignore';
623 $fieldPrefix = htmlspecialchars($this->name . $subscript);
624 switch ($fieldType) {
631 $lineHTML[] =
'<input type="hidden" name="' . $fieldPrefix .
'[type]" value="newlevel">';
638 $lineHTML[] =
'<div class="form-inline">';
640 if ($conf[
'comparison'] === 100 || $conf[
'comparison'] === 101) {
643 $lineHTML[] = $this->
getDateTimePickerField($fieldPrefix .
'[inputValue1]', $conf[
'inputValue1'],
'date');
647 $lineHTML[] =
'</div>';
650 $lineHTML[] =
'<div class="form-inline">';
652 if ($conf[
'comparison'] === 100 || $conf[
'comparison'] === 101) {
654 $lineHTML[] = $this->
getDateTimePickerField($fieldPrefix .
'[inputValue]', $conf[
'inputValue'],
'datetime');
655 $lineHTML[] = $this->
getDateTimePickerField($fieldPrefix .
'[inputValue1]', $conf[
'inputValue1'],
'datetime');
657 $lineHTML[] = $this->
getDateTimePickerField($fieldPrefix .
'[inputValue]', $conf[
'inputValue'],
'datetime');
659 $lineHTML[] =
'</div>';
664 $lineHTML[] =
'<div class="form-inline">';
666 if ($conf[
'comparison'] === 68 || $conf[
'comparison'] === 69 || $conf[
'comparison'] === 162 || $conf[
'comparison'] === 163) {
667 $lineHTML[] =
'<select class="form-control" name="' . $fieldPrefix .
'[inputValue]' .
'[]" multiple="multiple">';
668 }
elseif ($conf[
'comparison'] === 66 || $conf[
'comparison'] === 67) {
669 if (is_array($conf[
'inputValue'])) {
670 $conf[
'inputValue'] = implode(
',', $conf[
'inputValue']);
672 $lineHTML[] =
'<input class="form-control t3js-clearable" type="text" value="' . htmlspecialchars($conf[
'inputValue']) .
'" name="' . $fieldPrefix .
'[inputValue]' .
'">';
674 $lineHTML[] =
'<select class="form-control t3js-submit-change" name="' . $fieldPrefix .
'[inputValue]' .
'">';
676 if ($conf[
'comparison'] != 66 && $conf[
'comparison'] != 67) {
678 $lineHTML[] =
'</select>';
680 $lineHTML[] =
'</div>';
683 $lineHTML[] =
'<div class="form-inline">';
685 if ($conf[
'comparison'] === 68 || $conf[
'comparison'] === 69) {
686 $lineHTML[] =
'<select class="form-control" name="' . $fieldPrefix .
'[inputValue]' .
'[]" multiple="multiple">';
688 $lineHTML[] =
'<select class="form-control t3js-submit-change" name="' . $fieldPrefix .
'[inputValue]' .
'">';
691 $lineHTML[] =
'</select>';
692 if ($conf[
'comparison'] === 66 || $conf[
'comparison'] === 67) {
693 $lineHTML[] =
' + <input class="form-control t3js-clearable" type="text" value="' . htmlspecialchars($conf[
'inputValue1']) .
'" name="' . $fieldPrefix .
'[inputValue1]' .
'">';
695 $lineHTML[] =
'</div>';
698 $lineHTML[] =
'<div class="form-inline">';
700 $lineHTML[] =
'<input type="hidden" value="1" name="' . $fieldPrefix .
'[inputValue]' .
'">';
701 $lineHTML[] =
'</div>';
704 $lineHTML[] =
'<div class="form-inline">';
706 if ($conf[
'comparison'] === 37 || $conf[
'comparison'] === 36) {
708 $lineHTML[] =
'<input class="form-control t3js-clearable" type="text" value="' . htmlspecialchars($conf[
'inputValue']) .
'" name="' . $fieldPrefix .
'[inputValue]' .
'">';
709 $lineHTML[] =
'<input class="form-control t3js-clearable" type="text" value="' . htmlspecialchars($conf[
'inputValue1']) .
'" name="' . $fieldPrefix .
'[inputValue1]' .
'">';
711 $lineHTML[] =
'<input class="form-control t3js-clearable" type="text" value="' . htmlspecialchars($conf[
'inputValue']) .
'" name="' . $fieldPrefix .
'[inputValue]' .
'">';
713 $lineHTML[] =
'</div>';
715 if ($fieldType !==
'ignore') {
716 $lineHTML[] =
'<div class="btn-group action-button-group">';
719 $lineHTML[] =
'<button class="btn btn-default" title="Remove condition" name="qG_del' . htmlspecialchars($subscript) .
'"><i class="fa fa-trash fa-fw"></i></button>';
721 $lineHTML[] =
'<button class="btn btn-default" title="Add condition" name="qG_ins' . htmlspecialchars($subscript) .
'"><i class="fa fa-plus fa-fw"></i></button>';
723 $lineHTML[] =
'<button class="btn btn-default" title="Move up" name="qG_up' . htmlspecialchars($subscript) .
'"><i class="fa fa-chevron-up fa-fw"></i></button>';
725 if ($c != 0 && $fieldType !=
'newlevel') {
726 $lineHTML[] =
'<button class="btn btn-default" title="New level" name="qG_nl' . htmlspecialchars($subscript) .
'"><i class="fa fa-chevron-right fa-fw"></i></button>';
728 if ($fieldType ===
'newlevel') {
729 $lineHTML[] =
'<button class="btn btn-default" title="Collapse new level" name="qG_remnl' . htmlspecialchars($subscript) .
'"><i class="fa fa-chevron-left fa-fw"></i></button>';
731 $lineHTML[] =
'</div>';
732 $codeArr[$arrCount][
'html'] = implode(LF, $lineHTML);
733 $codeArr[$arrCount][
'query'] = $this->
getQuerySingle($conf, $c > 0 ? 0 : 1);
752 $fieldPrefix = $this->name . $subscript;
755 $lineHTML[] =
' <div class="input-group">';
756 $lineHTML[] = $this->
mkCompSelect($fieldPrefix .
'[comparison]', $conf[
'comparison'], $conf[
'negate'] ? 1 : 0);
757 $lineHTML[] =
' <div class="input-group-addon">';
758 $lineHTML[] =
' <input type="checkbox" class="checkbox t3js-submit-click"' . ($conf[
'negate'] ?
' checked' :
'') .
' name="' . htmlspecialchars($fieldPrefix) .
'[negate]' .
'">';
759 $lineHTML[] =
' </div>';
760 $lineHTML[] =
' </div>';
761 return implode(LF, $lineHTML);
777 if ($fieldSetup[
'type'] ===
'files') {
778 if ($conf[
'comparison'] === 66 || $conf[
'comparison'] === 67) {
779 $fileExtArray = explode(
',', $fieldSetup[
'allowed']);
780 natcasesort($fileExtArray);
781 foreach ($fileExtArray as $fileExt) {
783 $out[] =
'<option value="' . htmlspecialchars($fileExt) .
'" selected>.' . htmlspecialchars($fileExt) .
'</option>';
785 $out[] =
'<option value="' . htmlspecialchars($fileExt) .
'">.' . htmlspecialchars($fileExt) .
'</option>';
789 $d = dir(PATH_site . $fieldSetup[
'uploadfolder']);
790 while (
false !== ($entry = $d->read())) {
791 if ($entry ===
'.' || $entry ===
'..') {
794 $fileArray[] = $entry;
797 natcasesort($fileArray);
798 foreach ($fileArray as $fileName) {
800 $out[] =
'<option value="' . htmlspecialchars($fileName) .
'" selected>' . htmlspecialchars($fileName) .
'</option>';
802 $out[] =
'<option value="' . htmlspecialchars($fileName) .
'">' . htmlspecialchars($fileName) .
'</option>';
806 if ($fieldSetup[
'type'] ===
'multiple') {
807 foreach ($fieldSetup[
'items'] as $key => $val) {
808 if (substr($val[0], 0, 4) ===
'LLL:') {
809 $value = $languageService->sL($val[0]);
814 $out[] =
'<option value="' . htmlspecialchars($val[1]) .
'" selected>' . htmlspecialchars($value) .
'</option>';
816 $out[] =
'<option value="' . htmlspecialchars($val[1]) .
'">' . htmlspecialchars($value) .
'</option>';
820 if ($fieldSetup[
'type'] ===
'binary') {
821 foreach ($fieldSetup[
'items'] as $key => $val) {
822 if (substr($val[0], 0, 4) ===
'LLL:') {
823 $value = $languageService->sL($val[0]);
828 $out[] =
'<option value="' . pow(2, $key) .
'" selected>' . htmlspecialchars($value) .
'</option>';
830 $out[] =
'<option value="' . pow(2, $key) .
'">' . htmlspecialchars($value) .
'</option>';
834 if ($fieldSetup[
'type'] ===
'relation') {
837 $dontPrefixFirstTable = 0;
838 if ($fieldSetup[
'items']) {
839 foreach ($fieldSetup[
'items'] as $key => $val) {
840 if (substr($val[0], 0, 4) ===
'LLL:') {
841 $value = $languageService->sL($val[0]);
846 $out[] =
'<option value="' . htmlspecialchars($val[1]) .
'" selected>' . htmlspecialchars($value) .
'</option>';
848 $out[] =
'<option value="' . htmlspecialchars($val[1]) .
'">' . htmlspecialchars($value) .
'</option>';
852 if (stristr($fieldSetup[
'allowed'],
',')) {
853 $from_table_Arr = explode(
',', $fieldSetup[
'allowed']);
855 if (!$fieldSetup[
'prepend_tname']) {
858 while ($row = $databaseConnection->sql_fetch_assoc($checkres)) {
860 $checkContent = explode(
',', $row[$fieldName]);
861 foreach ($checkContent as $singleValue) {
862 if (!stristr($singleValue,
'_')) {
863 $dontPrefixFirstTable = 1;
868 if ($singleValue !==
'' && !stristr($singleValue,
'_')) {
869 $dontPrefixFirstTable = 1;
873 $databaseConnection->sql_free_result($checkres);
877 $from_table_Arr[0] = $fieldSetup[
'allowed'];
879 if ($fieldSetup[
'prepend_tname']) {
882 if ($fieldSetup[
'foreign_table']) {
883 $from_table_Arr[0] = $fieldSetup[
'foreign_table'];
886 $webMountPageTree =
'';
891 $labelFieldSelect = array();
892 foreach ($from_table_Arr as $from_table) {
893 $useSelectLabels =
false;
894 $useAltSelectLabels =
false;
895 if ($useTablePrefix && !$dontPrefixFirstTable && $counter != 1 || $counter === 1) {
896 $tablePrefix = $from_table .
'_';
899 if (is_array(
$GLOBALS[
'TCA'][$from_table])) {
900 $labelField =
$GLOBALS[
'TCA'][$from_table][
'ctrl'][
'label'];
901 $altLabelField =
$GLOBALS[
'TCA'][$from_table][
'ctrl'][
'label_alt'];
902 if (
$GLOBALS[
'TCA'][$from_table][
'columns'][$labelField][
'config'][
'items']) {
903 foreach (
$GLOBALS[
'TCA'][$from_table][
'columns'][$labelField][
'config'][
'items'] as $labelArray) {
904 if (substr($labelArray[0], 0, 4) ===
'LLL:') {
905 $labelFieldSelect[$labelArray[1]] = $languageService->sL($labelArray[0]);
907 $labelFieldSelect[$labelArray[1]] = $labelArray[0];
910 $useSelectLabels =
true;
912 if (
$GLOBALS[
'TCA'][$from_table][
'columns'][$altLabelField][
'config'][
'items']) {
913 foreach (
$GLOBALS[
'TCA'][$from_table][
'columns'][$altLabelField][
'config'][
'items'] as $altLabelArray) {
914 if (substr($altLabelArray[0], 0, 4) ===
'LLL:') {
915 $altLabelFieldSelect[$altLabelArray[1]] = $languageService->sL($altLabelArray[0]);
917 $altLabelFieldSelect[$altLabelArray[1]] = $altLabelArray[0];
920 $useAltSelectLabels =
true;
922 $altLabelFieldSelect = $altLabelField ?
',' . $altLabelField :
'';
923 $select_fields =
'uid,' . $labelField . $altLabelFieldSelect;
924 if (!$backendUserAuthentication->isAdmin() &&
$GLOBALS[
'TYPO3_CONF_VARS'][
'BE'][
'lockBeUserToDBmounts']) {
925 $webMounts = $backendUserAuthentication->returnWebmounts();
926 $perms_clause = $backendUserAuthentication->getPagePermsClause(1);
927 $webMountPageTreePrefix =
'';
928 foreach ($webMounts as $key => $val) {
929 if ($webMountPageTree) {
930 $webMountPageTreePrefix =
',';
932 $webMountPageTree .= $webMountPageTreePrefix . $this->
getTreeList($val, 999, ($begin = 0), $perms_clause);
934 if ($from_table ===
'pages') {
935 $where_clause =
'uid IN (' . $webMountPageTree .
') ';
936 if (!$module->MOD_SETTINGS[
'show_deleted']) {
940 $where_clause =
'pid IN (' . $webMountPageTree .
') ';
941 if (!$module->MOD_SETTINGS[
'show_deleted']) {
946 $where_clause =
'uid';
947 if (!$module->MOD_SETTINGS[
'show_deleted']) {
952 if (!$this->tableArray[$from_table]) {
953 $res = $databaseConnection->exec_SELECTquery($select_fields, $from_table, $where_clause, ($groupBy =
''), $orderBy, ($limit =
''));
955 while ($row = $databaseConnection->sql_fetch_assoc($res)) {
956 $this->tableArray[$from_table][] = $row;
958 $databaseConnection->sql_free_result($res);
961 foreach ($this->tableArray[$from_table] as $key => $val) {
962 if ($useSelectLabels) {
963 $outArray[$tablePrefix . $val[
'uid']] = htmlspecialchars($labelFieldSelect[$val[$labelField]]);
964 }
elseif ($val[$labelField]) {
965 $outArray[$tablePrefix . $val[
'uid']] = htmlspecialchars($val[$labelField]);
966 }
elseif ($useAltSelectLabels) {
967 $outArray[$tablePrefix . $val[
'uid']] = htmlspecialchars($altLabelFieldSelect[$val[$altLabelField]]);
969 $outArray[$tablePrefix . $val[
'uid']] = htmlspecialchars($val[$altLabelField]);
972 if ($module->MOD_SETTINGS[
'options_sortlabel'] && is_array($outArray)) {
973 natcasesort($outArray);
977 foreach ($outArray as $key2 => $val2) {
979 $out[] =
'<option value="' . htmlspecialchars($key2) .
'" selected>[' . htmlspecialchars($key2) .
'] ' . htmlspecialchars($val2) .
'</option>';
981 $out[] =
'<option value="' . htmlspecialchars($key2) .
'">[' . htmlspecialchars($key2) .
'] ' . htmlspecialchars($val2) .
'</option>';
985 return implode(LF, $out);
997 $indent =
'row-group';
998 if ($recursionLevel) {
999 $indent =
'row-group indent indent-' . (int)$recursionLevel;
1002 foreach ($codeArr as $k => $v) {
1003 $out[] =
'<div class="' . $indent .
'">';
1004 $out[] = $v[
'html'];
1006 if ($this->enableQueryParts) {
1008 $out[] = htmlspecialchars($v[
'query']);
1011 if (is_array($v[
'sub'])) {
1012 $out[] =
'<div class="' . $indent .
'">';
1013 $out[] = $this->
printCodeArray($v[
'sub'], ($recursionLevel + 1));
1019 return implode(LF, $out);
1032 return htmlspecialchars($str);
1048 $out[] =
'<select class="form-control from-control-operator' . ($submit ?
' t3js-submit-change' :
'') .
'" name="' . htmlspecialchars(
$name) .
'[operator]">';
1049 $out[] =
' <option value="AND"' . (!$op || $op ===
'AND' ?
' selected' :
'') .
'>' . htmlspecialchars($this->lang[
'AND']) .
'</option>';
1050 $out[] =
' <option value="OR"' . ($op ===
'OR' ?
' selected' :
'') .
'>' . htmlspecialchars($this->lang[
'OR']) .
'</option>';
1051 $out[] =
'</select>';
1053 $out[] =
'<input type="hidden" value="' . htmlspecialchars($op) .
'" name="' . htmlspecialchars(
$name) .
'[operator]">';
1055 return implode(LF, $out);
1069 $out[] =
'<select class="form-control t3js-submit-change" name="' . htmlspecialchars(
$name) .
'">';
1070 $out[] =
'<option value=""></option>';
1071 foreach ($this->fields as $key => $value) {
1073 $label = $this->fields[$key][
'label'];
1074 $out[] =
'<option value="' . htmlspecialchars($prepend . $key) .
'"' . ($key ===
$fieldName ?
' selected' :
'') .
'>' . htmlspecialchars($label) .
'</option>';
1077 $out[] =
'</select>';
1078 return implode(LF, $out);
1090 foreach ($this->fields as $key => $value) {
1110 $compOffSet = $comparison >> 5;
1112 for ($i = 32 * $compOffSet + $neg; $i < 32 * ($compOffSet + 1); $i += 2) {
1113 if ($first === -1) {
1116 if ($i >> 1 === $comparison >> 1) {
1133 $out[] =
'<div class="input-group">';
1134 $out[] =
' <div class="input-group-addon">';
1135 $out[] =
' <span class="input-group-btn">';
1137 $out[] =
' </span>';
1139 $out[] =
' <input type="text" class="form-control t3js-clearable" value="' . htmlspecialchars(
$fieldName) .
'" name="' . htmlspecialchars(
$name) .
'">';
1142 $out[] =
'<select class="form-control t3js-addfield" name="_fieldListDummy" size="5" data-field="' . htmlspecialchars(
$name) .
'">';
1143 foreach ($this->fields as $key => $value) {
1145 $label = $this->fields[$key][
'label'];
1146 $out[] =
'<option value="' . htmlspecialchars($key) .
'"' . ($key ===
$fieldName ?
' selected' :
'') .
'>' . htmlspecialchars($label) .
'</option>';
1149 $out[] =
'</select>';
1150 return implode(LF, $out);
1163 $out[] =
'<select class="form-control t3js-submit-change" name="' .
$name .
'">';
1164 $out[] =
'<option value=""></option>';
1165 foreach (
$GLOBALS[
'TCA'] as $tN => $value) {
1167 $out[] =
'<option value="' . htmlspecialchars($tN) .
'"' . ($tN === $cur ?
' selected' :
'') .
'>' . htmlspecialchars($this->
getLanguageService()->sl(
$GLOBALS[
'TCA'][$tN][
'ctrl'][
'title'])) .
'</option>';
1170 $out[] =
'</select>';
1171 return implode(LF, $out);
1184 $compOffSet = $comparison >> 5;
1186 $out[] =
'<select class="form-control t3js-submit-change" name="' .
$name .
'">';
1187 for ($i = 32 * $compOffSet + $neg; $i < 32 * ($compOffSet + 1); $i += 2) {
1188 if ($this->lang[
'comparison'][$i .
'_']) {
1189 $out[] =
'<option value="' . $i .
'"' . ($i >> 1 === $comparison >> 1 ?
' selected' :
'') .
'>' . htmlspecialchars($this->lang[
'comparison'][($i .
'_')]) .
'</option>';
1192 $out[] =
'</select>';
1193 return implode(LF, $out);
1205 while (is_array($arr)) {
1207 list($key, ) = each($arr);
1263 switch ($conf[
'type']) {
1265 $qs .= LF . $pad . trim($conf[
'operator']) .
' (' . $this->
getQuery(
$queryConfig[$key][
'nl'], ($pad .
' ')) . LF . $pad .
')';
1289 $prefix = $this->enablePrefix ? $this->table .
'.' :
'';
1292 $qs .= trim($conf[
'operator'] ?:
'AND') .
' ';
1294 $qsTmp = str_replace(
'#FIELD#', $prefix . trim(substr($conf[
'type'], 6)), $this->compSQL[$conf[
'comparison']]);
1296 if ($conf[
'comparison'] === 68 || $conf[
'comparison'] === 69) {
1297 $inputVal = explode(
',', $inputVal);
1298 foreach ($inputVal as $key => $fileName) {
1299 $inputVal[$key] =
'\'' . $fileName .
'\'';
1301 $inputVal = implode(
',', $inputVal);
1302 $qsTmp = str_replace(
'#VALUE#', $inputVal, $qsTmp);
1303 }
elseif ($conf[
'comparison'] === 162 || $conf[
'comparison'] === 163) {
1304 $inputValArray = explode(
',', $inputVal);
1306 foreach ($inputValArray as $fileName) {
1307 $inputVal += (int)$fileName;
1309 $qsTmp = str_replace(
'#VALUE#', $inputVal, $qsTmp);
1311 $qsTmp = str_replace(
'#VALUE#', $databaseConnection->quoteStr($inputVal, $this->table), $qsTmp);
1313 if ($conf[
'comparison'] === 37 || $conf[
'comparison'] === 36 || $conf[
'comparison'] === 66 || $conf[
'comparison'] === 67 || $conf[
'comparison'] === 100 || $conf[
'comparison'] === 101) {
1316 $qsTmp = str_replace(
'#VALUE1#', $databaseConnection->quoteStr($inputVal, $this->table), $qsTmp);
1318 $qs .= trim($qsTmp);
1331 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)) {
1332 $inputVal = $conf[
'inputValue' . $suffix];
1333 }
elseif ($conf[
'comparison'] === 39 || $conf[
'comparison'] === 38) {
1336 }
elseif ($conf[
'comparison'] === 68 || $conf[
'comparison'] === 69 || $conf[
'comparison'] === 162 || $conf[
'comparison'] === 163) {
1338 if (is_array($conf[
'inputValue' . $suffix])) {
1339 $inputVal = implode(
',', $conf[
'inputValue' . $suffix]);
1340 }
elseif ($conf[
'inputValue' . $suffix]) {
1341 $inputVal = $conf[
'inputValue' . $suffix];
1346 $inputVal = doubleval($conf[
'inputValue' . $suffix]);
1369 return '<button class="btn btn-default" title="Update" name="just_update"><i class="fa fa-refresh fa-fw"></i></button>';
1389 public function makeSelectorTable($modSettings, $enableList =
'table,fields,query,group,order,limit')
1392 $enableArr = explode(
',', $enableList);
1395 if (in_array(
'table', $enableArr) && !$backendUserAuthentication->userTS[
'mod.'][
'dbint.'][
'disableSelectATable']) {
1396 $out[] =
'<div class="form-group">';
1397 $out[] =
' <label for="SET[queryTable]">Select a table:</label>';
1398 $out[] = $this->
mkTableSelect(
'SET[queryTable]', $this->table);
1407 $this->extFieldLists[
'queryLimit'] = $modSettings[
'queryLimit'];
1408 if (!$this->extFieldLists[
'queryLimit']) {
1409 $this->extFieldLists[
'queryLimit'] = 100;
1413 $this->limitBegin = $parts[0];
1414 $this->limitLength = $parts[1];
1416 $this->limitLength = $this->extFieldLists[
'queryLimit'];
1418 $this->extFieldLists[
'queryLimit'] = implode(
',', array_slice($parts, 0, 2));
1420 if ($this->extFieldLists[
'queryOrder']) {
1421 $descParts = explode(
',', $modSettings[
'queryOrderDesc'] .
',' . $modSettings[
'queryOrder2Desc']);
1422 $orderParts = explode(
',', $this->extFieldLists[
'queryOrder']);
1424 foreach ($orderParts as $kk => $vv) {
1425 $reList[] = $vv . ($descParts[$kk] ?
' DESC' :
'');
1427 $this->extFieldLists[
'queryOrder_SQL'] = implode(
',', $reList);
1430 $this->
procesData($modSettings[
'queryConfig'] ? unserialize($modSettings[
'queryConfig']) :
'');
1432 $this->enableQueryParts = (bool)$modSettings[
'search_query_smallparts'];
1435 if (in_array(
'fields', $enableArr) && !$backendUserAuthentication->userTS[
'mod.'][
'dbint.'][
'disableSelectFields']) {
1436 $out[] =
'<div class="form-group form-group-with-button-addon">';
1437 $out[] =
' <label for="SET[queryFields]">Select fields:</label>';
1441 if (in_array(
'query', $enableArr) && !$backendUserAuthentication->userTS[
'mod.'][
'dbint.'][
'disableMakeQuery']) {
1442 $out[] =
'<div class="form-group">';
1443 $out[] =
' <label>Make Query:</label>';
1444 $out[] = $queryCode;
1447 if (in_array(
'group', $enableArr) && !$backendUserAuthentication->userTS[
'mod.'][
'dbint.'][
'disableGroupBy']) {
1448 $out[] =
'<div class="form-group form-inline">';
1449 $out[] =
' <label for="SET[queryGroup]">Group By:</label>';
1450 $out[] = $this->
mkTypeSelect(
'SET[queryGroup]', $this->extFieldLists[
'queryGroup'],
'');
1453 if (in_array(
'order', $enableArr) && !$backendUserAuthentication->userTS[
'mod.'][
'dbint.'][
'disableOrderBy']) {
1455 $orderByArr = explode(
',', $this->extFieldLists[
'queryOrder']);
1457 $orderBy[] = $this->
mkTypeSelect(
'SET[queryOrder]', $orderByArr[0],
'');
1458 $orderBy[] =
'<div class="checkbox">';
1459 $orderBy[] =
' <label for="checkQueryOrderDesc">';
1460 $orderBy[] =
BackendUtility::getFuncCheck($module->id,
'SET[queryOrderDesc]', $modSettings[
'queryOrderDesc'],
'',
'',
'id="checkQueryOrderDesc"') .
' Descending';
1461 $orderBy[] =
' </label>';
1462 $orderBy[] =
'</div>';
1464 if ($orderByArr[0]) {
1465 $orderBy[] = $this->
mkTypeSelect(
'SET[queryOrder2]', $orderByArr[1],
'');
1466 $orderBy[] =
'<div class="checkbox">';
1467 $orderBy[] =
' <label for="checkQueryOrder2Desc">';
1468 $orderBy[] =
BackendUtility::getFuncCheck($module->id,
'SET[queryOrder2Desc]', $modSettings[
'queryOrder2Desc'],
'',
'',
'id="checkQueryOrder2Desc"') .
' Descending';
1469 $orderBy[] =
' </label>';
1470 $orderBy[] =
'</div>';
1472 $out[] =
'<div class="form-group form-inline">';
1473 $out[] =
' <label>Order By:</label>';
1474 $out[] = implode(LF, $orderBy);
1477 if (in_array(
'limit', $enableArr) && !$backendUserAuthentication->userTS[
'mod.'][
'dbint.'][
'disableLimit']) {
1479 $limit[] =
'<div class="input-group">';
1480 $limit[] =
' <div class="input-group-addon">';
1481 $limit[] =
' <span class="input-group-btn">';
1483 $limit[] =
' </span>';
1484 $limit[] =
' </div>';
1485 $limit[] =
' <input type="text" class="form-control" value="' . htmlspecialchars($this->extFieldLists[
'queryLimit']) .
'" name="SET[queryLimit]" id="queryLimit">';
1486 $limit[] =
'</div>';
1488 $prevLimit = $this->limitBegin - $this->limitLength < 0 ? 0 : $this->limitBegin -
$this->limitLength;
1492 if ($this->limitBegin) {
1493 $prevButton =
'<input type="button" class="btn btn-default" value="previous ' . htmlspecialchars($this->limitLength) .
'" data-value="' . htmlspecialchars($prevLimit .
',' . $this->limitLength) .
'">';
1495 if (!$this->limitLength) {
1496 $this->limitLength = 100;
1500 if ($nextLimit < 0) {
1504 $nextButton =
'<input type="button" class="btn btn-default" value="next ' . htmlspecialchars($this->limitLength) .
'" data-value="' . htmlspecialchars($nextLimit .
',' . $this->limitLength) .
'">';
1507 $out[] =
'<div class="form-group form-group-with-button-addon">';
1508 $out[] =
' <label>Limit:</label>';
1509 $out[] =
' <div class="form-inline">';
1510 $out[] = implode(LF, $limit);
1511 $out[] =
' <div class="input-group">';
1512 $out[] =
' <div class="btn-group t3js-limit-submit">';
1513 $out[] = $prevButton;
1514 $out[] = $nextButton;
1516 $out[] =
' <div class="btn-group t3js-limit-submit">';
1517 $out[] =
' <input type="button" class="btn btn-default" data-value="10" value="10">';
1518 $out[] =
' <input type="button" class="btn btn-default" data-value="20" value="20">';
1519 $out[] =
' <input type="button" class="btn btn-default" data-value="50" value="50">';
1520 $out[] =
' <input type="button" class="btn btn-default" data-value="100" value="100">';
1527 $out[] = $this->
JSbottom($this->formName);
1528 return implode(LF, $out);
1542 $depth = (int)$depth;
1543 $begin = (int)$begin;
1553 if ($id && $depth > 0) {
1555 $res = $databaseConnection->exec_SELECTquery(
'uid',
'pages',
'pid=' . $id .
' ' .
BackendUtility::deleteClause(
'pages') .
' AND ' . $perms_clause);
1556 while ($row = $databaseConnection->sql_fetch_assoc($res)) {
1558 $theList .=
',' . $row[
'uid'];
1561 $theList .= $this->
getTreeList($row[
'uid'], $depth - 1, $begin - 1, $perms_clause);
1564 $databaseConnection->sql_free_result($res);
1580 $qString = $this->
getQuery($this->queryConfig);
1582 $qString =
'(' . $qString .
')';
1583 if (!$backendUserAuthentication->isAdmin() &&
$GLOBALS[
'TYPO3_CONF_VARS'][
'BE'][
'lockBeUserToDBmounts']) {
1584 $webMounts = $backendUserAuthentication->returnWebmounts();
1585 $perms_clause = $backendUserAuthentication->getPagePermsClause(1);
1586 $webMountPageTree =
'';
1587 $webMountPageTreePrefix =
'';
1588 foreach ($webMounts as $key => $val) {
1589 if ($webMountPageTree) {
1590 $webMountPageTreePrefix =
',';
1592 $webMountPageTree .= $webMountPageTreePrefix . $this->
getTreeList($val, 999, ($begin = 0), $perms_clause);
1594 if ($this->table ===
'pages') {
1595 $qString .=
' AND uid IN (' . $webMountPageTree .
')';
1597 $qString .=
' AND pid IN (' . $webMountPageTree .
')';
1601 if (!$this->
getModule()->MOD_SETTINGS[
'show_deleted']) {
1604 $query = $this->
getDatabaseConnection()->SELECTquery(
$fieldList, $this->table, $qString, trim($this->extFieldLists[
'queryGroup']), $this->extFieldLists[
'queryOrder'] ? trim($this->extFieldLists[
'queryOrder_SQL']) :
'', $this->extFieldLists[
'queryLimit']);
1619 if ($this->extJSCODE) {
1620 $out[] =
'<script language="javascript" type="text/javascript">';
1622 $out[] =
'</script>';
1624 return implode(LF, $out);
1636 $dateFormat =
$GLOBALS[
'TYPO3_CONF_VARS'][
'SYS'][
'USdateFormat'] ?
'%H:%M %m-%d-%Y' :
'%H:%M %d-%m-%Y';
1637 $value = ($timestamp > 0 ? strftime($dateFormat, $timestamp) :
'');
1640 $html[] =
'<div class="input-group" id="' . $id .
'-wrapper">';
1641 $html[] =
' <input data-formengine-input-name="' . htmlspecialchars(
$name) .
'" value="' . $value .
'" class="form-control t3js-datetimepicker t3js-clearable" data-date-type="' . htmlspecialchars($type) .
'" data-date-offset="0" type="text" id="' . $id .
'">';
1642 $html[] =
' <input name="' . htmlspecialchars(
$name) .
'" value="' . (int)$timestamp .
'" type="hidden">';
1643 $html[] =
' <span class="input-group-btn">';
1644 $html[] =
' <label class="btn btn-default" for="' . $id .
'">';
1645 $html[] =
' <span class="fa fa-calendar"></span>';
1646 $html[] =
' </label>';
1647 $html[] =
' </span>';
1649 return implode(LF, $html);