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
15 function get_text_for_indexing_doc(&$resource){
18 // SECURITY : do not allow non admin execute anything on system !!
19 if (!isadmin($USER->id
)) return;
21 // just call pdftotext over stdout and capture the output
22 if (!empty($CFG->block_search_word_to_text_cmd
)){
23 if (!file_exists("{$CFG->dirroot}/{$CFG->block_search_word_to_text_cmd}")){
24 mtrace('Error with MSWord to text converter command : exectuable not found.');
27 $file = $CFG->dataroot
.'/'.$resource->course
.'/'.$resource->reference
;
28 $text_converter_cmd = "{$CFG->dirroot}/{$CFG->block_search_word_to_text_cmd} $file";
29 if ($CFG->block_search_word_to_text_env
){
30 putenv($CFG->block_search_word_to_text_env
);
32 $result = shell_exec($text_converter_cmd);
34 return mb_convert_encoding($result, 'UTF8', 'auto');
37 mtrace('Error with MSWord to text converter command : execution failed.');
43 mtrace('Error with MSWord to text converter command : command not set up. Execute once search block configuration.');