191 if (is_array($this->sWArr)) {
192 $content = $this->
doSearch($this->sWArr);
208 $this->indexerConfig = unserialize(
$GLOBALS[
'TYPO3_CONF_VARS'][
'EXT'][
'extConf'][
'indexed_search']);
209 $this->enableMetaphoneSearch = $this->indexerConfig[
'enableMetaphoneSearch'] ? TRUE : FALSE;
212 if (is_array($TYPO3_CONF_VARS[
'EXTCONF'][
'indexed_search'][
'external_parsers'])) {
213 foreach ($TYPO3_CONF_VARS[
'EXTCONF'][
'indexed_search'][
'external_parsers'] as $extension => $_objRef) {
216 if (!$this->external_parsers[$extension]->softInit($extension)) {
217 unset($this->external_parsers[$extension]);
222 $lexerObjRef = $TYPO3_CONF_VARS[
'EXTCONF'][
'indexed_search'][
'lexer'] ? $TYPO3_CONF_VARS[
'EXTCONF'][
'indexed_search'][
'lexer'] :
'EXT:indexed_search/Classes/Lexer.php:&TYPO3\\CMS\\IndexedSearch\\Lexer';
225 if ($this->piVars[
'_sections']) {
226 $this->piVars[
'sections'] = $this->piVars[
'_sections'];
229 if ($this->piVars[
'_freeIndexUid'] !==
'_') {
230 $this->piVars[
'freeIndexUid'] = $this->piVars[
'_freeIndexUid'];
233 if ($this->piVars[
'sword_prev_include'] && $this->piVars[
'sword_prev']) {
234 $this->piVars[
'sword'] = trim($this->piVars[
'sword_prev']) .
' ' . $this->piVars[
'sword'];
238 $this->optValues = array(
240 '0' => $this->
pi_getLL(
'opt_type_0'),
241 '1' => $this->
pi_getLL(
'opt_type_1'),
242 '2' => $this->
pi_getLL(
'opt_type_2'),
243 '3' => $this->
pi_getLL(
'opt_type_3'),
244 '10' => $this->
pi_getLL(
'opt_type_10'),
245 '20' => $this->
pi_getLL(
'opt_type_20')
248 '0' => $this->
pi_getLL(
'opt_defOp_0'),
249 '1' => $this->
pi_getLL(
'opt_defOp_1')
252 '0' => $this->
pi_getLL(
'opt_sections_0'),
253 '-1' => $this->
pi_getLL(
'opt_sections_-1'),
254 '-2' => $this->
pi_getLL(
'opt_sections_-2'),
255 '-3' => $this->
pi_getLL(
'opt_sections_-3')
257 'freeIndexUid' => array(
258 '-1' => $this->
pi_getLL(
'opt_freeIndexUid_-1'),
259 '-2' => $this->
pi_getLL(
'opt_freeIndexUid_-2'),
260 '0' => $this->
pi_getLL(
'opt_freeIndexUid_0')
263 '-1' => $this->
pi_getLL(
'opt_media_-1'),
264 '0' => $this->
pi_getLL(
'opt_media_0'),
265 '-2' => $this->
pi_getLL(
'opt_media_-2')
268 'rank_flag' => $this->
pi_getLL(
'opt_order_rank_flag'),
269 'rank_freq' => $this->
pi_getLL(
'opt_order_rank_freq'),
270 'rank_first' => $this->
pi_getLL(
'opt_order_rank_first'),
271 'rank_count' => $this->
pi_getLL(
'opt_order_rank_count'),
272 'mtime' => $this->
pi_getLL(
'opt_order_mtime'),
273 'title' => $this->
pi_getLL(
'opt_order_title'),
274 'crdate' => $this->
pi_getLL(
'opt_order_crdate')
277 'sections' => $this->
pi_getLL(
'opt_group_sections'),
278 'flat' => $this->
pi_getLL(
'opt_group_flat')
281 -1 => $this->
pi_getLL(
'opt_lang_-1'),
285 '0' => $this->
pi_getLL(
'opt_desc_0'),
286 '1' => $this->
pi_getLL(
'opt_desc_1')
296 if (!$this->enableMetaphoneSearch) {
297 unset($this->optValues[
'type'][
'10']);
300 if ($this->conf[
'search.'][
'defaultFreeIndexUidList']) {
302 $indexCfgRecords =
$GLOBALS[
'TYPO3_DB']->exec_SELECTgetRows(
'uid,title',
'index_config',
'uid IN (' . implode(
',', $uidList) .
')' . $this->cObj->enableFields(
'index_config'),
'',
'',
'',
'uid');
303 foreach ($uidList as $uidValue) {
304 if (is_array($indexCfgRecords[$uidValue])) {
305 $this->optValues[
'freeIndexUid'][$uidValue] = $indexCfgRecords[$uidValue][
'title'];
310 if ($this->conf[
'search.'][
'skipExtendToSubpagesChecking']) {
311 $this->join_pages = 1;
314 if (strlen(trim($this->conf[
'search.'][
'mediaList']))) {
317 foreach ($this->external_parsers as $extension => $obj) {
322 if ($name = $obj->searchTypeMediaTitle($extension)) {
323 $this->optValues[
'media'][$extension] = $this->
pi_getLL(
'opt_sections_' . $extension, $name);
328 $this->operator_translate_table[] = array(
$GLOBALS[
'TSFE']->csConvObj->conv_case(
'utf-8',
$GLOBALS[
'TSFE']->csConvObj->utf8_encode($this->pi_getLL(
'local_operator_AND'),
$GLOBALS[
'TSFE']->renderCharset),
'toLower'),
'AND');
329 $this->operator_translate_table[] = array(
$GLOBALS[
'TSFE']->csConvObj->conv_case(
'utf-8',
$GLOBALS[
'TSFE']->csConvObj->utf8_encode($this->pi_getLL(
'local_operator_OR'),
$GLOBALS[
'TSFE']->renderCharset),
'toLower'),
'OR');
330 $this->operator_translate_table[] = array(
$GLOBALS[
'TSFE']->csConvObj->conv_case(
'utf-8',
$GLOBALS[
'TSFE']->csConvObj->utf8_encode($this->pi_getLL(
'local_operator_NOT'),
$GLOBALS[
'TSFE']->renderCharset),
'toLower'),
'AND NOT');
332 $this->wholeSiteIdList = (int)
$GLOBALS[
'TSFE']->config[
'rootLine'][0][
'uid'];
335 if ($this->conf[
'show.'][
'L1sections']) {
336 $firstLevelMenu = $this->
getMenu($this->wholeSiteIdList);
337 foreach ($firstLevelMenu as $optionName => $mR) {
338 if (!$mR[
'nav_hide']) {
339 $this->optValues[
'sections'][
'rl1_' . $mR[
'uid']] = trim($this->
pi_getLL(
'opt_RL1') .
' ' . $mR[
'title']);
340 if ($this->conf[
'show.'][
'L2sections']) {
341 $secondLevelMenu = $this->
getMenu($mR[
'uid']);
342 foreach ($secondLevelMenu as $kk2 => $mR2) {
343 if (!$mR2[
'nav_hide']) {
344 $this->optValues[
'sections'][
'rl2_' . $mR2[
'uid']] = trim($this->
pi_getLL(
'opt_RL2') .
' ' . $mR2[
'title']);
346 unset($secondLevelMenu[$kk2]);
349 $this->optValues[
'sections'][
'rl2_' . implode(
',', array_keys($secondLevelMenu))] = $this->
pi_getLL(
'opt_RL2ALL');
352 unset($firstLevelMenu[$optionName]);
355 $this->optValues[
'sections'][
'rl1_' . implode(
',', array_keys($firstLevelMenu))] = $this->
pi_getLL(
'opt_RL1ALL');
359 if ($this->conf[
'search.'][
'rootPidList']) {
363 $this->templateCode = $this->cObj->fileResource($this->conf[
'templateFile']);
365 $res =
$GLOBALS[
'TYPO3_DB']->exec_SELECTquery(
'*',
'sys_language',
'1=1' . $this->cObj->enableFields(
'sys_language'));
366 while (FALSE !== ($data =
$GLOBALS[
'TYPO3_DB']->sql_fetch_assoc($res))) {
367 $this->optValues[
'lang'][$data[
'uid']] = $data[
'title'];
369 $GLOBALS[
'TYPO3_DB']->sql_free_result($res);
371 if ($hookObj = $this->
hookRequest(
'initialize_postProc')) {
372 $hookObj->initialize_postProc();
376 foreach ($this->optValues as $optionName => $optionValue) {
377 if (!isset($this->piVars[$optionName])) {
379 $this->piVars[$optionName] = key($optionValue);
383 if (is_array($this->conf[
'blind.'])) {
384 foreach ($this->conf[
'blind.'] as $optionName => $optionValue) {
385 if (is_array($optionValue)) {
386 foreach ($optionValue as $optionValueSubKey => $optionValueSubValue) {
387 if (!is_array($optionValueSubValue) && $optionValueSubValue && is_array($this->optValues[substr($optionName, 0, -1)])) {
388 unset($this->optValues[substr($optionName, 0, -1)][$optionValueSubKey]);
391 } elseif ($optionValue) {
393 unset($this->optValues[$optionName]);
419 $inSW = substr($this->piVars[
'sword'], 0, 200);
421 $inSW =
$GLOBALS[
'TSFE']->csConvObj->utf8_encode($inSW,
$GLOBALS[
'TSFE']->metaCharset);
422 $inSW =
$GLOBALS[
'TSFE']->csConvObj->entities_to_utf8($inSW, TRUE);
424 if ($hookObj = $this->
hookRequest(
'getSearchWords')) {
425 $sWordArray = $hookObj->getSearchWords_splitSWords($inSW, $defOp);
427 if ($this->piVars[
'type'] == 20) {
429 $sWordArray = array(array(
'sword' => trim($inSW),
'oper' =>
'AND'));
432 $search->default_operator = $defOp == 1 ?
'OR' :
'AND';
434 $search->register_and_explode_search_string($inSW);
435 if (is_array($search->sword_array)) {
455 foreach ($SWArr as $wordDef) {
456 if (!strstr($wordDef[
'sword'],
' ')) {
459 $res = $this->lexerObj->split2Words($wordDef[
'sword']);
461 foreach ($res as $word) {
462 $newSWArr[] = array(
'sword' => $word,
'oper' => $wordDef[
'oper']);
465 $newSWArr[] = $wordDef;
486 $freeIndexUid = $this->piVars[
'freeIndexUid'];
487 if ($freeIndexUid == -2) {
488 $freeIndexUid = $this->conf[
'search.'][
'defaultFreeIndexUidList'];
491 $accumulatedContent =
'';
492 foreach ($indexCfgs as $freeIndexUid) {
495 if ($hookObj = $this->
hookRequest(
'getResultRows')) {
496 $resData = $hookObj->getResultRows(
$sWArr, $freeIndexUid);
502 if ($hookObj = $this->
hookRequest(
'getDisplayResults')) {
503 $content = $hookObj->getDisplayResults(
$sWArr, $resData, $freeIndexUid);
509 if (count($indexCfgs) > 1) {
510 if ($freeIndexUid > 0) {
511 $indexCfgRec =
$GLOBALS[
'TYPO3_DB']->exec_SELECTgetSingleRow(
'title',
'index_config',
'uid=' . (
int)$freeIndexUid . $this->cObj->enableFields(
'index_config'));
512 $titleString = $indexCfgRec[
'title'];
514 $titleString = $this->
pi_getLL(
'opt_freeIndexUid_header_' . $freeIndexUid);
516 $content =
'<h1 class="tx-indexedsearch-category">' . htmlspecialchars($titleString) .
'</h1>' . $content;
518 $accumulatedContent .= $content;
523 return $accumulatedContent;
536 $GLOBALS[
'TT']->push(
'Searching result');
537 if ($hookObj = &$this->
hookRequest(
'getResultRows_SQLpointer')) {
538 $res = $hookObj->getResultRows_SQLpointer($searchWordArray, $freeIndexUid);
546 $totalSearchResultCount =
$GLOBALS[
'TYPO3_DB']->sql_num_rows($res);
551 $positionInSearchResults = 0;
552 $groupingPhashes = array();
554 $groupingChashes = array();
558 $resultRows = array();
564 $calculateExactCount = (bool) $this->conf[
'search.'][
'exactCount'];
565 $lastResultNumberOnPreviousPage = $currentPageNumber * $this->piVars[
'results'];
566 $firstResultNumberOnNextPage = ($currentPageNumber + 1) * $this->piVars[
'results'];
567 $lastResultNumberToAnalyze = ($currentPageNumber + 1) * $this->piVars[
'results'] + $this->piVars[
'results'];
570 while (FALSE !== ($row =
$GLOBALS[
'TYPO3_DB']->sql_fetch_assoc($res))) {
575 $totalSearchResultCount--;
579 if ($positionInSearchResults === 0) {
584 $phashGr = !in_array($row[
'phash_grouping'], $groupingPhashes);
585 $chashGr = !in_array(($row[
'contentHash'] .
'.' . $row[
'data_page_id']), $groupingChashes);
586 if ($phashGr && $chashGr) {
587 if ($row[
'show_resume'] || $this->conf[
'show.'][
'forbiddenRecords']) {
591 $groupingPhashes[] = $row[
'phash_grouping'];
593 $groupingChashes[] = $row[
'contentHash'] .
'.' . $row[
'data_page_id'];
594 $positionInSearchResults++;
596 if ($positionInSearchResults > $lastResultNumberOnPreviousPage && $positionInSearchResults <= $lastResultNumberToAnalyze) {
598 $row[
'result_number'] = $positionInSearchResults;
599 $resultRows[] = $row;
607 $nextResultPosition = $positionInSearchResults + 1;
608 if (!$calculateExactCount && $nextResultPosition > $firstResultNumberOnNextPage) {
614 $totalSearchResultCount--;
620 $totalSearchResultCount--;
623 $GLOBALS[
'TYPO3_DB']->sql_free_result($res);
625 'resultRows' => $resultRows,
627 'count' => $totalSearchResultCount
643 $list = $this->getPhashList(
$sWArr);
647 $GLOBALS[
'TT']->push(
'execFinalQuery');
668 $GLOBALS[
'TT']->push(
'Display Final result');
670 $this->firstRow = $resData[
'firstRow'];
673 $rowcontent .= $this->
compileResult($resData[
'resultRows'], $freeIndexUid);
675 if ($resData[
'count']) {
676 $this->
internal[
'res_count'] = $resData[
'count'];
677 $this->
internal[
'results_at_a_time'] = $this->piVars[
'results'];
679 $addString = $resData[
'count'] && $this->piVars[
'group'] ==
'sections' && $freeIndexUid <= 0 ?
' ' . sprintf($this->
pi_getLL((count($this->resultSections) > 1 ?
'inNsections' :
'inNsection')), count($this->resultSections)) :
'';
684 if ($resData[
'count']) {
685 $content = $browseBox1 . $rowcontent . $browseBox2;
687 $content =
'<p' . $this->
pi_classParam(
'noresults') .
'>' . $this->
pi_getLL(
'noResults',
'', TRUE) .
'</p>';
691 $content .=
'<p' . $this->
pi_classParam(
'noresults') .
'>' . $this->
pi_getLL(
'noResults',
'', TRUE) .
'</p>';
694 $what = $this->
tellUsWhatIsSeachedFor(
$sWArr) . (substr($this->piVars[
'sections'], 0, 2) ==
'rl' ?
' ' . $this->
pi_getLL(
'inSection',
'', TRUE) .
' "' . preg_replace(
'#^/#',
'', htmlspecialchars($this->
getPathFromPageId(substr($this->piVars[
'sections'], 4)))) .
'"' :
'');
695 $what =
'<div' . $this->
pi_classParam(
'whatis') .
'>' . $this->cObj->stdWrap($what, $this->conf[
'whatis_stdWrap.']) .
'</div>';
696 $content = $what . $content;
713 $newResultRows = array();
714 foreach ($resultRows as $row) {
715 $id = md5($row[
'phash_grouping']);
716 if (is_array($newResultRows[$id])) {
717 if (!$newResultRows[$id][
'show_resume'] && $row[
'show_resume']) {
720 $subrows = $newResultRows[$id][
'_sub'];
721 unset($newResultRows[$id][
'_sub']);
722 $subrows[] = $newResultRows[$id];
724 $newResultRows[$id] = $row;
725 $newResultRows[$id][
'_sub'] = $subrows;
727 $newResultRows[$id][
'_sub'][] = $row;
730 $newResultRows[$id] = $row;
733 $resultRows = $newResultRows;
734 $this->resultSections = array();
735 if ($freeIndexUid <= 0) {
736 switch ($this->piVars[
'group']) {
738 $rl2flag = substr($this->piVars[
'sections'], 0, 2) ==
'rl';
740 foreach ($resultRows as $row) {
741 $id = $row[
'rl0'] .
'-' . $row[
'rl1'] . ($rl2flag ?
'-' . $row[
'rl2'] :
'');
742 $sections[$id][] = $row;
744 $this->resultSections = array();
745 foreach ($sections as $id => $resultRows) {
746 $rlParts = explode(
'-', $id);
747 $theId = $rlParts[2] ? $rlParts[2] : ($rlParts[1] ? $rlParts[1] : $rlParts[0]);
748 $theRLid = $rlParts[2] ?
'rl2_' . $rlParts[2] : ($rlParts[1] ?
'rl1_' . $rlParts[1] :
'0');
750 if ($sectionName[0] ==
'/') {
751 $sectionName = substr($sectionName, 1);
753 if (!trim($sectionName)) {
754 $sectionTitleLinked = $this->
pi_getLL(
'unnamedSection',
'', TRUE) .
':';
758 $sectionTitleLinked =
'<a href="#" onclick="' . htmlspecialchars($onclick) .
'">' . htmlspecialchars($sectionName) .
':</a>';
760 $this->resultSections[$id] = array($sectionName, count($resultRows));
762 $content .= $this->
makeSectionHeader($id, $sectionTitleLinked, count($resultRows));
765 foreach ($resultRows as $row) {
768 $content .= $this->cObj->stdWrap($resultlist, $this->conf[
'resultlist_stdWrap.']);
774 foreach ($resultRows as $row) {
777 $content .= $this->cObj->stdWrap($resultlist, $this->conf[
'resultlist_stdWrap.']);
781 foreach ($resultRows as $row) {
784 $content .= $this->cObj->stdWrap($resultlist, $this->conf[
'resultlist_stdWrap.']);
786 return '<div' . $this->
pi_classParam(
'res') .
'>' . $content .
'</div>';
802 public function getPhashList(
$sWArr) {
805 $totalHashList = array();
808 foreach (
$sWArr as $k => $v) {
810 $sWord = $v[
'sword'];
811 $theType = (string) $this->piVars[
'type'];
812 if (strstr($sWord,
' ')) {
816 $GLOBALS[
'TT']->push(
'SearchWord "' . $sWord .
'" - $theType=' . $theType);
821 $res = $this->
searchWord($sWord, self::WILDCARD_LEFT | self::WILDCARD_RIGHT);
825 $res = $this->
searchWord($sWord, self::WILDCARD_RIGHT);
829 $res = $this->
searchWord($sWord, self::WILDCARD_LEFT);
841 $res = $this->
searchMetaphone($indexerObj->metaphone($sWord, $this->storeMetaphoneInfoAsWords));
847 $this->piVars[
'order'] =
'mtime';
857 $phashList = array();
858 while ($row =
$GLOBALS[
'TYPO3_DB']->sql_fetch_assoc($res)) {
859 $phashList[] = $row[
'phash'];
861 $GLOBALS[
'TYPO3_DB']->sql_free_result($res);
864 switch ($v[
'oper']) {
866 $totalHashList = array_unique(array_merge($phashList, $totalHashList));
869 $totalHashList = array_diff($totalHashList, $phashList);
873 $totalHashList = array_intersect($totalHashList, $phashList);
876 $totalHashList = $phashList;
882 return implode(
',', $totalHashList);
894 return $GLOBALS[
'TYPO3_DB']->exec_SELECTquery(
'IR.phash',
'index_words IW, 896 index_section ISEC', $wordSel .
' 898 AND ISEC.phash = IR.phash 900 ' . $plusQ,
'IR.phash');
912 $wildcard_left = $mode & self::WILDCARD_LEFT ?
'%' :
'';
913 $wildcard_right = $mode & self::WILDCARD_RIGHT ?
'%' :
'';
914 $wSel =
'IW.baseword LIKE \'' . $wildcard_left .
$GLOBALS[
'TYPO3_DB']->quoteStr($sWord,
'index_words') . $wildcard_right .
'\'';
915 $this->wSelClauses[] = $wSel;
929 $this->wSelClauses[] = $wSel;
942 $res =
$GLOBALS[
'TYPO3_DB']->exec_SELECTquery(
'ISEC.phash',
'index_section ISEC, index_fulltext IFT',
'IFT.fulltextdata LIKE \'%' .
$GLOBALS[
'TYPO3_DB']->quoteStr($sSentence,
'index_fulltext') .
'%\' AND 943 ISEC.phash = IFT.phash 945 $this->wSelClauses[] =
'1=1';
957 $wSel =
'IW.metaphone=' . $sWord;
958 $this->wSelClauses[] = $wSel;
969 $out = $this->wholeSiteIdList < 0 ?
'' :
' AND ISEC.rl0 IN (' . $this->wholeSiteIdList .
')';
971 if (substr($this->piVars[
'sections'], 0, 4) ==
'rl1_') {
973 $out .=
' AND ISEC.rl1 IN (' . $list .
')';
975 } elseif (substr($this->piVars[
'sections'], 0, 4) ==
'rl2_') {
977 $out .=
' AND ISEC.rl2 IN (' . $list .
')';
979 } elseif (is_array(
$GLOBALS[
'TYPO3_CONF_VARS'][
'EXTCONF'][
'indexed_search'][
'addRootLineFields'])) {
981 foreach (
$GLOBALS[
'TYPO3_CONF_VARS'][
'EXTCONF'][
'indexed_search'][
'addRootLineFields'] as $fieldName => $rootLineLevel) {
982 if (substr($this->piVars[
'sections'], 0, strlen($fieldName) + 1) == $fieldName .
'_') {
984 $out .=
' AND ISEC.' . $fieldName .
' IN (' . $list .
')';
992 switch ((
string) $this->piVars[
'sections']) {
995 $out .=
' AND ISEC.page_id=' .
$GLOBALS[
'TSFE']->id;
999 $out .=
' AND ISEC.rl2=0';
1003 $out .=
' AND ISEC.rl2>0';
1017 switch ((
string) $this->piVars[
'media']) {
1020 $out =
' AND IP.item_type=' .
$GLOBALS[
'TYPO3_DB']->fullQuoteStr(
'0',
'index_phash');
1024 $out =
' AND IP.item_type<>' .
$GLOBALS[
'TYPO3_DB']->fullQuoteStr(
'0',
'index_phash');
1031 $out =
' AND IP.item_type=' .
$GLOBALS[
'TYPO3_DB']->fullQuoteStr($this->piVars[
'media'],
'index_phash');
1043 if ($this->piVars[
'lang'] >= 0) {
1045 return 'AND IP.sys_language_uid=' . (int)$this->piVars[
'lang'];
1057 if ($freeIndexUid >= 0) {
1059 $indexCfgRec =
$GLOBALS[
'TYPO3_DB']->exec_SELECTgetSingleRow(
'indexcfgs',
'index_config',
'type=5 AND uid=' . (
int)$freeIndexUid . $this->cObj->enableFields(
'index_config'));
1060 if (is_array($indexCfgRec)) {
1064 foreach ($refs as $ref) {
1067 case 'index_config':
1068 $idxRec =
$GLOBALS[
'TYPO3_DB']->exec_SELECTgetSingleRow(
'uid',
'index_config',
'uid=' . (
int)
$uid . $this->cObj->enableFields(
'index_config'));
1074 $indexCfgRecordsFromPid =
$GLOBALS[
'TYPO3_DB']->exec_SELECTgetRows(
'uid',
'index_config',
'pid=' . (
int)
$uid . $this->cObj->enableFields(
'index_config'));
1075 foreach ($indexCfgRecordsFromPid as $idxRec) {
1076 $list[] = $idxRec[
'uid'];
1081 $list = array_unique($list);
1083 $list = array((
int)$freeIndexUid);
1085 return ' AND IP.freeIndexUid IN (' . implode(
',', $list) .
')';
1102 if ($hookObj = $this->
hookRequest(
'execFinalQuery_idList')) {
1103 $page_where = $hookObj->execFinalQuery_idList($list);
1104 } elseif ($this->join_pages) {
1108 $page_where =
'pages.uid = ISEC.page_id 1109 ' . $this->cObj->enableFields(
'pages') .
' 1110 AND pages.no_search=0 1111 AND pages.doktype<200 1113 } elseif ($this->wholeSiteIdList >= 0) {
1117 foreach ($siteIdNumbers as $rootId) {
1118 $id_list[] = $this->cObj->getTreeList(-1 * $rootId, 9999);
1120 $page_where =
'ISEC.page_id IN (' . implode(
',', $id_list) .
')';
1123 $page_where =
'1=1';
1128 if (substr($this->piVars[
'order'], 0, 5) ==
'rank_') {
1129 switch ($this->piVars[
'order']) {
1133 $grsel =
'MAX(IR.flags) AS order_val1, SUM(IR.freq) AS order_val2';
1138 $grsel =
'AVG(IR.first) AS order_val';
1143 $grsel =
'SUM(IR.count) AS order_val';
1148 $grsel =
'SUM(IR.freq) AS order_val';
1153 $wordSel =
'(' . implode(
' OR ', $this->wSelClauses) .
') AND ';
1155 $res =
$GLOBALS[
'TYPO3_DB']->exec_SELECTquery(
1156 'ISEC.*, IP.*, ' . $grsel,
1160 index_phash IP' . $page_join,
1162 'IP.phash IN (' . $list .
') ' .
1165 AND ISEC.phash = IR.phash 1166 AND IP.phash = IR.phash 1167 AND ' . $page_where,
1168 'IP.phash,ISEC.phash,ISEC.phash_t3,ISEC.rl0,ISEC.rl1,ISEC.rl2 ,ISEC.page_id,ISEC.uniqid,IP.phash_grouping,IP.data_filename ,IP.data_page_id ,IP.data_page_reg1,IP.data_page_type,IP.data_page_mp,IP.gr_list,IP.item_type,IP.item_title,IP.item_description,IP.item_mtime,IP.tstamp,IP.item_size,IP.contentHash,IP.crdate,IP.parsetime,IP.sys_language_uid,IP.item_crdate,IP.cHashParams,IP.externalUrl,IP.recordUid,IP.freeIndexUid,IP.freeIndexSetId',
1174 switch ((
string) $this->piVars[
'order']) {
1185 $res =
$GLOBALS[
'TYPO3_DB']->exec_SELECTquery(
'ISEC.*, IP.*',
'index_phash IP,index_section ISEC' . $page_join,
'IP.phash IN (' . $list .
') ' . $this->
mediaTypeWhere() .
' ' . $this->
languageWhere() . $freeIndexUidClause .
' 1186 AND IP.phash = ISEC.phash 1187 AND ' . $page_where,
'IP.phash,ISEC.phash,ISEC.phash_t3,ISEC.rl0,ISEC.rl1,ISEC.rl2 ,ISEC.page_id,ISEC.uniqid,IP.phash_grouping,IP.data_filename ,IP.data_page_id ,IP.data_page_reg1,IP.data_page_type,IP.data_page_mp,IP.gr_list,IP.item_type,IP.item_title,IP.item_description,IP.item_mtime,IP.tstamp,IP.item_size,IP.contentHash,IP.crdate,IP.parsetime,IP.sys_language_uid,IP.item_crdate,IP.cHashParams,IP.externalUrl,IP.recordUid,IP.freeIndexUid,IP.freeIndexSetId', $orderBy);
1204 if ($row[
'freeIndexUid']) {
1208 if ($row[
'item_type']) {
1214 if (\
TYPO3\CMS\IndexedSearch\Utility\IndexedSearchUtility::isTableUsed(
'index_grlist')) {
1215 $res =
$GLOBALS[
'TYPO3_DB']->exec_SELECTquery(
'phash',
'index_grlist',
'phash=' . (
int)$row[
'phash_t3'] .
' AND gr_list=' .
$GLOBALS[
'TYPO3_DB']->fullQuoteStr(
$GLOBALS[
'TSFE']->gr_list,
'index_grlist'));
1219 if ($res &&
$GLOBALS[
'TYPO3_DB']->sql_num_rows($res)) {
1226 if ((
string)$row[
'gr_list'] !== (
string)
$GLOBALS[
'TSFE']->gr_list) {
1228 if (\
TYPO3\CMS\IndexedSearch\Utility\IndexedSearchUtility::isTableUsed(
'index_grlist')) {
1229 $res =
$GLOBALS[
'TYPO3_DB']->exec_SELECTquery(
'phash',
'index_grlist',
'phash=' . (
int)$row[
'phash'] .
' AND gr_list=' .
$GLOBALS[
'TYPO3_DB']->fullQuoteStr(
$GLOBALS[
'TSFE']->gr_list,
'index_grlist'));
1233 if ($res &&
$GLOBALS[
'TYPO3_DB']->sql_num_rows($res)) {
1253 $recordExists = TRUE;
1255 if ($row[
'item_type']) {
1257 if (!is_file($row[
'data_filename']) || !file_exists($row[
'data_filename'])) {
1258 $recordExists = FALSE;
1261 return $recordExists;
1272 $desc = $this->piVars[
'desc'];
1276 return !$desc ?
' DESC' :
'';
1289 $insertFields = array(
1290 'searchstring' => $this->piVars[
'sword'],
1291 'searchoptions' => serialize(array($this->piVars,
$sWArr, $pt)),
1292 'feuser_id' => (
int)$this->fe_user->user[
'uid'],
1294 'cookie' => (
string)$this->fe_user->id,
1298 'hits' => (
int)$count,
1302 $GLOBALS[
'TYPO3_DB']->exec_INSERTquery(
'index_stat_search', $insertFields);
1303 $newId =
$GLOBALS[
'TYPO3_DB']->sql_insert_id();
1305 foreach (
$sWArr as $val) {
1306 $insertFields = array(
1307 'word' => $val[
'sword'],
1308 'index_stat_search_id' => $newId,
1313 $GLOBALS[
'TYPO3_DB']->exec_INSERTquery(
'index_stat_word', $insertFields);
1331 $html = $this->cObj->getSubpart($this->templateCode,
'###SEARCH_FORM###');
1333 $substituteArray = array(
'legend',
'searchFor',
'extResume',
'atATime',
'orderBy',
'fromSection',
'searchIn',
'match',
'style',
'freeIndexUid');
1334 foreach ($substituteArray as $marker) {
1337 $markerArray[
'###FORM_SUBMIT###'] = $this->
pi_getLL(
'submit_button_label',
'', TRUE);
1339 $markerArray[
'###SWORD_VALUE###'] = htmlspecialchars($this->piVars[
'sword']);
1341 if ($this->conf[
'show.'][
'clearSearchBox'] && $this->conf[
'show.'][
'clearSearchBox.'][
'enableSubSearchCheckBox']) {
1342 $markerArray[
'###SWORD_PREV_VALUE###'] = htmlspecialchars($this->conf[
'show.'][
'clearSearchBox'] ?
'' : $this->piVars[
'sword']);
1343 $markerArray[
'###SWORD_PREV_INCLUDE_CHECKED###'] = $this->piVars[
'sword_prev_include'] ?
' checked="checked"' :
'';
1344 $markerArray[
'###ADD_TO_CURRENT_SEARCH###'] = $this->
pi_getLL(
'makerating_addToCurrentSearch',
'', TRUE);
1346 $html = $this->cObj->substituteSubpart($html,
'###ADDITONAL_KEYWORD###',
'');
1349 $hiddenFieldCode = $this->cObj->getSubpart($this->templateCode,
'###HIDDEN_FIELDS###');
1350 $hiddenFieldCode = preg_replace(
'/^\\n\\t(.+)/ms',
'$1', $hiddenFieldCode);
1352 $hiddenFieldArr = array();
1354 $hiddenFieldMarkerArray = array();
1355 $hiddenFieldMarkerArray[
'###HIDDEN_FIELDNAME###'] = $this->prefixId .
'[' . $fieldName .
']';
1356 $hiddenFieldMarkerArray[
'###HIDDEN_VALUE###'] = htmlspecialchars((
string) $this->piVars[$fieldName]);
1357 $hiddenFieldArr[$fieldName] = $this->cObj->substituteMarkerArrayCached($hiddenFieldCode, $hiddenFieldMarkerArray, array(), array());
1360 if ($this->piVars[
'ext']) {
1362 if (!is_array(
$optValues[
'type']) && !is_array(
$optValues[
'defOp']) || $this->conf[
'blind.'][
'type'] && $this->conf[
'blind.'][
'defOp']) {
1363 $html = $this->cObj->substituteSubpart($html,
'###SELECT_SEARCH_FOR###',
'');
1365 if (is_array(
$optValues[
'type']) && !$this->conf[
'blind.'][
'type']) {
1366 unset($hiddenFieldArr[
'type']);
1369 $html = $this->cObj->substituteSubpart($html,
'###SELECT_SEARCH_TYPE###',
'');
1371 if (is_array(
$optValues[
'defOp']) || !$this->conf[
'blind.'][
'defOp']) {
1374 $html = $this->cObj->substituteSubpart($html,
'###SELECT_SEARCH_DEFOP###',
'');
1378 if (!is_array(
$optValues[
'media']) && !is_array(
$optValues[
'lang']) || $this->conf[
'blind.'][
'media'] && $this->conf[
'blind.'][
'lang']) {
1379 $html = $this->cObj->substituteSubpart($html,
'###SELECT_SEARCH_IN###',
'');
1381 if (is_array(
$optValues[
'media']) && !$this->conf[
'blind.'][
'media']) {
1382 unset($hiddenFieldArr[
'media']);
1385 $html = $this->cObj->substituteSubpart($html,
'###SELECT_SEARCH_MEDIA###',
'');
1387 if (is_array(
$optValues[
'lang']) || !$this->conf[
'blind.'][
'lang']) {
1388 unset($hiddenFieldArr[
'lang']);
1391 $html = $this->cObj->substituteSubpart($html,
'###SELECT_SEARCH_LANG###',
'');
1395 if (!is_array(
$optValues[
'sections']) || $this->conf[
'blind.'][
'sections']) {
1396 $html = $this->cObj->substituteSubpart($html,
'###SELECT_SECTION###',
'');
1401 if (!is_array(
$optValues[
'freeIndexUid']) || $this->conf[
'blind.'][
'freeIndexUid']) {
1402 $html = $this->cObj->substituteSubpart($html,
'###SELECT_FREEINDEXUID###',
'');
1407 if (!is_array(
$optValues[
'order']) || !is_array(
$optValues[
'desc']) || $this->conf[
'blind.'][
'order']) {
1408 $html = $this->cObj->substituteSubpart($html,
'###SELECT_ORDER###',
'');
1410 unset($hiddenFieldArr[
'order']);
1411 unset($hiddenFieldArr[
'desc']);
1412 unset($hiddenFieldArr[
'results']);
1418 if (!is_array(
$optValues[
'results']) || !is_array(
$optValues[
'results']) || $this->conf[
'blind.'][
'results']) {
1419 $html = $this->cObj->substituteSubpart($html,
'###SELECT_RESULTS###',
'');
1424 if (!is_array(
$optValues[
'group']) || $this->conf[
'blind.'][
'group']) {
1425 $html = $this->cObj->substituteSubpart($html,
'###SELECT_GROUP###',
'');
1427 unset($hiddenFieldArr[
'group']);
1430 if ($this->conf[
'blind.'][
'extResume']) {
1431 $html = $this->cObj->substituteSubpart($html,
'###SELECT_EXTRESUME###',
'');
1433 $markerArray[
'###EXT_RESUME_CHECKED###'] = $this->piVars[
'extResume'] ?
' checked="checked"' :
'';
1437 $html = $this->cObj->substituteSubpart($html,
'###SEARCH_FORM_EXTENDED###',
'');
1439 if ($this->conf[
'show.'][
'advancedSearchLink']) {
1441 $markerArray[
'###LINKTOOTHERMODE###'] =
'<a href="' . htmlspecialchars($linkToOtherMode) .
'">' . $this->
pi_getLL(($this->piVars[
'ext'] ?
'link_regularSearch' :
'link_advancedSearch'),
'', TRUE) .
'</a>';
1443 $markerArray[
'###LINKTOOTHERMODE###'] =
'';
1446 $html = $this->cObj->substituteSubpart($html,
'###HIDDEN_FIELDS###', implode(
'', $hiddenFieldArr));
1447 $substitutedContent = $this->cObj->substituteMarkerArrayCached($html, $markerArray, array(), array());
1448 return $substitutedContent;
1464 $sel = (string)$k === (
string)$value ?
' selected="selected"' :
'';
1468 $opt[] =
'<option value="' . htmlspecialchars($k) .
'"' . $sel .
'>' . htmlspecialchars($v) .
'</option>';
1470 return implode(
'', $opt);
1481 if ($this->conf[
'show.'][
'rules']) {
1482 $html = $this->cObj->getSubpart($this->templateCode,
'###RULES###');
1483 $markerArray[
'###RULES_HEADER###'] = $this->
pi_getLL(
'rules_header',
'', TRUE);
1484 $markerArray[
'###RULES_TEXT###'] = nl2br(trim($this->
pi_getLL(
'rules_text',
'', TRUE)));
1485 $substitutedContent = $this->cObj->substituteMarkerArrayCached($html, $markerArray, array(), array());
1486 return $this->cObj->stdWrap($substitutedContent, $this->conf[
'rules_stdWrap.']);
1497 if (count($this->resultSections)) {
1499 $html = $this->cObj->getSubpart($this->templateCode,
'###RESULT_SECTION_LINKS###');
1500 $item = $this->cObj->getSubpart($this->templateCode,
'###RESULT_SECTION_LINKS_LINK###');
1501 foreach ($this->resultSections as $id => $dat) {
1502 $markerArray = array();
1503 $aBegin =
'<a href="' . htmlspecialchars((
$GLOBALS[
'TSFE']->anchorPrefix .
'#anchor_' . md5($id))) .
'">';
1504 $aContent = htmlspecialchars((trim($dat[0]) ? trim($dat[0]) : $this->
pi_getLL(
'unnamedSection'))) .
' (' . $dat[1] .
' ' . $this->
pi_getLL(($dat[1] > 1 ?
'word_pages' :
'word_page'),
'', TRUE) .
')';
1506 $markerArray[
'###LINK###'] = $aBegin . $aContent . $aEnd;
1507 $links[] = $this->cObj->substituteMarkerArrayCached($item, $markerArray, array(), array());
1509 $html = $this->cObj->substituteMarkerArrayCached($html, array(
'###LINKS###' => implode(
'', $links)), array(), array());
1510 return '<div' . $this->
pi_classParam(
'sectionlinks') .
'>' . $this->cObj->stdWrap($html, $this->conf[
'sectionlinks_stdWrap.']) .
'</div>';
1524 $html = $this->cObj->getSubpart($this->templateCode,
'###SECTION_HEADER###');
1525 $markerArray[
'###ANCHOR_URL###'] =
'anchor_' . md5($id);
1526 $markerArray[
'###SECTION_TITLE###'] = $sectionTitleLinked;
1527 $markerArray[
'###RESULT_COUNT###'] = $countResultRows;
1528 $markerArray[
'###RESULT_NAME###'] = $this->
pi_getLL(
'word_page' . ($countResultRows > 1 ?
's' :
''));
1529 $substitutedContent = $this->cObj->substituteMarkerArrayCached($html, $markerArray, array(), array());
1530 return $substitutedContent;
1544 if ($hookObj = $this->
hookRequest(
'printResultRow')) {
1545 return $hookObj->printResultRow($row, $headerOnly, $tmplContent);
1547 $html = $this->cObj->getSubpart($this->templateCode,
'###RESULT_OUTPUT###');
1548 if (!is_array($row[
'_sub'])) {
1549 $html = $this->cObj->substituteSubpart($html,
'###ROW_SUB###',
'');
1552 $html = $this->cObj->substituteSubpart($html,
'###ROW_SHORT###',
'');
1553 } elseif ($headerOnly == 1) {
1554 $html = $this->cObj->substituteSubpart($html,
'###ROW_LONG###',
'');
1555 } elseif ($headerOnly == 2) {
1556 $html = $this->cObj->substituteSubpart($html,
'###ROW_SHORT###',
'');
1557 $html = $this->cObj->substituteSubpart($html,
'###ROW_LONG###',
'');
1559 if (is_array($tmplContent)) {
1560 foreach ($tmplContent as $k => $v) {
1565 $markerArray[
'###TEXT_ITEM_SIZE###'] = $this->
pi_getLL(
'res_size',
'', TRUE);
1566 $markerArray[
'###TEXT_ITEM_CRDATE###'] = $this->
pi_getLL(
'res_created',
'', TRUE);
1567 $markerArray[
'###TEXT_ITEM_MTIME###'] = $this->
pi_getLL(
'res_modified',
'', TRUE);
1568 $markerArray[
'###TEXT_ITEM_PATH###'] = $this->
pi_getLL(
'res_path',
'', TRUE);
1569 $html = $this->cObj->substituteMarkerArrayCached($html, $markerArray, array(), array());
1571 if (is_array($row[
'_sub'])) {
1573 $html = str_replace(
'###TEXT_ROW_SUB###', $this->
pi_getLL(
'res_otherMatching',
'', TRUE), $html);
1574 foreach ($row[
'_sub'] as $subRow) {
1578 $markerArray[
'###TEXT_ROW_SUB###'] = $this->
pi_getLL(
'res_otherMatching',
'', TRUE);
1579 $html = str_replace(
'###TEXT_ROW_SUB###', $this->
pi_getLL(
'res_otherPageAsWell',
'', TRUE), $html);
1598 $pointer = (int)$this->piVars[
'pointer'];
1599 $count = (int)$this->
internal[
'res_count'];
1601 $pageCount = (int)ceil($count / $results_at_a_time);
1605 if ($pageCount > 1) {
1611 $links[] =
'<li>' . $this->
makePointerSelector_link($this->
pi_getLL(
'pi_list_browseresults_prev',
'< Previous', TRUE), $pointer - 1, $freeIndexUid) .
'</li>';
1613 $minPage = $pointer - (int)floor($maxPages / 2);
1614 $maxPage = $minPage + $maxPages - 1;
1617 $maxPage -= $minPage;
1619 } elseif ($maxPage >= $pageCount) {
1620 $minPage -= $maxPage - $pageCount + 1;
1621 $maxPage = $pageCount - 1;
1623 $pageLabel = $this->
pi_getLL(
'pi_list_browseresults_page',
'Page', TRUE);
1624 for ($a = $minPage; $a <= $maxPage; $a++) {
1625 $label = trim($pageLabel .
' ' . ($a + 1));
1627 if ($a === $pointer) {
1628 $links[] =
'<li' . $this->
pi_classParam(
'browselist-currentPage') .
'><strong>' . $link .
'</strong></li>';
1630 $links[] =
'<li>' . $link .
'</li>';
1633 if ($pointer + 1 < $pageCount) {
1637 if (!empty($links)) {
1639 <ul class="browsebox"> 1640 ' . implode(
'', $links) .
' 1643 $label = str_replace(
1644 array(
'###TAG_BEGIN###',
'###TAG_END###'),
1645 array(
'<strong>',
'</strong>'),
1646 $this->
pi_getLL(
'pi_list_browseresults_display',
'Displaying results ###TAG_BEGIN###%1$s to %2$s###TAG_END### out of ###TAG_BEGIN###%3$s###TAG_END###')
1648 $resultsFrom = $pointer * $results_at_a_time + 1;
1649 $resultsTo = min($resultsFrom + $results_at_a_time - 1, $count);
1650 $resultCountText =
'';
1651 if ($showResultCount) {
1652 $resultCountText =
'<p>' . sprintf($label, $resultsFrom, $resultsTo, $count) . $addString .
'</p>';
1656 . $addPart .
'</div>';
1676 $CSSsuffix = $specRowConf[
'CSSsuffix'] ?
'-' . $specRowConf[
'CSSsuffix'] :
'';
1678 if ($row[
'item_type']) {
1680 if ($row[
'show_resume']) {
1682 $targetAttribute =
'';
1683 if (
$GLOBALS[
'TSFE']->config[
'config'][
'fileTarget']) {
1684 $targetAttribute =
' target="' . htmlspecialchars(
$GLOBALS[
'TSFE']->config[
'config'][
'fileTarget']) .
'"';
1686 $title =
'<a href="' . htmlspecialchars($row[
'data_filename']) .
'"' . $targetAttribute .
'>' . htmlspecialchars($this->
makeTitle($row)) .
'</a>';
1690 unset($copy_row[
'cHashParams']);
1691 $title = $this->
linkPage($row[
'page_id'], htmlspecialchars($this->
makeTitle($row)), $copy_row);
1696 if ($this->conf[
'forwardSearchWordsInResultLink']) {
1697 $markUpSwParams = array(
'no_cache' => 1);
1698 foreach ($this->sWArr as $d) {
1699 $markUpSwParams[
'sword_list'][] = $d[
'sword'];
1702 $markUpSwParams = array();
1704 $title = $this->
linkPage($row[
'data_page_id'], htmlspecialchars($this->
makeTitle($row)), $row, $markUpSwParams);
1706 $tmplContent = array();
1707 $tmplContent[
'title'] = $title;
1708 $tmplContent[
'result_number'] = $this->conf[
'show.'][
'resultNumber'] ? $row[
'result_number'] .
': ' :
' ';
1709 $tmplContent[
'icon'] = $this->
makeItemTypeIcon($row[
'item_type'],
'', $specRowConf);
1710 $tmplContent[
'rating'] = $this->
makeRating($row);
1711 $tmplContent[
'description'] = $this->
makeDescription($row, $this->piVars[
'extResume'] && !$headerOnly ? 0 : 1);
1712 $tmplContent = $this->
makeInfo($row, $tmplContent);
1715 $tmplContent[
'CSSsuffix'] = $CSSsuffix;
1717 if ($hookObj = $this->
hookRequest(
'prepareResultRowTemplateData_postProc')) {
1718 $tmplContent = $hookObj->prepareResultRowTemplateData_postProc($tmplContent, $row, $headerOnly);
1720 return $tmplContent;
1735 foreach (
$sWArr as $k => $v) {
1737 switch ($v[
'oper']) {
1753 return $searchingFor;
1764 return '"<span' . $this->
pi_classParam(
'sw') .
'>' . htmlspecialchars($str) .
'</span>"';
1781 $sel = (string)$k === (
string)$value ?
' selected="selected"' :
'';
1785 $opt[] =
'<option value="' . htmlspecialchars($k) .
'"' . $sel .
'>' . htmlspecialchars($v) .
'</option>';
1787 return '<select name="' . $name .
'">' . implode(
'', $opt) .
'</select>';
1802 $onclick =
'document.getElementById(\'' . $this->prefixId .
'_pointer\').value=\'' . $p .
'\';
' . 'document.getElementById(\
'' . $this->prefixId .
'_freeIndexUid\').value=\'' . rawurlencode($freeIndexUid) .
'\';
' . 'document.getElementById(\
'' . $this->prefixId .
'\').submit();
return false;
'; 1803 return '<a href=
"#" onclick=
"' . htmlspecialchars($onclick) . '">
' . $str . '</a>
'; 1815 public function makeItemTypeIcon($it, $alt = '', $specRowConf) { 1816 // Build compound key if item type is 0, iconRendering is not used 1817 // and specConfs.[pid].pageIcon was set in TS 1818 if ($it === '0
' && $specRowConf['_pid
'] && is_array($specRowConf['pageIcon.
']) && !is_array($this->conf['iconRendering.
'])) { 1819 $it .= ':
' . $specRowConf['_pid
']; 1821 if (!isset($this->iconFileNameCache[$it])) { 1822 $this->iconFileNameCache[$it] = ''; 1823 // If TypoScript is used to render the icon: 1824 if (is_array($this->conf['iconRendering.
'])) { 1825 $this->cObj->setCurrentVal($it); 1826 $this->iconFileNameCache[$it] = $this->cObj->cObjGetSingle($this->conf['iconRendering
'], $this->conf['iconRendering.
']); 1828 // Default creation / finding of icon: 1830 if ($it === '0
' || substr($it, 0, 2) == '0:
') { 1831 if (is_array($specRowConf['pageIcon.
'])) { 1832 $this->iconFileNameCache[$it] = $this->cObj->IMAGE($specRowConf['pageIcon.
']); 1834 $icon = 'EXT:indexed_search/pi/res/pages.gif
'; 1836 } elseif ($this->external_parsers[$it]) { 1837 $icon = $this->external_parsers[$it]->getIcon($it); 1840 $fullPath = GeneralUtility::getFileAbsFileName($icon); 1842 $info = @getimagesize($fullPath); 1843 $iconPath = \TYPO3\CMS\Core\Utility\PathUtility::stripPathSitePrefix($fullPath); 1844 $this->iconFileNameCache[$it] = is_array($info) ? '<img src=
"' . $iconPath . '" ' . $info[3] . ' title=
"' . htmlspecialchars($alt) . '" alt=
"" />
' : ''; 1849 return $this->iconFileNameCache[$it]; 1859 public function makeRating($row) { 1860 switch ((string) $this->piVars['order
']) { 1862 // Number of occurencies on page 1863 return $row['order_val
'] . ' ' . $this->pi_getLL('maketitle_matches
'); 1866 // Close to top of page 1867 return ceil(\TYPO3\CMS\Core\Utility\MathUtility::forceIntegerInRange((255 - $row['order_val
']), 1, 255) / 255 * 100) . '%
'; 1870 // Based on priority assigned to <title> / <meta-keywords> / <meta-description> / <body> 1871 if ($this->firstRow['order_val2
']) { 1872 $base = $row['order_val1
'] * 256; 1873 // (3 MSB bit, 224 is highest value of order_val1 currently) 1874 $freqNumber = $row['order_val2
'] / $this->firstRow['order_val2
'] * pow(2, 12); 1876 $total = \TYPO3\CMS\Core\Utility\MathUtility::forceIntegerInRange($base + $freqNumber, 0, 32767); 1877 return ceil(log($total) / log(32767) * 100) . '%
'; 1881 // Based on frequency 1883 $total = \TYPO3\CMS\Core\Utility\MathUtility::forceIntegerInRange($row['order_val
'], 0, $max); 1884 return ceil(log($total) / log($max) * 100) . '%
'; 1887 // Based on creation date 1888 return $this->cObj->calcAge($GLOBALS['EXEC_TIME
'] - $row['item_crdate
'], 0); 1891 // Based on modification time 1892 return $this->cObj->calcAge($GLOBALS['EXEC_TIME
'] - $row['item_mtime
'], 0); 1909 public function makeDescription($row, $noMarkup = 0, $lgd = 180) { 1910 if ($row['show_resume
']) { 1913 if (\TYPO3\CMS\IndexedSearch\Utility\IndexedSearchUtility::isTableUsed('index_fulltext
')) { 1914 $res = $GLOBALS['TYPO3_DB
']->exec_SELECTquery('*
', 'index_fulltext
', 'phash=
' . (int)$row['phash
']); 1919 if ($ftdrow = $GLOBALS['TYPO3_DB
']->sql_fetch_assoc($res)) { 1920 // Cut HTTP references after some length 1921 $content = preg_replace('/(http:\\/\\/[^ ]{60})([^ ]+)/i
', '$1...
', $ftdrow['fulltextdata
']); 1922 $markedSW = $this->markupSWpartsOfString($content); 1924 $GLOBALS['TYPO3_DB
']->sql_free_result($res); 1927 if (!trim($markedSW)) { 1928 $outputStr = $GLOBALS['TSFE
']->csConvObj->crop('utf-8
', $row['item_description
'], $lgd); 1929 $outputStr = htmlspecialchars($outputStr); 1931 $output = $this->utf8_to_currentCharset($outputStr ?: $markedSW); 1933 $output = '<span
class=
"noResume">
' . $this->pi_getLL('res_noResume
', '', TRUE) . '</span>
'; 1945 public function markupSWpartsOfString($str) { 1946 $htmlParser = GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Html\\HtmlParser
'); 1948 $str = str_replace('
', ' ', $htmlParser->bidir_htmlspecialchars($str, -1)); 1949 $str = preg_replace('/\\s\\s+/
', ' ', $str); 1950 $swForReg = array(); 1951 // Prepare search words for regex: 1952 foreach ($this->sWArr as $d) { 1953 $swForReg[] = preg_quote($d['sword
'], '/
'); 1955 $regExString = '(
' . implode('|
', $swForReg) . ')
'; 1956 // Split and combine: 1957 $parts = preg_split('/
' . $regExString . '/ui
', ' ' . $str . ' ', 20000, PREG_SPLIT_DELIM_CAPTURE); 1961 $postPreLgd_offset = 5; 1963 $occurencies = (count($parts) - 1) / 2; 1965 $postPreLgd = \TYPO3\CMS\Core\Utility\MathUtility::forceIntegerInRange($summaryMax / $occurencies, $postPreLgd, $summaryMax / 2); 1970 // Shorten in-between strings: 1971 foreach ($parts as $k => $strP) { 1973 // Find length of the summary part: 1974 $strLen = $GLOBALS['TSFE
']->csConvObj->strlen('utf-8
', $parts[$k]); 1975 $output[$k] = $parts[$k]; 1976 // Possibly shorten string: 1978 // First entry at all (only cropped on the frontside) 1979 if ($strLen > $postPreLgd) { 1980 $output[$k] = $divider . preg_replace('/^[^[:space:]]+[[:space:]]/
', '', $GLOBALS['TSFE
']->csConvObj->crop('utf-8
', $parts[$k], -($postPreLgd - $postPreLgd_offset))); 1982 } elseif ($summaryLgd > $summaryMax || !isset($parts[($k + 1)])) { 1983 // In case summary length is exceed OR if there are no more entries at all: 1984 if ($strLen > $postPreLgd) { 1985 $output[$k] = preg_replace('/[[:space:]][^[:space:]]+$/
', '', $GLOBALS['TSFE
']->csConvObj->crop('utf-8
', $parts[$k], ($postPreLgd - $postPreLgd_offset))) . $divider; 1988 // In-between search words: 1989 if ($strLen > $postPreLgd * 2) { 1990 $output[$k] = preg_replace('/[[:space:]][^[:space:]]+$/
', '', $GLOBALS['TSFE
']->csConvObj->crop('utf-8
', $parts[$k], ($postPreLgd - $postPreLgd_offset))) . $divider . preg_replace('/^[^[:space:]]+[[:space:]]/
', '', $GLOBALS['TSFE
']->csConvObj->crop('utf-8
', $parts[$k], -($postPreLgd - $postPreLgd_offset))); 1993 $summaryLgd += $GLOBALS['TSFE
']->csConvObj->strlen('utf-8
', $output[$k]); 1995 $output[$k] = htmlspecialchars($output[$k]); 1996 // If summary lgd is exceed, break the process: 1997 if ($summaryLgd > $summaryMax) { 2001 $summaryLgd += $GLOBALS['TSFE
']->csConvObj->strlen('utf-8
', $strP); 2002 $output[$k] = '<strong
class=
"tx-indexedsearch-redMarkup">
' . htmlspecialchars($parts[$k]) . '</strong>
'; 2006 return implode('', $output); 2016 public function makeTitle($row) { 2018 if ($this->multiplePagesType($row['item_type
'])) { 2019 $dat = unserialize($row['cHashParams
']); 2020 $pp = explode('-
', $dat['key
']); 2021 if ($pp[0] != $pp[1]) { 2022 $add = ',
' . $this->pi_getLL('word_pages
') . ' ' . $dat['key
']; 2024 $add = ',
' . $this->pi_getLL('word_page
') . ' ' . $pp[0]; 2027 $outputString = $GLOBALS['TSFE
']->csConvObj->crop('utf-8
', $row['item_title
'], 50, '...
'); 2028 return $this->utf8_to_currentCharset($outputString) . $add; 2039 public function makeInfo($row, $tmplArray) { 2040 $tmplArray['size
'] = GeneralUtility::formatSize($row['item_size
']); 2041 $tmplArray['created
'] = $this->formatCreatedDate($row['item_crdate
']); 2042 $tmplArray['modified
'] = $this->formatModifiedDate($row['item_mtime
']); 2043 $pathId = $row['data_page_id
'] ?: $row['page_id
']; 2044 $pathMP = $row['data_page_id
'] ? $row['data_page_mp
'] : ''; 2045 $pI = parse_url($row['data_filename
']); 2046 if ($pI['scheme
']) { 2047 $targetAttribute = ''; 2048 if ($GLOBALS['TSFE
']->config['config
']['fileTarget
']) { 2049 $targetAttribute = ' target=
"' . htmlspecialchars($GLOBALS['TSFE']->config['config']['fileTarget']) . '"'; 2051 $tmplArray['path
'] = '<a href=
"' . htmlspecialchars($row['data_filename']) . '"' . $targetAttribute . '>
' . htmlspecialchars($row['data_filename
']) . '</a>
'; 2053 $pathStr = htmlspecialchars($this->getPathFromPageId($pathId, $pathMP)); 2054 $tmplArray['path
'] = $this->linkPage($pathId, $pathStr, array( 2055 'cHashParams
' => $row['cHashParams
'], 2056 'data_page_type
' => $row['data_page_type
'], 2057 'data_page_mp
' => $pathMP, 2058 'sys_language_uid
' => $row['sys_language_uid
'] 2071 public function getSpecialConfigForRow($row) { 2072 $pathId = $row['data_page_id
'] ?: $row['page_id
']; 2073 $pathMP = $row['data_page_id
'] ? $row['data_page_mp
'] : ''; 2074 $rl = $this->getRootLine($pathId, $pathMP); 2075 $specConf = $this->conf['specConfs.
']['0.
']; 2076 if (is_array($rl)) { 2077 foreach ($rl as $dat) { 2078 if (is_array($this->conf['specConfs.
'][$dat['uid
'] . '.
'])) { 2079 $specConf = $this->conf['specConfs.
'][$dat['uid
'] . '.
']; 2080 $specConf['_pid
'] = $dat['uid
']; 2095 public function makeLanguageIndication($row) { 2096 // If search result is a TYPO3 page: 2097 if ((string) $row['item_type
'] === '0
') { 2098 // If TypoScript is used to render the flag: 2099 if (is_array($this->conf['flagRendering.
'])) { 2100 $this->cObj->setCurrentVal($row['sys_language_uid
']); 2101 return $this->cObj->cObjGetSingle($this->conf['flagRendering
'], $this->conf['flagRendering.
']); 2103 // ... otherwise, get flag from sys_language record: 2104 // Get sys_language record 2105 $rowDat = $GLOBALS['TYPO3_DB
']->exec_SELECTgetSingleRow('*
', 'sys_language
', 'uid=
' . (int)$row['sys_language_uid
'] . ' ' . $this->cObj->enableFields('sys_language
')); 2107 $flag = $rowDat['flag
']; 2109 // FIXME not all flags from typo3/gfx/flags are available in media/flags/ 2110 $file = \TYPO3\CMS\Core\Utility\PathUtility::stripPathSitePrefix(PATH_tslib) . 'media/flags/flag_
' . $flag; 2111 $imgInfo = @getimagesize((PATH_site . $file)); 2112 if (is_array($imgInfo)) { 2113 $output = '<img src=
"' . $file . '" ' . $imgInfo[3] . ' title=
"' . htmlspecialchars($rowDat['title']) . '" alt=
"' . htmlspecialchars($rowDat['title']) . '" />
'; 2130 public function makeAccessIndication($id) { 2131 if (is_array($this->fe_groups_required[$id]) && count($this->fe_groups_required[$id])) { 2132 return '<img src=
"' . \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::siteRelPath('indexed_search') . 'pi/res/locked.gif" width=
"12" height=
"15" vspace=
"5" title=
"' . sprintf($this->pi_getLL('res_memberGroups', '', TRUE), implode(',', array_unique($this->fe_groups_required[$id]))) . '" alt=
"" />
'; 2146 public function linkPage($id, $str, $row = array(), $markUpSwParams = array()) { 2147 // Parameters for link: 2148 $urlParameters = (array) unserialize($row['cHashParams
']); 2149 // Add &type and &MP variable: 2150 if ($row['data_page_type
']) { 2151 $urlParameters['type
'] = $row['data_page_type
']; 2153 if ($row['data_page_mp
']) { 2154 $urlParameters['MP
'] = $row['data_page_mp
']; 2156 if ($row['sys_language_uid
']) { 2157 $urlParameters['L
'] = $row['sys_language_uid
']; 2160 $urlParameters = array_merge($urlParameters, $markUpSwParams); 2161 // This will make sure that the path is retrieved if it hasn't been already. Used only
for the sake of the domain_record thing...
2162 if (!is_array($this->domain_records[$id])) {
2166 if (count($this->domain_records[$id])) {
2167 reset($this->domain_records[$id]);
2168 $firstDom = current($this->domain_records[$id]);
2171 if (is_array($urlParameters)) {
2172 if (count($urlParameters)) {
2176 if ($target = $this->conf[
'search.'][
'detect_sys_domain_records.'][
'target']) {
2177 $target =
' target="' . $target .
'"';
2179 return '<a href="' . htmlspecialchars(($scheme . $firstDom .
'/index.php?id=' . $id . $addParams)) .
'"' . $target .
'>' . htmlspecialchars($str) .
'</a>';
2181 return $this->
pi_linkToPage($str, $id, $this->conf[
'result_link_target'], $urlParameters);
2194 $identStr = $id .
'|' . $pathMP;
2195 if (!isset($this->cache_path[$identStr])) {
2196 $this->cache_rl[$identStr] =
$GLOBALS[
'TSFE']->sys_page->getRootLine($id, $pathMP);
2198 return $this->cache_rl[$identStr];
2209 $res =
$GLOBALS[
'TYPO3_DB']->exec_SELECTquery(
'domainName',
'sys_domain',
'pid=' . (
int)$id . $this->cObj->enableFields(
'sys_domain'),
'',
'sorting');
2210 $row =
$GLOBALS[
'TYPO3_DB']->sql_fetch_assoc($res);
2211 return rtrim($row[
'domainName'],
'/');
2223 $identStr = $id .
'|' . $pathMP;
2224 if (!isset($this->cache_path[$identStr])) {
2225 $this->fe_groups_required[$id] = array();
2226 $this->domain_records[$id] = array();
2230 if (is_array($rl) && count($rl)) {
2231 foreach ($rl as $k => $v) {
2233 if ($v[
'fe_group'] && ($v[
'uid'] == $id || $v[
'extendToSubpages'])) {
2234 $this->fe_groups_required[$id][] = $v[
'fe_group'];
2237 if ($this->conf[
'search.'][
'detect_sys_domain_records']) {
2240 $this->domain_records[$id][] = $sysDName;
2242 $path = $sysDName . $path;
2247 if ($v[
'uid'] ==
$GLOBALS[
'TSFE']->config[
'rootLine'][0][
'uid']) {
2250 $path =
'/' . $v[
'title'] . $path;
2253 $this->cache_path[$identStr] = $path;
2254 if (is_array($this->conf[
'path_stdWrap.'])) {
2255 $this->cache_path[$identStr] = $this->cObj->stdWrap($this->cache_path[$identStr], $this->conf[
'path_stdWrap.']);
2258 return $this->cache_path[$identStr];
2269 if ($this->conf[
'show.'][
'LxALLtypes']) {
2271 $res =
$GLOBALS[
'TYPO3_DB']->exec_SELECTquery(
'title,uid',
'pages',
'pid=' . (
int)$id . $this->cObj->enableFields(
'pages'),
'',
'sorting');
2272 while ($row =
$GLOBALS[
'TYPO3_DB']->sql_fetch_assoc($res)) {
2273 $output[$row[
'uid']] =
$GLOBALS[
'TSFE']->sys_page->getPageOverlay($row);
2275 $GLOBALS[
'TYPO3_DB']->sql_free_result($res);
2278 return $GLOBALS[
'TSFE']->sys_page->getMenu($id);
2290 return is_object($this->external_parsers[$item_type]) && $this->external_parsers[$item_type]->isMultiplePageExtension($item_type);
2301 return $GLOBALS[
'TSFE']->csConv($str,
'utf-8');
2314 if ($TYPO3_CONF_VARS[
'EXTCONF'][
'indexed_search'][
'pi1_hooks'][$functionName]) {
2316 if (method_exists($hookObj, $functionName)) {
2317 $hookObj->pObj = $this;
2330 if ($targetUrlPid == 0) {
2331 $targetUrlPid =
$GLOBALS[
'TSFE']->id;
2343 if (isset($this->conf[
'search.'][
'targetPid']) || isset($this->conf[
'search.'][
'targetPid.'])) {
2344 if (is_array($this->conf[
'search.'][
'targetPid.'])) {
2345 $result = $this->cObj->stdWrap($this->conf[
'search.'][
'targetPid'], $this->conf[
'search.'][
'targetPid.']);
2347 $result = $this->conf[
'search.'][
'targetPid'];
2361 $defaultFormat =
$GLOBALS[
'TYPO3_CONF_VARS'][
'SYS'][
'ddmmyy'];
2362 return $this->
formatDate($date,
'created', $defaultFormat);
2372 $defaultFormat =
$GLOBALS[
'TYPO3_CONF_VARS'][
'SYS'][
'ddmmyy'] .
' ' .
$GLOBALS[
'TYPO3_CONF_VARS'][
'SYS'][
'hhmm'];
2373 return $this->
formatDate($date,
'modified', $defaultFormat);
2386 $strftimeFormat = $this->conf[
'dateFormat.'][$tsKey];
2387 if ($strftimeFormat) {
2388 $result = strftime($strftimeFormat, $date);
2390 $result = date($defaultFormat, $date);
2402 return (
int)$this->piVars[
'type'];
2411 return \TYPO3\CMS\Core\Utility\GeneralUtility::intExplode(
',', $this->wholeSiteIdList);
$TYPO3_CONF_VARS['SYS']['contentTable']
static forceIntegerInRange($theInt, $min, $max=2000000000, $defaultValue=0)
static md5inthash($stringToHash)
static quoteJSvalue($value)
static intExplode($delimiter, $string, $removeEmptyValues=FALSE, $limit=0)
static getIndpEnv($getEnvName)
static isTableUsed($tableName)
static getUserObj($classRef, $checkPrefix='', $silent=FALSE)
pi_classParam($class, $addClasses='')
static makeInstance($className)
static trimExplode($delim, $string, $removeEmptyValues=FALSE, $limit=0)
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.
pi_getLL($key, $alternativeLabel='', $hsc=FALSE)
pi_getPageLink($id, $target='', $urlParameters=array())
static implodeArrayForUrl($name, array $theArray, $str='', $skipBlank=FALSE, $rawurlencodeParamName=FALSE)
pi_linkToPage($str, $id, $target='', $urlParameters=array())
if(isset($ajaxID)) if(in_array( $ajaxID, $noUserAjaxIDs))
Re-apply pairs of single-quotes to the text.
if(!defined('TYPO3_MODE')) $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_userauth.php']['logoff_pre_processing'][]
static revExplode($delimiter, $string, $count=0)
static inList($list, $item)