function search_files_install_auto_helper_app_configuration in Search Files 6.2
Same name and namespace in other branches
- 7.2 search_files.module \search_files_install_auto_helper_app_configuration()
automatically detect helper apps and configure them
1 call to search_files_install_auto_helper_app_configuration()
- search_files_helper_autodetect_submit in ./
search_files.module - autodetect helper apps
File
- ./
search_files.module, line 114 - Used to index files in attachments and directories
Code
function search_files_install_auto_helper_app_configuration() {
// safe_mode will inhibit shell_exec()
if (search_files_issafemode()) {
// load sample helper apps into database
search_files_helper_db_add("PDF", "pdf", "/usr/bin/env pdftotext %file% -");
search_files_helper_db_add("Text", "txt", "/usr/bin/env cat %file%");
}
else {
// test for pdftotext
$location = trim(shell_exec('which pdftotext'));
$location = preg_replace("/^no .*\$/", "", $location);
if ($location) {
search_files_helper_db_add("PDF", "pdf", $location . " %file% -");
drupal_set_message(t('Helper app pdftotext has been detected and configured'));
}
// test for cat
$location = trim(shell_exec('which cat'));
$location = preg_replace("/^no .*\$/", "", $location);
if ($location) {
search_files_helper_db_add("Text files", "txt", $location . " %file%");
drupal_set_message(t('Helper app cat has been detected and configured'));
}
// test for catdoc
$location = trim(shell_exec('which catdoc'));
$location = preg_replace("/^no .*\$/", "", $location);
if ($location) {
search_files_helper_db_add("Word Documents", "doc", $location . " %file%");
drupal_set_message(t('Helper app catdoc has been detected and configured'));
}
// test for docx2txt
$location = trim(shell_exec('which docx2txt.pl'));
$location = preg_replace("/^no .*\$/", "", $location);
$perl_location = trim(shell_exec('which perl'));
$perl_location = preg_replace("/^no .*\$/", "", $perl_location);
if ($location && $perl_location) {
search_files_helper_db_add("Word 2007 files", "docx", $perl_location . ' ' . $location . " %file% -");
drupal_set_message(t('Helper app docx2txt has been detected and configured'));
}
// test for xls2csv
$location = trim(shell_exec('which xls2csv'));
$location = preg_replace("/^no .*\$/", "", $location);
if ($location) {
search_files_helper_db_add("Excel files", "xls", $location . " %file%");
drupal_set_message(t('Helper app xls2csv has been detected and configured'));
}
// test for catppt
$location = trim(shell_exec('which catppt'));
$location = preg_replace("/^no .*\$/", "", $location);
if ($location) {
search_files_helper_db_add("Power Point Presentations", "ppt", $location . " %file%");
drupal_set_message(t('Helper app catppt has been detected and configured'));
}
// test for unrtf
$location = trim(shell_exec('which unrtf'));
$location = preg_replace("/^no .*\$/", "", $location);
if ($location) {
search_files_helper_db_add("Rich Text Format files", "rtf", $location . " %file%");
drupal_set_message(t('Helper app unrtf has been detected and configured'));
}
}
}