Automatic installer.php lang files by installer_builder (20070726)
[moodle-linuxchix.git] / search / documents / physical_doc.php
blob3260451f5a7ddf8a93d119c82c01aa6bcb3332cf
1 <?php
2 /**
3 * Global Search Engine for Moodle
4 * add-on 1.8+ : Valery Fremaux [valery.fremaux@club-internet.fr]
5 * 2007/08/02
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
9 */
12 * MS Word extractor
15 function get_text_for_indexing_doc(&$resource){
16 global $CFG, $USER;
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.');
26 else{
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);
33 if ($result){
34 return mb_convert_encoding($result, 'UTF8', 'auto');
36 else{
37 mtrace('Error with MSWord to text converter command : execution failed.');
38 return '';
42 else {
43 mtrace('Error with MSWord to text converter command : command not set up. Execute once search block configuration.');
44 return '';