/**
  * 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);
 }
 /**
  * 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;
 }
Exemple #3
0
 /**
  * Get search hash, external files
  *
  * @param string $file File name / path which identifies it on the server
  * @param array $subinfo Additional content identifying the (subpart of) content. For instance; PDF files are divided into groups of pages for indexing.
  * @return array Array with "phash_grouping" and "phash" inside.
  */
 public function setExtHashes($file, $subinfo = array())
 {
     //  Set main array:
     $hash = array();
     $hArray = array('file' => $file);
     // Set grouping hash:
     $hash['phash_grouping'] = IndexedSearchUtility::md5inthash(serialize($hArray));
     // Add subinfo
     $hArray['subinfo'] = $subinfo;
     $hash['phash'] = IndexedSearchUtility::md5inthash(serialize($hArray));
     return $hash;
 }
 /**
  * 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;
 }
 /**
  * Splits the search word input into an array where each word is represented by an array with key "sword"
  * holding the search word and key "oper" holding the SQL operator (eg. AND, OR)
  *
  * Only words with 2 or more characters are accepted
  * Max 200 chars total
  * Space is used to split words, "" can be used search for a whole string
  * AND, OR and NOT are prefix words, overruling the default operator
  * +/|/- equals AND, OR and NOT as operators.
  * All search words are converted to lowercase.
  *
  * $defOp is the default operator. 1=OR, 0=AND
  *
  * @param bool $defaultOperator If TRUE, the default operator will be OR, not AND
  * @return array Search words if any found
  */
 protected function getSearchWords($defaultOperator)
 {
     // Shorten search-word string to max 200 bytes (does NOT take multibyte charsets into account - but never mind,
     // shortening the string here is only a run-away feature!)
     $searchWords = substr($this->sword, 0, 200);
     // Convert to UTF-8 + conv. entities (was also converted during indexing!)
     $searchWords = $GLOBALS['TSFE']->csConvObj->utf8_encode($searchWords, $GLOBALS['TSFE']->metaCharset);
     $searchWords = $GLOBALS['TSFE']->csConvObj->entities_to_utf8($searchWords, true);
     $sWordArray = false;
     if ($hookObj = $this->hookRequest('getSearchWords')) {
         $sWordArray = $hookObj->getSearchWords_splitSWords($searchWords, $defaultOperator);
     } else {
         // sentence
         if ($this->searchData['searchType'] == 20) {
             $sWordArray = array(array('sword' => trim($searchWords), 'oper' => 'AND'));
         } else {
             // case-sensitive. Defines the words, which will be
             // operators between words
             $operatorTranslateTable = array(array('+', 'AND'), array('|', 'OR'), array('-', 'AND NOT'), array($GLOBALS['TSFE']->csConvObj->conv_case('utf-8', $GLOBALS['TSFE']->csConvObj->utf8_encode(LocalizationUtility::translate('localizedOperandAnd', 'IndexedSearch'), $GLOBALS['TSFE']->renderCharset), 'toLower'), 'AND'), array($GLOBALS['TSFE']->csConvObj->conv_case('utf-8', $GLOBALS['TSFE']->csConvObj->utf8_encode(LocalizationUtility::translate('localizedOperandOr', 'IndexedSearch'), $GLOBALS['TSFE']->renderCharset), 'toLower'), 'OR'), array($GLOBALS['TSFE']->csConvObj->conv_case('utf-8', $GLOBALS['TSFE']->csConvObj->utf8_encode(LocalizationUtility::translate('localizedOperandNot', 'IndexedSearch'), $GLOBALS['TSFE']->renderCharset), 'toLower'), 'AND NOT'));
             $swordArray = \TYPO3\CMS\IndexedSearch\Utility\IndexedSearchUtility::getExplodedSearchString($searchWords, $defaultOperator == 1 ? 'OR' : 'AND', $operatorTranslateTable);
             if (is_array($swordArray)) {
                 $sWordArray = $this->procSearchWordsByLexer($swordArray);
             }
         }
     }
     return $sWordArray;
 }
 /**
  * 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);
 }