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 /************************************************************************/
12 // $Id: ContentOutputParser.class.php 10278 2010-10-04 16:47:45Z hwong $
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] != '') {
56 /* some attributes allow a listing of files to include seperated by commas (ie. applet->archive). */
57 if (strpos($attrs[$item], ',') !== false) {
58 $files = explode(',', $attrs[$item]);
59 foreach ($files as $file) {
60 $my_files[] = trim($file);
63 $my_files[] = $attrs[$item];
67 } else if (isset($elements[$name]) && ($attrs[$elements[$name]] != '')) {
68 //hack, if param[name]=src or none <param> tag, extract. Skip all other <param> attributes.
69 if ($name!='param' || $attrs['name']=='src'){
70 //skip glossary.html, tweak to accomodate atutor imscp; also skip repeated entries.
71 //skip javascript: links, void();, #, mailto:
72 if (strpos($attrs[$elements[$name]], 'glossary.html')===false
73 && !in_array($attrs[$elements[$name]], $my_files)
74 && $attrs[$elements[$name]]!='#'
75 && strpos($attrs[$elements[$name]], 'javascript:')===false
76 && strpos($attrs[$elements[$name]], 'mailto:')===false
77 && strpos($attrs[$elements[$name]], 'void(')===false
79 $my_files[] = $attrs[$elements[$name]];
85 function closeHandler(& $parser,$name) { }