diff --git a/t3lib/stddb/tables.php b/t3lib/stddb/tables.php index d1df1a3..d14c06e 100644 --- a/t3lib/stddb/tables.php +++ b/t3lib/stddb/tables.php @@ -179,6 +179,7 @@ $TCA['pages'] = array( '255' => 'recycler.gif', ), 'dynamicConfigFile' => 'T3LIB:tbl_pages.php', + 'searchFields' => 'title,alias,nav_title,subtitle,url,keywords,description,abstract,author,author_email', ) ); @@ -221,7 +222,8 @@ $TCA['be_users'] = array( 'useColumnsForDefaultValues' => 'usergroup,lockToDomain,options,db_mountpoints,file_mountpoints,fileoper_perms,userMods', 'dividers2tabs' => TRUE, 'dynamicConfigFile' => 'T3LIB:tbl_be.php', - 'versioningWS_alwaysAllowLiveEdit' => TRUE + 'versioningWS_alwaysAllowLiveEdit' => TRUE, + 'searchFields' => 'username,email,realName', ) ); @@ -256,7 +258,8 @@ $TCA['be_groups'] = array( 'useColumnsForDefaultValues' => 'lockToDomain, fileoper_perms', 'dividers2tabs' => TRUE, 'dynamicConfigFile' => 'T3LIB:tbl_be.php', - 'versioningWS_alwaysAllowLiveEdit' => TRUE + 'versioningWS_alwaysAllowLiveEdit' => TRUE, + 'searchFields' => 'title', ) ); @@ -281,7 +284,8 @@ $TCA['sys_filemounts'] = array( 'iconfile' => '_icon_ftp.gif', 'useColumnsForDefaultValues' => 'path,base', 'dynamicConfigFile' => 'T3LIB:tbl_be.php', - 'versioningWS_alwaysAllowLiveEdit' => TRUE + 'versioningWS_alwaysAllowLiveEdit' => TRUE, + 'searchFields' => 'title,path', ) ); diff --git a/t3lib/stddb/tbl_be.php b/t3lib/stddb/tbl_be.php index 920463d..07fa886 100644 --- a/t3lib/stddb/tbl_be.php +++ b/t3lib/stddb/tbl_be.php @@ -49,7 +49,10 @@ $TCA['be_users'] = array( 'type' => 'input', 'size' => '20', 'max' => '50', - 'eval' => 'nospace,lower,unique,required' + 'eval' => 'nospace,lower,unique,required', + 'search' => array( + 'nocase' + ), ) ), 'password' => array( @@ -194,7 +197,10 @@ $TCA['be_users'] = array( 'type' => 'input', 'size' => '20', 'eval' => 'trim', - 'max' => '80' + 'max' => '80', + 'search' => array( + 'nocase' + ), ) ), 'disable' => array( @@ -423,7 +429,10 @@ $TCA['be_groups'] = array( 'type' => 'input', 'size' => '25', 'max' => '50', - 'eval' => 'trim,required' + 'eval' => 'trim,required', + 'search' => array( + 'nocase' + ), ) ), 'db_mountpoints' => array( @@ -704,7 +713,10 @@ $TCA['sys_filemounts'] = array( 'type' => 'input', 'size' => '20', 'max' => '30', - 'eval' => 'required,trim' + 'eval' => 'required,trim', + 'search' => array( + 'nocase' + ), ) ), 'path' => array( diff --git a/t3lib/stddb/tbl_pages.php b/t3lib/stddb/tbl_pages.php index e8f7241..ac456d0 100644 --- a/t3lib/stddb/tbl_pages.php +++ b/t3lib/stddb/tbl_pages.php @@ -82,6 +82,9 @@ $TCA['pages'] = array( 'size' => '50', 'max' => '255', 'eval' => 'trim,required', + 'search' => array( + 'nocase' + ), ), ), 'TSconfig' => array( @@ -288,6 +291,9 @@ $TCA['pages'] = array( 'size' => '50', 'max' => '255', 'eval' => 'trim', + 'search' => array( + 'nocase' + ), ), ), 'nav_hide' => array( @@ -310,6 +316,9 @@ $TCA['pages'] = array( 'size' => '50', 'max' => '255', 'eval' => '', + 'search' => array( + 'nocase' + ), ), ), 'target' => array( @@ -331,6 +340,9 @@ $TCA['pages'] = array( 'max' => '32', 'eval' => 'nospace,alphanum_x,lower,unique', 'softref' => 'notify', + 'search' => array( + 'nocase' + ), ), ), 'url' => array( @@ -341,6 +353,9 @@ $TCA['pages'] = array( 'max' => '255', 'eval' => 'trim,required', 'softref' => 'url', + 'search' => array( + 'nocase' + ), ), ), 'urltype' => array( @@ -556,6 +571,9 @@ $TCA['pages'] = array( 'type' => 'text', 'cols' => '40', 'rows' => '3', + 'search' => array( + 'nocase' + ), ), ), 'description' => array( @@ -565,6 +583,9 @@ $TCA['pages'] = array( 'type' => 'text', 'cols' => '40', 'rows' => '3', + 'search' => array( + 'nocase' + ), ), ), 'abstract' => array( @@ -574,6 +595,9 @@ $TCA['pages'] = array( 'type' => 'text', 'cols' => '40', 'rows' => '3', + 'search' => array( + 'nocase' + ), ), ), 'author' => array( @@ -584,6 +608,9 @@ $TCA['pages'] = array( 'size' => '23', 'eval' => 'trim', 'max' => '80', + 'search' => array( + 'nocase' + ), ), ), 'author_email' => array( @@ -595,6 +622,9 @@ $TCA['pages'] = array( 'eval' => 'trim', 'max' => '80', 'softref' => 'email[subst]', + 'search' => array( + 'nocase' + ), ), ), 'media' => array( diff --git a/typo3/class.db_list.inc b/typo3/class.db_list.inc index 40fc778..85ae97d 100644 --- a/typo3/class.db_list.inc +++ b/typo3/class.db_list.inc @@ -189,7 +189,7 @@ class recordList extends t3lib_recordList { } // Set select levels: - $sL=intval($this->searchLevels); + $searchLevels = intval($this->searchLevels); $this->perms_clause = $GLOBALS['BE_USER']->getPagePermsClause(1); // this will hide records from display - it has nothing todo with user rights!! @@ -217,11 +217,16 @@ class recordList extends t3lib_recordList { } } - if ($sL>0) { - $tree = $this->getTreeObject($this->id, $sL, $this->perms_clause); + if ($searchLevels > 0) { + $tree = $this->getTreeObject($this->id, $searchLevels, $this->perms_clause); $pidList = implode(',', $GLOBALS['TYPO3_DB']->cleanIntArray($tree->ids)); $this->pidSelect = 'pid IN (' . $pidList . ')'; - } else { + } + elseif ($searchLevels < 0) { + // Search everywhere + $this->pidSelect = '1=1'; + } + else { $this->pidSelect = 'pid='.intval($id); } @@ -303,7 +308,7 @@ class recordList extends t3lib_recordList { $this->pidSelect = 'pid='.intval($this->id); } } -#debug($this->pidSelect,$tableName); + // Finally, render the list: $this->HTMLcode.=$this->getTable($tableName, $this->id, implode(',',$fields)); } @@ -499,7 +504,7 @@ class recordList extends t3lib_recordList { $pC = ($table=='pages' && $this->perms_clause)?' AND '.$this->perms_clause:''; // Adding search constraints: - $search = $this->makeSearchString($table); + $search = $this->makeSearchString($table, $id); // Compiling query array: $queryParts = array( @@ -549,39 +554,84 @@ class recordList extends t3lib_recordList { } /** - * Creates part of query for searching after a word ($this->searchString) fields in input table + * Creates part of query for searching after a word ($this->searchString) + * fields in input table. * - * @param string Table, in which the fields are being searched. - * @return string Returns part of WHERE-clause for searching, if applicable. + * @param string $table Table, in which the fields are being searched. + * @param int $currentPid Page id for the possible search limit. -1 only if called from an old XCLASS. + * @return string Returns part of WHERE-clause for searching, if applicable. */ - function makeSearchString($table) { + function makeSearchString($table, $currentPid = -1) { + global $TCA; - // Make query, only if table is valid and a search string is actually defined: - if ($GLOBALS['TCA'][$table] && $this->searchString) { - - // Loading full table description - we need to traverse fields: - t3lib_div::loadTCA($table); + $result = ''; - // Initialize field array: - $sfields=array(); - $sfields[]='uid'; // Adding "uid" by default. + $currentPid = intval($currentPid); + $tablePidField = ($table == 'pages' ? 'uid' : 'pid'); - // Traverse the configured columns and add all columns that can be searched: - foreach($GLOBALS['TCA'][$table]['columns'] as $fieldName => $info) { - if ($info['config']['type']=='text' || ($info['config']['type']=='input' && !preg_match('/date|time|int/',$info['config']['eval']))) { - $sfields[]=$fieldName; + // Make query, only if table is valid and a search string is actually defined: + if ($this->searchString) { + $result = ' AND 0=1'; + if ($TCA[$table] && $TCA[$table]['ctrl']['searchFields']) { + $searchableFields = t3lib_div::trimExplode(',', $TCA[$table]['ctrl']['searchFields'], true); + + // Loading full table description - we need to traverse fields: + t3lib_div::loadTCA($table); + + if (t3lib_div::testInt($this->searchString)) { + $whereParts = array( + 'uid=' . $this->searchString + ); + + foreach($searchableFields as $fieldName) { + if (isset($TCA[$table]['columns'][$fieldName])) { + $fieldConfig = &$TCA[$table]['columns'][$fieldName]['config']; + if ($fieldConfig['type'] == 'input' && $fieldConfig['eval'] && t3lib_div::inList($fieldConfig['eval'], 'int')) { + $condition = $fieldName . '=' . $this->searchString; + if (is_array($fieldConfig['search']) && in_array('pidonly', $fieldConfig['search']) && $currentPid > 0) { + $condition = '(' . $condition . ' AND ' . $tablePidField . '=' . $currentPid . ')'; + } + $whereParts[] = $condition; + } + } + } + } + else { + $whereParts = array(); + $like = '\'%' . + $GLOBALS['TYPO3_DB']->quoteStr($GLOBALS['TYPO3_DB']->escapeStrForLike($this->searchString, $table), $table) . + '%\''; + foreach($searchableFields as $fieldName) { + if (isset($TCA[$table]['columns'][$fieldName])) { + $fieldConfig = &$TCA[$table]['columns'][$fieldName]['config']; + $format = '%s LIKE %s'; + if (is_array($fieldConfig['search'])) { + if (in_array('nocase', $fieldConfig['search'])) { + $format = 'LCASE(%s) LIKE LCASE(%s)'; + } + if (in_array('pidonly', $fieldConfig['search']) && $currentPid > 0) { + $format = '(' . $format . ' AND ' . $tablePidField . '=' . $currentPid . ')'; + } + if ($fieldConfig['search']['andWhere']) { + $format = '((' . $fieldConfig['search']['andWhere'] . ') AND (' . $format . '))'; + } + } + if ($fieldConfig['type'] == 'text' || + $fieldConfig['type'] == 'flex' || + ($fieldConfig['type'] == 'input' && (!$fieldConfig['eval'] || !preg_match('/date|time|int/',$fieldConfig['eval'])))) { + $whereParts[] = sprintf($format, $fieldName, $like); + } + } + } } - } - - // 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.')'; - // Return query: - return $queryPart; + // If search-fields were defined (and there always are) we create the query: + if (count($whereParts)) { + $result = ' AND (' . implode(' OR ', $whereParts) . ')'; + } } } + return $result; } /** diff --git a/typo3/js/backendsearch.js b/typo3/js/backendsearch.js index 4865835..a68bb7d 100644 --- a/typo3/js/backendsearch.js +++ b/typo3/js/backendsearch.js @@ -114,7 +114,7 @@ var BackendSearch = Class.create({ break; case 'search': this.jump( - unescape(TYPO3.configuration.listModulePath + 'db_list.php?id=' + jsonResponse.firstMountPoint + '&search_field=' + jsonResponse.searchFor + '&search_levels=4'), + unescape(TYPO3.configuration.listModulePath + 'db_list.php?id=' + jsonResponse.firstMountPoint + '&search_field=' + jsonResponse.searchFor + '&search_levels=' + (jsonResponse.firstMountPoint > 0 ? '4' : '-1')), 'web_list', 'web' ); diff --git a/typo3/sysext/cms/ext_tables.php b/typo3/sysext/cms/ext_tables.php index 3a40c27..622eba3 100755 --- a/typo3/sysext/cms/ext_tables.php +++ b/typo3/sysext/cms/ext_tables.php @@ -103,7 +103,8 @@ $TCA['tt_content'] = array ( 'thumbnail' => 'image', 'requestUpdate' => 'list_type,rte_enabled', 'dynamicConfigFile' => t3lib_extMgm::extPath($_EXTKEY).'tbl_tt_content.php', - 'dividers2tabs' => 1 + 'dividers2tabs' => 1, + 'searchFields' => 'header,header_link,subheader,bodytext,pi_flexform', ) ); @@ -129,7 +130,8 @@ $TCA['fe_users'] = array ( ), 'useColumnsForDefaultValues' => 'usergroup,lockToDomain,disable,starttime,endtime', 'dynamicConfigFile' => t3lib_extMgm::extPath($_EXTKEY).'tbl_cms.php', - 'dividers2tabs' => 1 + 'dividers2tabs' => 1, + 'searchFields' => 'username,name,first_name,last_name,middle_name,address,telephone,fax,email,title,zip,city,country,company', ), 'feInterface' => array ( 'fe_admin_fieldList' => 'username,password,usergroup,name,address,telephone,fax,email,title,zip,city,country,www,company', @@ -156,7 +158,8 @@ $TCA['fe_groups'] = array ( ), 'useColumnsForDefaultValues' => 'lockToDomain', 'dynamicConfigFile' => t3lib_extMgm::extPath($_EXTKEY).'tbl_cms.php', - 'dividers2tabs' => 1 + 'dividers2tabs' => 1, + 'searchFields' => 'title,description', ) ); @@ -178,7 +181,8 @@ $TCA['sys_domain'] = array ( 'typeicon_classes' => array( 'default' => 'mimetypes-x-content-domain', ), - 'dynamicConfigFile' => t3lib_extMgm::extPath($_EXTKEY).'tbl_cms.php' + 'dynamicConfigFile' => t3lib_extMgm::extPath($_EXTKEY).'tbl_cms.php', + 'searchFields' => 'domainName,redirectTo', ) ); @@ -212,8 +216,8 @@ $TCA['pages_language_overlay'] = array ( 'typeicon_classes' => array( 'default' => 'mimetypes-x-content-page-language-overlay', ), - - 'dividers2tabs' => TRUE + 'dividers2tabs' => TRUE, + 'searchFields' => 'title,subtitle,nav_title,keywords,description,abstract,author,author_email,url', ) ); @@ -250,7 +254,8 @@ $TCA['sys_template'] = array ( '0' => 'template_add.gif' ), 'dividers2tabs' => 1, - 'dynamicConfigFile' => t3lib_extMgm::extPath($_EXTKEY).'tbl_cms.php' + 'dynamicConfigFile' => t3lib_extMgm::extPath($_EXTKEY).'tbl_cms.php', + 'searchFields' => 'title,constants,config', ) ); diff --git a/typo3/sysext/cms/tbl_cms.php b/typo3/sysext/cms/tbl_cms.php index a63b1af..4c1394f 100755 --- a/typo3/sysext/cms/tbl_cms.php +++ b/typo3/sysext/cms/tbl_cms.php @@ -52,7 +52,10 @@ $TCA['fe_users'] = array( 'type' => 'input', 'size' => '20', 'max' => '50', - 'eval' => 'nospace,lower,uniqueInPid,required' + 'eval' => 'nospace,lower,uniqueInPid,required', + 'search' => array( + 'nocase' + ), ) ), 'password' => array( @@ -93,7 +96,10 @@ $TCA['fe_users'] = array( 'type' => 'input', 'size' => '40', 'eval' => 'trim', - 'max' => '80' + 'max' => '80', + 'search' => array( + 'nocase' + ), ) ), 'first_name' => array( @@ -103,7 +109,10 @@ $TCA['fe_users'] = array( 'type' => 'input', 'size' => '25', 'eval' => 'trim', - 'max' => '50' + 'max' => '50', + 'search' => array( + 'nocase' + ), ) ), 'middle_name' => array( @@ -113,7 +122,10 @@ $TCA['fe_users'] = array( 'type' => 'input', 'size' => '25', 'eval' => 'trim', - 'max' => '50' + 'max' => '50', + 'search' => array( + 'nocase' + ), ) ), 'last_name' => array( @@ -123,7 +135,10 @@ $TCA['fe_users'] = array( 'type' => 'input', 'size' => '25', 'eval' => 'trim', - 'max' => '50' + 'max' => '50', + 'search' => array( + 'nocase' + ), ) ), 'address' => array( @@ -132,7 +147,10 @@ $TCA['fe_users'] = array( 'config' => array( 'type' => 'text', 'cols' => '20', - 'rows' => '3' + 'rows' => '3', + 'search' => array( + 'nocase' + ), ) ), 'telephone' => array( @@ -142,7 +160,10 @@ $TCA['fe_users'] = array( 'type' => 'input', 'eval' => 'trim', 'size' => '20', - 'max' => '20' + 'max' => '20', + 'search' => array( + 'nocase' + ), ) ), 'fax' => array( @@ -152,7 +173,10 @@ $TCA['fe_users'] = array( 'type' => 'input', 'size' => '20', 'eval' => 'trim', - 'max' => '20' + 'max' => '20', + 'search' => array( + 'nocase' + ), ) ), 'email' => array( @@ -162,7 +186,10 @@ $TCA['fe_users'] = array( 'type' => 'input', 'size' => '20', 'eval' => 'trim', - 'max' => '80' + 'max' => '80', + 'search' => array( + 'nocase' + ), ) ), 'title' => array( @@ -172,7 +199,10 @@ $TCA['fe_users'] = array( 'type' => 'input', 'size' => '20', 'eval' => 'trim', - 'max' => '40' + 'max' => '40', + 'search' => array( + 'nocase' + ), ) ), 'zip' => array( @@ -182,7 +212,10 @@ $TCA['fe_users'] = array( 'type' => 'input', 'eval' => 'trim', 'size' => '10', - 'max' => '10' + 'max' => '10', + 'search' => array( + 'nocase' + ), ) ), 'city' => array( @@ -192,7 +225,10 @@ $TCA['fe_users'] = array( 'type' => 'input', 'size' => '20', 'eval' => 'trim', - 'max' => '50' + 'max' => '50', + 'search' => array( + 'nocase' + ), ) ), 'country' => array( @@ -202,7 +238,10 @@ $TCA['fe_users'] = array( 'type' => 'input', 'size' => '20', 'eval' => 'trim', - 'max' => '40' + 'max' => '40', + 'search' => array( + 'nocase' + ), ) ), 'www' => array( @@ -222,7 +261,10 @@ $TCA['fe_users'] = array( 'type' => 'input', 'eval' => 'trim', 'size' => '20', - 'max' => '80' + 'max' => '80', + 'search' => array( + 'nocase' + ), ) ), 'image' => array( @@ -350,7 +392,10 @@ $TCA['fe_groups'] = array( 'type' => 'input', 'size' => '20', 'max' => '50', - 'eval' => 'trim,required' + 'eval' => 'trim,required', + 'search' => array( + 'nocase' + ), ) ), 'subgroup' => array( @@ -381,7 +426,10 @@ $TCA['fe_groups'] = array( 'config' => array( 'type' => 'text', 'rows' => 5, - 'cols' => 48 + 'cols' => 48, + 'search' => array( + 'nocase' + ), ) ), 'TSconfig' => array( @@ -434,7 +482,10 @@ $TCA['sys_domain'] = array( 'size' => '35', 'max' => '80', 'eval' => 'required,unique,lower,trim', - 'softref' => 'substitute' + 'softref' => 'substitute', + 'search' => array( + 'nocase' + ), ), ), 'redirectTo' => array( @@ -445,7 +496,10 @@ $TCA['sys_domain'] = array( 'max' => '255', 'default' => '', 'eval' => 'trim', - 'softref' => 'substitute' + 'softref' => 'substitute', + 'search' => array( + 'nocase' + ), ), ), 'redirectHttpStatusCode' => array( @@ -557,6 +611,9 @@ $TCA['pages_language_overlay'] = array( 'size' => '50', 'max' => '255', 'eval' => 'trim,required', + 'search' => array( + 'nocase' + ), ) ), 'subtitle' => array( @@ -568,6 +625,9 @@ $TCA['pages_language_overlay'] = array( 'size' => '50', 'max' => '255', 'eval' => 'trim', + 'search' => array( + 'nocase' + ), ) ), 'nav_title' => array( @@ -579,6 +639,9 @@ $TCA['pages_language_overlay'] = array( 'size' => '50', 'max' => '255', 'eval' => 'trim', + 'search' => array( + 'nocase' + ), ) ), 'keywords' => array( @@ -596,7 +659,10 @@ $TCA['pages_language_overlay'] = array( 'config' => array( 'type' => 'text', 'cols' => '40', - 'rows' => '3' + 'rows' => '3', + 'search' => array( + 'nocase' + ), ) ), 'abstract' => array( @@ -605,7 +671,10 @@ $TCA['pages_language_overlay'] = array( 'config' => array( 'type' => 'text', 'cols' => '40', - 'rows' => '3' + 'rows' => '3', + 'search' => array( + 'nocase' + ), ) ), 'author' => array( @@ -616,6 +685,9 @@ $TCA['pages_language_overlay'] = array( 'size' => '23', 'eval' => 'trim', 'max' => '80', + 'search' => array( + 'nocase' + ), ) ), 'author_email' => array( @@ -896,7 +968,10 @@ $TCA['sys_template'] = array( 'type' => 'input', 'size' => '25', 'max' => '256', - 'eval' => 'required' + 'eval' => 'required', + 'search' => array( + 'nocase' + ), ) ), 'hidden' => array( @@ -964,7 +1039,10 @@ $TCA['sys_template'] = array( 'cols' => '48', 'rows' => '10', 'wrap' => 'OFF', - 'softref' => 'TStemplate,email[subst],url[subst]' + 'softref' => 'TStemplate,email[subst],url[subst]', + 'search' => array( + 'nocase' + ), ), 'defaultExtras' => 'fixed-font : enable-tab', ), @@ -1076,7 +1154,10 @@ $TCA['sys_template'] = array( ) ), 'wrap' => 'OFF', - 'softref' => 'TStemplate,email[subst],url[subst]' + 'softref' => 'TStemplate,email[subst],url[subst]', + 'search' => array( + 'nocase' + ), ), 'defaultExtras' => 'fixed-font : enable-tab', ), @@ -1146,7 +1227,7 @@ $TCA['backend_layout'] = array( 'type' => 'input', 'size' => '25', 'max' => '256', - 'eval' => 'required' + 'eval' => 'required', ) ), 'description' => array( diff --git a/typo3/sysext/cms/tbl_tt_content.php b/typo3/sysext/cms/tbl_tt_content.php index aae25b6..f8a3354 100755 --- a/typo3/sysext/cms/tbl_tt_content.php +++ b/typo3/sysext/cms/tbl_tt_content.php @@ -335,6 +335,9 @@ $TCA['tt_content'] = array( 'type' => 'input', 'size' => '50', 'max' => '256', + 'search' => array( + 'nocase' + ) ), ), 'header_position' => array( @@ -430,6 +433,9 @@ $TCA['tt_content'] = array( 'size' => '50', 'max' => '256', 'softref' => 'email[subst]', + 'search' => array( + 'nocase' + ) ), ), 'bodytext' => array( @@ -487,6 +493,10 @@ $TCA['tt_content'] = array( ), ), 'softref' => 'typolink_tag,images,email[subst],url', + 'search' => array( + 'nocase', + 'andWhere' => 'CType=\'text\' OR CType=\'textpic\'', + ) ), ), 'text_align' => array( @@ -1629,6 +1639,10 @@ $TCA['tt_content'] = array( ', ',media' => file_get_contents(t3lib_extMgm::extPath('cms') . 'flexform_media.xml'), ), + 'search' => array( + 'nocase', + 'andWhere' => 'CType=\'list\'' + ) ), ), 'tx_impexp_origuid' => array(