[BUGFIX] ext:dbal Usage of dropped constant TYPO3_db
[Packages/TYPO3.CMS.git] / typo3 / sysext / dbal / Classes / RecordList / DatabaseRecordList.php
1 <?php
2 namespace TYPO3\CMS\Dbal\RecordList;
3
4 /*
5 * This file is part of the TYPO3 CMS project.
6 *
7 * It is free software; you can redistribute it and/or modify it under
8 * the terms of the GNU General Public License, either version 2
9 * of the License, or any later version.
10 *
11 * For the full copyright and license information, please read the
12 * LICENSE.txt file that was distributed with this source code.
13 *
14 * The TYPO3 project - inspiring people to share!
15 */
16
17 /**
18 * Child class for rendering of Web > List (not the final class)
19 */
20 class DatabaseRecordList extends \TYPO3\CMS\Recordlist\RecordList\DatabaseRecordList
21 {
22 /**
23 * Creates part of query for searching after a word ($this->searchString) fields in input table
24 *
25 * DBAL specific: no LIKE for numeric fields, in this case "uid" (breaks on Oracle)
26 * no LIKE for BLOB fields, skip
27 *
28 * @param string $table, in which the fields are being searched.
29 * @param int $currentPid argument not used in this method, only available for compatibility to parent class
30 * @return string Returns part of WHERE-clause for searching, if applicable.
31 */
32 public function makeSearchString($table, $currentPid = -1)
33 {
34 // Make query, only if table is valid and a search string is actually defined:
35 if ($GLOBALS['TCA'][$table] && $this->searchString) {
36 // Initialize field array:
37 $sfields = array();
38 $or = '';
39 // add the uid only if input is numeric, cast to int
40 if (is_numeric($this->searchString)) {
41 $queryPart = ' AND (uid=' . (int)$this->searchString . ' OR ';
42 } else {
43 $queryPart = ' AND (';
44 }
45 if ($GLOBALS['TYPO3_DB']->runningADOdbDriver('oci8')) {
46 foreach ($GLOBALS['TCA'][$table]['columns'] as $fieldName => $info) {
47 if ($GLOBALS['TYPO3_DB']->cache_fieldType[$table][$fieldName]['metaType'] === 'B') {
48 } elseif ($info['config']['type'] === 'text' || $info['config']['type'] === 'input' && !preg_match('/date|time|int/', $info['config']['eval'])) {
49 $queryPart .= $or . $fieldName . ' LIKE \'%' . $GLOBALS['TYPO3_DB']->quoteStr($this->searchString, $table) . '%\'';
50 $or = ' OR ';
51 }
52 }
53 } else {
54 // Traverse the configured columns and add all columns that can be searched
55 foreach ($GLOBALS['TCA'][$table]['columns'] as $fieldName => $info) {
56 if ($info['config']['type'] === 'text' || $info['config']['type'] === 'input' && !preg_match('/date|time|int/', $info['config']['eval'])) {
57 $sfields[] = $fieldName;
58 }
59 }
60 // If search-fields were defined (and there always are) we create the query:
61 if (!empty($sfields)) {
62 $like = ' LIKE \'%' . $GLOBALS['TYPO3_DB']->quoteStr($this->searchString, $table) . '%\'';
63 // Free-text
64 $queryPart .= implode(($like . ' OR '), $sfields) . $like;
65 }
66 }
67 // Return query:
68 return $queryPart . ')';
69 }
70 }
71 }