Allow fragments in link= parameter in <gallery> tags.
authorBrian Wolff <bawolff+wn@gmail.com>
Mon, 23 Jun 2014 20:45:41 +0000 (17:45 -0300)
committerBrian Wolff <bawolff+wn@gmail.com>
Mon, 23 Jun 2014 22:45:31 +0000 (19:45 -0300)
This brings the image syntax in gallery tags inline with normal
syntax. Handle <gallery>File:foo.png|link=bar#baz</gallery>
properly.

Bug: 62343
Change-Id: If6149ccc19f70605ad4481e4da2ca55676d6001d

includes/parser/Parser.php
tests/parser/parserTests.txt

index 236b999..61fd9cc 100644 (file)
@@ -5339,7 +5339,7 @@ class Parser {
                                                        } else {
                                                                $localLinkTitle = Title::newFromText( $linkValue );
                                                                if ( $localLinkTitle !== null ) {
-                                                                       $link = $localLinkTitle->getLocalURL();
+                                                                       $link = $localLinkTitle->getLinkURL();
                                                                }
                                                        }
                                                        break;
index c447a44..b3e9c51 100644 (file)
@@ -15134,6 +15134,37 @@ image:foobar.jpg|Blabla|alt=This is a foo-bar.|blabla.
 
 !! end
 
+!! test
+Gallery with link that has fragment
+!! wikitext
+<gallery>
+image:foobar.jpg|link=Main_Page
+image:foobar.jpg|link=Main_Page#section
+image:foobar.jpg|link=Main Page#section|caption
+</gallery>
+!! html
+<ul class="gallery mw-gallery-traditional">
+               <li class="gallerybox" style="width: 155px"><div style="width: 155px">
+                       <div class="thumb" style="width: 150px;"><div style="margin:68px auto;"><a href="/wiki/Main_Page"><img alt="Foobar.jpg" src="http://example.com/images/thumb/3/3a/Foobar.jpg/120px-Foobar.jpg" width="120" height="14" /></a></div></div>
+                       <div class="gallerytext">
+                       </div>
+               </div></li>
+               <li class="gallerybox" style="width: 155px"><div style="width: 155px">
+                       <div class="thumb" style="width: 150px;"><div style="margin:68px auto;"><a href="/wiki/Main_Page#section"><img alt="Foobar.jpg" src="http://example.com/images/thumb/3/3a/Foobar.jpg/120px-Foobar.jpg" width="120" height="14" /></a></div></div>
+                       <div class="gallerytext">
+                       </div>
+               </div></li>
+               <li class="gallerybox" style="width: 155px"><div style="width: 155px">
+                       <div class="thumb" style="width: 150px;"><div style="margin:68px auto;"><a href="/wiki/Main_Page#section"><img alt="" src="http://example.com/images/thumb/3/3a/Foobar.jpg/120px-Foobar.jpg" width="120" height="14" /></a></div></div>
+                       <div class="gallerytext">
+<p>caption
+</p>
+                       </div>
+               </div></li>
+</ul>
+
+!! end
+
 !! test
 Gallery with wikitext inside caption
 !! wikitext