Revert "Fixes silverstripe/silverstripe-framework#1910: shortcodes not parsed in RSS feeds"

This reverts commit 306281ed44dd0e12a6e88d8fa9e43177123ba684.
Breaks HTMLTextTest
This commit is contained in:
Ingo Schommer 2013-09-30 22:40:47 +02:00
parent b291f3d0cd
commit f18ece11ca
2 changed files with 13 additions and 14 deletions

View File

@ -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('<meta content="text/html; charset=utf-8" http-equiv="Content-type"/>' . $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*(<.+?>)*<img[^>]*>}', '', $parsedValue);
$str = preg_replace('{^\s*(<.+?>)*<img[^>]*>}', '', $this->value);
if (preg_match('{<p(\s[^<>]*)?>(.*[A-Za-z]+.*)</p>}', $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);

View File

@ -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.
*