/** * Returns the resume for the search-result. * * @param array Search result row * @param boolean If noMarkup is FALSE, then the index_fulltext table is used to select the content of the page, split it with regex to display the search words in the text. * @param integer String length * @return string HTML string ... * @todo Define visibility */ public function makeDescription($row, $noMarkup = 0, $lgd = 180) { if ($row['show_resume']) { if (!$noMarkup) { $markedSW = ''; if (\TYPO3\CMS\IndexedSearch\Utility\IndexedSearchUtility::isTableUsed('index_fulltext')) { $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('*', 'index_fulltext', 'phash=' . intval($row['phash'])); } else { $res = FALSE; } if ($res) { if ($ftdrow = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) { // Cut HTTP references after some length $content = preg_replace('/(http:\\/\\/[^ ]{60})([^ ]+)/i', '$1...', $ftdrow['fulltextdata']); $markedSW = $this->markupSWpartsOfString($content); } $GLOBALS['TYPO3_DB']->sql_free_result($res); } } if (!trim($markedSW)) { $outputStr = $GLOBALS['TSFE']->csConvObj->crop('utf-8', $row['item_description'], $lgd); $outputStr = htmlspecialchars($outputStr); } $output = $this->utf8_to_currentCharset($outputStr ? $outputStr : $markedSW); } else { $output = '<span class="noResume">' . $this->pi_getLL('res_noResume', '', 1) . '</span>'; } return $output; }
/** * Check if the tables provided are configured for usage. * This becomes necessary for extensions that provide additional database * functionality like indexed_search_mysql. * * @param string $table_list Comma-separated list of tables * @return boolean TRUE if given tables are enabled */ protected function isTableUsed($table_list) { return \TYPO3\CMS\IndexedSearch\Utility\IndexedSearchUtility::isTableUsed($table_list); }
/** * Submits RELATIONS between words and phash * * @param array $wordList Word list array * @param int $phash phash value * @return void */ public function submitWords($wordList, $phash) { if (IndexedSearchUtility::isTableUsed('index_rel')) { $stopWords = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows('wid', 'index_words', 'is_stopword != 0', '', '', '', 'wid'); $GLOBALS['TYPO3_DB']->exec_DELETEquery('index_rel', 'phash=' . (int) $phash); $fields = array('phash', 'wid', 'count', 'first', 'freq', 'flags'); $rows = array(); foreach ($wordList as $val) { if (isset($stopWords[$val['hash']])) { continue; } $rows[] = array((int) $phash, (int) $val['hash'], (int) $val['count'], (int) $val['first'], $this->freqMap($val['count'] / $this->wordcount), $val['cmp'] & $this->flagBitMask); } $GLOBALS['TYPO3_DB']->exec_INSERTmultipleRows('index_rel', $fields, $rows); } }
/** * Submits RELATIONS between words and phash * * @param array Word list array * @param integer phash value * @return void * @todo Define visibility */ public function submitWords($wordList, $phash) { if (\TYPO3\CMS\IndexedSearch\Utility\IndexedSearchUtility::isTableUsed('index_rel')) { $GLOBALS['TYPO3_DB']->exec_DELETEquery('index_rel', 'phash=' . (int) $phash); foreach ($wordList as $val) { $insertFields = array('phash' => (int) $phash, 'wid' => (int) $val['hash'], 'count' => (int) $val['count'], 'first' => (int) $val['first'], 'freq' => $this->freqMap($val['count'] / $this->wordcount), 'flags' => $val['cmp'] & $this->flagBitMask); $GLOBALS['TYPO3_DB']->exec_INSERTquery('index_rel', $insertFields); } } }
/** * Returns the resume for the search-result. * * @param array $row Search result row * @param bool $noMarkup If noMarkup is FALSE, then the index_fulltext table is used to select the content of the page, split it with regex to display the search words in the text. * @param int $lgd String length * @return string HTML string */ public function makeDescription($row, $noMarkup = false, $lgd = 180) { if ($row['show_resume']) { $markedSW = ''; $outputStr = ''; if (!$noMarkup) { if (\TYPO3\CMS\IndexedSearch\Utility\IndexedSearchUtility::isTableUsed('index_fulltext')) { $res = $this->databaseConnection->exec_SELECTquery('*', 'index_fulltext', 'phash=' . (int) $row['phash']); } else { $res = false; } if ($res) { if ($ftdrow = $this->databaseConnection->sql_fetch_assoc($res)) { // Cut HTTP references after some length $content = preg_replace('/(http:\\/\\/[^ ]{' . $this->conf['results.']['hrefInSummaryCropAfter'] . '})([^ ]+)/i', '$1...', $ftdrow['fulltextdata']); $markedSW = $this->markupSWpartsOfString($content); } $this->databaseConnection->sql_free_result($res); } } if (!trim($markedSW)) { $outputStr = $this->frontendController->csConvObj->crop('utf-8', $row['item_description'], $lgd, $this->conf['results.']['summaryCropSignifier']); $outputStr = htmlspecialchars($outputStr); } $output = $this->utf8_to_currentCharset($outputStr ?: $markedSW); } else { $output = '<span class="noResume">' . $this->pi_getLL('res_noResume', '', true) . '</span>'; } return $output; }
/** * Check if the tables provided are configured for usage. * This becomes necessary for extensions that provide additional database * functionality like indexed_search_mysql. * * @param string $table_list Comma-separated list of tables * @return bool TRUE if given tables are enabled */ protected function isTableUsed($table_list) { return IndexedSearchUtility::isTableUsed($table_list); }
/** * Submits RELATIONS between words and phash * * @param array $wordList Word list array * @param int $phash phash value * @return void */ public function submitWords($wordList, $phash) { if (!IndexedSearchUtility::isTableUsed('index_rel')) { return; } $connectionPool = GeneralUtility::makeInstance(ConnectionPool::class); $queryBuilder = $connectionPool->getQueryBuilderForTable('index_words'); $result = $queryBuilder->select('wid')->from('index_words')->where($queryBuilder->expr()->neq('is_stopword', $queryBuilder->createNamedParameter(0, \PDO::PARAM_INT)))->groupBy('wid')->execute(); $stopWords = []; while ($row = $result->fetch()) { $stopWords[$row['wid']] = $row; } $connectionPool->getConnectionForTable('index_rel')->delete('index_rel', ['phash' => (int) $phash]); $fields = ['phash', 'wid', 'count', 'first', 'freq', 'flags']; $rows = []; foreach ($wordList as $val) { if (isset($stopWords[$val['hash']])) { continue; } $rows[] = [(int) $phash, (int) $val['hash'], (int) $val['count'], (int) $val['first'], $this->freqMap($val['count'] / $this->wordcount), $val['cmp'] & $this->flagBitMask]; } $connectionPool->getConnectionForTable('index_rel')->bulkInsert('index_rel', $rows, $fields); }