Skip to content
This repository
Browse code

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

  • Loading branch information...
commit 54fd54a2fbc606a8f90b7109b6bba13b1b4f04da 1 parent 8055fc2
Mateusz U authored July 12, 2012 chillu committed July 12, 2012
2  code/model/SiteTree.php
@@ -366,7 +366,7 @@ public static function page_type_classes() {
366 366
 	}
367 367
 	
368 368
 	/**
369  
-	 * Replace a "[sitetree_link id=n]" shortcode with a link to the page with the corresponding ID.
  369
+	 * Replace a "[sitetree_link,id=n]" shortcode with a link to the page with the corresponding ID.
370 370
 	 *
371 371
 	 * @return string
372 372
 	 */
2  tasks/MigrateSiteTreeLinkingTask.php
@@ -26,7 +26,7 @@ public function run($request) {
26 26
 				// TOOD: Replace in all HTMLText fields
27 27
 				$page->Content = preg_replace (
28 28
 					"/href *= *([\"']?){$linked->URLSegment}\/?/i",
29  
-					"href=$1[sitetree_link id={$linked->ID}]",
  29
+					"href=$1[sitetree_link,id={$linked->ID}]",
30 30
 					$page->Content,
31 31
 					-1,
32 32
 					$replaced
2  tests/controller/ContentControllerTest.php
@@ -112,7 +112,7 @@ public function testLinkShortcodes() {
112 112
 		
113 113
 		$page = new SiteTree();
114 114
 		$page->URLSegment = 'linking-page';
115  
-		$page->Content = sprintf('<a href="[sitetree_link id=%s]">Testlink</a>', $linkedPage->ID);
  115
+		$page->Content = sprintf('<a href="[sitetree_link,id=%s]">Testlink</a>', $linkedPage->ID);
116 116
 		$page->write();
117 117
 		$page->publish('Stage', 'Live');
118 118
 
4  tests/model/SiteTreeBacklinksTest.php
@@ -36,7 +36,7 @@ function testSavingPageWithLinkAddsBacklink() {
36 36
 		$this->assertNotContains($page2->ID, $page1->BackLinkTracking()->column('ID'), 'Assert backlink to page 2 doesn\'t exist');
37 37
 		
38 38
 		// add hyperlink to page 1 on page 2
39  
-		$page2->Content .= '<p><a href="[sitetree_link id='.$page1->ID.']">Testing page 1 link</a></p>';
  39
+		$page2->Content .= '<p><a href="[sitetree_link,id='.$page1->ID.']">Testing page 1 link</a></p>';
40 40
 		$page2->write();
41 41
 		
42 42
 		// load page 1
@@ -205,7 +205,7 @@ function testLinkTrackingOnExtraContentFields() {
205 205
 		$this->assertNotContains($page2->ID, $page1->BackLinkTracking()->column('ID'), 'Assert backlink to page 2 doesn\'t exist');
206 206
 		
207 207
 		// add hyperlink to page 1 on page 2
208  
-		$page2->ExtraContent .= '<p><a href="[sitetree_link id='.$page1->ID.']">Testing page 1 link</a></p>';
  208
+		$page2->ExtraContent .= '<p><a href="[sitetree_link,id='.$page1->ID.']">Testing page 1 link</a></p>';
209 209
 		$page2->write();
210 210
 		$page2->doPublish();
211 211
 
2  tests/model/SiteTreeBacklinksTest.yml
@@ -11,7 +11,7 @@ Page:
11 11
    page3:
12 12
       Title: page3
13 13
       URLSegment: page3
14  
-      Content: '<p><a href="[sitetree_link id=1]">Testing page 1 link</a></p>'
  14
+      Content: '<p><a href="[sitetree_link,id=1]">Testing page 1 link</a></p>'
15 15
       LinkTracking: =>Page.page1
16 16
    
17 17
 
12  tests/model/SiteTreeBrokenLinksTest.php
@@ -21,11 +21,11 @@ static function tear_down_once() {
21 21
 	function testBrokenLinksBetweenPages() {
22 22
 		$obj = $this->objFromFixture('Page','content');
23 23
 		
24  
-		$obj->Content = '<a href="[sitetree_link id=3423423]">this is a broken link</a>';
  24
+		$obj->Content = '<a href="[sitetree_link,id=3423423]">this is a broken link</a>';
25 25
 		$obj->syncLinkTracking();
26 26
 		$this->assertTrue($obj->HasBrokenLink, 'Page has a broken link');
27 27
 		
28  
-		$obj->Content = '<a href="[sitetree_link id=' . $this->idFromFixture('Page','about') .']">this is not a broken link</a>';
  28
+		$obj->Content = '<a href="[sitetree_link,id=' . $this->idFromFixture('Page','about') .']">this is not a broken link</a>';
29 29
 		$obj->syncLinkTracking();
30 30
 		$this->assertFalse($obj->HasBrokenLink, 'Page does NOT have a broken link');
31 31
 	}
@@ -107,7 +107,7 @@ function testDeletingMarksBackLinkedPagesAsBroken() {
107 107
 		$linkDest->doPublish();
108 108
 		
109 109
 		$linkSrc = $this->objFromFixture('Page','content');
110  
-		$linkSrc->Content = "<p><a href=\"[sitetree_link id=$linkDest->ID]\">about us</a></p>";
  110
+		$linkSrc->Content = "<p><a href=\"[sitetree_link,id=$linkDest->ID]\">about us</a></p>";
111 111
 		$linkSrc->write();
112 112
 
113 113
 		$linkSrc->doPublish();
@@ -151,7 +151,7 @@ function testPublishingSourceBeforeDestHasBrokenLink() {
151 151
 		$linkDest->doDeleteFromLive();
152 152
 		
153 153
 		$linkSrc = $this->objFromFixture('Page','content');
154  
-		$linkSrc->Content = "<p><a href=\"[sitetree_link id=$linkDest->ID]\">about us</a></p>";
  154
+		$linkSrc->Content = "<p><a href=\"[sitetree_link,id=$linkDest->ID]\">about us</a></p>";
155 155
 		$linkSrc->write();
156 156
 		
157 157
 		// Publish the source of the link, while the dest is still unpublished. 
@@ -175,7 +175,7 @@ function testRestoreFixesBrokenLinks() {
175 175
 		// Content links are one kind of link to pages
176 176
 		$p2 = new Page();
177 177
 		$p2->Title = "regular link";
178  
-		$p2->Content = "<a href=\"[sitetree_link id=$p->ID]\">test</a>";
  178
+		$p2->Content = "<a href=\"[sitetree_link,id=$p->ID]\">test</a>";
179 179
 		$p2->write();
180 180
 		$this->assertTrue($p2->doPublish());
181 181
 
@@ -250,7 +250,7 @@ function testRevertToLiveFixesBrokenLinks() {
250 250
 		// Content links are one kind of link to pages
251 251
 		$p2 = new Page();
252 252
 		$p2->Title = "regular link";
253  
-		$p2->Content = "<a href=\"[sitetree_link id=$p->ID]\">test</a>";
  253
+		$p2->Content = "<a href=\"[sitetree_link,id=$p->ID]\">test</a>";
254 254
 		$p2->write();
255 255
 		$this->assertTrue($p2->doPublish());
256 256
 
12  tests/model/SiteTreeHTMLEditorFieldTest.php
@@ -11,12 +11,12 @@ public function testLinkTracking() {
11 11
 		$aboutID   = $this->idFromFixture('SiteTree', 'about');
12 12
 		$contactID = $this->idFromFixture('SiteTree', 'contact');
13 13
 
14  
-		$editor->setValue("<a href=\"[sitetree_link id=$aboutID]\">Example Link</a>");
  14
+		$editor->setValue("<a href=\"[sitetree_link,id=$aboutID]\">Example Link</a>");
15 15
 		$editor->saveInto($sitetree);
16 16
 		$this->assertEquals(array($aboutID => $aboutID), $sitetree->LinkTracking()->getIdList(), 'Basic link tracking works.');
17 17
 
18 18
 		$editor->setValue (
19  
-			"<a href=\"[sitetree_link id=$aboutID]\"></a><a href=\"[sitetree_link id=$contactID]\"></a>"
  19
+			"<a href=\"[sitetree_link,id=$aboutID]\"></a><a href=\"[sitetree_link,id=$contactID]\"></a>"
20 20
 		);
21 21
 		$editor->saveInto($sitetree);
22 22
 		$this->assertEquals (
@@ -89,13 +89,13 @@ public function testBrokenLinkTracking() {
89 89
 
90 90
 		$this->assertFalse((bool) $sitetree->HasBrokenLink);
91 91
 
92  
-		$editor->setValue('<p><a href="[sitetree_link id=0]">Broken Link</a></p>');
  92
+		$editor->setValue('<p><a href="[sitetree_link,id=0]">Broken Link</a></p>');
93 93
 		$editor->saveInto($sitetree);
94 94
 
95 95
 		$this->assertTrue($sitetree->HasBrokenLink);
96 96
 
97 97
 		$editor->setValue(sprintf (
98  
-			'<p><a href="[sitetree_link id=%d]">Working Link</a></p>',
  98
+			'<p><a href="[sitetree_link,id=%d]">Working Link</a></p>',
99 99
 			$this->idFromFixture('SiteTree', 'home')
100 100
 		));
101 101
 		$sitetree->HasBrokenLink = false;
@@ -108,13 +108,13 @@ public function testBrokenLinkHighlighting() {
108 108
 		$sitetree = new SiteTree();
109 109
 		$editor   = new HtmlEditorField('Content');
110 110
 
111  
-		$editor->setValue('<a href="[sitetree_link id=0]">Broken Link</a>');
  111
+		$editor->setValue('<a href="[sitetree_link,id=0]">Broken Link</a>');
112 112
 
113 113
 		$element = new SimpleXMLElement(html_entity_decode((string) new SimpleXMLElement($editor->Field())));
114 114
 		$this->assertContains('ss-broken', (string) $element['class'], 'A broken link class is added to broken links');
115 115
 
116 116
 		$editor->setValue(sprintf (
117  
-			'<a href="[sitetree_link id=%d]">Working Link</a>',
  117
+			'<a href="[sitetree_link,id=%d]">Working Link</a>',
118 118
 			$this->idFromFixture('SiteTree', 'home')
119 119
 		));
120 120
 
10  tests/model/SiteTreeTest.php
@@ -587,8 +587,8 @@ public function testLinkShortcodeHandler() {
587 587
 		$parser = new ShortcodeParser();
588 588
 		$parser->register('sitetree_link', array('SiteTree', 'link_shortcode_handler'));
589 589
 		
590  
-		$aboutShortcode = sprintf('[sitetree_link id=%d]', $aboutPage->ID);
591  
-		$aboutEnclosed  = sprintf('[sitetree_link id=%d]Example Content[/sitetree_link]', $aboutPage->ID);
  590
+		$aboutShortcode = sprintf('[sitetree_link,id=%d]', $aboutPage->ID);
  591
+		$aboutEnclosed  = sprintf('[sitetree_link,id=%d]Example Content[/sitetree_link]', $aboutPage->ID);
592 592
 		
593 593
 		$aboutShortcodeExpected = $aboutPage->Link();
594 594
 		$aboutEnclosedExpected  = sprintf('<a href="%s">Example Content</a>', $aboutPage->Link());
@@ -601,8 +601,8 @@ public function testLinkShortcodeHandler() {
601 601
 		$this->assertEquals($aboutShortcodeExpected, $parser->parse($aboutShortcode), 'Test that deleted pages still link.');
602 602
 		$this->assertEquals($aboutEnclosedExpected, $parser->parse($aboutEnclosed));
603 603
 		
604  
-		$aboutShortcode = '[sitetree_link id="-1"]';
605  
-		$aboutEnclosed  = '[sitetree_link id="-1"]Example Content[/sitetree_link]';
  604
+		$aboutShortcode = '[sitetree_link,id="-1"]';
  605
+		$aboutEnclosed  = '[sitetree_link,id="-1"]Example Content[/sitetree_link]';
606 606
 		
607 607
 		$aboutShortcodeExpected = $errorPage->Link();
608 608
 		$aboutEnclosedExpected  = sprintf('<a href="%s">Example Content</a>', $errorPage->Link());
@@ -611,7 +611,7 @@ public function testLinkShortcodeHandler() {
611 611
 		$this->assertEquals($aboutEnclosedExpected, $parser->parse($aboutEnclosed));
612 612
 		
613 613
 		$this->assertEquals('', $parser->parse('[sitetree_link]'), 'Test that invalid ID attributes are not parsed.');
614  
-		$this->assertEquals('', $parser->parse('[sitetree_link id="text"]'));
  614
+		$this->assertEquals('', $parser->parse('[sitetree_link,id="text"]'));
615 615
 		$this->assertEquals('', $parser->parse('[sitetree_link]Example Content[/sitetree_link]'));
616 616
 	}
617 617
 	
10  tests/tasks/MigrateSiteTreeLinkingTaskTest.php
@@ -29,25 +29,25 @@ public function testLinkingMigration() {
29 29
 		$hashID   = $this->idFromFixture('SiteTree', 'hash_link');
30 30
 		
31 31
 		$homeContent = sprintf (
32  
-			'<a href="[sitetree_link id=%d]">About</a><a href="[sitetree_link id=%d]">Staff</a><a href="http://silverstripe.org/">External Link</a>',
  32
+			'<a href="[sitetree_link,id=%d]">About</a><a href="[sitetree_link,id=%d]">Staff</a><a href="http://silverstripe.org/">External Link</a>',
33 33
 			$aboutID,
34 34
 			$staffID
35 35
 		);
36 36
 		$aboutContent = sprintf (
37  
-			'<a href="[sitetree_link id=%d]">Home</a><a href="[sitetree_link id=%d]">Staff</a>',
  37
+			'<a href="[sitetree_link,id=%d]">Home</a><a href="[sitetree_link,id=%d]">Staff</a>',
38 38
 			$homeID,
39 39
 			$staffID
40 40
 		);
41 41
 		$staffContent = sprintf (
42  
-			'<a href="[sitetree_link id=%d]">Home</a><a href="[sitetree_link id=%d]">About</a>',
  42
+			'<a href="[sitetree_link,id=%d]">Home</a><a href="[sitetree_link,id=%d]">About</a>',
43 43
 			$homeID,
44 44
 			$aboutID
45 45
 		);
46 46
 		$actionContent = sprintf (
47  
-			'<a href="[sitetree_link id=%d]SearchForm">Search Form</a>', $homeID
  47
+			'<a href="[sitetree_link,id=%d]SearchForm">Search Form</a>', $homeID
48 48
 		);
49 49
 		$hashLinkContent = sprintf (
50  
-			'<a href="[sitetree_link id=%d]#anchor">Home</a><a href="[sitetree_link id=%d]#second-anchor">About</a>',
  50
+			'<a href="[sitetree_link,id=%d]#anchor">Home</a><a href="[sitetree_link,id=%d]#second-anchor">About</a>',
51 51
 			$homeID,
52 52
 			$aboutID
53 53
 		);

0 notes on commit 54fd54a

Please sign in to comment.
Something went wrong with that request. Please try again.