BUGFIX Fixed SiteTree->Content link shortcode parsing introduced in r101093 (#5227) (from r101302)

git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@111992 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
Sam Minnee 2010-10-13 00:42:17 +00:00
parent 875197b934
commit 135b65ee04
2 changed files with 21 additions and 1 deletions

View File

@ -245,7 +245,7 @@ class ViewableData extends Object implements IteratorAggregate {
* @return string
*/
public function castingHelper($field) {
if($this instanceof DataObject && ($fieldSpec = $this->db($field))) {
if($this->hasMethod('db') && $fieldSpec = $this->db($field)) {
return $fieldSpec;
}
@ -441,6 +441,7 @@ class ViewableData extends Object implements IteratorAggregate {
*/
public function XML_val($field, $arguments = null, $cache = false) {
$result = $this->obj($field, $arguments, false, $cache);
return is_object($result) ? $result->forTemplate() : $result;
}

View File

@ -103,6 +103,25 @@ class ContentControllerTest extends FunctionalTest {
}
public function testLinkShortcodes() {
$linkedPage = new SiteTree();
$linkedPage->URLSegment = 'linked-page';
$linkedPage->write();
$linkedPage->publish('Stage', 'Live');
$page = new SiteTree();
$page->URLSegment = 'linking-page';
$page->Content = sprintf('<a href="[sitetree_link id=%s]">Testlink</a>', $linkedPage->ID);
$page->write();
$page->publish('Stage', 'Live');
$this->assertContains(
sprintf('<a href="%s">Testlink</a>', $linkedPage->Link()),
$this->get($page->RelativeLink())->getBody(),
'"sitetree_link" shortcodes get parsed properly'
);
}
}