]> git.mjollnir.org Git - moodle.git/commitdiff
Improvement to filters, providing speed boost AND better compatibility
authormoodler <moodler>
Sun, 8 Aug 2004 06:57:44 +0000 (06:57 +0000)
committermoodler <moodler>
Sun, 8 Aug 2004 06:57:44 +0000 (06:57 +0000)
with Turck MMCache.

Filter function must now have a particular name

   eg resource_filter

where "resource" is the name of the directory that filter.php is in.

filter/activitynames/filter.php
filter/algebra/filter.php
filter/censor/filter.php
filter/mediaplugin/filter.php
filter/multilang/filter.php
filter/tex/filter.php
lib/weblib.php
mod/glossary/filter.php
mod/resource/filter.php
mod/wiki/filter.php

index b35d748d96e57e655765fc8f8817080e75bf1a79..9e52f155c1cfa0eb28655267de9e7b9b60acf76b 100644 (file)
@@ -4,12 +4,6 @@
     //It's based in the glosssary filter by Williams Castillo
     //Modifications by stronk7.
 
-    $textfilter_function='activitynames_filter';
-
-    if (function_exists($textfilter_function)) {
-        return;
-    }
-
     function activitynames_filter($courseid, $text) {
 
         global $CFG;
index 704eec8f49f4ded0df8b2188a19a29c0560640ca..8558684ebfd11b0d1da10eb5a616cd253bb1511f 100644 (file)
       $CFG->algebrafilterdirwin = "filter\\algebra";
     }
 
-
-
-/// These lines are important - the variable must match the name 
-/// of the actual function below
-    $textfilter_function='algebra_filter';
-
-    if (function_exists($textfilter_function)) {
-        return;
-    }
-
-
 function string_file_picture_algebra($imagefile, $tex= "", $height="", $width="") {
   // Given the path to a picture file in a course, or a URL,
   // this function includes the picture in the page.
@@ -243,4 +232,4 @@ function algebra_filter ($courseid, $text) {
     return $text; 
 }
 
-?>
\ No newline at end of file
+?>
index 2d4705a07dad856a443d4d33b44c8881cf48d619..df769b28bf46c485879b7400c378f63c605990e8 100644 (file)
 //
 //////////////////////////////////////////////////////////////
 
-/// These lines are important - the variable must match the name 
-/// of the actual function below
-
-    $textfilter_function = 'censor_filter';
-
-    if (function_exists($textfilter_function)) {
-        return;
-    }
-
-
 /// This is the filtering function itself.  It accepts the 
 /// courseid and the text to be filtered (in HTML form).
 
index d38d3f29cdc9ebe7a4efb769830990764b377bac..58a446b0d111a67127171de482390d8fa7aba627 100644 (file)
 //
 //////////////////////////////////////////////////////////////
 
-/// These lines are important - the variable must match the name 
-/// of the actual function below
-
-    $textfilter_function = 'mediaplugin_filter';
-
-    if (function_exists($textfilter_function)) {
-        return;
-    }
-
-
 /// This is the filtering function itself.  It accepts the 
 /// courseid and the text to be filtered (in HTML form).
 
index bf64f517f3b62e012ec1856304c675cea17459de..c736e460ac029204b996374323e1d6af4e20295f 100644 (file)
 //                                                                       //\r
 ///////////////////////////////////////////////////////////////////////////\r
 \r
-/// These lines are important - the variable must match the name \r
-/// of the actual function below\r
-\r
-$textfilter_function = 'multilang_filter';\r
-\r
-if (function_exists($textfilter_function)) {\r
-    return;\r
-}\r
-\r
 \r
 /// Given XML multilinguage text, return relevant text according to\r
 /// current language.  i.e.=\r
index 0fc204a2c4cb5d92021fb158d075dc7328c47554..f3c69ce0649dbe658fa16eb507ce6cf1457cdeec 100644 (file)
 
 $CFG->texfilterdir = "filter/tex";
 
-/// These lines are important - the variable must match the name 
-/// of the actual function below
-$textfilter_function='tex_filter';
-
-if (function_exists($textfilter_function)) {
-    return;
-}
-
 
 function string_file_picture_tex($imagefile, $tex= "", $height="", $width="") {
     // Given the path to a picture file in a course, or a URL,
index b0bcfa418965d6c4f725ee84523c734946992243..53703ebc4f0699453c58f4f94477695f9b2379ba 100644 (file)
@@ -704,8 +704,11 @@ function filter_text($text, $courseid=NULL) {
         $textfilters = explode(',', $CFG->textfilters);
         foreach ($textfilters as $textfilter) {
             if (is_readable("$CFG->dirroot/$textfilter/filter.php")) {
-                include("$CFG->dirroot/$textfilter/filter.php");
-                $text = $textfilter_function($courseid, $text);
+                include_once("$CFG->dirroot/$textfilter/filter.php");
+                $functionname = basename($textfilter).'_filter';
+                if (function_exists($functionname)) {
+                    $text = $functionname($courseid, $text);
+                }
             }
         }
     }
index d8003a7b229a85123963efaac3c7f55f0cbbfe6e..3544778d4df7e92f5df6fd1883ea548597b2917f 100644 (file)
@@ -1,12 +1,6 @@
 <?PHP // $Id$
 
-    $textfilter_function = 'glossary_dynamic_link';
-
-    if (function_exists($textfilter_function)) {
-        return;
-    }
-
-    function glossary_dynamic_link($courseid, $text) {
+    function glossary_filter($courseid, $text) {
         global $CFG;
 
         if (empty($courseid)) {
index c670f403e52290dd7bce5a8767b1ff3ab2ed5fcc..4a9819811891d44e6e0ef2a888ac847ea1ac1473 100644 (file)
@@ -4,13 +4,7 @@
     //It's based in the glosssary filter by Williams Castillo
     //Modifications by stronk7. Enjoy! :-)
 
-    $textfilter_function='resource_names_filter';
-
-    if (function_exists($textfilter_function)) {
-        return;
-    }
-
-    function resource_names_filter($courseid, $text) {
+    function resource_filter($courseid, $text) {
 
         global $CFG;
 
index 900683e2babb20f6285e4e4bf628069180208bb2..6243e5d361d3dd4f49d61966c86705c3882093ad 100755 (executable)
@@ -6,13 +6,7 @@
 \r
     require_once($CFG->dirroot.'/mod/wiki/lib.php');\r
 \r
-    $textfilter_function='wiki_page_filter';\r
-\r
-    if (function_exists($textfilter_function)) {\r
-        return;\r
-    }\r
-\r
-    function wiki_page_filter($courseid, $text) {\r
+    function wiki_filter($courseid, $text) {\r
 \r
         global $CFG;\r
 \r