52 array(
'-',
'AND NOT'),
56 array(
'not',
'AND NOT')
120 if (!is_null(
$cObj)) {
132 public function render($conf = array()) {
142 $rootLine =
$GLOBALS[
'TSFE']->sys_page->getRootLine($temp_theStartId);
144 foreach ($rootLine as $val) {
145 if ($val[
'uid'] ==
$GLOBALS[
'TSFE']->tmpl->rootLine[0][
'uid']) {
146 $theStartId = $temp_theStartId;
152 $theRootLine =
$GLOBALS[
'TSFE']->tmpl->rootLine;
155 $pId = (int)$locDat_arr[0];
157 $altRootLine =
$GLOBALS[
'TSFE']->sys_page->getRootLine($pId);
159 if (count($altRootLine)) {
162 $theNewRoot = array();
163 foreach ($altRootLine as $val) {
164 if ($hitRoot || $val[
'uid'] ==
$GLOBALS[
'TSFE']->tmpl->rootLine[0][
'uid']) {
166 $theNewRoot[] = $val;
171 $theRootLine = $theNewRoot;
175 $key = $this->cObj->getKey($pointer, $theRootLine);
176 $theStartId = $theRootLine[$key][
'uid'];
184 $this->pageIdList .= $this->cObj->getTreeList(-1 * $theStartId, $depth);
185 $endClause =
'pages.uid IN (' . $this->pageIdList .
') 186 AND pages.doktype in (' .
$GLOBALS[
'TYPO3_CONF_VARS'][
'FE'][
'content_doktypes'] . ($conf[
'addExtUrlsAndShortCuts'] ?
',3,4' :
'') .
') 187 AND pages.no_search=0' . $this->cObj->enableFields($this->fTable) . $this->cObj->enableFields(
'pages');
188 if ($conf[
'languageField.'][$this->fTable]) {
191 $endClause .=
' AND ' . $this->fTable .
'.' . $conf[
'languageField.'][
$this->fTable] .
' = ' . (int)
$GLOBALS[
'TSFE']->sys_language_uid;
203 $range = isset($conf[
'range.']) ? $this->cObj->stdWrap($conf[
'range'], $conf[
'range.']) : $conf[
'range'];
205 $theRange = (int)$range;
210 $noOrderBy = isset($conf[
'noOrderBy.']) ? $this->cObj->stdWrap($conf[
'noOrderBy'], $conf[
'noOrderBy.']) : $conf[
'noOrderBy'];
212 $this->queryParts[
'ORDERBY'] =
'pages.lastUpdated, pages.tstamp';
214 $this->queryParts[
'LIMIT'] = $spointer .
',' . $theRange;
217 if (
$GLOBALS[
'TYPO3_DB']->sql_num_rows($this->result)) {
223 $target = isset($conf[
'target.']) ? $this->cObj->stdWrap($conf[
'target'], $conf[
'target.']) : $conf[
'target'];
224 $LD =
$GLOBALS[
'TSFE']->tmpl->linkData(
$GLOBALS[
'TSFE']->page, $target, 1,
'',
'', $this->cObj->getClosestMPvalueForPage(
$GLOBALS[
'TSFE']->page[
'uid']));
225 $targetPart = $LD[
'target'] ?
' target="' . htmlspecialchars($LD[
'target']) .
'"' :
'';
239 $this->cObj->cObjGetSingle($conf[
'layout'], $conf[
'layout.'],
'layout')
241 if ($rangeHigh < $total) {
242 $next = $this->cObj->cObjGetSingle($conf[
'next'], $conf[
'next.'],
'next');
243 $next =
'<a href="' . htmlspecialchars(($urlParams .
'&spointer=' . ($spointer + $theRange))) .
'"' . $targetPart .
$GLOBALS[
'TSFE']->ATagParams .
'>' . $next .
'</a>';
249 $prev = $this->cObj->cObjGetSingle($conf[
'prev'], $conf[
'prev.'],
'prev');
250 $prev =
'<a href="' . htmlspecialchars(($urlParams .
'&spointer=' . ($spointer - $theRange))) .
'"' . $targetPart .
$GLOBALS[
'TSFE']->ATagParams .
'>' . $prev .
'</a>';
256 $theValue = $this->cObj->cObjGetSingle($conf[
'resultObj'], $conf[
'resultObj.'],
'resultObj');
259 $cObj->setParent($this->cObj->data, $this->cObj->currentRecord);
261 while ($row =
$GLOBALS[
'TYPO3_DB']->sql_fetch_assoc($this->result)) {
265 $renderCode .=
$cObj->cObjGetSingle($conf[
'renderObj'], $conf[
'renderObj.'],
'renderObj');
267 $renderWrap = isset($conf[
'renderWrap.']) ? $this->cObj->stdWrap($conf[
'renderWrap'], $conf[
'renderWrap.']) : $conf[
'renderWrap'];
268 $theValue .= $this->cObj->wrap($renderCode, $renderWrap);
269 $theValue = str_replace(
'###RESULT###', $theValue,
$result);
271 $theValue = $this->cObj->cObjGetSingle($conf[
'noResultObj'], $conf[
'noResultObj.'],
'noResultObj');
273 $GLOBALS[
'TT']->setTSlogMessage(
'Search in fields: ' . $this->listOfSearchFields);
275 $content = $theValue;
276 $wrap = isset($conf[
'wrap.']) ? $this->cObj->stdWrap($conf[
'wrap'], $conf[
'wrap.']) : $conf[
'wrap'];
278 $content = $this->cObj->wrap($content, $wrap);
280 if (isset($conf[
'stdWrap.'])) {
281 $content = $this->cObj->stdWrap($content, $conf[
'stdWrap.']);
284 $GLOBALS[
'TSFE']->set_no_cache(
'Search result page');
302 foreach ($rCols as $k => $v) {
303 $rCols[$k] = trim($v);
304 if (in_array($rCols[$k], $aCols)) {
305 $parts = explode(
'.', $rCols[$k]);
306 $this->tables[$parts[0]][
'searchfields'][] = $parts[1];
309 $this->tables[
'pages'][
'primary_key'] =
'uid';
310 $this->tables[
'pages'][
'resultfields'][] =
'uid';
311 unset($this->tables[
'pages'][
'fkey']);
312 foreach ($aCols as $k => $v) {
313 $aCols[$k] = trim($v);
314 $parts = explode(
'.', $aCols[$k]);
315 $this->tables[$parts[0]][
'resultfields'][] = $parts[1] .
' AS ' . str_replace(
'.',
'_', $aCols[$k]);
316 $this->tables[$parts[0]][
'fkey'] =
'pid';
319 foreach ($this->tables as $t => $v) {
321 if (!$this->fTable) {
324 unset($this->tables[$t]);
339 $theArray = explode(
':', $in);
341 foreach ($theArray as $val) {
343 $parts = explode(
'.', $val);
344 if ($parts[0] && $parts[1]) {
345 $subparts = explode(
'-', $parts[1]);
346 foreach ($subparts as $piece) {
347 $piece = trim($piece);
349 $out[] = $parts[0] .
'.' . $piece;
367 $sword = trim($sword);
369 $components = $this->
split($sword);
372 if (is_array($components)) {
375 foreach ($components as $key => $val) {
378 $lastoper = $operator;
379 } elseif (strlen($val) > 1) {
381 $this->sword_array[$i][
'sword'] = $val;
401 public function split($origSword, $specchars =
'+-', $delchars =
'+.,-') {
403 $specs =
'[' . preg_quote($specchars,
'/') .
']';
407 if (preg_match(
'/^"/', $sword)) {
409 $sword = preg_replace(
'/^"/',
'', $sword);
411 preg_match(
'/^[^"]*/', $sword, $reg);
414 $sword = preg_replace(
'/^' . preg_quote($reg[0],
'/') .
'/',
'', $sword);
416 $sword = trim(preg_replace(
'/^"/',
'', $sword));
417 } elseif (preg_match(
'/^' . $specs .
'/', $sword, $reg)) {
420 $sword = trim(preg_replace(
'/^' . $specs .
'/',
'', $sword));
421 } elseif (preg_match(
'/[\\+\\-]/', $sword)) {
426 $a_sword = explode(
' ', $sword);
428 $word = array_shift($a_sword);
430 $word = rtrim($word, $delchars);
434 $sword = implode(
' ', $a_sword);
437 preg_match(
'/^[^ ' . preg_quote($specchars,
'/') .
']*/', $sword, $reg);
439 $word = rtrim(trim($reg[0]), $delchars);
441 $sword = trim(preg_replace(
'/^' . preg_quote($reg[0],
'/') .
'/',
'', $sword));
459 if (is_array($this->tables)) {
463 foreach (
$tables as $key => $val) {
464 if (
$tables[$key][
'primary_key']) {
465 $primary_table = $key;
468 if ($primary_table) {
470 $this->queryParts = array(
479 $fieldArray = array();
480 $tableArray = array();
481 foreach (
$tables as $key => $val) {
482 $tableArray[] = $key;
483 $resultfields =
$tables[$key][
'resultfields'];
484 if (is_array($resultfields)) {
485 foreach ($resultfields as $key2 => $val2) {
486 $fieldArray[] = $key .
'.' . $val2;
490 $this->queryParts[
'SELECT'] = implode(
',', $fieldArray);
491 $this->queryParts[
'FROM'] = implode(
',', $tableArray);
493 $whereArray = array();
494 $primary_table_and_key = $primary_table .
'.' .
$tables[$primary_table][
'primary_key'];
496 foreach (
$tables as $key => $val) {
499 $primKeys[] = $key .
'.' . $fkey .
'=' . $primary_table_and_key;
502 if (count($primKeys)) {
503 $whereArray[] =
'(' . implode(
' OR ', $primKeys) .
')';
506 if (trim($endClause)) {
507 $whereArray[] = trim($endClause);
512 $query_part =
'(0!=0)';
514 $whereArray[] =
'(' . $query_part .
')';
516 $this->queryParts[
'WHERE'] = implode(
' AND ', $whereArray);
518 if ($this->group_by) {
519 if ($this->group_by ==
'PRIMARY_KEY') {
520 $this->queryParts[
'GROUPBY'] = $primary_table_and_key;
537 if (is_array($this->sword_array)) {
538 $main_query_part = array();
539 foreach ($this->sword_array as $key => $val) {
540 $s_sword = $this->sword_array[$key][
'sword'];
542 $sub_query_part = array();
543 $this->listOfSearchFields =
'';
544 foreach ($this->tables as $key3 => $val3) {
545 $searchfields = $this->tables[$key3][
'searchfields'];
546 if (is_array($searchfields)) {
547 foreach ($searchfields as $key2 => $val2) {
548 $this->listOfSearchFields .= $key3 .
'.' . $val2 .
',';
549 $sub_query_part[] = $key3 .
'.' . $val2 .
' LIKE \'%' .
$GLOBALS[
'TYPO3_DB']->quoteStr($s_sword, $key3) .
'%\'';
553 if (count($sub_query_part)) {
554 $main_query_part[] = $this->sword_array[$key][
'oper'];
555 $main_query_part[] =
'(' . implode(
' OR ', $sub_query_part) .
')';
558 if (count($main_query_part)) {
560 unset($main_query_part[0]);
561 return implode(
' ', $main_query_part);
575 $operator = trim($operator);
577 if ($this->operator_translate_table_caseinsensitive) {
580 $operator = strtolower($operator);
582 foreach ($op_array as $key => $val) {
583 $item = $op_array[$key][0];
584 if ($this->operator_translate_table_caseinsensitive) {
586 $item = strtolower($item);
588 if ($operator == $item) {
589 return $op_array[$key][1];
601 if (is_array($this->queryParts)) {
602 $res =
$GLOBALS[
'TYPO3_DB']->exec_SELECTquery($this->queryParts[
'SELECT'], $this->queryParts[
'FROM'], $this->queryParts[
'WHERE'], $this->queryParts[
'GROUPBY']);
603 $this->res_count =
$GLOBALS[
'TYPO3_DB']->sql_num_rows($res);
615 if (is_array($this->queryParts)) {
616 $this->result =
$GLOBALS[
'TYPO3_DB']->exec_SELECT_queryArray($this->queryParts);
630 if (is_array($this->sword_array)) {
631 foreach ($this->sword_array as $key => $val) {
632 $SWORD_PARAMS .=
'&sword_list[]=' . rawurlencode($val[
'sword']);
635 return $SWORD_PARAMS;
645 if (is_array($this->sword_array)) {
646 foreach ($this->sword_array as $key => $val) {
647 $swords[] = $val[
'sword'];
register_and_explode_search_string($sword)
__construct(\TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer $cObj=NULL)
split($origSword, $specchars='+-', $delchars='+.,-')
static forceIntegerInRange($theInt, $min, $max=2000000000, $defaultValue=0)
static canBeInterpretedAsInteger($var)
static makeInstance($className)
build_search_query_for_searchwords()
build_search_query($endClause)
if($list_of_literals) if(!empty($literals)) if(!empty($literals)) $result
Analyse literals to prepend the N char to them if their contents aren't numeric.
$operator_translate_table_caseinsensitive
register_tables_and_columns($requestedCols, $allowedCols)
if(!defined('TYPO3_MODE')) $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_userauth.php']['logoff_pre_processing'][]
$operator_translate_table