fixes HTM files parsing

This commit is contained in:
diml
2008-04-07 19:56:44 +00:00
parent 9b1102f6f0
commit e1778c0c5e
+5 -5
View File
@@ -24,16 +24,16 @@ function get_text_for_indexing_htm(&$resource){
if (!isadmin($USER->id)) return;
// just get text
$text = implode('', file("{$CFG->dataroot}/{$resource->course}/($resource->reference)"));
$text = implode('', file("{$CFG->dataroot}/{$resource->course}/{$resource->reference}"));
// extract keywords and other interesting meta information and put it back as real content for indexing
if (preg_match('/(.*)<meta ([^>]*)>(.*)/is',$text, $matches)){
if (preg_match('/(.*)<meta ([^>]*)>(.*)/is', $text, $matches)){
$prefix = $matches[1];
$meta_attributes = $matches[2];
$suffix = $matches[3];
if (preg_match('/name="(keywords|description)"/i', $attributes)){
preg_match('/content="[^"]+"/i', $attributes, $matches);
$text = $prefix.' '.$matches[1].' '.$suffix;
if (preg_match('/name="(keywords|description)"/i', $meta_attributes)){
preg_match('/content="[^"]+"/i', $meta_attributes, $matches);
$text = $prefix.' '.$matches[0].' '.$suffix;
}
}
// filter all html tags