/** * creates a index entry for a given file * * @param string $file * @param string $content */ public function storeToIndex($file, $content) { $tags = ''; tx_kesearch_helper::makeTags($tags, array('file')); // get data from FAL if ($file instanceof \TYPO3\CMS\Core\Resource\File) { $metadata = $file->_getMetaData(); $orig_uid = $file->getUid(); } else { $orig_uid = 0; } $indexRecordValues = array('storagepid' => $this->indexerConfig['storagepid'], 'title' => $this->fileInfo->getName(), 'type' => 'file:' . $this->fileInfo->getExtension(), 'targetpid' => 1, 'tags' => $tags, 'params' => '', 'abstract' => '', 'language_uid' => -1, 'starttime' => 0, 'endtime' => 0, 'fe_group' => 0, 'debug' => false); $additionalFields = array('sortdate' => $this->fileInfo->getModificationTime(), 'orig_uid' => $orig_uid, 'orig_pid' => 0, 'directory' => $this->fileInfo->getRelativePath(), 'hash' => $this->getUniqueHashForFile()); // add additional content if FAL is used if ($this->pObj->indexerConfig['fal_storage'] > 0) { // index meta data from FAL: title, description, alternative if ($metadata['title']) { $indexRecordValues['content'] = $metadata['title'] . "\n" . $indexRecordValues['content']; } if ($metadata['description']) { $indexRecordValues['abstract'] = $metadata['description']; $content = $metadata['description'] . "\n" . $content; } if ($metadata['alternative']) { $content .= "\n" . $metadata['alternative']; } // make tags from assigned categories $categories = tx_kesearch_helper::getCategories($metadata['uid'], 'sys_file_metadata'); tx_kesearch_helper::makeTags($indexRecordValues['tags'], $categories['title_list']); } // hook for custom modifications of the indexed data, e. g. the tags if (is_array($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['ke_search']['modifyFileIndexEntry'])) { foreach ($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['ke_search']['modifyFileIndexEntry'] as $_classRef) { if (TYPO3_VERSION_INTEGER >= 7000000) { $_procObj =& TYPO3\CMS\Core\Utility\GeneralUtility::getUserObj($_classRef); } else { $_procObj =& t3lib_div::getUserObj($_classRef); } $_procObj->modifyFileIndexEntry($file, $content, $additionalFields, $indexRecordValues, $this); } } // store record in index table $this->pObj->storeInIndex($indexRecordValues['storagepid'], $indexRecordValues['title'], $indexRecordValues['type'], $indexRecordValues['targetpid'], $content, $indexRecordValues['tags'], $indexRecordValues['params'], $indexRecordValues['abstract'], $indexRecordValues['language_uid'], $indexRecordValues['starttime'], $indexRecordValues['endtime'], $indexRecordValues['fe_group'], $indexRecordValues['debug'], $additionalFields); }