You are here

function search_files_attachments_get_file_contents in Search Files 6.2

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

get the file contents using the helpers configured in the search_files_module

1 call to search_files_attachments_get_file_contents()
search_files_attachments_index_file in ./search_files_attachments.module
get files to index

File

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

Code

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