2 /***************************************************************
5 * (c) 1999-2010 Kasper Skaarhoj (kasperYYYY@typo3.com)
6 * (c) 2006-2010 Karsten Dambekalns <karsten@typo3.org>
9 * This script is part of the TYPO3 project. The TYPO3 project is
10 * free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
15 * The GNU General Public License can be found at
16 * http://www.gnu.org/copyleft/gpl.html.
17 * A copy is found in the textfile GPL.txt and important notices to the license
18 * from the author is found in LICENSE.txt distributed with these scripts.
21 * This script is distributed in the hope that it will be useful,
22 * but WITHOUT ANY WARRANTY; without even the implied warranty of
23 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24 * GNU General Public License for more details.
26 * This copyright notice MUST APPEAR in all copies of the script!
27 ***************************************************************/
29 * Include file extending localRecordList for DBAL compatibility
31 * $Id: class.ux_db_list_extra.php 25913 2009-10-27 14:20:41Z xperseguers $
33 * @author Kasper Skaarhoj <kasperYYYY@typo3.com>
34 * @author Karsten Dambekalns <k.dambekalns@fishfarm.de>
38 * Child class for rendering of Web > List (not the final class. see class.db_list_extra)
40 * @author Kasper Skaarhoj <kasperYYYY@typo3.com>
41 * @author Karsten Dambekalns <k.dambekalns@fishfarm.de>
45 class ux_localRecordList
extends localRecordList
{
48 * Creates part of query for searching after a word ($this->searchString) fields in input table
50 * DBAL specific: no LIKE for numeric fields, in this case "uid" (breaks on Oracle)
51 * no LIKE for BLOB fields, skip
53 * @param string Table, in which the fields are being searched.
54 * @return string Returns part of WHERE-clause for searching, if applicable.
56 function makeSearchString($table) {
57 // Make query, only if table is valid and a search string is actually defined:
58 if ($GLOBALS['TCA'][$table] && $this->searchString
) {
60 // Loading full table description - we need to traverse fields:
61 t3lib_div
::loadTCA($table);
63 // Initialize field array:
67 // add the uid only if input is numeric, cast to int
68 if (is_numeric($this->searchString
)) {
69 $queryPart = ' AND (uid=' . (int)$this->searchString
. ' OR ';
71 $queryPart = ' AND (';
74 if ($GLOBALS['TYPO3_DB']->runningADOdbDriver('oci8')) {
75 foreach ($GLOBALS['TCA'][$table]['columns'] as $fieldName => $info) {
76 if ($GLOBALS['TYPO3_DB']->cache_fieldType
[$table][$fieldName]['metaType'] === 'B') {
77 // skip, LIKE is not supported on BLOB columns...
78 } elseif ($info['config']['type'] === 'text' ||
($info['config']['type'] === 'input' && !preg_match('/date|time|int/', $info['config']['eval']))) {
79 $queryPart .= $or . $fieldName . ' LIKE \'%' . $GLOBALS['TYPO3_DB']->quoteStr($this->searchString
, $table) . '%\'';
84 // Traverse the configured columns and add all columns that can be searched
85 foreach ($GLOBALS['TCA'][$table]['columns'] as $fieldName => $info) {
86 if ($info['config']['type'] === 'text' ||
($info['config']['type'] === 'input' && !preg_match('/date|time|int/', $info['config']['eval']))) {
87 $sfields[] = $fieldName;
91 // If search-fields were defined (and there always are) we create the query:
92 if (count($sfields)) {
93 $like = ' LIKE \'%'.$GLOBALS['TYPO3_DB']->quoteStr($this->searchString
, $table) . '%\''; // Free-text
94 $queryPart .= implode($like . ' OR ', $sfields) . $like;
99 return $queryPart . ')';
105 if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE
]['XCLASS']['ext/dbal/class.ux_db_list_extra.php']) {
106 include_once($TYPO3_CONF_VARS[TYPO3_MODE
]['XCLASS']['ext/dbal/class.ux_db_list_extra.php']);