From f18ece11ca8271c6f884d011dbb20a3bf7a9d2df Mon Sep 17 00:00:00 2001 From: Ingo Schommer Date: Mon, 30 Sep 2013 22:40:47 +0200 Subject: [PATCH] Revert "Fixes silverstripe/silverstripe-framework#1910: shortcodes not parsed in RSS feeds" This reverts commit 306281ed44dd0e12a6e88d8fa9e43177123ba684. Breaks HTMLTextTest --- model/fieldtypes/HTMLText.php | 19 +++++-------------- model/fieldtypes/Text.php | 8 ++++++++ 2 files changed, 13 insertions(+), 14 deletions(-) diff --git a/model/fieldtypes/HTMLText.php b/model/fieldtypes/HTMLText.php index 127c0dda3..188ec256b 100644 --- a/model/fieldtypes/HTMLText.php +++ b/model/fieldtypes/HTMLText.php @@ -58,7 +58,6 @@ class HTMLText extends Text { */ public function Summary($maxWords = 50, $flex = 15, $add = '...') { $str = false; - $parsedValue = $this->forTemplate(); /* First we need the text of the first paragraph, without tags. Try using SimpleXML first */ if (class_exists('SimpleXMLElement')) { @@ -67,7 +66,7 @@ class HTMLText extends Text { // Catch warnings thrown by loadHTML and turn them into a failure boolean rather than a SilverStripe error set_error_handler(create_function('$no, $str', 'throw new Exception("HTML Parse Error: ".$str);'), E_ALL); // Nonbreaking spaces get converted into weird characters, so strip them - $value = str_replace(' ', ' ', $parsedValue); + $value = str_replace(' ', ' ', $this->value); try { $res = $doc->loadHTML('' . $value); } @@ -87,11 +86,11 @@ class HTMLText extends Text { /* See if we can pull a paragraph out*/ // Strip out any images in case there's one at the beginning. Not doing this will return a blank paragraph - $str = preg_replace('{^\s*(<.+?>)*]*>}', '', $parsedValue); + $str = preg_replace('{^\s*(<.+?>)*]*>}', '', $this->value); if (preg_match('{]*)?>(.*[A-Za-z]+.*)

}', $str, $matches)) $str = $matches[2]; /* If _that_ failed, just use the whole text */ - if (!$str) $str = $parsedValue; + if (!$str) $str = $this->value; /* Now pull out all the html-alike stuff */ /* Take out anything that is obviously a tag */ @@ -140,16 +139,8 @@ class HTMLText extends Text { /* If we didn't find a sentence ending, use the summary. We re-call rather than using paragraph so that * Summary will limit the result this time */ return $this->Summary(); - } - - /** - * Return the value of the field with relative links converted to absolute urls. - * @return string - */ - public function AbsoluteLinks() { - return HTTP::absoluteURLs($this->forTemplate()); - } - + } + public function forTemplate() { if ($this->processShortcodes) { return ShortcodeParser::get_active()->parse($this->value); diff --git a/model/fieldtypes/Text.php b/model/fieldtypes/Text.php index 55bcdc9dd..63d057381 100644 --- a/model/fieldtypes/Text.php +++ b/model/fieldtypes/Text.php @@ -62,6 +62,14 @@ class Text extends StringField { return strip_tags($this->value); } + /** + * Return the value of the field with relative links converted to absolute urls. + * @return string + */ + public function AbsoluteLinks() { + return HTTP::absoluteURLs($this->value); + } + /** * Limit sentences, can be controlled by passing an integer. *