/** * get title for result row * @return string The linked result title */ public function getTitle() { // configure the link $linkconf = $this->getResultLinkConfiguration(); list($type) = explode(':', $this->row['type']); switch ($type) { case 'file': // if we use FAL, see if we have a title in the metadata if ($this->row['orig_uid'] && ($fileObject = tx_kesearch_helper::getFile($this->row['orig_uid']))) { $metadata = $fileObject->_getMetaData(); $linktext = $metadata['title'] ? $metadata['title'] : $this->row['title']; } else { $linktext = $this->row['title']; } break; default: $linktext = $this->row['title']; break; } // clean title $linktext = strip_tags($linktext); $linktext = $this->pObj->div->removeXSS($linktext); // highlight hits in result title? if ($this->conf['highlightSword'] && count($this->pObj->swords)) { $linktext = $this->highlightArrayOfWordsInContent($this->pObj->swords, $linktext); } return $this->cObj->typoLink($linktext, $linkconf); }
/** * renders the preview image of a file result * * @param array $row result row * @author Christian Bülter <*****@*****.**> * @since 17.10.14 * @return string */ public function renderFilePreview($row) { list($type, $filetype) = explode(':', $row['type']); if (in_array($filetype, $this->fileTypesWithPreviewPossible)) { $imageConf = $this->conf['previewImage.']; // if index record is of type "file" and contains an orig_uid, this is the reference // to a FAL record. Otherwise we use the path directly. if ($row['orig_uid'] && ($fileObject = tx_kesearch_helper::getFile($row['orig_uid']))) { $metadata = $fileObject->_getMetaData(); $imageConf['file'] = $fileObject->getPublicUrl(); $imageConf['altText'] = $metadata['alternative']; } else { $imageConf['file'] = $row['directory'] . rawurlencode($row['title']); } return $this->renderPreviewImage($imageConf); } }
/** * renders a link to a search result * * @param array $resultRow * @param string $targetDefault * @param string $targetFiles * @author Christian Bülter <*****@*****.**> * @since 31.10.14 * @return array */ public static function getResultLinkConfiguration($resultRow, $targetDefault = '', $targetFiles = '') { $linkconf = array(); list($type) = explode(':', $resultRow['type']); switch ($type) { case 'file': // render a link for files // if we use FAL, we can use the API if ($resultRow['orig_uid'] && ($fileObject = tx_kesearch_helper::getFile($resultRow['orig_uid']))) { $linkconf['parameter'] = $fileObject->getPublicUrl(); } else { $linkconf['parameter'] = $resultRow['directory'] . rawurlencode($resultRow['title']); } $linkconf['fileTarget'] = $targetFiles; break; case 'external': // render a link for external results (provided by eg. ke_search_premium or tt_news) $linkconf['parameter'] = $resultRow['params']; $linkconf['useCacheHash'] = false; $linkconf['additionalParams'] = ''; $extConfPremium = tx_kesearch_helper::getExtConfPremium(); $linkconf['extTarget'] = $extConfPremium['apiExternalResultTarget'] ? $extConfPremium['apiExternalResultTarget'] : '_blank'; break; default: // render a link for page targets // if params are filled, add them to the link generation process if (!empty($resultRow['params'])) { $linkconf['additionalParams'] = $resultRow['params']; } $linkconf['parameter'] = $resultRow['targetpid']; $linkconf['useCacheHash'] = true; $linkconf['target'] = $targetDefault; break; } return $linkconf; }