Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

BUG Change all shortcodes into the new, comma separated, format.

  • Loading branch information...
commit 54fd54a2fbc606a8f90b7109b6bba13b1b4f04da 1 parent 8055fc2
@mateusz mateusz authored chillu committed
View
2  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
*/
View
2  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
View
2  tests/controller/ContentControllerTest.php
@@ -112,7 +112,7 @@ public function testLinkShortcodes() {
$page = new SiteTree();
$page->URLSegment = 'linking-page';
- $page->Content = sprintf('<a href="[sitetree_link id=%s]">Testlink</a>', $linkedPage->ID);
+ $page->Content = sprintf('<a href="[sitetree_link,id=%s]">Testlink</a>', $linkedPage->ID);
$page->write();
$page->publish('Stage', 'Live');
View
4 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 .= '<p><a href="[sitetree_link id='.$page1->ID.']">Testing page 1 link</a></p>';
+ $page2->Content .= '<p><a href="[sitetree_link,id='.$page1->ID.']">Testing page 1 link</a></p>';
$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 .= '<p><a href="[sitetree_link id='.$page1->ID.']">Testing page 1 link</a></p>';
+ $page2->ExtraContent .= '<p><a href="[sitetree_link,id='.$page1->ID.']">Testing page 1 link</a></p>';
$page2->write();
$page2->doPublish();
View
2  tests/model/SiteTreeBacklinksTest.yml
@@ -11,7 +11,7 @@ Page:
page3:
Title: page3
URLSegment: page3
- Content: '<p><a href="[sitetree_link id=1]">Testing page 1 link</a></p>'
+ Content: '<p><a href="[sitetree_link,id=1]">Testing page 1 link</a></p>'
LinkTracking: =>Page.page1
View
12 tests/model/SiteTreeBrokenLinksTest.php
@@ -21,11 +21,11 @@ static function tear_down_once() {
function testBrokenLinksBetweenPages() {
$obj = $this->objFromFixture('Page','content');
- $obj->Content = '<a href="[sitetree_link id=3423423]">this is a broken link</a>';
+ $obj->Content = '<a href="[sitetree_link,id=3423423]">this is a broken link</a>';
$obj->syncLinkTracking();
$this->assertTrue($obj->HasBrokenLink, 'Page has a broken link');
- $obj->Content = '<a href="[sitetree_link id=' . $this->idFromFixture('Page','about') .']">this is not a broken link</a>';
+ $obj->Content = '<a href="[sitetree_link,id=' . $this->idFromFixture('Page','about') .']">this is not a broken link</a>';
$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 = "<p><a href=\"[sitetree_link id=$linkDest->ID]\">about us</a></p>";
+ $linkSrc->Content = "<p><a href=\"[sitetree_link,id=$linkDest->ID]\">about us</a></p>";
$linkSrc->write();
$linkSrc->doPublish();
@@ -151,7 +151,7 @@ function testPublishingSourceBeforeDestHasBrokenLink() {
$linkDest->doDeleteFromLive();
$linkSrc = $this->objFromFixture('Page','content');
- $linkSrc->Content = "<p><a href=\"[sitetree_link id=$linkDest->ID]\">about us</a></p>";
+ $linkSrc->Content = "<p><a href=\"[sitetree_link,id=$linkDest->ID]\">about us</a></p>";
$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 = "<a href=\"[sitetree_link id=$p->ID]\">test</a>";
+ $p2->Content = "<a href=\"[sitetree_link,id=$p->ID]\">test</a>";
$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 = "<a href=\"[sitetree_link id=$p->ID]\">test</a>";
+ $p2->Content = "<a href=\"[sitetree_link,id=$p->ID]\">test</a>";
$p2->write();
$this->assertTrue($p2->doPublish());
View
12 tests/model/SiteTreeHTMLEditorFieldTest.php
@@ -11,12 +11,12 @@ public function testLinkTracking() {
$aboutID = $this->idFromFixture('SiteTree', 'about');
$contactID = $this->idFromFixture('SiteTree', 'contact');
- $editor->setValue("<a href=\"[sitetree_link id=$aboutID]\">Example Link</a>");
+ $editor->setValue("<a href=\"[sitetree_link,id=$aboutID]\">Example Link</a>");
$editor->saveInto($sitetree);
$this->assertEquals(array($aboutID => $aboutID), $sitetree->LinkTracking()->getIdList(), 'Basic link tracking works.');
$editor->setValue (
- "<a href=\"[sitetree_link id=$aboutID]\"></a><a href=\"[sitetree_link id=$contactID]\"></a>"
+ "<a href=\"[sitetree_link,id=$aboutID]\"></a><a href=\"[sitetree_link,id=$contactID]\"></a>"
);
$editor->saveInto($sitetree);
$this->assertEquals (
@@ -89,13 +89,13 @@ public function testBrokenLinkTracking() {
$this->assertFalse((bool) $sitetree->HasBrokenLink);
- $editor->setValue('<p><a href="[sitetree_link id=0]">Broken Link</a></p>');
+ $editor->setValue('<p><a href="[sitetree_link,id=0]">Broken Link</a></p>');
$editor->saveInto($sitetree);
$this->assertTrue($sitetree->HasBrokenLink);
$editor->setValue(sprintf (
- '<p><a href="[sitetree_link id=%d]">Working Link</a></p>',
+ '<p><a href="[sitetree_link,id=%d]">Working Link</a></p>',
$this->idFromFixture('SiteTree', 'home')
));
$sitetree->HasBrokenLink = false;
@@ -108,13 +108,13 @@ public function testBrokenLinkHighlighting() {
$sitetree = new SiteTree();
$editor = new HtmlEditorField('Content');
- $editor->setValue('<a href="[sitetree_link id=0]">Broken Link</a>');
+ $editor->setValue('<a href="[sitetree_link,id=0]">Broken Link</a>');
$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 (
- '<a href="[sitetree_link id=%d]">Working Link</a>',
+ '<a href="[sitetree_link,id=%d]">Working Link</a>',
$this->idFromFixture('SiteTree', 'home')
));
View
10 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('<a href="%s">Example Content</a>', $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('<a href="%s">Example Content</a>', $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]'));
}
View
10 tests/tasks/MigrateSiteTreeLinkingTaskTest.php
@@ -29,25 +29,25 @@ public function testLinkingMigration() {
$hashID = $this->idFromFixture('SiteTree', 'hash_link');
$homeContent = sprintf (
- '<a href="[sitetree_link id=%d]">About</a><a href="[sitetree_link id=%d]">Staff</a><a href="http://silverstripe.org/">External Link</a>',
+ '<a href="[sitetree_link,id=%d]">About</a><a href="[sitetree_link,id=%d]">Staff</a><a href="http://silverstripe.org/">External Link</a>',
$aboutID,
$staffID
);
$aboutContent = sprintf (
- '<a href="[sitetree_link id=%d]">Home</a><a href="[sitetree_link id=%d]">Staff</a>',
+ '<a href="[sitetree_link,id=%d]">Home</a><a href="[sitetree_link,id=%d]">Staff</a>',
$homeID,
$staffID
);
$staffContent = sprintf (
- '<a href="[sitetree_link id=%d]">Home</a><a href="[sitetree_link id=%d]">About</a>',
+ '<a href="[sitetree_link,id=%d]">Home</a><a href="[sitetree_link,id=%d]">About</a>',
$homeID,
$aboutID
);
$actionContent = sprintf (
- '<a href="[sitetree_link id=%d]SearchForm">Search Form</a>', $homeID
+ '<a href="[sitetree_link,id=%d]SearchForm">Search Form</a>', $homeID
);
$hashLinkContent = sprintf (
- '<a href="[sitetree_link id=%d]#anchor">Home</a><a href="[sitetree_link id=%d]#second-anchor">About</a>',
+ '<a href="[sitetree_link,id=%d]#anchor">Home</a><a href="[sitetree_link,id=%d]#second-anchor">About</a>',
$homeID,
$aboutID
);
Please sign in to comment.
Something went wrong with that request. Please try again.