MDL-42711 import learnmoodle fixes: Fix the broken links in RSS feed block
authorDavid Mudrák <david@moodle.com>
Wed, 21 Aug 2013 13:13:08 +0000 (15:13 +0200)
committerAparup Banerjee <aparup@moodle.com>
Fri, 8 Nov 2013 07:35:54 +0000 (15:35 +0800)
If the <description> of the feed contains URLs longer than 30 characters, the
URL is split because of the break_up_long_words(). When combined with the
filter that converts URLs to links, this produces broken links.

The proper solution would be to improve break_up_long_words() so that it does
not modifies URLs at all. As a temporary solution for our purpose now is to
call format_text() prior to break_up_long_words() as it will not modify the
inner content of the <a> tag.

This should be fixed upstream. See also discussion at
https://moodle.org/mod/forum/discuss.php?d=34947

blocks/rss_client/block_rss_client.php

index e2ab922..ed070a7 100644 (file)
 
             if($this->config->display_description && !empty($description)){
 
-                $description = break_up_long_words($description, 30);
-
                 $formatoptions = new stdClass();
                 $formatoptions->para = false;
 
                 $r.= html_writer::start_tag('div',array('class'=>'description'));
-                    $r.= format_text($description, FORMAT_HTML, $formatoptions, $this->page->course->id);
+                    $description = format_text($description, FORMAT_HTML, $formatoptions, $this->page->course->id);
+                    $description = break_up_long_words($description, 30);
+                    $r.= $description;
                 $r.= html_writer::end_tag('div');
             }
         $r.= html_writer::end_tag('li');