A proper GUI for filters :-)
Still needs work, but it works fine now. Later I want to add config pages for each filter, like modules have.
This commit is contained in:
@@ -410,46 +410,6 @@
|
||||
<?php print_string("configopentogoogle") ?>
|
||||
</td>
|
||||
</tr>
|
||||
<tr valign=top>
|
||||
<td align=right><p>textfilters:</td>
|
||||
<td>
|
||||
<textarea name=textfilters rows=3 cols=30><?php p($config->textfilters) ?></textarea>
|
||||
</td>
|
||||
<td>
|
||||
<?php print_string("configtextfilters") ?>
|
||||
</td>
|
||||
</tr>
|
||||
<tr valign=top>
|
||||
<td align=right><p>cachetext:</td>
|
||||
<td>
|
||||
<?php
|
||||
unset($options);
|
||||
$options[10800] = get_string('numhours', '', 3);
|
||||
$options[7200] = get_string('numhours', '', 2);
|
||||
$options[3600] = get_string('numhours', '', 1);
|
||||
$options[2700] = get_string('numminutes', '', 45);
|
||||
$options[1800] = get_string('numminutes', '', 30);
|
||||
$options[900] = get_string('numminutes', '', 15);
|
||||
$options[600] = get_string('numminutes', '', 10);
|
||||
$options[540] = get_string('numminutes', '', 9);
|
||||
$options[480] = get_string('numminutes', '', 8);
|
||||
$options[420] = get_string('numminutes', '', 7);
|
||||
$options[360] = get_string('numminutes', '', 6);
|
||||
$options[300] = get_string('numminutes', '', 5);
|
||||
$options[240] = get_string('numminutes', '', 4);
|
||||
$options[180] = get_string('numminutes', '', 3);
|
||||
$options[120] = get_string('numminutes', '', 2);
|
||||
$options[60] = get_string('numminutes', '', 1);
|
||||
$options[30] = get_string('numseconds', '', 30);
|
||||
$options[0] = get_string('no');
|
||||
|
||||
choose_from_menu ($options, "cachetext", $config->cachetext, "", "", "");
|
||||
?>
|
||||
</td>
|
||||
<td>
|
||||
<?php print_string("configcachetext") ?>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td colspan=3 align=center>
|
||||
|
||||
@@ -32,6 +32,8 @@
|
||||
get_string("adminhelplanguage"));
|
||||
$table->data[] = array("<b><a href=\"modules.php\">".get_string("managemodules")."</a></b>",
|
||||
get_string("adminhelpmanagemodules"));
|
||||
$table->data[] = array("<b><a href=\"filters.php\">".get_string("managefilters")."</a></b>",
|
||||
get_string("adminhelpmanagefilters"));
|
||||
$table->data[] = array("<b><a href=\"backup.php\">".get_string("backup")."</a></b>",
|
||||
get_string("adminhelpbackup"));
|
||||
|
||||
|
||||
@@ -0,0 +1,124 @@
|
||||
<?php print_simple_box_start("center", "", "$THEME->cellheading"); ?>
|
||||
|
||||
<form name="filters" id="filters" method="post" action="filters.php">
|
||||
<table align="center" border="0" cellpadding="5" cellspacing="0">
|
||||
<tr>
|
||||
<td valign="top"><div align="right">
|
||||
<br />
|
||||
<input name="up" type="submit" id="up" value="↑" />
|
||||
<br />
|
||||
<input name="down" type="submit" id="down" value="↓" />
|
||||
<br />
|
||||
</div></td>
|
||||
<td valign="top">
|
||||
<?php p($stractive) ?>
|
||||
<br />
|
||||
|
||||
<select name="iselect" size="20" id="iselect"
|
||||
onclick="filters.add.disabled=true;
|
||||
filters.remove.disabled=false;
|
||||
filters.uselect.selectedIndex=-1;">
|
||||
<?php
|
||||
$runscript = "";
|
||||
foreach ($installedfilters as $filter) {
|
||||
if ($selectedfilter == $filter) {
|
||||
$selected = " selected ";
|
||||
$runscript = "eval(\"document.filters.add.disabled=true\");
|
||||
eval(\"document.filters.remove.disabled=false\");
|
||||
eval(\"document.filters.uselect.selectedIndex=-1\");";
|
||||
} else {
|
||||
$selected = "";
|
||||
}
|
||||
echo "<option value=\"$filter\" $selected>".$allfilters[$filter]."</option>";
|
||||
}
|
||||
?>
|
||||
</select></td>
|
||||
<td valign="top">
|
||||
<br />
|
||||
<input name="add" type="submit" id="add" value="←" />
|
||||
<br />
|
||||
<input name="remove" type="submit" id="remove" value="→" />
|
||||
<br />
|
||||
</td>
|
||||
<td valign="top">
|
||||
<?php p($strinactive) ?>
|
||||
<br />
|
||||
<select name="uselect" size="20" id="select"
|
||||
onclick="filters.add.disabled=false;
|
||||
filters.remove.disabled=true;
|
||||
filters.iselect.selectedIndex=-1;">
|
||||
<?php
|
||||
foreach ($uninstalledfilters as $filter) {
|
||||
if ($selectedfilter == $filter) {
|
||||
$selected = " selected ";
|
||||
$runscript = "eval(\"document.filters.add.disabled=false\");
|
||||
eval(\"document.filters.remove.disabled=true\");
|
||||
eval(\"document.filters.iselect.selectedIndex=-1\");";
|
||||
} else {
|
||||
$selected = "";
|
||||
}
|
||||
echo "<option value=\"$filter\" $selected>".$allfilters[$filter]."</option>";
|
||||
}
|
||||
?>
|
||||
</select></td>
|
||||
</tr>
|
||||
</table>
|
||||
</form>
|
||||
|
||||
<script language="Javascript">
|
||||
<!--
|
||||
<?php echo $runscript ?>
|
||||
|
||||
-->
|
||||
</script>
|
||||
<?php print_simple_box_end(); ?>
|
||||
|
||||
<br />
|
||||
<br />
|
||||
|
||||
|
||||
<?php print_simple_box_start("center", "", "$THEME->cellheading"); ?>
|
||||
|
||||
<form name="options" id="options" method="post" action="filters.php">
|
||||
<input type="hidden" name="options" value="1">
|
||||
<table cellpadding="20">
|
||||
<tr valign=top>
|
||||
<td nowrap="nowrap" align="right"><?php p($strcachetext) ?>:</td>
|
||||
<td>
|
||||
<?php
|
||||
unset($options);
|
||||
$options[10800] = get_string('numhours', '', 3);
|
||||
$options[7200] = get_string('numhours', '', 2);
|
||||
$options[3600] = get_string('numhours', '', 1);
|
||||
$options[2700] = get_string('numminutes', '', 45);
|
||||
$options[1800] = get_string('numminutes', '', 30);
|
||||
$options[900] = get_string('numminutes', '', 15);
|
||||
$options[600] = get_string('numminutes', '', 10);
|
||||
$options[540] = get_string('numminutes', '', 9);
|
||||
$options[480] = get_string('numminutes', '', 8);
|
||||
$options[420] = get_string('numminutes', '', 7);
|
||||
$options[360] = get_string('numminutes', '', 6);
|
||||
$options[300] = get_string('numminutes', '', 5);
|
||||
$options[240] = get_string('numminutes', '', 4);
|
||||
$options[180] = get_string('numminutes', '', 3);
|
||||
$options[120] = get_string('numminutes', '', 2);
|
||||
$options[60] = get_string('numminutes', '', 1);
|
||||
$options[30] = get_string('numseconds', '', 30);
|
||||
$options[0] = get_string('no');
|
||||
|
||||
choose_from_menu ($options, "cachetext", $config->cachetext, "", "", "");
|
||||
?>
|
||||
</td>
|
||||
<td>
|
||||
<?php p($strconfigcachetext) ?>
|
||||
</td>
|
||||
</tr>
|
||||
<tr valign=top>
|
||||
<td> </td>
|
||||
<td><input type="submit" value="<?php print_string("savechanges") ?>"></td>
|
||||
<td> </td>
|
||||
</tr>
|
||||
</table>
|
||||
</form>
|
||||
|
||||
<?php print_simple_box_end(); ?>
|
||||
@@ -0,0 +1,158 @@
|
||||
<?PHP // $Id$
|
||||
// Allows the admin to create, delete and rename course categories
|
||||
|
||||
require_once("../config.php");
|
||||
|
||||
optional_variable($iselect);
|
||||
optional_variable($uselect);
|
||||
optional_variable($add);
|
||||
optional_variable($remove);
|
||||
optional_variable($up);
|
||||
optional_variable($down);
|
||||
|
||||
|
||||
if (!isadmin()) {
|
||||
error("Only administrators can use this page!");
|
||||
}
|
||||
|
||||
if (!$site = get_site()) {
|
||||
error("Site isn't defined!");
|
||||
}
|
||||
|
||||
/// Print headings
|
||||
|
||||
$stradministration = get_string("administration");
|
||||
$strconfiguration = get_string("configuration");
|
||||
$strmanagefilters = get_string("managefilters");
|
||||
$strversion = get_string("version");
|
||||
$strsettings = get_string("settings");
|
||||
$strup = get_string("up");
|
||||
$strdown = get_string("down");
|
||||
$stractive = get_string("active");
|
||||
$strinactive = get_string("inactive");
|
||||
$strcachetext = get_string("cachetext", "admin");
|
||||
$strconfigcachetext = get_string("configcachetext");
|
||||
|
||||
print_header("$site->shortname: $strmanagefilters", "$site->fullname",
|
||||
"<a href=\"index.php\">$stradministration</a> -> ".
|
||||
"<a href=\"configure.php\">$strconfiguration</a> -> $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();
|
||||
|
||||
?>
|
||||
@@ -381,6 +381,8 @@
|
||||
get_string("adminhelplanguage")."</font><br />";
|
||||
$configdata .= "<font size=+1> </font><a href=\"modules.php\">".get_string("managemodules")."</a> - <font size=1>".
|
||||
get_string("adminhelpmanagemodules")."</font><br />";
|
||||
$configdata .= "<font size=+1> </font><a href=\"filters.php\">".get_string("managefilters")."</a> - <font size=1>".
|
||||
get_string("adminhelpmanagefilters")."</font><br />";
|
||||
if (!isset($CFG->disablescheduledbackups)) {
|
||||
$configdata .= "<font size=+1> </font><a href=\"backup.php\">".get_string("backup")."</a> - <font size=1>".
|
||||
get_string("adminhelpbackup")."</font><br />";
|
||||
|
||||
@@ -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;
|
||||
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
}
|
||||
|
||||
+2
-3
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user