3 * Global Search Engine for Moodle
4 * add-on 1.8+ : Valery Fremaux [valery.fremaux@club-internet.fr]
7 * this is a format handler for getting text out of a proprietary binary format
8 * so it can be indexed by Lucene search engine
11 function get_text_for_indexing_pdf(&$resource){
14 // SECURITY : do not allow non admin execute anything on system !!
15 if (!isadmin($USER->id
)) return;
17 // just call pdftotext over stdout and capture the output
18 if (!empty($CFG->block_search_pdf_to_text_cmd
)){
19 preg_match("/^\S+/", $CFG->block_search_pdf_to_text_cmd
, $matches);
20 if (!file_exists("{$CFG->dirroot}/{$matches[0]}")){
21 mtrace('Error with pdf to text converter command : exectuable not found.');
24 $file = $CFG->dataroot
.'/'.$resource->course
.'/'.$resource->reference
;
25 $text_converter_cmd = "{$CFG->dirroot}/{$CFG->block_search_pdf_to_text_cmd} $file -";
26 $result = shell_exec($text_converter_cmd);
31 mtrace('Error with pdf to text converter command : execution failed.');
37 mtrace('Error with pdf to text converter command : command not set up. Execute once search block configuration.');