/** * get filecontent of allowed extensions * * @param string $file * @return mixed false or fileinformations as array */ public function getFileContent($file) { // we can continue only when given file is a true file and not a directory or what ever if ($this->fileInfo->getIsFile()) { $className = 'tx_kesearch_indexer_filetypes_' . $this->fileInfo->getExtension(); // check if class exists if (class_exists($className)) { // make instance $fileObj = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance($className); // check if new object has interface implemented if ($fileObj instanceof tx_kesearch_indexer_filetypes) { // now we can execute the method of our new object $fileContent = $fileObj->getContent($file); $this->addError($fileObj->getErrors()); return $fileContent; } else { return false; } } else { // if no indexer for this type of file exists, we do a fallback: // we return an empty content. Doing this at least the FAL metadata // can be indexed. So this makes only sense when using FAL. if ($this->pObj->indexerConfig['fal_storage'] > 0) { return ''; } else { $this->addError('No indexer for this type of file. (class ' . $className . ' does not exist).'); return false; } } } else { $this->addError($file . ' is not a file.'); return false; } }
/** * get filecontent of allowed extensions * @param string $file * @return mixed false or fileinformations as array */ public function getFileContent($file) { // we can continue only when given file is really file and not a directory if ($this->fileInfo->getIsFile()) { $className = 'tx_kesearch_indexer_filetypes_' . $this->fileInfo->getExtension(); // check if class exists if (class_exists($className)) { // make instance $fileObj = GeneralUtility::makeInstance($className); // check if new object has interface implemented if ($fileObj instanceof tx_kesearch_indexer_filetypes) { // Do the check if a file has already been indexed at this early point in order // to skip the time expensive "get content" process which includes calls to external tools // fetch the file content directly from the index $fileContent = $this->getFileContentFromIndex($this->getUniqueHashForFile()); // if there's no matching index entry, we execute the "get file content" method of our new object if (!$fileContent) { $fileContent = $fileObj->getContent($file); $this->addError($fileObj->getErrors()); } return $fileContent; } else { return false; } } else { // if no indexer for this type of file exists, we do a fallback: // we return an empty content. Doing this at least the FAL metadata // can be indexed. So this makes only sense when using FAL. if ($this->pObj->indexerConfig['fal_storage'] > 0) { return ''; } else { $this->addError('No indexer for this type of file. (class ' . $className . ' does not exist).'); return false; } } } else { $this->addError($file . ' is not a file.'); return false; } }