2 namespace TYPO3\CMS\Backend\Search\LiveSearch;
79 $this->userPermissions =
$GLOBALS[
'BE_USER']->getPagePermsClause(1);
92 $pageId = $this->queryParser->getId($searchQuery);
94 if (!empty($pageRecord)) {
106 public function find($searchQuery)
108 $recordArray = array();
110 $mounts =
$GLOBALS[
'BE_USER']->returnWebmounts();
111 foreach ($mounts as $pageId) {
114 $pageIdList = implode(
',', array_unique(explode(
',', implode(
',', $pageList))));
117 if ($this->queryParser->isValidCommand($searchQuery)) {
118 $this->
setQueryString($this->queryParser->getSearchQueryValue($searchQuery));
119 $tableName = $this->queryParser->getTableNameFromCommand($searchQuery);
121 $recordArray[] = $this->
findByTable($tableName, $pageIdList, $limit);
138 $pageRecord = array();
140 if (is_array($row)) {
155 $getRecordArray = array();
156 foreach (
$GLOBALS[
'TCA'] as $tableName => $value) {
158 if (!
$GLOBALS[
'BE_USER']->check(
'tables_select', $tableName) && !
$GLOBALS[
'BE_USER']->check(
'tables_modify', $tableName)) {
161 $recordArray = $this->
findByTable($tableName, $pageIdList,
'0,' . $limit);
162 $recordCount = count($recordArray);
164 $limit = $limit - $recordCount;
165 $getRecordArray[] = $recordArray;
171 return $getRecordArray;
189 $getRecordArray = array();
190 if (!empty($fieldsToSearchWithin)) {
191 $pageBasedPermission = $tableName ==
'pages' && $this->userPermissions ? $this->userPermissions :
'1=1 ';
192 $where =
'pid IN (' . $pageIdList .
') AND ' . $pageBasedPermission . $this->
makeQuerySearchByTable($tableName, $fieldsToSearchWithin);
195 return $getRecordArray;
215 'FROM' => $tableName,
217 'ORDERBY' => $orderBy,
220 $result =
$GLOBALS[
'TYPO3_DB']->exec_SELECT_queryArray($queryParts);
221 $dbCount =
$GLOBALS[
'TYPO3_DB']->sql_num_rows($result);
223 while ($row =
$GLOBALS[
'TYPO3_DB']->sql_fetch_assoc($result)) {
224 $title =
'id=' . $row[
'uid'] .
', pid=' . $row[
'pid'];
226 'id' => $tableName .
':' . $row[
'uid'],
227 'pageId' => $tableName ===
'pages' ? $row[
'uid'] : $row[
'pid'],
229 'iconHTML' =>
'<span title="' . htmlspecialchars($title) .
'">' . $iconFactory->getIconForRecord($tableName, $row,
Icon::SIZE_SMALL)->render() .
'</span>',
231 'editLink' => htmlspecialchars($this->
getEditLink($tableName, $row))
235 $GLOBALS[
'TYPO3_DB']->sql_free_result($result);
250 $calcPerms =
$GLOBALS[
'BE_USER']->calcPerms($pageInfo);
252 if ($tableName ==
'pages') {
260 $returnUrl = BackendUtility::getModuleUrl(
'web_list', array(
'id' => $row[
'pid']));
261 $editLink = BackendUtility::getModuleUrl(
'record_edit', array(
262 'edit[' . $tableName .
'][' . $row[
'uid'] .
']' =>
'edit',
263 'returnUrl' => $returnUrl
293 $titleLength =
$GLOBALS[
'BE_USER']->uc[
'titleLen'];
308 $whereParts = array();
311 foreach ($fieldsToSearchWithin as $fieldName) {
312 if ($fieldName ==
'uid' || $fieldName ==
'pid' || isset(
$GLOBALS[
'TCA'][$tableName][
'columns'][$fieldName])) {
313 $fieldConfig = &
$GLOBALS[
'TCA'][$tableName][
'columns'][$fieldName][
'config'];
315 if ($fieldName ==
'uid' || $fieldName ==
'pid' || $fieldConfig[
'type'] ==
'input' && $fieldConfig[
'eval'] &&
GeneralUtility::inList($fieldConfig[
'eval'],
'int')) {
318 $fieldConfig[
'type'] ==
'text' ||
319 $fieldConfig[
'type'] ==
'flex' ||
320 ($fieldConfig[
'type'] ==
'input' && (!$fieldConfig[
'eval'] ||
321 !preg_match(
'/date|time|int/', $fieldConfig[
'eval'])))) {
323 $whereParts[] = $fieldName .
' LIKE \'%' . $this->queryString .
'%\'';
328 $like =
'\'%
' . $GLOBALS['TYPO3_DB
']->escapeStrForLike($GLOBALS['TYPO3_DB
']->quoteStr($this->queryString, $tableName), $tableName) . '%\
'';
329 foreach ($fieldsToSearchWithin as $fieldName) {
330 if (isset(
$GLOBALS[
'TCA'][$tableName][
'columns'][$fieldName])) {
331 $fieldConfig = &
$GLOBALS[
'TCA'][$tableName][
'columns'][$fieldName][
'config'];
333 $format =
'LOWER(%s) LIKE LOWER(%s)';
334 if (is_array($fieldConfig[
'search'])) {
335 if (in_array(
'case', $fieldConfig[
'search'])) {
336 $format =
'%s LIKE %s';
339 if ($fieldConfig[
'search'][
'andWhere']) {
340 $format =
'((' . $fieldConfig[
'search'][
'andWhere'] .
') AND (' . $format .
'))';
344 if ($fieldConfig[
'type'] ==
'text' || $fieldConfig[
'type'] ==
'flex' || $fieldConfig[
'type'] ==
'input' && (!$fieldConfig[
'eval'] || !preg_match(
'/date|time|int/', $fieldConfig[
'eval']))) {
345 $whereParts[] = sprintf($format, $fieldName, $like);
351 if (!empty($whereParts)) {
352 $queryPart =
' AND (' . implode(
' OR ', $whereParts) .
')';
357 $queryPart =
' AND 0 = 1';
371 if (is_array(
$GLOBALS[
'TCA'][$tableName][
'ctrl']) && array_key_exists(
'sortby',
$GLOBALS[
'TCA'][$tableName][
'ctrl'])) {
372 $sortBy = trim(
$GLOBALS[
'TCA'][$tableName][
'ctrl'][
'sortby']);
373 if (!empty($sortBy)) {
374 $orderBy =
'ORDER BY ' . $sortBy;
377 $orderBy =
$GLOBALS[
'TCA'][$tableName][
'ctrl'][
'default_sortby'];
379 return $GLOBALS[
'TYPO3_DB']->stripOrderBy($orderBy);
391 if (isset(
$GLOBALS[
'TCA'][$tableName][
'ctrl'][
'searchFields'])) {
394 $fieldListArray = array();
397 if (
$GLOBALS[
'BE_USER']->isAdmin()) {
398 $fieldListArray[] =
'uid';
399 $fieldListArray[] =
'pid';
401 return $fieldListArray;
412 return $GLOBALS[
'TYPO3_DB']->quoteStr($this->queryString, $tableName);
425 $this->limitCount = $limit;
463 $tree->init(
'AND ' . $this->userPermissions);
465 $tree->fieldArray = array(
'uid',
'php_tree_stop');
467 $tree->getTree($id, $depth,
'');
470 $idList = implode(
',', $tree->ids);