[0;0m? MDL-14582_filters.patch[0;0m
[1;32mIndex: activitynames/filter.php[0;0m
[1;32m===================================================================[0;0m
[1;32mRCS file: /cvsroot/moodle/moodle/filter/activitynames/filter.php,v[0;0m
[1;32mretrieving revision 1.24[0;0m
[1;32mdiff -u -u -r1.24 filter.php[0;0m
[1;31m--- activitynames/filter.php	7 Dec 2008 18:57:38 -0000	1.24[0;0m
[1;34m+++ activitynames/filter.php	11 Dec 2008 07:33:16 -0000[0;0m
[1;35m@@ -3,33 +3,37 @@[0;0m
[0;0m     //activities when its name (title) is found inside every Moodle text[0;0m
[0;0m     //It's based in the glosssary filter by Williams Castillo[0;0m
[0;0m     //Modifications by stronk7.[0;0m
[1;34m+class activitynames_filter extends filter_base {[0;0m
[1;34m+    // Trivial-cache - keyed on $cachedcourseid[0;0m
[1;34m+    static $activitylist = null;[0;0m
[1;34m+    static $cachedcourseid;[0;0m
[0;0m [0;0m
[1;31m-    function activitynames_filter($courseid, $text) {[0;0m
[1;31m-        global $CFG, $COURSE, $DB;[0;0m
[1;34m+    function __construct($courseid, $format, $options){[0;0m
[1;34m+        parent::__construct($courseid, $format, $options);[0;0m
[1;34m+    }[0;0m
[0;0m [0;0m
[1;31m-        // Trivial-cache - keyed on $cachedcourseid[0;0m
[1;31m-        static $activitylist = null;[0;0m
[1;31m-        static $cachedcourseid;[0;0m
[1;34m+    function dofilter($text) {[0;0m
[1;34m+        global $CFG, $COURSE, $DB;[0;0m
[0;0m [0;0m
[1;31m-        if (empty($courseid)) {[0;0m
[1;31m-            $courseid = SITEID;[0;0m
[1;34m+        if (empty($this->courseid)) {[0;0m
[1;34m+            $this->courseid = SITEID;[0;0m
[0;0m         }[0;0m
[0;0m [0;0m
[0;0m         // Initialise/invalidate our trivial cache if dealing with a different course[0;0m
[1;31m-        if (!isset($cachedcourseid) || $cachedcourseid !== (int)$courseid) {[0;0m
[1;31m-            $activitylist = null;[0;0m
[1;34m+        if (!isset($this->cachedcourseid) || $this->cachedcourseid !== (int)$this->courseid) {[0;0m
[1;34m+            $this->activitylist = null;[0;0m
[0;0m         } [0;0m
[1;31m-        $cachedcourseid = (int)$courseid;[0;0m
[1;34m+        $this->cachedcourseid = (int)$this->courseid;[0;0m
[0;0m [0;0m
[0;0m         /// It may be cached[0;0m
[0;0m [0;0m
[1;31m-        if (is_null($activitylist)) {[0;0m
[1;31m-            $activitylist = array();[0;0m
[1;34m+        if (is_null($this->activitylist)) {[0;0m
[1;34m+            $this->activitylist = array();[0;0m
[0;0m [0;0m
[1;31m-            if ($COURSE->id == $courseid) {[0;0m
[1;34m+            if ($COURSE->id == $this->courseid) {[0;0m
[0;0m                 $course = $COURSE;[0;0m
[0;0m             } else {[0;0m
[1;31m-                $course = $DB->get_record("course", array("id"=>$courseid));[0;0m
[1;34m+                $course = $DB->get_record("course", array("id"=>$this->courseid));[0;0m
[0;0m             }[0;0m
[0;0m [0;0m
[0;0m             if (!isset($course->modinfo)) {[0;0m
[1;35m@@ -41,7 +45,7 @@[0;0m
[0;0m [0;0m
[0;0m             if (!empty($modinfo)) {[0;0m
[0;0m [0;0m
[1;31m-                $activitylist = array();      /// We will store all the activities here[0;0m
[1;34m+                $this->activitylist = array();      /// We will store all the activities here[0;0m
[0;0m [0;0m
[0;0m                 //Sort modinfo by name length[0;0m
[0;0m                 usort($modinfo, 'comparemodulenamesbylength');[0;0m
[1;35m@@ -55,9 +59,9 @@[0;0m
[0;0m                         /// Avoid empty or unlinkable activity names[0;0m
[0;0m                         if (!empty($title)) {[0;0m
[0;0m                             $href_tag_begin = "<a class=\"autolink\" title=\"$title\" href=\"$CFG->wwwroot/mod/$activity->mod/view.php?id=$activity->cm\" $CFG->frametarget>";[0;0m
[1;31m-                            $activitylist[] = new filterobject($currentname, $href_tag_begin, '</a>', false, true);[0;0m
[1;34m+                            $this->activitylist[] = new filterobject($currentname, $href_tag_begin, '</a>', false, true);[0;0m
[0;0m                             if ($currentname != $entitisedname) { /// If name has some entity (&amp; &quot; &lt; &gt;) add that filter too. MDL-17545[0;0m
[1;31m-                                $activitylist[] = new filterobject($entitisedname, $href_tag_begin, '</a>', false, true);[0;0m
[1;34m+                                $this->activitylist[] = new filterobject($entitisedname, $href_tag_begin, '</a>', false, true);[0;0m
[0;0m                             }[0;0m
[0;0m                         }[0;0m
[0;0m                     }[0;0m
[1;35m@@ -65,20 +69,21 @@[0;0m
[0;0m             }[0;0m
[0;0m         }[0;0m
[0;0m [0;0m
[1;31m-        if ($activitylist) {[0;0m
[1;31m-            return $text = filter_phrases ($text, $activitylist);[0;0m
[1;34m+        if ($this->activitylist) {[0;0m
[1;34m+            return $text = filter_phrases ($text, $this->activitylist);[0;0m
[0;0m         } else {[0;0m
[0;0m             return $text;[0;0m
[0;0m         }[0;0m
[0;0m     }[0;0m
[1;34m+}[0;0m
[0;0m [0;0m
[0;0m [0;0m
[0;0m [0;0m
[1;31m-    //This function is used to order module names from longer to shorter[0;0m
[1;31m-    function comparemodulenamesbylength($a, $b)  {[0;0m
[1;31m-        if (strlen($a->name) == strlen($b->name)) {[0;0m
[1;31m-            return 0;[0;0m
[1;31m-        }[0;0m
[1;31m-        return (strlen($a->name) < strlen($b->name)) ? 1 : -1;[0;0m
[1;34m+//This function is used to order module names from longer to shorter[0;0m
[1;34m+function comparemodulenamesbylength($a, $b)  {[0;0m
[1;34m+    if (strlen($a->name) == strlen($b->name)) {[0;0m
[1;34m+        return 0;[0;0m
[0;0m     }[0;0m
[1;34m+    return (strlen($a->name) < strlen($b->name)) ? 1 : -1;[0;0m
[1;34m+}[0;0m
[0;0m ?>[0;0m
[1;32mIndex: algebra/filter.php[0;0m
[1;32m===================================================================[0;0m
[1;32mRCS file: /cvsroot/moodle/moodle/filter/algebra/filter.php,v[0;0m
[1;32mretrieving revision 1.26[0;0m
[1;32mdiff -u -u -r1.26 filter.php[0;0m
[1;31m--- algebra/filter.php	31 May 2008 18:05:42 -0000	1.26[0;0m
[1;34m+++ algebra/filter.php	11 Dec 2008 07:33:16 -0000[0;0m
[1;35m@@ -84,16 +84,19 @@[0;0m
[0;0m   return $output;[0;0m
[0;0m }[0;0m
[0;0m [0;0m
[1;31m-[0;0m
[1;31m-function algebra_filter ($courseid, $text) {[0;0m
[1;31m-    global $CFG, $DB;[0;0m
[1;31m-[0;0m
[1;31m-    /// Do a quick check using stripos to avoid unnecessary wor[0;0m
[1;31m-    if (!preg_match('/<algebra/i',$text) && !strstr($text,'@@')) {[0;0m
[1;31m-        return $text;[0;0m
[1;34m+class algebra_filter extends filter_base{[0;0m
[1;34m+    function __construct($courseid, $format, $options){[0;0m
[1;34m+        parent::__construct($courseid, $format, $options);[0;0m
[0;0m     }[0;0m
[1;34m+    function dofilter($text){[0;0m
[1;34m+        global $CFG, $DB;[0;0m
[1;34m+[0;0m
[1;34m+        /// Do a quick check using stripos to avoid unnecessary wor[0;0m
[1;34m+        if (!preg_match('/<algebra/i',$text) && !strstr($text,'@@')) {[0;0m
[1;34m+            return $text;[0;0m
[1;34m+        }[0;0m
[0;0m [0;0m
[1;31m-#    //restrict filtering to forum 130 (Maths Tools on moodle.org)[0;0m
[1;34m+//restrict filtering to forum 130 (Maths Tools on moodle.org)[0;0m
[0;0m #    $scriptname = $_SERVER['SCRIPT_NAME'];[0;0m
[0;0m #    if (!strstr($scriptname,'/forum/')) {[0;0m
[0;0m #        return $text;[0;0m
[1;35m@@ -102,7 +105,7 @@[0;0m
[0;0m #        $parent = forum_get_post_full($_GET['reply']);[0;0m
[0;0m #        $discussion = $DB->get_record("forum_discussions",array("id"=>$parent->discussion));[0;0m
[0;0m #    } else if (strstr($scriptname,'discuss.php')) {[0;0m
[1;31m-#        $discussion = $DB->get_record("forum_discussions", array("id"=>$_GET['d']));[0;0m
[1;34m+#        $discussion = $DB->get_record("forum_discussions",array("id"=>$_GET['d']));[0;0m
[0;0m #    } else {[0;0m
[0;0m #        return $text;[0;0m
[0;0m #    }[0;0m
[1;35m@@ -111,125 +114,126 @@[0;0m
[0;0m #    }[0;0m
[0;0m [0;0m
[0;0m [0;0m
[1;31m-    $text .= ' ';[0;0m
[1;34m+        $text .= ' ';[0;0m
[0;0m [0;0m
[1;31m-    preg_match_all('/@(@@+)([^@])/',$text,$matches);[0;0m
[1;31m-    for ($i=0;$i<count($matches[0]);$i++) {[0;0m
[1;31m-        $replacement = str_replace('@','&#x00040;',$matches[1][$i]).$matches[2][$i];[0;0m
[1;31m-        $text = str_replace($matches[0][$i],$replacement,$text);[0;0m
[1;31m-    }[0;0m
[1;34m+        preg_match_all('/@(@@+)([^@])/',$text,$matches);[0;0m
[1;34m+        for ($i=0;$i<count($matches[0]);$i++) {[0;0m
[1;34m+            $replacement = str_replace('@','&#x00040;',$matches[1][$i]).$matches[2][$i];[0;0m
[1;34m+            $text = str_replace($matches[0][$i],$replacement,$text);[0;0m
[1;34m+        }[0;0m
[0;0m [0;0m
[1;31m-    // <algebra> some algebraic input expression </algebra>[0;0m
[1;31m-    // or @@ some algebraic input expression @@[0;0m
[1;34m+        // <algebra> some algebraic input expression </algebra>[0;0m
[1;34m+        // or @@ some algebraic input expression @@[0;0m
[0;0m [0;0m
[1;31m-    preg_match_all('/<algebra>(.+?)<\/algebra>|@@(.+?)@@/is', $text, $matches);[0;0m
[1;31m-    for ($i=0; $i<count($matches[0]); $i++) {[0;0m
[1;31m-        $algebra = $matches[1][$i] . $matches[2][$i];[0;0m
[1;31m-        $algebra = str_replace('<nolink>','',$algebra);[0;0m
[1;31m-        $algebra = str_replace('</nolink>','',$algebra);[0;0m
[1;31m-        $algebra = str_replace('<span class="nolink">','',$algebra);[0;0m
[1;31m-        $algebra = str_replace('</span>','',$algebra);[0;0m
[1;31m-        $align = "middle";[0;0m
[1;31m-        if (preg_match('/^align=bottom /',$algebra)) {[0;0m
[1;31m-          $align = "text-bottom";[0;0m
[1;31m-          $algebra = preg_replace('/^align=bottom /','',$algebra);[0;0m
[1;31m-        } else if (preg_match('/^align=top /',$algebra)) {[0;0m
[1;31m-          $align = "text-top";[0;0m
[1;31m-          $algebra = preg_replace('/^align=top /','',$algebra);[0;0m
[1;31m-        }[0;0m
[1;31m-        $md5 =  md5($algebra);[0;0m
[1;31m-        $filename =  $md5  . ".gif";[0;0m
[1;31m-        if (! $texcache = $DB->get_record("cache_filters", array("filter"=>"algebra", "md5key"=>$md5))) {[0;0m
[1;31m-           $algebra = str_replace('&lt;','<',$algebra);[0;0m
[1;31m-           $algebra = str_replace('&gt;','>',$algebra);[0;0m
[1;31m-           $algebra = str_replace('<>','#',$algebra);[0;0m
[1;31m-           $algebra = str_replace('<=','%',$algebra);[0;0m
[1;31m-           $algebra = str_replace('>=','!',$algebra);[0;0m
[1;31m-           $algebra = preg_replace('/([=><%!#] *)-/',"\$1 zeroplace -",$algebra);[0;0m
[1;31m-           $algebra = str_replace('delta','zdelta',$algebra);[0;0m
[1;31m-           $algebra = str_replace('beta','bita',$algebra);[0;0m
[1;31m-           $algebra = str_replace('theta','thita',$algebra);[0;0m
[1;31m-           $algebra = str_replace('zeta','zita',$algebra);[0;0m
[1;31m-           $algebra = str_replace('eta','xeta',$algebra);[0;0m
[1;31m-           $algebra = str_replace('epsilon','zepslon',$algebra);[0;0m
[1;31m-           $algebra = str_replace('upsilon','zupslon',$algebra);[0;0m
[1;31m-           $algebra = preg_replace('!\r\n?!',' ',$algebra);[0;0m
[1;31m-           $algebra = escapeshellarg($algebra);[0;0m
[1;31m-           if ( (PHP_OS == "WINNT") || (PHP_OS == "WIN32") || (PHP_OS == "Windows") ) {[0;0m
[1;31m-              $cmd  = "cd $CFG->dirroot\\filter\\algebra & algebra2tex.pl $algebra";[0;0m
[1;31m-           } else {[0;0m
[1;31m-              $cmd  = "cd $CFG->dirroot/filter/algebra; ./algebra2tex.pl $algebra";[0;0m
[1;31m-           }[0;0m
[1;31m-           $texexp = `$cmd`;[0;0m
[1;31m-           if (preg_match('/parsehilight/',$texexp)) {[0;0m
[1;31m-             $text = str_replace( $matches[0][$i],"<b>Syntax error:</b> " . $texexp,$text);[0;0m
[1;31m-           } else if ($texexp) {[0;0m
[1;31m-              $texexp = str_replace('zeroplace','',$texexp);[0;0m
[1;31m-              $texexp = str_replace('#','\not= ',$texexp);[0;0m
[1;31m-              $texexp = str_replace('%','\leq ',$texexp);[0;0m
[1;31m-              $texexp = str_replace('!','\geq ',$texexp);[0;0m
[1;31m-              $texexp = str_replace('\left{','{',$texexp);[0;0m
[1;31m-              $texexp = str_replace('\right}','}',$texexp);[0;0m
[1;31m-              $texexp = str_replace('\fun',' ',$texexp);[0;0m
[1;31m-              $texexp = str_replace('infty','\infty',$texexp);[0;0m
[1;31m-              $texexp = str_replace('alpha','\alpha',$texexp);[0;0m
[1;31m-              $texexp = str_replace('gamma','\gamma',$texexp);[0;0m
[1;31m-              $texexp = str_replace('iota','\iota',$texexp);[0;0m
[1;31m-              $texexp = str_replace('kappa','\kappa',$texexp);[0;0m
[1;31m-              $texexp = str_replace('lambda','\lambda',$texexp);[0;0m
[1;31m-              $texexp = str_replace('mu','\mu',$texexp);[0;0m
[1;31m-              $texexp = str_replace('nu','\nu',$texexp);[0;0m
[1;31m-              $texexp = str_replace('xi','\xi',$texexp);[0;0m
[1;31m-              $texexp = str_replace('rho','\rho',$texexp);[0;0m
[1;31m-              $texexp = str_replace('sigma','\sigma',$texexp);[0;0m
[1;31m-              $texexp = str_replace('tau','\tau',$texexp);[0;0m
[1;31m-              $texexp = str_replace('phi','\phi',$texexp);[0;0m
[1;31m-              $texexp = str_replace('chi','\chi',$texexp);[0;0m
[1;31m-              $texexp = str_replace('psi','\psi',$texexp);[0;0m
[1;31m-              $texexp = str_replace('omega','\omega',$texexp);[0;0m
[1;31m-              $texexp = str_replace('zdelta','\delta',$texexp);[0;0m
[1;31m-              $texexp = str_replace('bita','\beta',$texexp);[0;0m
[1;31m-              $texexp = str_replace('thita','\theta',$texexp);[0;0m
[1;31m-              $texexp = str_replace('zita','\zeta',$texexp);[0;0m
[1;31m-              $texexp = str_replace('xeta','\eta',$texexp);[0;0m
[1;31m-              $texexp = str_replace('zepslon','\epsilon',$texexp);[0;0m
[1;31m-              $texexp = str_replace('zupslon','\upsilon',$texexp);[0;0m
[1;31m-              $texexp = str_replace('\mbox{logten}','\mbox{log}_{10}',$texexp);[0;0m
[1;31m-              $texexp = str_replace('\mbox{acos}','\mbox{cos}^{-1}',$texexp);[0;0m
[1;31m-              $texexp = str_replace('\mbox{asin}','\mbox{sin}^{-1}',$texexp);[0;0m
[1;31m-              $texexp = str_replace('\mbox{atan}','\mbox{tan}^{-1}',$texexp);[0;0m
[1;31m-              $texexp = str_replace('\mbox{asec}','\mbox{sec}^{-1}',$texexp);[0;0m
[1;31m-              $texexp = str_replace('\mbox{acsc}','\mbox{csc}^{-1}',$texexp);[0;0m
[1;31m-              $texexp = str_replace('\mbox{acot}','\mbox{cot}^{-1}',$texexp);[0;0m
[1;31m-              $texexp = str_replace('\mbox{acosh}','\mbox{cosh}^{-1}',$texexp);[0;0m
[1;31m-              $texexp = str_replace('\mbox{asinh}','\mbox{sinh}^{-1}',$texexp);[0;0m
[1;31m-              $texexp = str_replace('\mbox{atanh}','\mbox{tanh}^{-1}',$texexp);[0;0m
[1;31m-              $texexp = str_replace('\mbox{asech}','\mbox{sech}^{-1}',$texexp);[0;0m
[1;31m-              $texexp = str_replace('\mbox{acsch}','\mbox{csch}^{-1}',$texexp);[0;0m
[1;31m-              $texexp = str_replace('\mbox{acoth}','\mbox{coth}^{-1}',$texexp);[0;0m
[1;31m-              //$texexp = preg_replace('/\\\frac{(.+?)}{\\\left\((.+?)\\\right\)}/s','\frac{'."\$1}{\$2}",$texexp);[0;0m
[1;31m-              $texexp = preg_replace('/\\\sqrt{(.+?),(.+?)}/s','\sqrt['. "\$2]{\$1}",$texexp);[0;0m
[1;31m-              $texexp = preg_replace('/\\\mbox{abs}\\\left\((.+?)\\\right\)/s',"|\$1|",$texexp);[0;0m
[1;31m-              $texexp = preg_replace('/\\\log\\\left\((.+?),(.+?)\\\right\)/s','\log_{'. "\$2}\\left(\$1\\right)",$texexp);[0;0m
[1;31m-              $texexp = preg_replace('/(\\\cos|\\\sin|\\\tan|\\\sec|\\\csc|\\\cot)([h]*)\\\left\((.+?),(.+?)\\\right\)/s',"\$1\$2^{". "\$4}\\left(\$3\\right)",$texexp);[0;0m
[1;31m-              $texexp = preg_replace('/\\\int\\\left\((.+?),(.+?),(.+?)\\\right\)/s','\int_'. "{\$2}^{\$3}\$1 ",$texexp);[0;0m
[1;31m-              $texexp = preg_replace('/\\\int\\\left\((.+?d[a-z])\\\right\)/s','\int '. "\$1 ",$texexp);[0;0m
[1;31m-              $texexp = preg_replace('/\\\lim\\\left\((.+?),(.+?),(.+?)\\\right\)/s','\lim_'. "{\$2\\to \$3}\$1 ",$texexp);[0;0m
[1;31m-              $texcache->filter = 'algebra';[0;0m
[1;31m-              $texcache->version = 1;[0;0m
[1;31m-              $texcache->md5key = $md5;[0;0m
[1;31m-              $texcache->rawtext = $texexp;[0;0m
[1;31m-              $texcache->timemodified = time();[0;0m
[1;31m-              $DB->insert_record("cache_filters",$texcache, false);[0;0m
[1;31m-              $text = str_replace( $matches[0][$i], string_file_picture_algebra($filename, $texexp, '', '', $align), $text);[0;0m
[1;31m-           } else {[0;0m
[1;31m-              $text = str_replace( $matches[0][$i],"<b>Undetermined error:</b> ",$text);[0;0m
[1;31m-           }[0;0m
[1;31m-        } else {[0;0m
[1;31m-           $text = str_replace( $matches[0][$i], string_file_picture_algebra($filename, $texcache->rawtext), $text);[0;0m
[1;34m+        preg_match_all('/<algebra>(.+?)<\/algebra>|@@(.+?)@@/is', $text, $matches);[0;0m
[1;34m+        for ($i=0; $i<count($matches[0]); $i++) {[0;0m
[1;34m+            $algebra = $matches[1][$i] . $matches[2][$i];[0;0m
[1;34m+            $algebra = str_replace('<nolink>','',$algebra);[0;0m
[1;34m+            $algebra = str_replace('</nolink>','',$algebra);[0;0m
[1;34m+            $algebra = str_replace('<span class="nolink">','',$algebra);[0;0m
[1;34m+            $algebra = str_replace('</span>','',$algebra);[0;0m
[1;34m+            $align = "middle";[0;0m
[1;34m+            if (preg_match('/^align=bottom /',$algebra)) {[0;0m
[1;34m+              $align = "text-bottom";[0;0m
[1;34m+              $algebra = preg_replace('/^align=bottom /','',$algebra);[0;0m
[1;34m+            } else if (preg_match('/^align=top /',$algebra)) {[0;0m
[1;34m+              $align = "text-top";[0;0m
[1;34m+              $algebra = preg_replace('/^align=top /','',$algebra);[0;0m
[1;34m+            }[0;0m
[1;34m+            $md5 =  md5($algebra);[0;0m
[1;34m+            $filename =  $md5  . ".gif";[0;0m
[1;34m+            if (! $texcache = $DB->get_record("cache_filters",array("filter"=>"algebra", "md5key"=>$md5))) {[0;0m
[1;34m+               $algebra = str_replace('&lt;','<',$algebra);[0;0m
[1;34m+               $algebra = str_replace('&gt;','>',$algebra);[0;0m
[1;34m+               $algebra = str_replace('<>','#',$algebra);[0;0m
[1;34m+               $algebra = str_replace('<=','%',$algebra);[0;0m
[1;34m+               $algebra = str_replace('>=','!',$algebra);[0;0m
[1;34m+               $algebra = preg_replace('/([=><%!#] *)-/',"\$1 zeroplace -",$algebra);[0;0m
[1;34m+               $algebra = str_replace('delta','zdelta',$algebra);[0;0m
[1;34m+               $algebra = str_replace('beta','bita',$algebra);[0;0m
[1;34m+               $algebra = str_replace('theta','thita',$algebra);[0;0m
[1;34m+               $algebra = str_replace('zeta','zita',$algebra);[0;0m
[1;34m+               $algebra = str_replace('eta','xeta',$algebra);[0;0m
[1;34m+               $algebra = str_replace('epsilon','zepslon',$algebra);[0;0m
[1;34m+               $algebra = str_replace('upsilon','zupslon',$algebra);[0;0m
[1;34m+               $algebra = preg_replace('!\r\n?!',' ',$algebra);[0;0m
[1;34m+               $algebra = escapeshellarg($algebra);[0;0m
[1;34m+               if ( (PHP_OS == "WINNT") || (PHP_OS == "WIN32") || (PHP_OS == "Windows") ) {[0;0m
[1;34m+                  $cmd  = "cd $CFG->dirroot\\filter\\algebra & algebra2tex.pl $algebra";[0;0m
[1;34m+               } else {[0;0m
[1;34m+                  $cmd  = "cd $CFG->dirroot/filter/algebra; ./algebra2tex.pl $algebra";[0;0m
[1;34m+               }[0;0m
[1;34m+               $texexp = `$cmd`;[0;0m
[1;34m+               if (preg_match('/parsehilight/',$texexp)) {[0;0m
[1;34m+                 $text = str_replace( $matches[0][$i],"<b>Syntax error:</b> " . $texexp,$text);[0;0m
[1;34m+               } else if ($texexp) {[0;0m
[1;34m+                  $texexp = str_replace('zeroplace','',$texexp);[0;0m
[1;34m+                  $texexp = str_replace('#','\not= ',$texexp);[0;0m
[1;34m+                  $texexp = str_replace('%','\leq ',$texexp);[0;0m
[1;34m+                  $texexp = str_replace('!','\geq ',$texexp);[0;0m
[1;34m+                  $texexp = str_replace('\left{','{',$texexp);[0;0m
[1;34m+                  $texexp = str_replace('\right}','}',$texexp);[0;0m
[1;34m+                  $texexp = str_replace('\fun',' ',$texexp);[0;0m
[1;34m+                  $texexp = str_replace('infty','\infty',$texexp);[0;0m
[1;34m+                  $texexp = str_replace('alpha','\alpha',$texexp);[0;0m
[1;34m+                  $texexp = str_replace('gamma','\gamma',$texexp);[0;0m
[1;34m+                  $texexp = str_replace('iota','\iota',$texexp);[0;0m
[1;34m+                  $texexp = str_replace('kappa','\kappa',$texexp);[0;0m
[1;34m+                  $texexp = str_replace('lambda','\lambda',$texexp);[0;0m
[1;34m+                  $texexp = str_replace('mu','\mu',$texexp);[0;0m
[1;34m+                  $texexp = str_replace('nu','\nu',$texexp);[0;0m
[1;34m+                  $texexp = str_replace('xi','\xi',$texexp);[0;0m
[1;34m+                  $texexp = str_replace('rho','\rho',$texexp);[0;0m
[1;34m+                  $texexp = str_replace('sigma','\sigma',$texexp);[0;0m
[1;34m+                  $texexp = str_replace('tau','\tau',$texexp);[0;0m
[1;34m+                  $texexp = str_replace('phi','\phi',$texexp);[0;0m
[1;34m+                  $texexp = str_replace('chi','\chi',$texexp);[0;0m
[1;34m+                  $texexp = str_replace('psi','\psi',$texexp);[0;0m
[1;34m+                  $texexp = str_replace('omega','\omega',$texexp);[0;0m
[1;34m+                  $texexp = str_replace('zdelta','\delta',$texexp);[0;0m
[1;34m+                  $texexp = str_replace('bita','\beta',$texexp);[0;0m
[1;34m+                  $texexp = str_replace('thita','\theta',$texexp);[0;0m
[1;34m+                  $texexp = str_replace('zita','\zeta',$texexp);[0;0m
[1;34m+                  $texexp = str_replace('xeta','\eta',$texexp);[0;0m
[1;34m+                  $texexp = str_replace('zepslon','\epsilon',$texexp);[0;0m
[1;34m+                  $texexp = str_replace('zupslon','\upsilon',$texexp);[0;0m
[1;34m+                  $texexp = str_replace('\mbox{logten}','\mbox{log}_{10}',$texexp);[0;0m
[1;34m+                  $texexp = str_replace('\mbox{acos}','\mbox{cos}^{-1}',$texexp);[0;0m
[1;34m+                  $texexp = str_replace('\mbox{asin}','\mbox{sin}^{-1}',$texexp);[0;0m
[1;34m+                  $texexp = str_replace('\mbox{atan}','\mbox{tan}^{-1}',$texexp);[0;0m
[1;34m+                  $texexp = str_replace('\mbox{asec}','\mbox{sec}^{-1}',$texexp);[0;0m
[1;34m+                  $texexp = str_replace('\mbox{acsc}','\mbox{csc}^{-1}',$texexp);[0;0m
[1;34m+                  $texexp = str_replace('\mbox{acot}','\mbox{cot}^{-1}',$texexp);[0;0m
[1;34m+                  $texexp = str_replace('\mbox{acosh}','\mbox{cosh}^{-1}',$texexp);[0;0m
[1;34m+                  $texexp = str_replace('\mbox{asinh}','\mbox{sinh}^{-1}',$texexp);[0;0m
[1;34m+                  $texexp = str_replace('\mbox{atanh}','\mbox{tanh}^{-1}',$texexp);[0;0m
[1;34m+                  $texexp = str_replace('\mbox{asech}','\mbox{sech}^{-1}',$texexp);[0;0m
[1;34m+                  $texexp = str_replace('\mbox{acsch}','\mbox{csch}^{-1}',$texexp);[0;0m
[1;34m+                  $texexp = str_replace('\mbox{acoth}','\mbox{coth}^{-1}',$texexp);[0;0m
[1;34m+                  //$texexp = preg_replace('/\\\frac{(.+?)}{\\\left\((.+?)\\\right\)}/s','\frac{'."\$1}{\$2}",$texexp);[0;0m
[1;34m+                  $texexp = preg_replace('/\\\sqrt{(.+?),(.+?)}/s','\sqrt['. "\$2]{\$1}",$texexp);[0;0m
[1;34m+                  $texexp = preg_replace('/\\\mbox{abs}\\\left\((.+?)\\\right\)/s',"|\$1|",$texexp);[0;0m
[1;34m+                  $texexp = preg_replace('/\\\log\\\left\((.+?),(.+?)\\\right\)/s','\log_{'. "\$2}\\left(\$1\\right)",$texexp);[0;0m
[1;34m+                  $texexp = preg_replace('/(\\\cos|\\\sin|\\\tan|\\\sec|\\\csc|\\\cot)([h]*)\\\left\((.+?),(.+?)\\\right\)/s',"\$1\$2^{". "\$4}\\left(\$3\\right)",$texexp);[0;0m
[1;34m+                  $texexp = preg_replace('/\\\int\\\left\((.+?),(.+?),(.+?)\\\right\)/s','\int_'. "{\$2}^{\$3}\$1 ",$texexp);[0;0m
[1;34m+                  $texexp = preg_replace('/\\\int\\\left\((.+?d[a-z])\\\right\)/s','\int '. "\$1 ",$texexp);[0;0m
[1;34m+                  $texexp = preg_replace('/\\\lim\\\left\((.+?),(.+?),(.+?)\\\right\)/s','\lim_'. "{\$2\\to \$3}\$1 ",$texexp);[0;0m
[1;34m+                  $texcache->filter = 'algebra';[0;0m
[1;34m+                  $texcache->version = 1;[0;0m
[1;34m+                  $texcache->md5key = $md5;[0;0m
[1;34m+                  $texcache->rawtext = $texexp;[0;0m
[1;34m+                  $texcache->timemodified = time();[0;0m
[1;34m+                  $DB->insert_record("cache_filters", $texcache, false);[0;0m
[1;34m+                  $text = str_replace( $matches[0][$i], string_file_picture_algebra($filename, $texexp, '', '', $align), $text);[0;0m
[1;34m+               } else {[0;0m
[1;34m+                  $text = str_replace( $matches[0][$i],"<b>Undetermined error:</b> ",$text);[0;0m
[1;34m+               }[0;0m
[1;34m+            } else {[0;0m
[1;34m+               $text = str_replace( $matches[0][$i], string_file_picture_algebra($filename, $texcache->rawtext), $text);[0;0m
[1;34m+            }[0;0m
[0;0m         }[0;0m
[1;34m+        return $text;[0;0m
[0;0m     }[0;0m
[1;31m-    return $text;[0;0m
[0;0m }[0;0m
[0;0m [0;0m
[0;0m ?>[0;0m
[1;32mIndex: censor/filter.php[0;0m
[1;32m===================================================================[0;0m
[1;32mRCS file: /cvsroot/moodle/moodle/filter/censor/filter.php,v[0;0m
[1;32mretrieving revision 1.12[0;0m
[1;32mdiff -u -u -r1.12 filter.php[0;0m
[1;31m--- censor/filter.php	13 Nov 2007 20:03:27 -0000	1.12[0;0m
[1;34m+++ censor/filter.php	11 Dec 2008 07:33:16 -0000[0;0m
[1;35m@@ -9,37 +9,60 @@[0;0m
[0;0m //[0;0m
[0;0m //////////////////////////////////////////////////////////////[0;0m
[0;0m [0;0m
[1;31m-/// This is the filtering function itself.  It accepts the [0;0m
[1;31m-/// courseid and the text to be filtered (in HTML form).[0;0m
[1;31m-[0;0m
[1;31m-function censor_filter($courseid, $text) {[0;0m
[1;31m-[0;0m
[1;31m-    static $words;[0;0m
[1;31m-    global $CFG;[0;0m
[1;31m-[0;0m
[1;31m-    if (!isset($CFG->filter_censor_badwords)) {[0;0m
[1;31m-        set_config( 'filter_censor_badwords','' );[0;0m
[1;34m+/// This is the filtering class. It accepts the courseid and [0;0m
[1;34m+/// options to be filtered (In HTML form).[0;0m
[1;34m+class censor_filter extends filter_base{[0;0m
[1;34m+    function __construct($courseid, $format, $options){[0;0m
[1;34m+        parent::__construct($courseid, $format, $options);[0;0m
[0;0m     }[0;0m
[1;31m-[0;0m
[1;31m-    if (empty($words)) {[0;0m
[1;31m-        $words = array();[0;0m
[1;31m-        // if no user-specified words, use default list from language pack[0;0m
[1;31m-        if (empty($CFG->filter_censor_badwords)) {[0;0m
[1;31m-            $badwords = explode(',',get_string('badwords','censor') );[0;0m
[1;31m-        }[0;0m
[1;31m-        else {[0;0m
[1;31m-            $badwords = explode(',', $CFG->filter_censor_badwords );[0;0m
[1;34m+    function canseecensor(){[0;0m
[1;34m+        $cansee = false;[0;0m
[1;34m+        $context = get_context_instance(CONTEXT_SYSTEM, SITEID);[0;0m
[1;34m+        if (has_capability('moodle/site:doanything', $context)){[0;0m
[1;34m+            $cansee = true; [0;0m
[0;0m         }[0;0m
[1;31m-        foreach ($badwords as $badword) {[0;0m
[1;31m-            $badword = trim($badword);[0;0m
[1;31m-            // See MDL-3964 for explanation of leaving the badword in the span title [0;0m
[1;31m-            $words[] = new filterobject($badword, '<span class="censoredtext" title="'.$badword.'">', '</span>', [0;0m
[1;31m-                                        false, false, str_pad('',strlen($badword),'*'));[0;0m
[1;34m+        return $cansee;[0;0m
[1;34m+    }[0;0m
[1;34m+    function hash(){[0;0m
[1;34m+        $cap = "mod/filter:censor";[0;0m
[1;34m+        $context = get_context_instance(CONTEXT_SYSTEM, SITEID);[0;0m
[1;34m+        if (has_capability('moodle/site:doanything', $context)){[0;0m
[1;34m+            $cap = "mod/filter:seecensor";[0;0m
[0;0m         }[0;0m
[1;34m+        return $cap;[0;0m
[0;0m     }[0;0m
[1;34m+    function dofilter($text){[0;0m
[1;34m+        static $words;[0;0m
[1;34m+        global $CFG;[0;0m
[0;0m [0;0m
[1;31m-    return filter_phrases($text, $words);  // Look for all these words in the text[0;0m
[1;31m-}[0;0m
[1;34m+        if (!isset($CFG->filter_censor_badwords)) {[0;0m
[1;34m+            set_config( 'filter_censor_badwords','' );[0;0m
[1;34m+        }[0;0m
[0;0m [0;0m
[1;34m+        if (empty($words)) {[0;0m
[1;34m+            $words = array();[0;0m
[1;34m+            if (empty($CFG->filter_censor_badwords)) {[0;0m
[1;34m+                $badwords = explode(',',get_string('badwords','censor') );[0;0m
[1;34m+            }[0;0m
[1;34m+            else {[0;0m
[1;34m+                $badwords = explode(',', $CFG->filter_censor_badwords );[0;0m
[1;34m+            }[0;0m
[1;34m+            foreach ($badwords as $badword) {[0;0m
[1;34m+                $badword = trim($badword);[0;0m
[1;34m+                if($this->canseecensor()){[0;0m
[1;34m+                    $words[] = new filterobject($badword, '<span[0;0m
[1;34m+                            title"'.$badword.'">', '</span>', false,[0;0m
[1;34m+                            false, $badword);[0;0m
[1;34m+                } else {[0;0m
[1;34m+                    $words[] = new filterobject($badword, '<span[0;0m
[1;34m+                            class="censoredtext"[0;0m
[1;34m+                            title="'.$badword.'">', '</span>', [0;0m
[1;34m+                                                false, false, str_pad('',strlen($badword),'*'));[0;0m
[1;34m+                }[0;0m
[1;34m+            }[0;0m
[1;34m+        }[0;0m
[1;34m+        return filter_phrases($text, $words);[0;0m
[1;34m+    }[0;0m
[1;34m+}[0;0m
[0;0m [0;0m
[0;0m ?>[0;0m
[1;32mIndex: emailprotect/filter.php[0;0m
[1;32m===================================================================[0;0m
[1;32mRCS file: /cvsroot/moodle/moodle/filter/emailprotect/filter.php,v[0;0m
[1;32mretrieving revision 1.2[0;0m
[1;32mdiff -u -u -r1.2 filter.php[0;0m
[1;31m--- emailprotect/filter.php	30 Mar 2007 21:10:15 -0000	1.2[0;0m
[1;34m+++ emailprotect/filter.php	11 Dec 2008 07:33:16 -0000[0;0m
[1;35m@@ -1,43 +1,44 @@[0;0m
[0;0m <?PHP // $Id: filter.php,v 1.2 2007/03/30 21:10:15 skodak Exp $[0;0m
[1;31m-      // This function looks for email addresses in Moodle text and [0;0m
[1;34m+      // This class looks for email addresses in Moodle text and [0;0m
[0;0m       // hides them using the Moodle obfuscate_text function. [0;0m
[0;0m       // Original code by Mike Churchward[0;0m
[0;0m [0;0m
[1;31m-function emailprotect_filter($courseid, $text) {[0;0m
[1;31m-[0;0m
[1;31m-    [0;0m
[1;31m-    if (!empty($CFG->formatstring)) {[0;0m
[1;31m-        return $text;[0;0m
[1;34m+class emailprotect_filter extends filter_base{[0;0m
[1;34m+    function __construct($courseid, $format, $options){[0;0m
[1;34m+        parent::__construct($courseid, $format, $options);[0;0m
[0;0m     }[0;0m
[1;31m-                                            [0;0m
[1;31m-/// Do a quick check using stripos to avoid unnecessary work[0;0m
[1;31m-    if (strpos($text, '@') === false) {[0;0m
[1;34m+    function dofilter($text){[0;0m
[1;34m+        if (!empty($CFG->formatstring)) {[0;0m
[1;34m+            return $text;[0;0m
[1;34m+        }[0;0m
[1;34m+                                                [0;0m
[1;34m+    /// Do a quick check using stripos to avoid unnecessary work[0;0m
[1;34m+        if (strpos($text, '@') === false) {[0;0m
[1;34m+            return $text;[0;0m
[1;34m+        }[0;0m
[1;34m+[0;0m
[1;34m+    /// There might be an email in here somewhere so continue ...[0;0m
[1;34m+        $matches = array();[0;0m
[1;34m+[0;0m
[1;34m+    /// regular expression to define a standard email string.[0;0m
[1;34m+        $emailregex = '((?:[\w\.\-])+\@(?:(?:[a-zA-Z\d\-])+\.)+(?:[a-zA-Z\d]{2,4}))';[0;0m
[1;34m+[0;0m
[1;34m+    /// pattern to find a mailto link with the linked text.[0;0m
[1;34m+        $pattern = '|(<a\s+href\s*=\s*[\'"]?mailto:)'.$emailregex.'([\'"]?\s*>)'.'(.*)'.'(</a>)|iU';[0;0m
[1;34m+        $text = preg_replace_callback($pattern, 'alter_mailto', $text);[0;0m
[1;34m+[0;0m
[1;34m+    /// pattern to find any other email address in the text.[0;0m
[1;34m+        $pattern = '/(^|\s+|>)'.$emailregex.'($|\s+|\.\s+|\.$|<)/i';[0;0m
[1;34m+        $text = preg_replace_callback($pattern, 'alter_email', $text);[0;0m
[1;34m+[0;0m
[0;0m         return $text;[0;0m
[0;0m     }[0;0m
[1;31m-[0;0m
[1;31m-/// There might be an email in here somewhere so continue ...[0;0m
[1;31m-    $matches = array();[0;0m
[1;31m-[0;0m
[1;31m-/// regular expression to define a standard email string.[0;0m
[1;31m-    $emailregex = '((?:[\w\.\-])+\@(?:(?:[a-zA-Z\d\-])+\.)+(?:[a-zA-Z\d]{2,4}))';[0;0m
[1;31m-[0;0m
[1;31m-/// pattern to find a mailto link with the linked text.[0;0m
[1;31m-    $pattern = '|(<a\s+href\s*=\s*[\'"]?mailto:)'.$emailregex.'([\'"]?\s*>)'.'(.*)'.'(</a>)|iU';[0;0m
[1;31m-    $text = preg_replace_callback($pattern, 'alter_mailto', $text);[0;0m
[1;31m-[0;0m
[1;31m-/// pattern to find any other email address in the text.[0;0m
[1;31m-    $pattern = '/(^|\s+|>)'.$emailregex.'($|\s+|\.\s+|\.$|<)/i';[0;0m
[1;31m-    $text = preg_replace_callback($pattern, 'alter_email', $text);[0;0m
[1;31m-[0;0m
[1;31m-    return $text;[0;0m
[0;0m }[0;0m
[0;0m [0;0m
[1;31m-[0;0m
[0;0m function alter_email($matches) {[0;0m
[0;0m     return $matches[1].obfuscate_text($matches[2]).$matches[3];[0;0m
[0;0m }[0;0m
[0;0m [0;0m
[1;31m-[0;0m
[0;0m function alter_mailto($matches) {[0;0m
[0;0m     return obfuscate_mailto($matches[2], $matches[4]);[0;0m
[0;0m }[0;0m
[1;32mIndex: mediaplugin/filter.php[0;0m
[1;32m===================================================================[0;0m
[1;32mRCS file: /cvsroot/moodle/moodle/filter/mediaplugin/filter.php,v[0;0m
[1;32mretrieving revision 1.48[0;0m
[1;32mdiff -u -u -r1.48 filter.php[0;0m
[1;31m--- mediaplugin/filter.php	26 Nov 2008 01:47:46 -0000	1.48[0;0m
[1;34m+++ mediaplugin/filter.php	11 Dec 2008 07:33:16 -0000[0;0m
[1;35m@@ -17,93 +17,98 @@[0;0m
[0;0m [0;0m
[0;0m require_once($CFG->libdir.'/filelib.php');[0;0m
[0;0m [0;0m
[1;34m+class mediaplugin_filter extends filter_base{[0;0m
[1;34m+    private $eolas_fix_applied;[0;0m
[1;34m+    function __construct($courseid, $format, $options){[0;0m
[1;34m+        parent::__construct($courseid, $format, $options);[0;0m
[1;34m+        $this->eolas_fix_applied = false;[0;0m
[1;34m+    }[0;0m
[1;34m+    function dofilter($text){[0;0m
[1;34m+        global $CFG;[0;0m
[1;34m+        // You should never modify parameters passed to a method or function, it's BAD practice. Create a copy instead.[0;0m
[1;34m+        // The reason is that you must always be able to refer to the original parameter that was passed.[0;0m
[1;34m+        // For this reason, I changed $text = preg_replace(..,..,$text) into $newtext = preg.... (NICOLAS CONNAULT)[0;0m
[1;34m+        // Thanks to Pablo Etcheverry for pointing this out! MDL-10177[0;0m
[1;34m+[0;0m
[1;34m+        // We're using the UFO technique for flash to attain XHTML Strict 1.0[0;0m
[1;34m+        // See: http://www.bobbyvandersluis.com/ufo/[0;0m
[1;34m+        if (!is_string($text)) {[0;0m
[1;34m+            // non string data can not be filtered anyway[0;0m
[1;34m+            return $text;[0;0m
[1;34m+        }[0;0m
[1;34m+        $newtext = $text; // fullclone is slow and not needed here[0;0m
[1;34m+[0;0m
[1;34m+        if ($CFG->filter_mediaplugin_enable_mp3) {[0;0m
[1;34m+            $search = '/<a.*?href="([^<]+\.mp3)"[^>]*>.*?<\/a>/is';[0;0m
[1;34m+            $newtext = preg_replace_callback($search, 'mediaplugin_filter_mp3_callback', $newtext);[0;0m
[1;34m+        }[0;0m
[1;34m+[0;0m
[1;34m+        if ($CFG->filter_mediaplugin_enable_swf) {[0;0m
[1;34m+            $search = '/<a.*?href="([^<]+\.swf)(\?d=([\d]{1,3}%?)x([\d]{1,3}%?))?"[^>]*>.*?<\/a>/is';[0;0m
[1;34m+            $newtext = preg_replace_callback($search, 'mediaplugin_filter_swf_callback', $newtext);[0;0m
[1;34m+        }[0;0m
[1;34m+[0;0m
[1;34m+        if ($CFG->filter_mediaplugin_enable_flv) {[0;0m
[1;34m+            $search = '/<a.*?href="([^<]+\.flv)(\?d=([\d]{1,3}%?)x([\d]{1,3}%?))?"[^>]*>.*?<\/a>/is';[0;0m
[1;34m+            $newtext = preg_replace_callback($search, 'mediaplugin_filter_flv_callback', $newtext);[0;0m
[1;34m+        }[0;0m
[1;34m+[0;0m
[1;34m+        if ($CFG->filter_mediaplugin_enable_mov) {[0;0m
[1;34m+            $search = '/<a.*?href="([^<]+\.mov)(\?d=([\d]{1,3}%?)x([\d]{1,3}%?))?"[^>]*>.*?<\/a>/is';[0;0m
[1;34m+            $newtext = preg_replace_callback($search, 'mediaplugin_filter_qt_callback', $newtext);[0;0m
[1;34m+        }[0;0m
[1;34m+[0;0m
[1;34m+        if ($CFG->filter_mediaplugin_enable_wmv) {[0;0m
[1;34m+            $search = '/<a.*?href="([^<]+\.wmv)(\?d=([\d]{1,3}%?)x([\d]{1,3}%?))?"[^>]*>.*?<\/a>/is';[0;0m
[1;34m+            $newtext = preg_replace_callback($search, 'mediaplugin_filter_wmp_callback', $newtext);[0;0m
[1;34m+        }[0;0m
[1;34m+[0;0m
[1;34m+        if ($CFG->filter_mediaplugin_enable_mpg) {[0;0m
[1;34m+            $search = '/<a.*?href="([^<]+\.mpe?g)(\?d=([\d]{1,3}%?)x([\d]{1,3}%?))?"[^>]*>.*?<\/a>/is';[0;0m
[1;34m+            $newtext = preg_replace_callback($search, 'mediaplugin_filter_qt_callback', $newtext);[0;0m
[1;34m+        }[0;0m
[1;34m+[0;0m
[1;34m+        if ($CFG->filter_mediaplugin_enable_avi) {[0;0m
[1;34m+            $search = '/<a.*?href="([^<]+\.avi)(\?d=([\d]{1,3}%?)x([\d]{1,3}%?))?"[^>]*>.*?<\/a>/is';[0;0m
[1;34m+            $newtext = preg_replace_callback($search, 'mediaplugin_filter_wmp_callback', $newtext);[0;0m
[1;34m+        }[0;0m
[1;34m+[0;0m
[1;34m+        if ($CFG->filter_mediaplugin_enable_ram) {[0;0m
[1;34m+            $search = '/<a.*?href="([^<]+\.ram)"[^>]*>.*?<\/a>/is';[0;0m
[1;34m+            $newtext = preg_replace_callback($search, 'mediaplugin_filter_real_callback', $newtext);[0;0m
[1;34m+        }[0;0m
[1;34m+[0;0m
[1;34m+        if ($CFG->filter_mediaplugin_enable_rpm) {[0;0m
[1;34m+            $search = '/<a.*?href="([^<]+\.rpm)"[^>]*>.*?<\/a>/is';[0;0m
[1;34m+            $newtext = preg_replace_callback($search, 'mediaplugin_filter_real_callback', $newtext);[0;0m
[1;34m+        }[0;0m
[1;34m+[0;0m
[1;34m+        if ($CFG->filter_mediaplugin_enable_rm) {[0;0m
[1;34m+            $search = '/<a.*?href="([^<]+\.rm)"[^>]*>.*?<\/a>/is';[0;0m
[1;34m+            $newtext = preg_replace_callback($search, 'mediaplugin_filter_real_callback', $newtext);[0;0m
[1;34m+        }[0;0m
[1;34m+[0;0m
[1;34m+        if (!empty($CFG->filter_mediaplugin_enable_youtube)) {[0;0m
[1;34m+            $search = '/<a.*?href="([^<]*)youtube.com\/watch\?v=([^"]*)"[^>]*>(.*?)<\/a>/is';[0;0m
[1;34m+            $newtext = preg_replace_callback($search, 'mediaplugin_filter_youtube_callback', $newtext);[0;0m
[1;34m+[0;0m
[1;34m+            $search = '/<a.*?href="([^<]*)youtube.com\/v\/([^"]*)"[^>]*>(.*?)<\/a>/is';[0;0m
[1;34m+            $newtext = preg_replace_callback($search, 'mediaplugin_filter_youtube_callback', $newtext);[0;0m
[1;34m+        }[0;0m
[1;34m+[0;0m
[1;34m+        if (empty($newtext) or $newtext === $text) {[0;0m
[1;34m+            // error or not filtered[0;0m
[1;34m+            unset($newtext);[0;0m
[1;34m+            return $text;[0;0m
[1;34m+        }[0;0m
[1;34m+[0;0m
[1;34m+        if (!$this->eolas_fix_applied) {[0;0m
[1;34m+            $newtext .= '<script defer="defer" src="' . $CFG->wwwroot . '/filter/mediaplugin/eolas_fix.js" type="text/javascript">// <![CDATA[ ]]></script>';[0;0m
[1;34m+            $this->eolas_fix_applied = true;[0;0m
[1;34m+        }[0;0m
[0;0m [0;0m
[1;31m-function mediaplugin_filter($courseid, $text) {[0;0m
[1;31m-    global $CFG;[0;0m
[1;31m-    static $eolas_fix_applied = false;[0;0m
[1;31m-[0;0m
[1;31m-    // You should never modify parameters passed to a method or function, it's BAD practice. Create a copy instead.[0;0m
[1;31m-    // The reason is that you must always be able to refer to the original parameter that was passed.[0;0m
[1;31m-    // For this reason, I changed $text = preg_replace(..,..,$text) into $newtext = preg.... (NICOLAS CONNAULT)[0;0m
[1;31m-    // Thanks to Pablo Etcheverry for pointing this out! MDL-10177[0;0m
[1;31m-[0;0m
[1;31m-    // We're using the UFO technique for flash to attain XHTML Strict 1.0[0;0m
[1;31m-    // See: http://www.bobbyvandersluis.com/ufo/[0;0m
[1;31m-    if (!is_string($text)) {[0;0m
[1;31m-        // non string data can not be filtered anyway[0;0m
[1;31m-        return $text;[0;0m
[1;31m-    }[0;0m
[1;31m-    $newtext = $text; // fullclone is slow and not needed here[0;0m
[1;31m-[0;0m
[1;31m-    if (!empty($CFG->filter_mediaplugin_enable_mp3)) {[0;0m
[1;31m-        $search = '/<a.*?href="([^<]+\.mp3)"[^>]*>.*?<\/a>/is';[0;0m
[1;31m-        $newtext = preg_replace_callback($search, 'mediaplugin_filter_mp3_callback', $newtext);[0;0m
[1;31m-    }[0;0m
[1;31m-[0;0m
[1;31m-    if (!empty($CFG->filter_mediaplugin_enable_swf)) {[0;0m
[1;31m-        $search = '/<a.*?href="([^<]+\.swf)(\?d=([\d]{1,4}%?)x([\d]{1,4}%?))?"[^>]*>.*?<\/a>/is';[0;0m
[1;31m-        $newtext = preg_replace_callback($search, 'mediaplugin_filter_swf_callback', $newtext);[0;0m
[1;31m-    }[0;0m
[1;31m-[0;0m
[1;31m-    if (!empty($CFG->filter_mediaplugin_enable_flv)) {[0;0m
[1;31m-        $search = '/<a.*?href="([^<]+\.flv)(\?d=([\d]{1,4}%?)x([\d]{1,4}%?))?"[^>]*>.*?<\/a>/is';[0;0m
[1;31m-        $newtext = preg_replace_callback($search, 'mediaplugin_filter_flv_callback', $newtext);[0;0m
[1;34m+        return $newtext;[0;0m
[0;0m     }[0;0m
[1;31m-[0;0m
[1;31m-    if (!empty($CFG->filter_mediaplugin_enable_mov)) {[0;0m
[1;31m-        $search = '/<a.*?href="([^<]+\.mov)(\?d=([\d]{1,4}%?)x([\d]{1,4}%?))?"[^>]*>.*?<\/a>/is';[0;0m
[1;31m-        $newtext = preg_replace_callback($search, 'mediaplugin_filter_qt_callback', $newtext);[0;0m
[1;31m-    }[0;0m
[1;31m-[0;0m
[1;31m-    if (!empty($CFG->filter_mediaplugin_enable_wmv)) {[0;0m
[1;31m-        $search = '/<a.*?href="([^<]+\.wmv)(\?d=([\d]{1,4}%?)x([\d]{1,4}%?))?"[^>]*>.*?<\/a>/is';[0;0m
[1;31m-        $newtext = preg_replace_callback($search, 'mediaplugin_filter_wmp_callback', $newtext);[0;0m
[1;31m-    }[0;0m
[1;31m-[0;0m
[1;31m-    if (!empty($CFG->filter_mediaplugin_enable_mpg)) {[0;0m
[1;31m-        $search = '/<a.*?href="([^<]+\.mpe?g)(\?d=([\d]{1,4}%?)x([\d]{1,4}%?))?"[^>]*>.*?<\/a>/is';[0;0m
[1;31m-        $newtext = preg_replace_callback($search, 'mediaplugin_filter_qt_callback', $newtext);[0;0m
[1;31m-    }[0;0m
[1;31m-[0;0m
[1;31m-    if (!empty($CFG->filter_mediaplugin_enable_avi)) {[0;0m
[1;31m-        $search = '/<a.*?href="([^<]+\.avi)(\?d=([\d]{1,4}%?)x([\d]{1,4}%?))?"[^>]*>.*?<\/a>/is';[0;0m
[1;31m-        $newtext = preg_replace_callback($search, 'mediaplugin_filter_wmp_callback', $newtext);[0;0m
[1;31m-    }[0;0m
[1;31m-[0;0m
[1;31m-    if (!empty($CFG->filter_mediaplugin_enable_ram)) {[0;0m
[1;31m-        $search = '/<a.*?href="([^<]+\.ram)"[^>]*>.*?<\/a>/is';[0;0m
[1;31m-        $newtext = preg_replace_callback($search, 'mediaplugin_filter_real_callback', $newtext);[0;0m
[1;31m-    }[0;0m
[1;31m-[0;0m
[1;31m-    if (!empty($CFG->filter_mediaplugin_enable_rpm)) {[0;0m
[1;31m-        $search = '/<a.*?href="([^<]+\.rpm)"[^>]*>.*?<\/a>/is';[0;0m
[1;31m-        $newtext = preg_replace_callback($search, 'mediaplugin_filter_real_callback', $newtext);[0;0m
[1;31m-    }[0;0m
[1;31m-[0;0m
[1;31m-    if (!empty($CFG->filter_mediaplugin_enable_rm)) {[0;0m
[1;31m-        $search = '/<a.*?href="([^<]+\.rm)"[^>]*>.*?<\/a>/is';[0;0m
[1;31m-        $newtext = preg_replace_callback($search, 'mediaplugin_filter_real_callback', $newtext);[0;0m
[1;31m-    }[0;0m
[1;31m-[0;0m
[1;31m-    if (!empty($CFG->filter_mediaplugin_enable_youtube)) {[0;0m
[1;31m-        $search = '/<a.*?href="([^<]*)youtube.com\/watch\?v=([^"]*)"[^>]*>(.*?)<\/a>/is';[0;0m
[1;31m-        $newtext = preg_replace_callback($search, 'mediaplugin_filter_youtube_callback', $newtext);[0;0m
[1;31m-[0;0m
[1;31m-        $search = '/<a.*?href="([^<]*)youtube.com\/v\/([^"]*)"[^>]*>(.*?)<\/a>/is';[0;0m
[1;31m-        $newtext = preg_replace_callback($search, 'mediaplugin_filter_youtube_callback', $newtext);[0;0m
[1;31m-    }[0;0m
[1;31m-[0;0m
[1;31m-    if (is_null($newtext) or $newtext === $text) {[0;0m
[1;31m-        // error or not filtered[0;0m
[1;31m-        return $text;[0;0m
[1;31m-    }[0;0m
[1;31m-    [0;0m
[1;31m-    if (!$eolas_fix_applied) {[0;0m
[1;31m-        $newtext .= '<script defer="defer" src="' . $CFG->wwwroot . '/filter/mediaplugin/eolas_fix.js" type="text/javascript">// <![CDATA[ ]]></script>';[0;0m
[1;31m-        $eolas_fix_applied = true;[0;0m
[1;31m-    }[0;0m
[1;31m-[0;0m
[1;31m-    return $newtext;[0;0m
[0;0m }[0;0m
[0;0m [0;0m
[0;0m ///===========================[0;0m
[1;32mIndex: multilang/filter.php[0;0m
[1;32m===================================================================[0;0m
[1;32mRCS file: /cvsroot/moodle/moodle/filter/multilang/filter.php,v[0;0m
[1;32mretrieving revision 1.20[0;0m
[1;32mdiff -u -u -r1.20 filter.php[0;0m
[1;31m--- multilang/filter.php	19 Jun 2007 17:24:34 -0000	1.20[0;0m
[1;34m+++ multilang/filter.php	11 Dec 2008 07:33:16 -0000[0;0m
[1;35m@@ -36,32 +36,38 @@[0;0m
[0;0m // Following new syntax is not compatible with old one:[0;0m
[0;0m //   <span lang="XX" class="multilang">one lang</span><span lang="YY" class="multilang">another language</span>[0;0m
[0;0m [0;0m
[1;31m-function multilang_filter($courseid, $text) {[0;0m
[1;31m-    global $CFG;[0;0m
[1;31m-[0;0m
[1;31m-    // [pj] I don't know about you but I find this new implementation funny :P[0;0m
[1;31m-    // [skodak] I was laughing while rewriting it ;-)[0;0m
[1;31m-    // [nicolasconnault] Should support inverted attributes: <span class="multilang" lang="en"> (Doesn't work curently)[0;0m
[1;31m-    // [skodak] it supports it now, though it is slower - any better idea? [0;0m
[1;31m-[0;0m
[1;31m-    if (empty($text) or is_numeric($text)) {[0;0m
[1;31m-        return $text;[0;0m
[1;31m-    }[0;0m
[1;31m-[0;0m
[1;31m-    if (empty($CFG->filter_multilang_force_old) and !empty($CFG->filter_multilang_converted)) {[0;0m
[1;31m-        // new syntax[0;0m
[1;31m-        $search = '/(<span(\s+lang="[a-zA-Z0-9_-]+"|\s+class="multilang"){2}\s*>.*?<\/span>)(\s*<span(\s+lang="[a-zA-Z0-9_-]+"|\s+class="multilang"){2}\s*>.*?<\/span>)+/is';[0;0m
[1;31m-    } else {[0;0m
[1;31m-        // old syntax[0;0m
[1;31m-        $search = '/(<(?:lang|span) lang="[a-zA-Z0-9_-]*".*?>.*?<\/(?:lang|span)>)(\s*<(?:lang|span) lang="[a-zA-Z0-9_-]*".*?>.*?<\/(?:lang|span)>)+/is';[0;0m
[1;31m-    }[0;0m
[1;31m-[0;0m
[1;31m-    $result = preg_replace_callback($search, 'multilang_filter_impl', $text);[0;0m
[1;31m-[0;0m
[1;31m-    if (is_null($result)) {[0;0m
[1;31m-        return $text; //error during regex processing (too many nested spans?)[0;0m
[1;31m-    } else {[0;0m
[1;31m-        return $result;[0;0m
[1;34m+class multilang_filter extends filter_base{[0;0m
[1;34m+    function __construct($courseid, $format, $options){[0;0m
[1;34m+        parent::__construct($courseid, $format, $options);[0;0m
[1;34m+    }[0;0m
[1;34m+[0;0m
[1;34m+    function dofilter($text) {[0;0m
[1;34m+        global $CFG;[0;0m
[1;34m+[0;0m
[1;34m+        // [pj] I don't know about you but I find this new implementation funny :P[0;0m
[1;34m+        // [skodak] I was laughing while rewriting it ;-)[0;0m
[1;34m+        // [nicolasconnault] Should support inverted attributes: <span class="multilang" lang="en"> (Doesn't work curently)[0;0m
[1;34m+        // [skodak] it supports it now, though it is slower - any better idea? [0;0m
[1;34m+[0;0m
[1;34m+        if (empty($text) or is_numeric($text)) {[0;0m
[1;34m+            return $text;[0;0m
[1;34m+        }[0;0m
[1;34m+[0;0m
[1;34m+        if (empty($CFG->filter_multilang_force_old) and !empty($CFG->filter_multilang_converted)) {[0;0m
[1;34m+            // new syntax[0;0m
[1;34m+            $search = '/(<span(\s+lang="[a-zA-Z0-9_-]+"|\s+class="multilang"){2}\s*>.*?<\/span>)(\s*<span(\s+lang="[a-zA-Z0-9_-]+"|\s+class="multilang"){2}\s*>.*?<\/span>)+/is';[0;0m
[1;34m+        } else {[0;0m
[1;34m+            // old syntax[0;0m
[1;34m+            $search = '/(<(?:lang|span) lang="[a-zA-Z0-9_-]*".*?>.*?<\/(?:lang|span)>)(\s*<(?:lang|span) lang="[a-zA-Z0-9_-]*".*?>.*?<\/(?:lang|span)>)+/is';[0;0m
[1;34m+        }[0;0m
[1;34m+[0;0m
[1;34m+        $result = preg_replace_callback($search, 'multilang_filter_impl', $text);[0;0m
[1;34m+[0;0m
[1;34m+        if (is_null($result)) {[0;0m
[1;34m+            return $text; //error during regex processing (too many nested spans?)[0;0m
[1;34m+        } else {[0;0m
[1;34m+            return $result;[0;0m
[1;34m+        }[0;0m
[0;0m     }[0;0m
[0;0m }[0;0m
[0;0m [0;0m
[1;32mIndex: tex/filter.php[0;0m
[1;32m===================================================================[0;0m
[1;32mRCS file: /cvsroot/moodle/moodle/filter/tex/filter.php,v[0;0m
[1;32mretrieving revision 1.23[0;0m
[1;32mdiff -u -u -r1.23 filter.php[0;0m
[1;31m--- tex/filter.php	2 Jun 2008 08:47:10 -0000	1.23[0;0m
[1;34m+++ tex/filter.php	11 Dec 2008 07:33:16 -0000[0;0m
[1;35m@@ -91,13 +91,18 @@[0;0m
[0;0m     return $output;[0;0m
[0;0m }[0;0m
[0;0m [0;0m
[1;31m-function tex_filter ($courseid, $text) {[0;0m
[1;31m-    global $CFG, $DB;[0;0m
[1;31m-[0;0m
[1;31m-    /// Do a quick check using stripos to avoid unnecessary work[0;0m
[1;31m-    if (!preg_match('/<tex/i',$text) and !strstr($text,'$$') and !strstr($text,'\\[') and !preg_match('/\[tex/i',$text)) { //added one more tag (dlnsk)[0;0m
[1;31m-        return $text;[0;0m
[1;34m+class tex_filter extends filter_base{[0;0m
[1;34m+    function __construct($courseid, $format, $options){[0;0m
[1;34m+        parent::__construct($courseid, $format, $options);[0;0m
[0;0m     }[0;0m
[1;34m+    function dofilter ($text) {[0;0m
[1;34m+[0;0m
[1;34m+        global $CFG, $DB;[0;0m
[1;34m+[0;0m
[1;34m+        /// Do a quick check using stripos to avoid unnecessary work[0;0m
[1;34m+        if (!preg_match('/<tex/i',$text) and !strstr($text,'$$') and !strstr($text,'\\[') and !preg_match('/\[tex/i',$text)) { //added one more tag (dlnsk)[0;0m
[1;34m+            return $text;[0;0m
[1;34m+        }[0;0m
[0;0m [0;0m
[0;0m #    //restrict filtering to forum 130 (Maths Tools on moodle.org)[0;0m
[0;0m #    $scriptname = $_SERVER['SCRIPT_NAME'];[0;0m
[1;35m@@ -115,48 +120,49 @@[0;0m
[0;0m #    if ($discussion->forum != 130) {[0;0m
[0;0m #        return $text;[0;0m
[0;0m #    }[0;0m
[1;31m-    $text .= ' ';[0;0m
[1;31m-    preg_match_all('/\$(\$\$+?)([^\$])/s',$text,$matches);[0;0m
[1;31m-    for ($i=0;$i<count($matches[0]);$i++) {[0;0m
[1;31m-        $replacement = str_replace('$','&#x00024;',$matches[1][$i]).$matches[2][$i];[0;0m
[1;31m-        $text = str_replace($matches[0][$i],$replacement,$text);[0;0m
[1;31m-    }[0;0m
[1;31m-[0;0m
[1;31m-    // <tex> TeX expression </tex>[0;0m
[1;31m-    // or <tex alt="My alternative text to be used instead of the TeX form"> TeX expression </tex>[0;0m
[1;31m-    // or $$ TeX expression $$[0;0m
[1;31m-    // or \[ TeX expression \]          // original tag of MathType and TeXaide (dlnsk)[0;0m
[1;31m-    // or [tex] TeX expression [/tex]   // somtime it's more comfortable than <tex> (dlnsk)[0;0m
[1;31m-    preg_match_all('/<tex(?:\s+alt=["\'](.*?)["\'])?>(.+?)<\/tex>|\$\$(.+?)\$\$|\\\\\[(.+?)\\\\\]|\\[tex\\](.+?)\\[\/tex\\]/is', $text, $matches);[0;0m
[1;31m-    for ($i=0; $i<count($matches[0]); $i++) {[0;0m
[1;31m-        $texexp = $matches[2][$i] . $matches[3][$i] . $matches[4][$i] . $matches[5][$i];[0;0m
[1;31m-        $alt = $matches[1][$i];[0;0m
[1;31m-        $texexp = str_replace('<nolink>','',$texexp);[0;0m
[1;31m-        $texexp = str_replace('</nolink>','',$texexp);[0;0m
[1;31m-        $texexp = str_replace('<span class="nolink">','',$texexp);[0;0m
[1;31m-        $texexp = str_replace('</span>','',$texexp);[0;0m
[1;31m-        $texexp = eregi_replace("<br[[:space:]]*\/?>", '', $texexp);  //dlnsk[0;0m
[1;31m-        $align = "middle";[0;0m
[1;31m-        if (preg_match('/^align=bottom /',$texexp)) {[0;0m
[1;31m-          $align = "text-bottom";[0;0m
[1;31m-          $texexp = preg_replace('/^align=bottom /','',$texexp);[0;0m
[1;31m-        } else if (preg_match('/^align=top /',$texexp)) {[0;0m
[1;31m-          $align = "text-top";[0;0m
[1;31m-          $texexp = preg_replace('/^align=top /','',$texexp);[0;0m
[1;34m+        $text .= ' ';[0;0m
[1;34m+        preg_match_all('/\$(\$\$+?)([^\$])/s',$text,$matches);[0;0m
[1;34m+        for ($i=0;$i<count($matches[0]);$i++) {[0;0m
[1;34m+            $replacement = str_replace('$','&#x00024;',$matches[1][$i]).$matches[2][$i];[0;0m
[1;34m+            $text = str_replace($matches[0][$i],$replacement,$text);[0;0m
[0;0m         }[0;0m
[1;31m-        $md5 = md5($texexp);[0;0m
[1;31m-        if (! $texcache = $DB->get_record("cache_filters", array("filter"=>"tex", "md5key"=>$md5))) {[0;0m
[1;31m-            $texcache->filter = 'tex';[0;0m
[1;31m-            $texcache->version = 1;[0;0m
[1;31m-            $texcache->md5key = $md5;[0;0m
[1;31m-            $texcache->rawtext = $texexp;[0;0m
[1;31m-            $texcache->timemodified = time();[0;0m
[1;31m-            $DB->insert_record("cache_filters",$texcache, false);[0;0m
[1;34m+[0;0m
[1;34m+        // <tex> TeX expression </tex>[0;0m
[1;34m+        // or <tex alt="My alternative text to be used instead of the TeX form"> TeX expression </tex>[0;0m
[1;34m+        // or $$ TeX expression $$[0;0m
[1;34m+        // or \[ TeX expression \]          // original tag of MathType and TeXaide (dlnsk)[0;0m
[1;34m+        // or [tex] TeX expression [/tex]   // somtime it's more comfortable than <tex> (dlnsk)[0;0m
[1;34m+        preg_match_all('/<tex(?:\s+alt=["\'](.*?)["\'])?>(.+?)<\/tex>|\$\$(.+?)\$\$|\\\\\[(.+?)\\\\\]|\\[tex\\](.+?)\\[\/tex\\]/is', $text, $matches);[0;0m
[1;34m+        for ($i=0; $i<count($matches[0]); $i++) {[0;0m
[1;34m+            $texexp = $matches[2][$i] . $matches[3][$i] . $matches[4][$i] . $matches[5][$i];[0;0m
[1;34m+            $alt = $matches[1][$i];[0;0m
[1;34m+            $texexp = str_replace('<nolink>','',$texexp);[0;0m
[1;34m+            $texexp = str_replace('</nolink>','',$texexp);[0;0m
[1;34m+            $texexp = str_replace('<span class="nolink">','',$texexp);[0;0m
[1;34m+            $texexp = str_replace('</span>','',$texexp);[0;0m
[1;34m+            $texexp = eregi_replace("<br[[:space:]]*\/?>", '', $texexp);  //dlnsk[0;0m
[1;34m+            $align = "middle";[0;0m
[1;34m+            if (preg_match('/^align=bottom /',$texexp)) {[0;0m
[1;34m+              $align = "text-bottom";[0;0m
[1;34m+              $texexp = preg_replace('/^align=bottom /','',$texexp);[0;0m
[1;34m+            } else if (preg_match('/^align=top /',$texexp)) {[0;0m
[1;34m+              $align = "text-top";[0;0m
[1;34m+              $texexp = preg_replace('/^align=top /','',$texexp);[0;0m
[1;34m+            }[0;0m
[1;34m+            $md5 = md5($texexp);[0;0m
[1;34m+            if (! $texcache = $DB->get_record("cache_filters", array("filter"=>"tex", "md5key"=>$md5))) {[0;0m
[1;34m+                $texcache->filter = 'tex';[0;0m
[1;34m+                $texcache->version = 1;[0;0m
[1;34m+                $texcache->md5key = $md5;[0;0m
[1;34m+                $texcache->rawtext = $texexp;[0;0m
[1;34m+                $texcache->timemodified = time();[0;0m
[1;34m+                $DB->insert_record("cache_filters", $texcache, false);[0;0m
[1;34m+            }[0;0m
[1;34m+            $filename = $md5 . ".gif";[0;0m
[1;34m+            $text = str_replace( $matches[0][$i], string_file_picture_tex($filename, $texexp, '', '', $align, $alt), $text);[0;0m
[0;0m         }[0;0m
[1;31m-        $filename = $md5 . ".gif";[0;0m
[1;31m-        $text = str_replace( $matches[0][$i], string_file_picture_tex($filename, $texexp, '', '', $align, $alt), $text);[0;0m
[1;34m+        return $text;[0;0m
[0;0m     }[0;0m
[1;31m-    return $text;[0;0m
[0;0m }[0;0m
[0;0m [0;0m
[0;0m ?>[0;0m
[1;32mIndex: tidy/filter.php[0;0m
[1;32m===================================================================[0;0m
[1;32mRCS file: /cvsroot/moodle/moodle/filter/tidy/filter.php,v[0;0m
[1;32mretrieving revision 1.2[0;0m
[1;32mdiff -u -u -r1.2 filter.php[0;0m
[1;31m--- tidy/filter.php	3 Apr 2007 08:43:30 -0000	1.2[0;0m
[1;34m+++ tidy/filter.php	11 Dec 2008 07:33:16 -0000[0;0m
[1;35m@@ -1,6 +1,6 @@[0;0m
[0;0m <?php[0;0m
[0;0m       [0;0m
[1;31m-// This function looks for text including markup and[0;0m
[1;34m+// This class looks for text including markup and[0;0m
[0;0m // applies tidy's repair function to it.[0;0m
[0;0m // Tidy is a HTML clean and[0;0m
[0;0m // repair utility, which is currently available for PHP 4.3.x and PHP 5 as a[0;0m
[1;35m@@ -11,37 +11,42 @@[0;0m
[0;0m // If you want to know what you can set in $tidyoptions and what their default[0;0m
[0;0m // values are, see http://php.net/manual/en/function.tidy-get-config.php.[0;0m
[0;0m       [0;0m
[1;31m-/**[0;0m
[1;31m-* @author Hannes Gassert <hannes at mediagonal dot ch>[0;0m
[1;31m-* @param        int            course id[0;0m
[1;31m-* @param        string         text to be filtered[0;0m
[1;31m-*/[0;0m
[1;31m-function tidy_filter($courseid, $text) {[0;0m
[1;31m-       [0;0m
[1;31m-/// Configuration for tidy. Feel free to tune for your needs, e.g. to allow[0;0m
[1;31m-/// proprietary markup.[0;0m
[1;31m-    $tidyoptions = array(             [0;0m
[1;31m-             'output-xhtml' => true,[0;0m
[1;31m-             'show-body-only' => true,[0;0m
[1;31m-             'tidy-mark' => false,[0;0m
[1;31m-             'drop-proprietary-attributes' => true,[0;0m
[1;31m-             'drop-font-tags' => true,[0;0m
[1;31m-             'drop-empty-paras' => true,[0;0m
[1;31m-             'indent' => true,[0;0m
[1;31m-             'quiet' => true,[0;0m
[1;31m-    );[0;0m
[1;31m-    [0;0m
[1;31m-/// Do a quick check using strpos to avoid unnecessary work[0;0m
[1;31m-    if (strpos($text, '<') === false) {[0;0m
[1;31m-        return $text;[0;0m
[1;34m+class tidy_filter extends filter_base{[0;0m
[1;34m+    function __construct($courseid, $format, $options){[0;0m
[1;34m+        parent::__construct($courseid, $format, $options);[0;0m
[0;0m     }[0;0m
[0;0m [0;0m
[1;31m-    [0;0m
[1;31m-/// If enabled: run tidy over the entire string[0;0m
[1;31m-    if (function_exists('tidy_repair_string')){[0;0m
[1;31m-        $text = tidy_repair_string($text, $tidyoptions, 'utf8');[0;0m
[1;31m-    }[0;0m
[1;34m+    /**[0;0m
[1;34m+    * @author Hannes Gassert <hannes at mediagonal dot ch>[0;0m
[1;34m+    * @param        string         text to be filtered[0;0m
[1;34m+    */[0;0m
[1;34m+    function dofilter($text) {[0;0m
[1;34m+           [0;0m
[1;34m+    /// Configuration for tidy. Feel free to tune for your needs, e.g. to allow[0;0m
[1;34m+    /// proprietary markup.[0;0m
[1;34m+        $tidyoptions = array(             [0;0m
[1;34m+                 'output-xhtml' => true,[0;0m
[1;34m+                 'show-body-only' => true,[0;0m
[1;34m+                 'tidy-mark' => false,[0;0m
[1;34m+                 'drop-proprietary-attributes' => true,[0;0m
[1;34m+                 'drop-font-tags' => true,[0;0m
[1;34m+                 'drop-empty-paras' => true,[0;0m
[1;34m+                 'indent' => true,[0;0m
[1;34m+                 'quiet' => true,[0;0m
[1;34m+        );[0;0m
[1;34m+        [0;0m
[1;34m+    /// Do a quick check using strpos to avoid unnecessary work[0;0m
[1;34m+        if (strpos($text, '<') === false) {[0;0m
[1;34m+            return $text;[0;0m
[1;34m+        }[0;0m
[1;34m+[0;0m
[1;34m+        [0;0m
[1;34m+    /// If enabled: run tidy over the entire string[0;0m
[1;34m+        if (function_exists('tidy_repair_string')){[0;0m
[1;34m+            $text = tidy_repair_string($text, $tidyoptions, 'utf8');[0;0m
[1;34m+        }[0;0m
[0;0m [0;0m
[1;31m-    return $text;[0;0m
[1;34m+        return $text;[0;0m
[1;34m+    }[0;0m
[0;0m }[0;0m
[0;0m ?>[0;0m
