TYPO3 API  SVNRelease
class.ux_db_list_extra.php
Go to the documentation of this file.
00001 <?php
00002 /***************************************************************
00003 *  Copyright notice
00004 *
00005 *  (c) 1999-2009 Kasper Skårhøj (kasperYYYY@typo3.com)
00006 *  (c) 2006-2009 Karsten Dambekalns <karsten@typo3.org>
00007 *  All rights reserved
00008 *
00009 *  This script is part of the TYPO3 project. The TYPO3 project is
00010 *  free software; you can redistribute it and/or modify
00011 *  it under the terms of the GNU General Public License as published by
00012 *  the Free Software Foundation; either version 2 of the License, or
00013 *  (at your option) any later version.
00014 *
00015 *  The GNU General Public License can be found at
00016 *  http://www.gnu.org/copyleft/gpl.html.
00017 *  A copy is found in the textfile GPL.txt and important notices to the license
00018 *  from the author is found in LICENSE.txt distributed with these scripts.
00019 *
00020 *
00021 *  This script is distributed in the hope that it will be useful,
00022 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00023 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00024 *  GNU General Public License for more details.
00025 *
00026 *  This copyright notice MUST APPEAR in all copies of the script!
00027 ***************************************************************/
00028 /**
00029  * Include file extending localRecordList for DBAL compatibility
00030  *
00031  * $Id: class.ux_db_list_extra.php 40828 2010-12-05 14:55:53Z xperseguers $
00032  *
00033  * @author  Kasper Skårhøj <kasperYYYY@typo3.com>
00034  * @author  Karsten Dambekalns <k.dambekalns@fishfarm.de>
00035  */
00036 
00037 /**
00038  * Child class for rendering of Web > List (not the final class. see class.db_list_extra)
00039  *
00040  * @author  Kasper Skårhøj <kasperYYYY@typo3.com>
00041  * @author  Karsten Dambekalns <k.dambekalns@fishfarm.de>
00042  * @package TYPO3
00043  * @subpackage DBAL
00044  */
00045 class ux_localRecordList extends localRecordList {
00046 
00047     /**
00048      * Creates part of query for searching after a word ($this->searchString) fields in input table
00049      *
00050      * DBAL specific: no LIKE for numeric fields, in this case "uid" (breaks on Oracle)
00051      *                no LIKE for BLOB fields, skip
00052      *
00053      * @param   string      Table, in which the fields are being searched.
00054      * @return  string      Returns part of WHERE-clause for searching, if applicable.
00055      */
00056     function makeSearchString($table) {
00057             // Make query, only if table is valid and a search string is actually defined:
00058         if ($GLOBALS['TCA'][$table] && $this->searchString) {
00059 
00060                 // Loading full table description - we need to traverse fields:
00061             t3lib_div::loadTCA($table);
00062 
00063                 // Initialize field array:
00064             $sfields = array();
00065             $or = '';
00066 
00067                 // add the uid only if input is numeric, cast to int
00068             if (is_numeric($this->searchString)) {
00069                 $queryPart = ' AND (uid=' . (int)$this->searchString . ' OR ';
00070             } else {
00071                 $queryPart = ' AND (';
00072             }
00073 
00074             if ($GLOBALS['TYPO3_DB']->runningADOdbDriver('oci8')) {
00075                 foreach ($GLOBALS['TCA'][$table]['columns'] as $fieldName => $info) {
00076                     if ($GLOBALS['TYPO3_DB']->cache_fieldType[$table][$fieldName]['metaType'] === 'B') {
00077                         // skip, LIKE is not supported on BLOB columns...
00078                     } elseif ($info['config']['type'] === 'text' || ($info['config']['type'] === 'input' && !preg_match('/date|time|int/', $info['config']['eval']))) {
00079                         $queryPart .= $or . $fieldName . ' LIKE \'%' . $GLOBALS['TYPO3_DB']->quoteStr($this->searchString, $table) . '%\'';
00080                         $or = ' OR ';
00081                     }
00082                 }
00083             } else {
00084                     // Traverse the configured columns and add all columns that can be searched
00085                 foreach ($GLOBALS['TCA'][$table]['columns'] as $fieldName => $info) {
00086                     if ($info['config']['type'] === 'text' || ($info['config']['type'] === 'input' && !preg_match('/date|time|int/', $info['config']['eval']))) {
00087                         $sfields[] = $fieldName;
00088                     }
00089                 }
00090 
00091                     // If search-fields were defined (and there always are) we create the query:
00092                 if (count($sfields)) {
00093                     $like = ' LIKE \'%'.$GLOBALS['TYPO3_DB']->quoteStr($this->searchString, $table) . '%\'';        // Free-text
00094                     $queryPart .= implode($like . ' OR ', $sfields) . $like;
00095                 }
00096             }
00097 
00098                 // Return query:
00099             return $queryPart . ')';
00100         }
00101     }
00102 }
00103 
00104 
00105 if (defined('TYPO3_MODE') && isset($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['XCLASS']['ext/dbal/class.ux_db_list_extra.php'])) {
00106     include_once($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['XCLASS']['ext/dbal/class.ux_db_list_extra.php']);
00107 }
00108 
00109 ?>