/** * This function will return content of specific searchable column. It uses inherited * behaviour for all columns except for `filecontent`. In case of this column function * will return file content if file type is marked as searchable (text documents, office * documents etc). * * @param string $column_name Column name * @return string */ function getSearchableColumnContent($column_name) { if ($column_name == 'filecontent') { $file_type = $this->getFileType(); // Unknown type or type not searchable if (!$file_type instanceof FileType) { return null; } // if // Simple search for .txt and .html documents if ($file_type->getIsSearchable()) { $content = strip_tags($this->getFileContent()); // Remove unnecesary html tags if (strlen($content) > MAX_SEARCHABLE_FILE_SIZE) { $content = substr($content, 0, MAX_SEARCHABLE_FILE_SIZE); } return $content; } else { // Search for .doc and .ppt documents if (($this->getFileType()->getExtension() == "doc" || $this->getFileType()->getExtension() == "ppt") && FileRepository::getBackend() instanceof FileRepository_Backend_FileSystem) { $backend = FileRepository::getBackend(); if ($backend->isInRepository($this->getRepositoryId())) { $filepath = $backend->getFilePath($this->getRepositoryId()); $fileContents = $this->cat_file($filepath, $this->getFileType()->getExtension()); if ($fileContents) { if (strlen($fileContents) > MAX_SEARCHABLE_FILE_SIZE) { $fileContents = substr($fileContents, 0, MAX_SEARCHABLE_FILE_SIZE); } return $fileContents; } } } } return null; } else { return parent::getSearchableColumnContent($column_name); } }
/** * This function will return content of specific searchable column. It uses inherited * behaviour for all columns except for `filecontent`. In case of this column function * will return file content if file type is marked as searchable (text documents, office * documents etc). * * @param string $column_name Column name * @return string */ function getSearchableColumnContent($column_name) { if ($column_name == 'filecontent') { // Unknown type or type not searchable $file_type = $this->getFileType(); if (!$file_type instanceof FileType || !$file_type->getIsSearchable()) { return null; } // if $content = $this->getFileContent(); if (strlen($content) <= MAX_SEARCHABLE_FILE_SIZE) { return $content; } } else { return parent::getSearchableColumnContent($column_name); } // if }