/** * Opens file by it's absolute path. Returns true on success. * * @param string $filePath * @return bool * */ public function openFile($filePath) { $this->fileHandler = null; $io = CBXVirtualIo::getInstance(); $file = $io->getFile($filePath); $this->fileHandler = $file->open("rb"); if (is_resource($this->fileHandler)) { if ($this->filePosition > 0) { fseek($this->fileHandler, $this->filePosition); } $this->elementStack = array(); $this->positionStack = array(); foreach (explode("/", $this->xmlPosition) as $pathPart) { @(list($elementPosition, $elementName) = explode("@", $pathPart, 2)); $this->elementStack[] = $elementName; $this->positionStack[] = $elementPosition; } return true; } else { return false; } }
private function getFileContent(File $file) { static $maxFileSize = null; if (!isset($maxFileSize)) { $maxFileSize = Option::get("search", "max_file_size", 0) * 1024; } $searchData = ''; $searchData .= strip_tags($file->getName()) . "\r\n"; if ($maxFileSize > 0 && $file->getSize() > $maxFileSize) { return ''; } $searchDataFile = array(); $fileArray = CFile::makeFileArray($file->getFileId()); if ($fileArray && $fileArray['tmp_name']) { $fileAbsPath = \CBXVirtualIo::getInstance()->getLogicalName($fileArray['tmp_name']); foreach (GetModuleEvents('search', 'OnSearchGetFileContent', true) as $event) { if ($searchDataFile = executeModuleEventEx($event, array($fileAbsPath, getFileExtension($fileArray['name'])))) { break; } } return is_array($searchDataFile) ? $searchData . "\r\n" . $searchDataFile['CONTENT'] : $searchData; } return $searchData; }