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

git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/branches/2.4@101302 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
Ingo Schommer 2010-03-18 05:22:20 +00:00 committed by Sam Minnee
parent 3fd6d47e86
commit 3e8b155557
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'
);
}
}