Index: trunk/phase3/tests/parser/parserTests.txt |
— | — | @@ -7312,7 +7312,6 @@ |
7313 | 7313 | File:Nonexistant.jpg |
7314 | 7314 | image:foobar.jpg|some '''caption''' [[Main Page]] |
7315 | 7315 | image:foobar.jpg |
7316 | | -image:foobar.jpg|Blabla|alt= This is a foo-bar.|blabla. |
7317 | 7316 | </gallery> |
7318 | 7317 | !! result |
7319 | 7318 | <ul class="gallery" style="max-width: 202px;_width: 202px;"> |
— | — | @@ -7341,13 +7340,6 @@ |
7342 | 7341 | <div class="gallerytext"> |
7343 | 7342 | </div> |
7344 | 7343 | </div></li> |
7345 | | - <li class="gallerybox" style="width: 95px"><div style="width: 95px"> |
7346 | | - <div class="thumb" style="width: 90px;"><div style="margin:26px auto;"><a href="https://www.mediawiki.org/wiki/File:Foobar.jpg" class="image"><img alt="This is a foo-bar." src="http://example.com/images/3/3a/Foobar.jpg" width="60" height="7" /></a></div></div> |
7347 | | - <div class="gallerytext"> |
7348 | | -<p>Blabla|blabla. |
7349 | | -</p> |
7350 | | - </div> |
7351 | | - </div></li> |
7352 | 7344 | </ul> |
7353 | 7345 | |
7354 | 7346 | !! end |
— | — | @@ -7433,6 +7425,17 @@ |
7434 | 7426 | !! end |
7435 | 7427 | |
7436 | 7428 | !! test |
| 7429 | +Gallery with wikitext inside caption |
| 7430 | +!! input |
| 7431 | +<gallery> |
| 7432 | +File:Wiki.png|[[File:Wiki.png|20px|desc|alt=inneralt]]|alt=galleryalt |
| 7433 | +File:Wiki.png|{{tl|test|alt=param}}|alt=galleryalt |
| 7434 | +</gallery> |
| 7435 | +!! result |
| 7436 | + |
| 7437 | +!! end |
| 7438 | + |
| 7439 | +!! test |
7437 | 7440 | HTML Hex character encoding (spells the word "JavaScript") |
7438 | 7441 | !! input |
7439 | 7442 | JavaScript |
Index: trunk/phase3/includes/parser/Parser.php |
— | — | @@ -4733,37 +4733,21 @@ |
4734 | 4734 | if ( strpos( $matches[0], '%' ) !== false ) { |
4735 | 4735 | $matches[1] = rawurldecode( $matches[1] ); |
4736 | 4736 | } |
4737 | | - $title = Title::newFromText( $matches[1], NS_FILE ); |
4738 | | - if ( is_null( $title ) ) { |
| 4737 | + $tp = Title::newFromText( $matches[1], NS_FILE ); |
| 4738 | + $nt =& $tp; |
| 4739 | + if ( is_null( $nt ) ) { |
4739 | 4740 | # Bogus title. Ignore these so we don't bomb out later. |
4740 | 4741 | continue; |
4741 | 4742 | } |
4742 | | - |
4743 | | - $label = ''; |
4744 | | - $alt = ''; |
4745 | 4743 | if ( isset( $matches[3] ) ) { |
4746 | | - // look for an |alt= definition while trying not to break existing |
4747 | | - // captions with multiple pipes (|) in it, until a more sensible grammar |
4748 | | - // is defined for images in galleries |
4749 | | - |
4750 | | - $altmatches = StringUtils::explode('|', $matches[3]); |
4751 | | - |
4752 | | - foreach ( $altmatches as $altmatch ) { |
4753 | | - if ( substr( $altmatch, 0, 4 ) === 'alt=' ) { |
4754 | | - $alt = $this->stripAltText( trim( substr( $altmatch, 4 ) ), false ); |
4755 | | - } |
4756 | | - else { |
4757 | | - // concatenate all other pipes |
4758 | | - $label .= '|' . $altmatch; |
4759 | | - } |
4760 | | - } |
4761 | | - // remove the first pipe |
4762 | | - $label = substr( $label, 1 ); |
| 4744 | + $label = $matches[3]; |
| 4745 | + } else { |
| 4746 | + $label = ''; |
4763 | 4747 | } |
4764 | 4748 | |
4765 | 4749 | $html = $this->recursiveTagParse( trim( $label ) ); |
4766 | 4750 | |
4767 | | - $ig->add( $title, $html, $alt ); |
| 4751 | + $ig->add( $nt, $html ); |
4768 | 4752 | } |
4769 | 4753 | return $ig->toHTML(); |
4770 | 4754 | } |
Index: trunk/phase3/includes/ImageGallery.php |
— | — | @@ -136,15 +136,14 @@ |
137 | 137 | * Add an image to the gallery. |
138 | 138 | * |
139 | 139 | * @param $title Title object of the image that is added to the gallery |
140 | | - * @param $html String: Additional HTML text to be shown. The name and size of the image are always shown. |
141 | | - * @param $alt String: Alt text for the image |
| 140 | + * @param $html String: additional HTML text to be shown. The name and size of the image are always shown. |
142 | 141 | */ |
143 | | - function add( $title, $html = '', $alt = '' ) { |
| 142 | + function add( $title, $html='' ) { |
144 | 143 | if ( $title instanceof File ) { |
145 | 144 | // Old calling convention |
146 | 145 | $title = $title->getTitle(); |
147 | 146 | } |
148 | | - $this->mImages[] = array( $title, $html, $alt ); |
| 147 | + $this->mImages[] = array( $title, $html ); |
149 | 148 | wfDebug( "ImageGallery::add " . $title->getText() . "\n" ); |
150 | 149 | } |
151 | 150 | |
— | — | @@ -152,15 +151,14 @@ |
153 | 152 | * Add an image at the beginning of the gallery. |
154 | 153 | * |
155 | 154 | * @param $title Title object of the image that is added to the gallery |
156 | | - * @param $html String: Additional HTML text to be shown. The name and size of the image are always shown. |
157 | | - * @param $alt String: Alt text for the image |
| 155 | + * @param $html String: Additional HTML text to be shown. The name and size of the image are always shown. |
158 | 156 | */ |
159 | | - function insert( $title, $html='', $alt='' ) { |
| 157 | + function insert( $title, $html='' ) { |
160 | 158 | if ( $title instanceof File ) { |
161 | 159 | // Old calling convention |
162 | 160 | $title = $title->getTitle(); |
163 | 161 | } |
164 | | - array_unshift( $this->mImages, array( &$title, $html, $alt ) ); |
| 162 | + array_unshift( $this->mImages, array( &$title, $html ) ); |
165 | 163 | } |
166 | 164 | |
167 | 165 | |
— | — | @@ -220,16 +218,15 @@ |
221 | 219 | if ( $this->mPerRow > 0 ) { |
222 | 220 | $maxwidth = $this->mPerRow * ( $this->mWidths + self::THUMB_PADDING + self::GB_PADDING + self::GB_BORDERS ); |
223 | 221 | $oldStyle = isset( $this->mAttribs['style'] ) ? $this->mAttribs['style'] : ""; |
224 | | - # _width is ignored by any sane browser. IE6 doesn't know max-width so it uses _width instead |
225 | 222 | $this->mAttribs['style'] = "max-width: {$maxwidth}px;_width: {$maxwidth}px;" . $oldStyle; |
226 | 223 | } |
227 | 224 | |
228 | 225 | $attribs = Sanitizer::mergeAttributes( |
229 | 226 | array( 'class' => 'gallery' ), $this->mAttribs ); |
230 | 227 | |
231 | | - $output = Xml::openElement( 'ul', $attribs ); |
| 228 | + $s = Xml::openElement( 'ul', $attribs ); |
232 | 229 | if ( $this->mCaption ) { |
233 | | - $output .= "\n\t<li class='gallerycaption'>{$this->mCaption}</li>"; |
| 230 | + $s .= "\n\t<li class='gallerycaption'>{$this->mCaption}</li>"; |
234 | 231 | } |
235 | 232 | |
236 | 233 | $params = array( 'width' => $this->mWidths, 'height' => $this->mHeights ); |
— | — | @@ -237,7 +234,6 @@ |
238 | 235 | foreach ( $this->mImages as $pair ) { |
239 | 236 | $nt = $pair[0]; |
240 | 237 | $text = $pair[1]; # "text" means "caption" here |
241 | | - $alt = $pair[2]; |
242 | 238 | |
243 | 239 | $descQuery = false; |
244 | 240 | if ( $nt->getNamespace() == NS_FILE ) { |
— | — | @@ -276,19 +272,18 @@ |
277 | 273 | $thumbhtml = "\n\t\t\t".'<div style="height: '.(self::THUMB_PADDING + $this->mHeights).'px;">' |
278 | 274 | . htmlspecialchars( $img->getLastError() ) . '</div>'; |
279 | 275 | } else { |
280 | | - # We get layout problems with the margin, if the image is smaller |
281 | | - # than the line-height (17), so we add less margin in these cases. |
| 276 | + //We get layout problems with the margin, if the image is smaller |
| 277 | + //than the line-height, so we less margin in these cases. |
282 | 278 | $minThumbHeight = $thumb->height > 17 ? $thumb->height : 17; |
283 | 279 | $vpad = floor(( self::THUMB_PADDING + $this->mHeights - $minThumbHeight ) /2); |
284 | 280 | |
285 | 281 | |
286 | 282 | $imageParameters = array( |
287 | 283 | 'desc-link' => true, |
288 | | - 'desc-query' => $descQuery, |
289 | | - 'alt' => $alt, |
| 284 | + 'desc-query' => $descQuery |
290 | 285 | ); |
291 | | - # In the absence of both alt text and caption, fall back on providing screen readers with the filename as alt text |
292 | | - if ( $alt == '' && $text == '' ) { |
| 286 | + # In the absence of a caption, fall back on providing screen readers with the filename as alt text |
| 287 | + if ( $text == '' ) { |
293 | 288 | $imageParameters['alt'] = $nt->getText(); |
294 | 289 | } |
295 | 290 | |
— | — | @@ -313,14 +308,14 @@ |
314 | 309 | |
315 | 310 | if( $this->mShowBytes ) { |
316 | 311 | if( $img ) { |
317 | | - $fileSize = wfMsgExt( 'nbytes', array( 'parsemag', 'escape'), |
| 312 | + $nb = wfMsgExt( 'nbytes', array( 'parsemag', 'escape'), |
318 | 313 | $wgLang->formatNum( $img->getSize() ) ); |
319 | 314 | } else { |
320 | | - $fileSize = wfMsgHtml( 'filemissing' ); |
| 315 | + $nb = wfMsgHtml( 'filemissing' ); |
321 | 316 | } |
322 | | - $fileSize = "$fileSize<br />\n"; |
| 317 | + $nb = "$nb<br />\n"; |
323 | 318 | } else { |
324 | | - $fileSize = ''; |
| 319 | + $nb = ''; |
325 | 320 | } |
326 | 321 | |
327 | 322 | $textlink = $this->mShowFilename ? |
— | — | @@ -337,20 +332,20 @@ |
338 | 333 | # in version 4.8.6 generated crackpot html in its absence, see: |
339 | 334 | # http://bugzilla.wikimedia.org/show_bug.cgi?id=1765 -Ævar |
340 | 335 | |
341 | | - # Weird double wrapping (the extra div inside the li) needed due to FF2 bug |
| 336 | + # Weird double wrapping in div needed due to FF2 bug |
342 | 337 | # Can be safely removed if FF2 falls completely out of existance |
343 | | - $output .= |
| 338 | + $s .= |
344 | 339 | "\n\t\t" . '<li class="gallerybox" style="width: ' . ( $this->mWidths + self::THUMB_PADDING + self::GB_PADDING ) . 'px">' |
345 | 340 | . '<div style="width: ' . ( $this->mWidths + self::THUMB_PADDING + self::GB_PADDING ) . 'px">' |
346 | 341 | . $thumbhtml |
347 | 342 | . "\n\t\t\t" . '<div class="gallerytext">' . "\n" |
348 | | - . $textlink . $text . $fileSize |
| 343 | + . $textlink . $text . $nb |
349 | 344 | . "\n\t\t\t</div>" |
350 | 345 | . "\n\t\t</div></li>"; |
351 | 346 | } |
352 | | - $output .= "\n</ul>"; |
| 347 | + $s .= "\n</ul>"; |
353 | 348 | |
354 | | - return $output; |
| 349 | + return $s; |
355 | 350 | } |
356 | 351 | |
357 | 352 | /** |