TYPO3  7.6
dbal/Classes/RecordList/DatabaseRecordList.php
Go to the documentation of this file.
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 
20 class DatabaseRecordList extends \TYPO3\CMS\Recordlist\RecordList\DatabaseRecordList
21 {
31  public function makeSearchString($table)
32  {
33  // Make query, only if table is valid and a search string is actually defined:
34  if ($GLOBALS['TCA'][$table] && $this->searchString) {
35  // Initialize field array:
36  $sfields = array();
37  $or = '';
38  // add the uid only if input is numeric, cast to int
39  if (is_numeric($this->searchString)) {
40  $queryPart = ' AND (uid=' . (int)$this->searchString . ' OR ';
41  } else {
42  $queryPart = ' AND (';
43  }
44  if ($GLOBALS['TYPO3_DB']->runningADOdbDriver('oci8')) {
45  foreach ($GLOBALS['TCA'][$table]['columns'] as $fieldName => $info) {
46  if ($GLOBALS['TYPO3_DB']->cache_fieldType[$table][$fieldName]['metaType'] === 'B') {
47  } elseif ($info['config']['type'] === 'text' || $info['config']['type'] === 'input' && !preg_match('/date|time|int/', $info['config']['eval'])) {
48  $queryPart .= $or . $fieldName . ' LIKE \'%' . $GLOBALS['TYPO3_DB']->quoteStr($this->searchString, $table) . '%\'';
49  $or = ' OR ';
50  }
51  }
52  } else {
53  // Traverse the configured columns and add all columns that can be searched
54  foreach ($GLOBALS['TCA'][$table]['columns'] as $fieldName => $info) {
55  if ($info['config']['type'] === 'text' || $info['config']['type'] === 'input' && !preg_match('/date|time|int/', $info['config']['eval'])) {
56  $sfields[] = $fieldName;
57  }
58  }
59  // If search-fields were defined (and there always are) we create the query:
60  if (!empty($sfields)) {
61  $like = ' LIKE \'%' . $GLOBALS['TYPO3_DB']->quoteStr($this->searchString, $table) . '%\'';
62  // Free-text
63  $queryPart .= implode(($like . ' OR '), $sfields) . $like;
64  }
65  }
66  // Return query:
67  return $queryPart . ')';
68  }
69  }
70 }