diff --git a/admin/config.html b/admin/config.html
index 5d93556dc83..e6e3db38862 100644
--- a/admin/config.html
+++ b/admin/config.html
@@ -410,46 +410,6 @@
-
diff --git a/admin/configure.php b/admin/configure.php
index d4e4d7e8d8c..2b58a26a299 100644
--- a/admin/configure.php
+++ b/admin/configure.php
@@ -32,6 +32,8 @@
get_string("adminhelplanguage"));
$table->data[] = array("".get_string("managemodules")."",
get_string("adminhelpmanagemodules"));
+ $table->data[] = array("".get_string("managefilters")."",
+ get_string("adminhelpmanagefilters"));
$table->data[] = array("".get_string("backup")."",
get_string("adminhelpbackup"));
diff --git a/admin/filters.html b/admin/filters.html
new file mode 100644
index 00000000000..73cb1b5d989
--- /dev/null
+++ b/admin/filters.html
@@ -0,0 +1,124 @@
+cellheading"); ?>
+
+
+
+
+
+
+
+
+
+
+cellheading"); ?>
+
+
+
+
diff --git a/admin/filters.php b/admin/filters.php
new file mode 100644
index 00000000000..1fb7676f16f
--- /dev/null
+++ b/admin/filters.php
@@ -0,0 +1,158 @@
+shortname: $strmanagefilters", "$site->fullname",
+ "$stradministration -> ".
+ "$strconfiguration -> $strmanagefilters");
+
+ print_heading($strmanagefilters);
+
+
+/// Make a list of all available filters and the best names for them we can find
+ $allfilters = array();
+
+ $filterlocations = array("mod", "filter");
+
+ foreach ($filterlocations as $filterlocation) {
+ $plugins = get_list_of_plugins($filterlocation);
+ foreach ($plugins as $key => $plugin) {
+ if (is_readable("$CFG->dirroot/$filterlocation/$plugin/filter.php")) {
+ $name = get_string("filtername", $plugin);
+ if ($name == "[[filtername]]") {
+ $name = $plugin;
+ }
+ $allfilters["$filterlocation/$plugin"] = $name;
+ }
+ }
+ }
+
+
+/// Make an array of all the currently installed filters
+
+ $installedfilters = array();
+ if (!empty($CFG->textfilters)) {
+ $installedfilters = explode(',',$CFG->textfilters);
+
+ // Do a little cleanup for robustness
+ foreach ($installedfilters as $key => $installedfilter) {
+ if (empty($installedfilter)) {
+ unset($installedfilters[$key]);
+ set_config("textfilters", implode(',', $installedfilters));
+ }
+ }
+ }
+
+ $selectedfilter = "none";
+
+/// If data submitted, then process and store.
+
+ if (!empty($add) and !empty($uselect)) {
+ $selectedfilter = $uselect;
+ if (!in_array($selectedfilter, $installedfilters)) {
+ $installedfilters[] = $selectedfilter;
+ set_config("textfilters", implode(',', $installedfilters));
+ }
+
+ } else if (!empty($remove) and !empty($iselect)) {
+ $selectedfilter = $iselect;
+ foreach ($installedfilters as $key => $installedfilter) {
+ if ($installedfilter == $selectedfilter) {
+ unset($installedfilters[$key]);
+ }
+ }
+ set_config("textfilters", implode(',', $installedfilters));
+
+ } else if ((!empty($up) or !empty($down)) and !empty($iselect)) {
+
+ if (!empty($up)) {
+ if ($allfilters[$iselect]) {
+ foreach ($installedfilters as $key => $installedfilter) {
+ if ($installedfilter == $iselect) {
+ $movefilter = $key;
+ break;
+ }
+ $swapfilter = $key;
+ }
+ }
+ }
+ if (!empty($down)) {
+ if ($allfilters[$iselect]) {
+ $choosenext = false;
+ foreach ($installedfilters as $key => $installedfilter) {
+ if ($choosenext) {
+ $swapfilter = $key;
+ break;
+ }
+ if ($installedfilter == $iselect) {
+ $movefilter = $key;
+ $choosenext = true;
+ }
+ }
+ }
+ }
+ if (isset($swapfilter) and isset($movefilter)) {
+ $tempfilter = $installedfilters[$swapfilter];
+ $installedfilters[$swapfilter] = $installedfilters[$movefilter];
+ $installedfilters[$movefilter] = $tempfilter;
+ set_config("textfilters", implode(',', $installedfilters));
+ }
+ $selectedfilter = $iselect;
+ }
+
+
+
+/// Make an array of all the currently uninstalled filters
+
+ $uninstalledfilters = array();
+ foreach ($allfilters as $filter => $name) {
+ $installed = false;
+ foreach ($installedfilters as $installedfilter) {
+ if ($installedfilter == $filter) {
+ $installed = true;
+ }
+ }
+ if (!$installed) {
+ $uninstalledfilters[] = $filter;
+ }
+ }
+
+/// Print the current form
+
+ include("filters.html");
+
+
+ print_footer();
+
+?>
diff --git a/admin/index.php b/admin/index.php
index 8211578758a..adfc7d7da15 100644
--- a/admin/index.php
+++ b/admin/index.php
@@ -381,6 +381,8 @@
get_string("adminhelplanguage")." ";
$configdata .= " ".get_string("managemodules")." - ".
get_string("adminhelpmanagemodules")." ";
+ $configdata .= " ".get_string("managefilters")." - ".
+ get_string("adminhelpmanagefilters")." ";
if (!isset($CFG->disablescheduledbackups)) {
$configdata .= " ".get_string("backup")." - ".
get_string("adminhelpbackup")." ";
diff --git a/lib/db/mysql.php b/lib/db/mysql.php
index 87e2fda7c12..bf1c5ac9629 100644
--- a/lib/db/mysql.php
+++ b/lib/db/mysql.php
@@ -695,6 +695,7 @@ function main_upgrade($oldversion=0) {
$CFG->textfilters = str_replace("censor.php", "filter.php", $CFG->textfilters);
$CFG->textfilters = str_replace("mediaplugin.php", "filter.php", $CFG->textfilters);
$CFG->textfilters = str_replace("algebra_filter.php", "filter.php", $CFG->textfilters);
+ $CFG->textfilters = str_replace("dynalink.php", "filter.php", $CFG->textfilters);
set_config("textfilters", $CFG->textfilters);
}
}
@@ -703,6 +704,17 @@ function main_upgrade($oldversion=0) {
table_column("user", "", "emailstop", "integer", "1", "unsigned", "0", "not null", "email");
}
+ if ($oldversion < 2004022200) { /// Final renaming I hope. :-)
+ if (!empty($CFG->textfilters)) {
+ $CFG->textfilters = str_replace("/filter.php", "", $CFG->textfilters);
+ $textfilters = explode(',', $CFG->textfilters);
+ foreach ($textfilters as $key => $textfilter) {
+ $textfilters[$key] = trim($textfilter);
+ }
+ set_config("textfilters", implode(',',$textfilters));
+ }
+ }
+
return $result;
}
diff --git a/lib/db/postgres7.php b/lib/db/postgres7.php
index 5ad03d1a9fb..17f63775f3f 100644
--- a/lib/db/postgres7.php
+++ b/lib/db/postgres7.php
@@ -440,6 +440,7 @@ function main_upgrade($oldversion=0) {
$CFG->textfilters = str_replace("censor.php", "filter.php", $CFG->textfilters);
$CFG->textfilters = str_replace("mediaplugin.php", "filter.php", $CFG->textfilters);
$CFG->textfilters = str_replace("algebra_filter.php", "filter.php", $CFG->textfilters);
+ $CFG->textfilters = str_replace("dynalink.php", "filter.php", $CFG->textfilters);
set_config("textfilters", $CFG->textfilters);
}
}
@@ -448,6 +449,17 @@ function main_upgrade($oldversion=0) {
table_column("user", "", "emailstop", "integer", "1", "unsigned", "0", "not null", "email");
}
+ if ($oldversion < 2004022200) { /// Final renaming I hope. :-)
+ if (!empty($CFG->textfilters)) {
+ $CFG->textfilters = str_replace("/filter.php", "", $CFG->textfilters);
+ $textfilters = explode(',', $CFG->textfilters);
+ foreach ($textfilters as $key => $textfilter) {
+ $textfilters[$key] = trim($textfilter);
+ }
+ set_config("textfilters", implode(',',$textfilters));
+ }
+ }
+
return $result;
}
diff --git a/lib/weblib.php b/lib/weblib.php
index f504b24a657..13b3f88a870 100644
--- a/lib/weblib.php
+++ b/lib/weblib.php
@@ -612,9 +612,8 @@ function filter_text($text, $courseid=NULL) {
if (!empty($CFG->textfilters)) {
$textfilters = explode(',', $CFG->textfilters);
foreach ($textfilters as $textfilter) {
- $textfilter = trim($textfilter);
- if (is_readable($CFG->dirroot.'/'.$textfilter)) {
- include($CFG->dirroot.'/'.$textfilter);
+ if (is_readable("$CFG->dirroot/$textfilter/filter.php")) {
+ include("$CFG->dirroot/$textfilter/filter.php");
$text = $textfilter_function($courseid, $text);
}
}
diff --git a/version.php b/version.php
index 68a0851fb2e..7fa7f7939c4 100644
--- a/version.php
+++ b/version.php
@@ -5,7 +5,7 @@
// database to determine whether upgrades should
// be performed (see lib/db/*.php)
-$version = 2004022100; // The current version is a date (YYYYMMDDXX)
+$version = 2004022200; // The current version is a date (YYYYMMDDXX)
$release = "1.2 alpha"; // User-friendly version number
|