MDL-50491 filters: Some final touches.

- Complete the deprecation information to follow the rules.
- Minor tweak to PLAIN tests to have clearer expectations.
- Completely delete get_global_config() from filters, there
  was not much utility keeping it there. Note we have opted
  for direct deletion because it's private API, not public one
  (and searching github/google/docs did not reveal any use
  of those functions either, just in case).
This commit is contained in:
Eloy Lafuente (stronk7)
2015-06-18 04:11:24 +02:00
parent 41e5e524f9
commit 0d6f53e8f7
5 changed files with 16 additions and 34 deletions
+1 -15
View File
@@ -48,7 +48,7 @@ class filter_emoticon extends moodle_text_filter {
// be stripped. therefore, we do nothing
return $text;
}
if (in_array($options['originalformat'], explode(',', $this->get_global_config('formats')))) {
if (in_array($options['originalformat'], explode(',', get_config('filter_emoticon', 'formats')))) {
$this->replace_emoticons($text);
}
return $text;
@@ -58,20 +58,6 @@ class filter_emoticon extends moodle_text_filter {
// internal implementation starts here
////////////////////////////////////////////////////////////////////////////
/**
* Returns the global filter setting
*
* If the $name is provided, returns single value. Otherwise returns all
* global settings in object. Returns null if the named setting is not
* found.
*
* @param mixed $name optional config variable name, defaults to null for all
* @return string|object|null
*/
protected function get_global_config($name=null) {
return get_config(get_class($this), $name);
}
/**
* Replace emoticons found in the text with their images
*
+1 -1
View File
@@ -69,6 +69,6 @@ class testable_filter_emoticon extends filter_emoticon {
// Use this context for filtering.
$this->context = context_system::instance();
// Define FORMAT_HTML as only one filtering in DB.
set_config('formats', implode(',', array(FORMAT_HTML)), get_class($this));
set_config('formats', implode(',', array(FORMAT_HTML)), 'filter_emoticon');
}
}
+2 -16
View File
@@ -51,7 +51,7 @@ class filter_urltolink extends moodle_text_filter {
// be stripped. therefore, we do nothing
return $text;
}
if (in_array($options['originalformat'], explode(',', $this->get_global_config('formats')))) {
if (in_array($options['originalformat'], explode(',', get_config('filter_urltolink', 'formats')))) {
$this->convert_urls_into_links($text);
}
return $text;
@@ -61,20 +61,6 @@ class filter_urltolink extends moodle_text_filter {
// internal implementation starts here
////////////////////////////////////////////////////////////////////////////
/**
* Returns the global filter setting
*
* If the $name is provided, returns single value. Otherwise returns all
* global settings in object. Returns null if the named setting is not
* found.
*
* @param mixed $name optional config variable name, defaults to null for all
* @return string|object|null
*/
protected function get_global_config($name=null) {
return get_config('filter_urltolink', $name);
}
/**
* Given some text this function converts any URLs it finds into HTML links
*
@@ -162,7 +148,7 @@ class filter_urltolink extends moodle_text_filter {
$text = str_replace(array_keys($ignoretags),$ignoretags,$text);
}
if ($this->get_global_config('embedimages')) {
if (get_config('filter_urltolink', 'embedimages')) {
// now try to inject the images, this code was originally in the mediapluing filter
// this may be useful only if somebody relies on the fact the links in FORMAT_MOODLE get converted
// to URLs which in turn change to real images
+4 -2
View File
@@ -233,7 +233,8 @@ class filter_manager {
}
/**
* @deprecated Since Moodle 3.0. This was used by the old text filtering system, but no more.
* @deprecated Since Moodle 3.0 MDL-50491. This was used by the old text filtering system, but no more.
* @todo MDL-50632 This will be deleted in Moodle 3.2.
* @param context $context the context.
* @return string the hash.
*/
@@ -385,7 +386,8 @@ abstract class moodle_text_filter {
}
/**
* @deprecated Since Moodle 3.0. This was used by the old text filtering system, but no more.
* @deprecated Since Moodle 3.0 MDL-50491. This was used by the old text filtering system, but no more.
* @todo MDL-50632 This will be deleted in Moodle 3.2.
* @return string The class name of the current class
*/
public function hash() {
+8
View File
@@ -49,6 +49,14 @@ class core_weblib_format_text_testcase extends advanced_testcase {
}
public function test_format_text_format_plain() {
// Note FORMAT_PLAIN does not filter ever, no matter we ask for filtering.
$this->resetAfterTest();
filter_set_global_state('emoticon', TEXTFILTER_ON);
$this->assertEquals(':-)',
format_text(':-)', FORMAT_PLAIN));
}
public function test_format_text_format_plain_no_filters() {
$this->resetAfterTest();
filter_set_global_state('emoticon', TEXTFILTER_ON);
$this->assertEquals(':-)',