Bug #17796 ยป bug_6722.diff
class.db_list.inc.ori Thu Nov 15 14:55:03 2007 | ||
---|---|---|
* @param string Table, in which the fields are being searched.
|
||
* @return string Returns part of WHERE-clause for searching, if applicable.
|
||
*/
|
||
function makeSearchString($table) { // MOD 12.10.2007 by markus.kappe@dix.at (handle search for date/time)
|
||
function makeSearchString($table) {
|
||
global $TCA;
|
||
|
||
// Make query, only if table is valid and a search string is actually defined:
|
||
if ($TCA[$table] && $this->searchString) {
|
||
$dateTimeFormat = '%d.%m.%Y %H:%i'; // understandable date/time format by the DB function FROM_UNIXTIME
|
||
// maybe the $GLOBALS['TYPO3_CONF_VARS']['SYS']['ddmmyy'] can be reformatted and used?
|
||
$masked_dateTimeFormat = preg_replace('/%/', '%%', $dateTimeFormat); // modify so that string can be used in sprintf
|
||
// Make query, only if table is valid and a search string is actually defined:
|
||
if ($TCA[$table] && $this->searchString) {
|
||
// Loading full table description - we need to traverse fields:
|
||
t3lib_div::loadTCA($table);
|
||
... | ... | |
// Initialize field array:
|
||
$sfields=array();
|
||
$sfields[]='uid'; // Adding "uid" by default.
|
||
$dateFields = array();
|
||
$qParts = array();
|
||
// Traverse the configured columns and add all columns that can be searched:
|
||
foreach($TCA[$table]['columns'] as $fieldName => $info) {
|
||
if ($info['config']['type']=='text' || ($info['config']['type']=='input' && !ereg('date|time|int',$info['config']['eval']))) {
|
||
$sfields[]=$fieldName;
|
||
} elseif ($info['config']['type']=='input' && ereg('date|time',$info['config']['eval'])) {
|
||
$dateFields[]=$fieldName;
|
||
}
|
||
}
|
||
$likeNormal = ' LIKE \'%'.$GLOBALS['TYPO3_DB']->quoteStr($this->searchString, $table).'%\''; // Free-text searching...
|
||
$likeDate = " FROM_UNIXTIME(%s, '$masked_dateTimeFormat')".' LIKE \'%%'.$GLOBALS['TYPO3_DB']->quoteStr($this->searchString, $table).'%%\'';
|
||
// If search-fields were defined (and there always are) we create the query:
|
||
if (count($sfields)) {
|
||
$like = ' LIKE \'%'.$GLOBALS['TYPO3_DB']->quoteStr($this->searchString, $table).'%\''; // Free-text searching...
|
||
$queryPart = ' AND ('.implode($like.' OR ',$sfields).$like.')';
|
||
foreach ($sfields as $sfield) {
|
||
$qParts[] = $sfield.$likeNormal;
|
||
}
|
||
foreach ($dateFields as $sfield) {
|
||
$qParts[] = sprintf($likeDate, $sfield);
|
||
// Return query:
|
||
return $queryPart;
|
||
}
|
||
$queryPart = ' AND ('.implode(' OR ',$qParts).') ';
|
||
return $queryPart;
|
||
}
|
||
}
|
||
... | ... | |
if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['typo3/class.db_list.inc']) {
|
||
include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['typo3/class.db_list.inc']);
|
||
}
|
||
?>
|
||
?>
|