[svn r11746] Improvements in parsing HTML link attributes - now also getting CSS @import links

skala
Yannick Warnier 19 years ago
parent 96fcf0fe25
commit 71d6bde3d8
  1. 24
      main/newscorm/learnpathItem.class.php

@ -486,6 +486,7 @@ class learnpathItem{
case 'html':
case 'htm':
case 'shtml':
$wanted_attributes = array('src','url','@import');
//parse it for included resources
/*
$fh = fopen($abs_path,'r');
@ -506,7 +507,6 @@ class learnpathItem{
}*/
$file_content = file_get_contents($abs_path);
//get an array of attributes from the HTML source
$wanted_attributes = array('src');
$attributes = $this->parse_HTML_attributes($file_content,$wanted_attributes);
//look at 'src' attributes in this file
if(isset($attributes['src']))
@ -1076,23 +1076,32 @@ class learnpathItem{
$reduced = true;
}
if (preg_match_all(
"/(([A-Za-z_:]|[^\\x00-\\x7F])([A-Za-z0-9_:\\.-]|[^\\x00-\\x7F])*)" .
"/(((([A-Za-z_:])([A-Za-z0-9_:\\.-]|[^\\x00-\\x7F])*)" .
"([ \\n\\t\\r]+)?(" .
"(=([ \\n\\t\\r]+)?(\"[^\"]*\"|'[^']*'|[^ \\n\\t\\r]*))" .
"|" .
"(\\(([ \\n\\t\\r]+)?(\"[^\"]*\"|'[^']*'|[^ \\n\\t\\r]*)\\))" .
")?/",
"))" .
"|" .
"(@import([ \\n\\t\\r]+)?(\"[^\"]*\"|'[^']*'|[^ \\n\\t\\r]*)))?/",
$attrString,
$regs
)) {
for ($i = 0; $i < count($regs[1]); $i++) {
$name = trim($regs[1][$i]);
$name = trim($regs[3][$i]);
$check = trim($regs[0][$i]);
$value = trim($regs[8][$i]);
if(empty($value) and !empty($regs[11][$i]))
$value = trim($regs[10][$i]);
if(empty($value) and !empty($regs[13][$i]))
{
$value = $regs[13][$i];
}
if(empty($name) && !empty($regs[16][$i]))
{
$value = $regs[11][$i];
$name = '@import';
$value = trim($regs[16][$i]);
}
if(!empty($name))
{
if(!$reduced OR in_array(strtolower($name),$wanted))
{
if ($name == $check) {
@ -1106,6 +1115,7 @@ class learnpathItem{
}
}
}
}
return $attributes;
}
/**

Loading…
Cancel
Save