filters: MDL-17684 Look for the filter name in filter_myfilter.php first.
This makes filters more plugginable, becuase with this lang file name, get_string will look for the filter name in filter/myfilter/lang/en_utf8/filter_myfilter.php. To do this, there is a new function filter_get_name in filterlib that contains the logic. Also, a new function filter_get_all_installed to replace the logic for getting all filters that was duplicated in three places. filter_get_name no longer does such a nice fall-back if the name is missing, to encourage people to supply the right string. The fallback now looks like '[[filtername]] (filter/tidy)'.
This commit is contained in:
+15
-31
@@ -3720,18 +3720,15 @@ class admin_setting_managefilters extends admin_setting {
|
||||
return true;
|
||||
}
|
||||
|
||||
$filternames = filter_get_all_installed();
|
||||
$textlib = textlib_get_instance();
|
||||
$filterlocations = array('mod','filter');
|
||||
foreach ($filterlocations as $filterlocation) {
|
||||
$plugins = get_list_of_plugins($filterlocation);
|
||||
foreach ($plugins as $plugin) {
|
||||
if (strpos($plugin, $query) !== false) {
|
||||
return true;
|
||||
}
|
||||
$name = get_string('filtername', $plugin);
|
||||
if (strpos($textlib->strtolower($name), $query) !== false) {
|
||||
return true;
|
||||
}
|
||||
foreach ($filternames as $path => $strfiltername) {
|
||||
if (strpos($textlib->strtolower($strfiltername), $query) !== false) {
|
||||
return true;
|
||||
}
|
||||
list($type, $filter) = explode('/', $path);
|
||||
if (strpos($filter, $query) !== false) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
@@ -3752,25 +3749,12 @@ class admin_setting_managefilters extends admin_setting {
|
||||
// get a list of possible filters (and translate name if possible)
|
||||
// note filters can be in the dedicated filters area OR in their
|
||||
// associated modules
|
||||
$installedfilters = array();
|
||||
$installedfilters = filter_get_all_installed();
|
||||
$filtersettings_new = array();
|
||||
$filterlocations = array('mod','filter');
|
||||
foreach ($filterlocations as $filterlocation) {
|
||||
$plugins = get_list_of_plugins($filterlocation);
|
||||
foreach ($plugins as $plugin) {
|
||||
$pluginpath = "$CFG->dirroot/$filterlocation/$plugin/filter.php";
|
||||
$settingspath_new = "$CFG->dirroot/$filterlocation/$plugin/filtersettings.php";
|
||||
if (is_readable($pluginpath)) {
|
||||
$name = trim(get_string("filtername", $plugin));
|
||||
if (empty($name) or ($name == '[[filtername]]')) {
|
||||
$textlib = textlib_get_instance();
|
||||
$name = $textlib->strtotitle($plugin);
|
||||
}
|
||||
$installedfilters["$filterlocation/$plugin"] = $name;
|
||||
if (is_readable($settingspath_new)) {
|
||||
$filtersettings_new[] = "$filterlocation/$plugin";
|
||||
}
|
||||
}
|
||||
foreach ($installedfilters as $path => $strfiltername) {
|
||||
$settingspath_new = $CFG->dirroot . '/' . $path . '/filtersettings.php';
|
||||
if (is_readable($settingspath_new)) {
|
||||
$filtersettings_new[] = $path;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3790,8 +3774,8 @@ class admin_setting_managefilters extends admin_setting {
|
||||
}
|
||||
}
|
||||
|
||||
// construct the display array with installed filters
|
||||
// at the top in the right order
|
||||
// Get the list of all filters, and pull the active filters
|
||||
// to the top.
|
||||
$displayfilters = array();
|
||||
foreach ($activefilters as $activefilter) {
|
||||
$name = $installedfilters[$activefilter];
|
||||
|
||||
Reference in New Issue
Block a user