From 74a89c9a28c9a102efb2e58e40ef46f5e5d42ba5 Mon Sep 17 00:00:00 2001 From: Harris Wong Date: Fri, 8 Oct 2010 18:42:19 +0000 Subject: [PATCH] --- .../classes/ContentOutputParser.class.php | 87 +++++++++++++++++++ 1 file changed, 87 insertions(+) create mode 100644 docs/include/classes/ContentOutputParser.class.php diff --git a/docs/include/classes/ContentOutputParser.class.php b/docs/include/classes/ContentOutputParser.class.php new file mode 100644 index 0000000..b756030 --- /dev/null +++ b/docs/include/classes/ContentOutputParser.class.php @@ -0,0 +1,87 @@ + + + img => src + a => href // ignore if href doesn't exist (ie. ) + object => data | classid // probably only want data + applet => classid | archive // whatever these two are should double check to see if it's a valid file (not a dir) + link => href + script => src + form => action + input => src + iframe => src + + */ + $elements = array( 'img' => 'src', + 'a' => 'href', + 'object' => array('data', 'classid'), + 'applet' => array('classid', 'archive'), + 'link' => 'href', + 'script' => 'src', + 'form' => 'action', + 'input' => 'src', + 'iframe' => 'src', + 'embed' => 'src', + 'param' => 'value'); + + /* check if this attribute specifies the files in different ways: (ie. java) */ + if (is_array($elements[$name])) { + $items = $elements[$name]; + foreach ($items as $item) { + if ($attrs[$item] != '') { + + /* some attributes allow a listing of files to include seperated by commas (ie. applet->archive). */ + if (strpos($attrs[$item], ',') !== false) { + $files = explode(',', $attrs[$item]); + foreach ($files as $file) { + $my_files[] = trim($file); + } + } else { + $my_files[] = $attrs[$item]; + } + } + } + } else if (isset($elements[$name]) && ($attrs[$elements[$name]] != '')) { + //hack, if param[name]=src or none tag, extract. Skip all other attributes. + if ($name!='param' || $attrs['name']=='src'){ + //skip glossary.html, tweak to accomodate atutor imscp; also skip repeated entries. + //skip javascript: links, void();, #, mailto: + if (strpos($attrs[$elements[$name]], 'glossary.html')===false + && !in_array($attrs[$elements[$name]], $my_files) + && $attrs[$elements[$name]]!='#' + && strpos($attrs[$elements[$name]], 'javascript:')===false + && strpos($attrs[$elements[$name]], 'mailto:')===false + && strpos($attrs[$elements[$name]], 'void(')===false + ){ + $my_files[] = $attrs[$elements[$name]]; + } + } + } + } + + function closeHandler(& $parser,$name) { } +} +?> \ No newline at end of file -- 2.17.1