2 // Allows the admin to create, delete and rename course categories
4 require_once("../config.php");
6 optional_variable($iselect);
7 optional_variable($uselect);
8 optional_variable($add);
9 optional_variable($remove);
10 optional_variable($up);
11 optional_variable($down);
16 error("Only administrators can use this page!");
19 if (!confirm_sesskey()) {
20 error(get_string('confirmsesskeybad', 'error'));
23 if (!$site = get_site()) {
24 error("Site isn't defined!");
29 $stradministration = get_string("administration");
30 $strconfiguration = get_string("configuration");
31 $strmanagefilters = get_string("managefilters");
32 $strversion = get_string("version");
33 $strsettings = get_string("settings");
34 $strup = get_string("up");
35 $strdown = get_string("down");
36 $stractive = get_string("active");
37 $strinactive = get_string("inactive");
38 $strcachetext = get_string("cachetext", "admin");
39 $strconfigcachetext = get_string("configcachetext");
40 $strfilteruploadedfiles = get_string("filteruploadedfiles", "admin");
41 $strconfigfilteruploadedfiles = get_string("configfilteruploadedfiles");
43 print_header("$site->shortname: $strmanagefilters", "$site->fullname",
44 "<a href=\"index.php\">$stradministration</a> -> ".
45 "<a href=\"configure.php\">$strconfiguration</a> -> $strmanagefilters");
47 print_heading($strmanagefilters);
50 /// Make a list of all available filters and the best names for them we can find
51 $allfilters = array();
53 $filterlocations = array("mod", "filter");
55 foreach ($filterlocations as $filterlocation) {
56 $plugins = get_list_of_plugins($filterlocation);
57 foreach ($plugins as $key => $plugin) {
58 if (is_readable("$CFG->dirroot/$filterlocation/$plugin/filter.php")) {
59 $name = trim(get_string("filtername", $plugin));
60 if (empty($name) or $name == "[[filtername]]") {
63 $allfilters["$filterlocation/$plugin"] = $name;
69 /// Make an array of all the currently installed filters
71 $installedfilters = array();
72 if (!empty($CFG->textfilters
)) {
73 $installedfilters = explode(',',$CFG->textfilters
);
75 // Do a little cleanup for robustness
76 foreach ($installedfilters as $key => $installedfilter) {
77 if (empty($installedfilter)) {
78 unset($installedfilters[$key]);
79 set_config("textfilters", implode(',', $installedfilters));
84 $selectedfilter = "none";
86 /// If data submitted, then process and store.
88 if (!empty($options)) {
89 if ($config = data_submitted()) {
90 unset($config->options
);
91 foreach ($config as $name => $value) {
92 set_config($name, $value);
97 if (!empty($add) and !empty($uselect)) {
98 $selectedfilter = $uselect;
99 if (!in_array($selectedfilter, $installedfilters)) {
100 $installedfilters[] = $selectedfilter;
101 set_config("textfilters", implode(',', $installedfilters));
104 } else if (!empty($remove) and !empty($iselect)) {
105 $selectedfilter = $iselect;
106 foreach ($installedfilters as $key => $installedfilter) {
107 if ($installedfilter == $selectedfilter) {
108 unset($installedfilters[$key]);
111 set_config("textfilters", implode(',', $installedfilters));
113 } else if ((!empty($up) or !empty($down)) and !empty($iselect)) {
116 if ($allfilters[$iselect]) {
117 foreach ($installedfilters as $key => $installedfilter) {
118 if ($installedfilter == $iselect) {
127 if ($allfilters[$iselect]) {
129 foreach ($installedfilters as $key => $installedfilter) {
134 if ($installedfilter == $iselect) {
141 if (isset($swapfilter) and isset($movefilter)) {
142 $tempfilter = $installedfilters[$swapfilter];
143 $installedfilters[$swapfilter] = $installedfilters[$movefilter];
144 $installedfilters[$movefilter] = $tempfilter;
145 set_config("textfilters", implode(',', $installedfilters));
147 $selectedfilter = $iselect;
152 /// Make an array of all the currently uninstalled filters
154 $uninstalledfilters = array();
155 foreach ($allfilters as $filter => $name) {
157 foreach ($installedfilters as $installedfilter) {
158 if ($installedfilter == $filter) {
163 $uninstalledfilters[] = $filter;
167 /// Print the current form
169 include("filters.html");