MDL-16553 Assignment, student view: whitespace fix
[moodle.git] / search / documents / physical_xml.php
blobae5bb102b6c0c1a6d87ce8114d85c8aa2cb654ae
1 <?php
2 /**
3 * Global Search Engine for Moodle
5 * @package search
6 * @category core
7 * @subpackage document_wrappers
8 * @author Valery Fremaux [valery.fremaux@club-internet.fr] > 1.8
9 * @date 2008/03/31
10 * @license http://www.gnu.org/copyleft/gpl.html GNU Public License
12 * this is a format handler for getting text out of a proprietary binary format
13 * so it can be indexed by Lucene search engine
16 /**
17 * @param object $resource
18 * @uses $CFG
20 function get_text_for_indexing_xml(&$resource, $directfile = ''){
21 global $CFG;
23 // SECURITY : do not allow non admin execute anything on system !!
24 if (!has_capability('moodle/site:doanything', get_context_instance(CONTEXT_SYSTEM))) return;
26 // just get text
27 if ($directfile == ''){
28 $text = implode('', file("{$CFG->dataroot}/{$resource->course}/{$resource->reference}"));
29 } else {
30 $text = implode('', file("{$CFG->dataroot}/{$directfile}"));
33 // filter out all xml tags
34 $text = preg_replace("/<[^>]*>/", ' ', $text);
36 if (!empty($CFG->block_search_limit_index_body)){
37 $text = shorten_text($text, $CFG->block_search_limit_index_body);
39 return $text;