diff --git a/filter/emoticon/filter.php b/filter/emoticon/filter.php index 2aad78cf16a..d579bf65b9f 100644 --- a/filter/emoticon/filter.php +++ b/filter/emoticon/filter.php @@ -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 * diff --git a/filter/emoticon/tests/filter_test.php b/filter/emoticon/tests/filter_test.php index 38b69ccb36a..8aba2227591 100644 --- a/filter/emoticon/tests/filter_test.php +++ b/filter/emoticon/tests/filter_test.php @@ -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'); } } diff --git a/filter/urltolink/filter.php b/filter/urltolink/filter.php index 5d270ebc947..b232edae8b8 100644 --- a/filter/urltolink/filter.php +++ b/filter/urltolink/filter.php @@ -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 diff --git a/lib/filterlib.php b/lib/filterlib.php index ba447f53705..ba89fd23ede 100644 --- a/lib/filterlib.php +++ b/lib/filterlib.php @@ -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() { diff --git a/lib/tests/weblib_format_text_test.php b/lib/tests/weblib_format_text_test.php index dce2330a22b..deecb6fd943 100644 --- a/lib/tests/weblib_format_text_test.php +++ b/lib/tests/weblib_format_text_test.php @@ -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(':-)',