2 /************************************************************************/
4 /************************************************************************/
5 /* Copyright (c) 2002 - 2009 */
6 /* Inclusive Design Institute */
8 /* This program is free software. You can redistribute it and/or */
9 /* modify it under the terms of the GNU General Public License */
10 /* as published by the Free Software Foundation. */
11 /************************************************************************/
14 class ContentOutputParser {
15 function ContentOutputParser(){}
16 function openHandler(& $parser,$name,$attrs) {
19 $name = strtolower($name);
20 $attrs = array_change_key_case($attrs, CASE_LOWER);
23 the following resources are to be identified:
24 even if some of these can't be images, they can still be files in the content dir.
25 theoretically the only urls we wouldn't deal with would be for a <!DOCTYPE and <form>
28 a => href // ignore if href doesn't exist (ie. <a name>)
29 object => data | classid // probably only want data
30 applet => classid | archive // whatever these two are should double check to see if it's a valid file (not a dir)
38 $elements = array( 'img' => 'src',
40 'object' => array('data', 'classid'),
41 'applet' => array('classid', 'archive'),
50 /* check if this attribute specifies the files in different ways: (ie. java) */
51 if (is_array($elements[$name])) {
52 $items = $elements[$name];
53 foreach ($items as $item) {
54 if ($attrs[$item] != '') {
55 /* some attributes allow a listing of files to include seperated by commas (ie. applet->archive). */
56 if (strpos($attrs[$item], ',') !== false) {
57 $files = explode(',', $attrs[$item]);
58 foreach ($files as $file) {
59 $my_files[] = trim($file);
62 $file = trim($attrs[$item]);
63 // filter our classid="clsid:..."
64 if (!strpos($file, "clsid:")) {
70 } else if (isset($elements[$name]) && ($attrs[$elements[$name]] != '')) {
71 //hack, if param[name]=src or none <param> tag, extract. Skip all other <param> attributes.
72 if ($name!='param' || $attrs['name']=='src'){
73 //skip glossary.html, tweak to accomodate atutor imscp; also skip repeated entries.
74 //skip javascript: links, void();, #, mailto:
75 if (strpos($attrs[$elements[$name]], 'glossary.html')===false
76 && !in_array($attrs[$elements[$name]], $my_files)
77 && $attrs[$elements[$name]]!='#'
78 && strpos($attrs[$elements[$name]], 'javascript:')===false
79 && strpos($attrs[$elements[$name]], 'mailto:')===false
80 && strpos($attrs[$elements[$name]], 'void(')===false
82 $my_files[] = $attrs[$elements[$name]];
88 function closeHandler(& $parser,$name) { }