You are here

function search_files_attachments_get_file_contents in Search Files 7.2

Same name and namespace in other branches
  1. 6.2 search_files_attachments.module \search_files_attachments_get_file_contents()

Get the file contents using the helpers.

1 call to search_files_attachments_get_file_contents()
search_files_attachments_index_file in ./search_files_attachments.module
Indexing file contents.

File

./search_files_attachments.module, line 222
Used to index files in attachments

Code

function search_files_attachments_get_file_contents($path) {
  $helpers = search_files_get_helpers();
  $wrapper = file_stream_wrapper_get_instance_by_uri($path);
  $realpath = $wrapper
    ->realpath();
  $pathinfo = (object) pathinfo($realpath);
  if (isset($helpers[$pathinfo->extension]) && is_file($realpath)) {
    $cmd = preg_replace('/%file%/', escapeshellarg($realpath), $helpers[$pathinfo->extension]);
    $contents = shell_exec($cmd);
    return $contents;
  }
  return FALSE;
}