|
Moodle
2.2.1
http://www.collinsharper.com
|
00001 <?php 00002 00003 defined('MOODLE_INTERNAL') || die(); 00004 /* 00005 Can be used to allow preserving of certain "safe" HTML <tags> 00006 (as seen in [sfWiki | http://sfwiki.sf.net/]. 00007 "Safe" tags include Q, S, PRE, TT, H1-H6, KBD, VAR, XMP, B, I 00008 but just see (or change) ewiki_format() for more. They are not 00009 accepted if written with mixed lowercase and uppercase letters, 00010 and they cannot contain any tag attributes. 00011 00012 RESCUE_HTML was formerly part of the main rendering function, but 00013 has now been extracted into this plugin, so one only needs to 00014 include it to get simple html tags working. 00015 */ 00016 00017 00018 $ewiki_plugins["format_source"][] = "ewiki_moodle_rescue_html"; 00019 00020 00021 function ewiki_moodle_rescue_html(&$wiki_source) { 00022 $safe_html = EWIKI_RESCUE_HTML; 00023 $safe_html += 1; 00024 00025 $rescue_html = array( 00026 "br", "tt", "b", "i", "strong", "em", "s", "kbd", "var", "xmp", "sup", "sub", 00027 "pre", "q", "h1", "h2", "h3", "h4", "h5", "h6", "cite", "code", "u", 00028 ); 00029 00030 00031 00032 #-- unescape allowed html 00033 if ($safe_html) { 00034 /* 00035 foreach ($rescue_html as $tag) { 00036 foreach(array($tag, "/$tag", ($tag=strtoupper($tag)), "/$tag") as $tag) { 00037 $wiki_source = str_replace('<'.$tag.'>', "<".$tag.">", $wiki_source); 00038 } } 00039 */ 00040 $regexp='#<(/?('.implode("|",$rescue_html).'))( /)?>#i'; 00041 $wiki_source = preg_replace($regexp, '<$1>', $wiki_source); 00042 } 00043 00044 } 00045