diff --git a/code/model/SiteTree.php b/code/model/SiteTree.php index 18620015ab..e5ac2d90ef 100644 --- a/code/model/SiteTree.php +++ b/code/model/SiteTree.php @@ -366,7 +366,7 @@ public static function page_type_classes() { } /** - * Replace a "[sitetree_link id=n]" shortcode with a link to the page with the corresponding ID. + * Replace a "[sitetree_link,id=n]" shortcode with a link to the page with the corresponding ID. * * @return string */ diff --git a/tasks/MigrateSiteTreeLinkingTask.php b/tasks/MigrateSiteTreeLinkingTask.php index ea7f17d66b..2ffa0bfef5 100644 --- a/tasks/MigrateSiteTreeLinkingTask.php +++ b/tasks/MigrateSiteTreeLinkingTask.php @@ -26,7 +26,7 @@ public function run($request) { // TOOD: Replace in all HTMLText fields $page->Content = preg_replace ( "/href *= *([\"']?){$linked->URLSegment}\/?/i", - "href=$1[sitetree_link id={$linked->ID}]", + "href=$1[sitetree_link,id={$linked->ID}]", $page->Content, -1, $replaced diff --git a/tests/controller/ContentControllerTest.php b/tests/controller/ContentControllerTest.php index 2db39bd96e..b290444f87 100644 --- a/tests/controller/ContentControllerTest.php +++ b/tests/controller/ContentControllerTest.php @@ -112,7 +112,7 @@ public function testLinkShortcodes() { $page = new SiteTree(); $page->URLSegment = 'linking-page'; - $page->Content = sprintf('Testlink', $linkedPage->ID); + $page->Content = sprintf('Testlink', $linkedPage->ID); $page->write(); $page->publish('Stage', 'Live'); diff --git a/tests/model/SiteTreeBacklinksTest.php b/tests/model/SiteTreeBacklinksTest.php index 17cf26d37a..af8e590386 100644 --- a/tests/model/SiteTreeBacklinksTest.php +++ b/tests/model/SiteTreeBacklinksTest.php @@ -36,7 +36,7 @@ function testSavingPageWithLinkAddsBacklink() { $this->assertNotContains($page2->ID, $page1->BackLinkTracking()->column('ID'), 'Assert backlink to page 2 doesn\'t exist'); // add hyperlink to page 1 on page 2 - $page2->Content .= '

Testing page 1 link

'; + $page2->Content .= '

Testing page 1 link

'; $page2->write(); // load page 1 @@ -205,7 +205,7 @@ function testLinkTrackingOnExtraContentFields() { $this->assertNotContains($page2->ID, $page1->BackLinkTracking()->column('ID'), 'Assert backlink to page 2 doesn\'t exist'); // add hyperlink to page 1 on page 2 - $page2->ExtraContent .= '

Testing page 1 link

'; + $page2->ExtraContent .= '

Testing page 1 link

'; $page2->write(); $page2->doPublish(); diff --git a/tests/model/SiteTreeBacklinksTest.yml b/tests/model/SiteTreeBacklinksTest.yml index 67b1b4be3c..02040f08c3 100644 --- a/tests/model/SiteTreeBacklinksTest.yml +++ b/tests/model/SiteTreeBacklinksTest.yml @@ -11,7 +11,7 @@ Page: page3: Title: page3 URLSegment: page3 - Content: '

Testing page 1 link

' + Content: '

Testing page 1 link

' LinkTracking: =>Page.page1 diff --git a/tests/model/SiteTreeBrokenLinksTest.php b/tests/model/SiteTreeBrokenLinksTest.php index 34a26addcb..e330e62138 100644 --- a/tests/model/SiteTreeBrokenLinksTest.php +++ b/tests/model/SiteTreeBrokenLinksTest.php @@ -21,11 +21,11 @@ static function tear_down_once() { function testBrokenLinksBetweenPages() { $obj = $this->objFromFixture('Page','content'); - $obj->Content = 'this is a broken link'; + $obj->Content = 'this is a broken link'; $obj->syncLinkTracking(); $this->assertTrue($obj->HasBrokenLink, 'Page has a broken link'); - $obj->Content = 'this is not a broken link'; + $obj->Content = 'this is not a broken link'; $obj->syncLinkTracking(); $this->assertFalse($obj->HasBrokenLink, 'Page does NOT have a broken link'); } @@ -107,7 +107,7 @@ function testDeletingMarksBackLinkedPagesAsBroken() { $linkDest->doPublish(); $linkSrc = $this->objFromFixture('Page','content'); - $linkSrc->Content = "

ID]\">about us

"; + $linkSrc->Content = "

ID]\">about us

"; $linkSrc->write(); $linkSrc->doPublish(); @@ -151,7 +151,7 @@ function testPublishingSourceBeforeDestHasBrokenLink() { $linkDest->doDeleteFromLive(); $linkSrc = $this->objFromFixture('Page','content'); - $linkSrc->Content = "

ID]\">about us

"; + $linkSrc->Content = "

ID]\">about us

"; $linkSrc->write(); // Publish the source of the link, while the dest is still unpublished. @@ -175,7 +175,7 @@ function testRestoreFixesBrokenLinks() { // Content links are one kind of link to pages $p2 = new Page(); $p2->Title = "regular link"; - $p2->Content = "ID]\">test"; + $p2->Content = "ID]\">test"; $p2->write(); $this->assertTrue($p2->doPublish()); @@ -250,7 +250,7 @@ function testRevertToLiveFixesBrokenLinks() { // Content links are one kind of link to pages $p2 = new Page(); $p2->Title = "regular link"; - $p2->Content = "ID]\">test"; + $p2->Content = "ID]\">test"; $p2->write(); $this->assertTrue($p2->doPublish()); diff --git a/tests/model/SiteTreeHTMLEditorFieldTest.php b/tests/model/SiteTreeHTMLEditorFieldTest.php index 752281c2ad..6e3eb5f31e 100644 --- a/tests/model/SiteTreeHTMLEditorFieldTest.php +++ b/tests/model/SiteTreeHTMLEditorFieldTest.php @@ -11,12 +11,12 @@ public function testLinkTracking() { $aboutID = $this->idFromFixture('SiteTree', 'about'); $contactID = $this->idFromFixture('SiteTree', 'contact'); - $editor->setValue("Example Link"); + $editor->setValue("Example Link"); $editor->saveInto($sitetree); $this->assertEquals(array($aboutID => $aboutID), $sitetree->LinkTracking()->getIdList(), 'Basic link tracking works.'); $editor->setValue ( - "" + "" ); $editor->saveInto($sitetree); $this->assertEquals ( @@ -89,13 +89,13 @@ public function testBrokenLinkTracking() { $this->assertFalse((bool) $sitetree->HasBrokenLink); - $editor->setValue('

Broken Link

'); + $editor->setValue('

Broken Link

'); $editor->saveInto($sitetree); $this->assertTrue($sitetree->HasBrokenLink); $editor->setValue(sprintf ( - '

Working Link

', + '

Working Link

', $this->idFromFixture('SiteTree', 'home') )); $sitetree->HasBrokenLink = false; @@ -108,13 +108,13 @@ public function testBrokenLinkHighlighting() { $sitetree = new SiteTree(); $editor = new HtmlEditorField('Content'); - $editor->setValue('Broken Link'); + $editor->setValue('Broken Link'); $element = new SimpleXMLElement(html_entity_decode((string) new SimpleXMLElement($editor->Field()))); $this->assertContains('ss-broken', (string) $element['class'], 'A broken link class is added to broken links'); $editor->setValue(sprintf ( - 'Working Link', + 'Working Link', $this->idFromFixture('SiteTree', 'home') )); diff --git a/tests/model/SiteTreeTest.php b/tests/model/SiteTreeTest.php index ea8cbcdf27..f8134aa3db 100644 --- a/tests/model/SiteTreeTest.php +++ b/tests/model/SiteTreeTest.php @@ -587,8 +587,8 @@ public function testLinkShortcodeHandler() { $parser = new ShortcodeParser(); $parser->register('sitetree_link', array('SiteTree', 'link_shortcode_handler')); - $aboutShortcode = sprintf('[sitetree_link id=%d]', $aboutPage->ID); - $aboutEnclosed = sprintf('[sitetree_link id=%d]Example Content[/sitetree_link]', $aboutPage->ID); + $aboutShortcode = sprintf('[sitetree_link,id=%d]', $aboutPage->ID); + $aboutEnclosed = sprintf('[sitetree_link,id=%d]Example Content[/sitetree_link]', $aboutPage->ID); $aboutShortcodeExpected = $aboutPage->Link(); $aboutEnclosedExpected = sprintf('Example Content', $aboutPage->Link()); @@ -601,8 +601,8 @@ public function testLinkShortcodeHandler() { $this->assertEquals($aboutShortcodeExpected, $parser->parse($aboutShortcode), 'Test that deleted pages still link.'); $this->assertEquals($aboutEnclosedExpected, $parser->parse($aboutEnclosed)); - $aboutShortcode = '[sitetree_link id="-1"]'; - $aboutEnclosed = '[sitetree_link id="-1"]Example Content[/sitetree_link]'; + $aboutShortcode = '[sitetree_link,id="-1"]'; + $aboutEnclosed = '[sitetree_link,id="-1"]Example Content[/sitetree_link]'; $aboutShortcodeExpected = $errorPage->Link(); $aboutEnclosedExpected = sprintf('Example Content', $errorPage->Link()); @@ -611,7 +611,7 @@ public function testLinkShortcodeHandler() { $this->assertEquals($aboutEnclosedExpected, $parser->parse($aboutEnclosed)); $this->assertEquals('', $parser->parse('[sitetree_link]'), 'Test that invalid ID attributes are not parsed.'); - $this->assertEquals('', $parser->parse('[sitetree_link id="text"]')); + $this->assertEquals('', $parser->parse('[sitetree_link,id="text"]')); $this->assertEquals('', $parser->parse('[sitetree_link]Example Content[/sitetree_link]')); } diff --git a/tests/tasks/MigrateSiteTreeLinkingTaskTest.php b/tests/tasks/MigrateSiteTreeLinkingTaskTest.php index d27967f741..5547a98fcc 100644 --- a/tests/tasks/MigrateSiteTreeLinkingTaskTest.php +++ b/tests/tasks/MigrateSiteTreeLinkingTaskTest.php @@ -29,25 +29,25 @@ public function testLinkingMigration() { $hashID = $this->idFromFixture('SiteTree', 'hash_link'); $homeContent = sprintf ( - 'AboutStaffExternal Link', + 'AboutStaffExternal Link', $aboutID, $staffID ); $aboutContent = sprintf ( - 'HomeStaff', + 'HomeStaff', $homeID, $staffID ); $staffContent = sprintf ( - 'HomeAbout', + 'HomeAbout', $homeID, $aboutID ); $actionContent = sprintf ( - 'Search Form', $homeID + 'Search Form', $homeID ); $hashLinkContent = sprintf ( - 'HomeAbout', + 'HomeAbout', $homeID, $aboutID );