r25335 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r25334‎ | r25335 | r25336 >
Date:02:51, 31 August 2007
Author:tstarling
Status:old
Tags:
Comment:
In OggHandler:
* Changed display style: added a "more" link which expands a box for player selection.
* Allow return to the still image only display.
* Fixed Java detection in IE (I hope)

Elsewhere:
* Changed MediaTransformOutput::toHtml() parameters, now accepts a single associative array with well-defined elements. Allows OggHandler to distinguish between file download links and image description links.
* Made image links consistently have an anchor tag with class=image, instead of a mixture of image and internalParse.
* Made most images have a border=0 attribute, instead of just images on the image description page. Does not appear to adversely affect display at all, it was just convenient.
* Use the image name as the title attribute for the <a> tag, when an a caption was not given by the user
* Block centering by the auto margins method in ImageGallery
* Fixed complete breakage of the thumbnail on upload conflict feature
* TODO: test DjVu
Modified paths:
  • /trunk/extensions/OggHandler/OggHandler.i18n.php (modified) (history)
  • /trunk/extensions/OggHandler/OggHandler_body.php (modified) (history)
  • /trunk/extensions/OggHandler/OggPlayer.js (modified) (history)
  • /trunk/phase3/includes/ImageGallery.php (modified) (history)
  • /trunk/phase3/includes/ImagePage.php (modified) (history)
  • /trunk/phase3/includes/Linker.php (modified) (history)
  • /trunk/phase3/includes/MediaTransformOutput.php (modified) (history)
  • /trunk/phase3/includes/SpecialUpload.php (modified) (history)
  • /trunk/phase3/includes/filerepo/File.php (modified) (history)
  • /trunk/phase3/includes/media/Bitmap.php (modified) (history)
  • /trunk/phase3/includes/media/DjVu.php (modified) (history)
  • /trunk/phase3/includes/media/Generic.php (modified) (history)
  • /trunk/phase3/includes/media/SVG.php (modified) (history)
  • /trunk/phase3/maintenance/parserTests.txt (modified) (history)

Diff [purge]

Index: trunk/phase3/maintenance/parserTests.txt
@@ -2946,7 +2946,7 @@
29472947 !! input
29482948 [[Image:foobar.jpg]]
29492949 !! result
2950 -<p><a href="https://www.mediawiki.org/wiki/Image:Foobar.jpg" class="image" title="Image:foobar.jpg"><img alt="Image:foobar.jpg" longdesc="/wiki/Image:Foobar.jpg" src="http://example.com/images/3/3a/Foobar.jpg" width="1941" height="220" /></a>
 2950+<p><a href="https://www.mediawiki.org/wiki/Image:Foobar.jpg" class="image" title="Image:foobar.jpg"><img alt="Image:foobar.jpg" src="http://example.com/images/3/3a/Foobar.jpg" width="1941" height="220" border="0" /></a>
29512951 </p>
29522952 !! end
29532953
@@ -2955,7 +2955,7 @@
29562956 !! input
29572957 [[Image:foobar.jpg|right]]
29582958 !! result
2959 -<div class="floatright"><span><a href="https://www.mediawiki.org/wiki/Image:Foobar.jpg" class="image" title=""><img alt="" longdesc="/wiki/Image:Foobar.jpg" src="http://example.com/images/3/3a/Foobar.jpg" width="1941" height="220" /></a></span></div>
 2959+<div class="floatright"><span><a href="https://www.mediawiki.org/wiki/Image:Foobar.jpg" class="image" title="Foobar.jpg"><img alt="" src="http://example.com/images/3/3a/Foobar.jpg" width="1941" height="220" border="0" /></a></span></div>
29602960
29612961 !! end
29622962
@@ -2964,7 +2964,7 @@
29652965 !! input
29662966 [[Image:foobar.jpg|right|Caption text]]
29672967 !! result
2968 -<div class="floatright"><span><a href="https://www.mediawiki.org/wiki/Image:Foobar.jpg" class="image" title="Caption text"><img alt="Caption text" longdesc="/wiki/Image:Foobar.jpg" src="http://example.com/images/3/3a/Foobar.jpg" width="1941" height="220" /></a></span></div>
 2968+<div class="floatright"><span><a href="https://www.mediawiki.org/wiki/Image:Foobar.jpg" class="image" title="Caption text"><img alt="Caption text" src="http://example.com/images/3/3a/Foobar.jpg" width="1941" height="220" border="0" /></a></span></div>
29692969
29702970 !! end
29712971
@@ -2973,7 +2973,7 @@
29742974 !! input
29752975 [[Image:Foobar.jpg|frame|left|This is a test image [[Main Page]]]]
29762976 !! result
2977 -<div class="thumb tleft"><div class="thumbinner" style="width:1943px;"><a href="https://www.mediawiki.org/wiki/Image:Foobar.jpg" class="internal" title="This is a test image Main Page"><img alt="This is a test image Main Page" longdesc="/wiki/Image:Foobar.jpg" class="thumbimage" src="http://example.com/images/3/3a/Foobar.jpg" width="1941" height="220" /></a> <div class="thumbcaption">This is a test image <a href="https://www.mediawiki.org/wiki/Main_Page" title="Main Page">Main Page</a></div></div></div>
 2977+<div class="thumb tleft"><div class="thumbinner" style="width:1943px;"><a href="https://www.mediawiki.org/wiki/Image:Foobar.jpg" class="image" title="This is a test image Main Page"><img alt="This is a test image Main Page" src="http://example.com/images/3/3a/Foobar.jpg" width="1941" height="220" border="0" class="thumbimage" /></a> <div class="thumbcaption">This is a test image <a href="https://www.mediawiki.org/wiki/Main_Page" title="Main Page">Main Page</a></div></div></div>
29782978
29792979 !! end
29802980
@@ -2993,7 +2993,7 @@
29942994 !! input
29952995 [[Image:foobar.jpg|http://example.com]]
29962996 !! result
2997 -<p><a href="https://www.mediawiki.org/wiki/Image:Foobar.jpg" class="image" title="http://example.com"><img alt="http://example.com" longdesc="/wiki/Image:Foobar.jpg" src="http://example.com/images/3/3a/Foobar.jpg" width="1941" height="220" /></a>
 2997+<p><a href="https://www.mediawiki.org/wiki/Image:Foobar.jpg" class="image" title="http://example.com"><img alt="http://example.com" src="http://example.com/images/3/3a/Foobar.jpg" width="1941" height="220" border="0" /></a>
29982998 </p>
29992999 !! end
30003000
@@ -3002,7 +3002,7 @@
30033003 !! input
30043004 [[Image:foobar.jpg|thumb|http://example.com]]
30053005 !! result
3006 -<div class="thumb tright"><div class="thumbinner" style="width:182px;"><a href="https://www.mediawiki.org/wiki/Image:Foobar.jpg" class="internal" title="http://example.com"><img alt="http://example.com" longdesc="/wiki/Image:Foobar.jpg" class="thumbimage" src="http://example.com/images/thumb/3/3a/Foobar.jpg/180px-Foobar.jpg" width="180" height="20" /></a> <div class="thumbcaption"><div class="magnify" style="float:right"><a href="https://www.mediawiki.org/wiki/Image:Foobar.jpg" class="internal" title="Enlarge"><img src="/skins/common/images/magnify-clip.png" width="15" height="11" alt="" /></a></div><a href="http://example.com" class="external free" title="http://example.com" rel="nofollow">http://example.com</a></div></div></div>
 3006+<div class="thumb tright"><div class="thumbinner" style="width:182px;"><a href="https://www.mediawiki.org/wiki/Image:Foobar.jpg" class="image" title="http://example.com"><img alt="http://example.com" src="http://example.com/images/thumb/3/3a/Foobar.jpg/180px-Foobar.jpg" width="180" height="20" border="0" class="thumbimage" /></a> <div class="thumbcaption"><div class="magnify" style="float:right"><a href="https://www.mediawiki.org/wiki/Image:Foobar.jpg" class="internal" title="Enlarge"><img src="/skins/common/images/magnify-clip.png" width="15" height="11" alt="" /></a></div><a href="http://example.com" class="external free" title="http://example.com" rel="nofollow">http://example.com</a></div></div></div>
30073007
30083008 !! end
30093009
@@ -3011,7 +3011,7 @@
30123012 !! input
30133013 [[Image:foobar.jpg|thumb|ISBN 1235467890]]
30143014 !! result
3015 -<div class="thumb tright"><div class="thumbinner" style="width:182px;"><a href="https://www.mediawiki.org/wiki/Image:Foobar.jpg" class="internal" title="ISBN 1235467890"><img alt="ISBN 1235467890" longdesc="/wiki/Image:Foobar.jpg" class="thumbimage" src="http://example.com/images/thumb/3/3a/Foobar.jpg/180px-Foobar.jpg" width="180" height="20" /></a> <div class="thumbcaption"><div class="magnify" style="float:right"><a href="https://www.mediawiki.org/wiki/Image:Foobar.jpg" class="internal" title="Enlarge"><img src="/skins/common/images/magnify-clip.png" width="15" height="11" alt="" /></a></div><a href="https://www.mediawiki.org/index.php?title=Special:Booksources&amp;isbn=1235467890" class="internal">ISBN 1235467890</a></div></div></div>
 3015+<div class="thumb tright"><div class="thumbinner" style="width:182px;"><a href="https://www.mediawiki.org/wiki/Image:Foobar.jpg" class="image" title="ISBN 1235467890"><img alt="ISBN 1235467890" src="http://example.com/images/thumb/3/3a/Foobar.jpg/180px-Foobar.jpg" width="180" height="20" border="0" class="thumbimage" /></a> <div class="thumbcaption"><div class="magnify" style="float:right"><a href="https://www.mediawiki.org/wiki/Image:Foobar.jpg" class="internal" title="Enlarge"><img src="/skins/common/images/magnify-clip.png" width="15" height="11" alt="" /></a></div><a href="https://www.mediawiki.org/index.php?title=Special:Booksources&amp;isbn=1235467890" class="internal">ISBN 1235467890</a></div></div></div>
30163016
30173017 !! end
30183018
@@ -3020,7 +3020,7 @@
30213021 !! input
30223022 [[Image:foobar.jpg|thumb|This is RFC 12354]]
30233023 !! result
3024 -<div class="thumb tright"><div class="thumbinner" style="width:182px;"><a href="https://www.mediawiki.org/wiki/Image:Foobar.jpg" class="internal" title="This is RFC 12354"><img alt="This is RFC 12354" longdesc="/wiki/Image:Foobar.jpg" class="thumbimage" src="http://example.com/images/thumb/3/3a/Foobar.jpg/180px-Foobar.jpg" width="180" height="20" /></a> <div class="thumbcaption"><div class="magnify" style="float:right"><a href="https://www.mediawiki.org/wiki/Image:Foobar.jpg" class="internal" title="Enlarge"><img src="/skins/common/images/magnify-clip.png" width="15" height="11" alt="" /></a></div>This is <a href="http://tools.ietf.org/html/rfc12354" class="external" title="http://tools.ietf.org/html/rfc12354">RFC 12354</a></div></div></div>
 3024+<div class="thumb tright"><div class="thumbinner" style="width:182px;"><a href="https://www.mediawiki.org/wiki/Image:Foobar.jpg" class="image" title="This is RFC 12354"><img alt="This is RFC 12354" src="http://example.com/images/thumb/3/3a/Foobar.jpg/180px-Foobar.jpg" width="180" height="20" border="0" class="thumbimage" /></a> <div class="thumbcaption"><div class="magnify" style="float:right"><a href="https://www.mediawiki.org/wiki/Image:Foobar.jpg" class="internal" title="Enlarge"><img src="/skins/common/images/magnify-clip.png" width="15" height="11" alt="" /></a></div>This is <a href="http://tools.ietf.org/html/rfc12354" class="external" title="http://tools.ietf.org/html/rfc12354">RFC 12354</a></div></div></div>
30253025
30263026 !! end
30273027
@@ -3029,7 +3029,7 @@
30303030 !! input
30313031 [[Image:foobar.jpg|thumb|Please mailto:nobody@example.com]]
30323032 !! result
3033 -<div class="thumb tright"><div class="thumbinner" style="width:182px;"><a href="https://www.mediawiki.org/wiki/Image:Foobar.jpg" class="internal" title="Please mailto:nobody@example.com"><img alt="Please mailto:nobody@example.com" longdesc="/wiki/Image:Foobar.jpg" class="thumbimage" src="http://example.com/images/thumb/3/3a/Foobar.jpg/180px-Foobar.jpg" width="180" height="20" /></a> <div class="thumbcaption"><div class="magnify" style="float:right"><a href="https://www.mediawiki.org/wiki/Image:Foobar.jpg" class="internal" title="Enlarge"><img src="/skins/common/images/magnify-clip.png" width="15" height="11" alt="" /></a></div>Please <a href="mailto:nobody@example.com" class="external free" title="mailto:nobody@example.com" rel="nofollow">mailto:nobody@example.com</a></div></div></div>
 3033+<div class="thumb tright"><div class="thumbinner" style="width:182px;"><a href="https://www.mediawiki.org/wiki/Image:Foobar.jpg" class="image" title="Please mailto:nobody@example.com"><img alt="Please mailto:nobody@example.com" src="http://example.com/images/thumb/3/3a/Foobar.jpg/180px-Foobar.jpg" width="180" height="20" border="0" class="thumbimage" /></a> <div class="thumbcaption"><div class="magnify" style="float:right"><a href="https://www.mediawiki.org/wiki/Image:Foobar.jpg" class="internal" title="Enlarge"><img src="/skins/common/images/magnify-clip.png" width="15" height="11" alt="" /></a></div>Please <a href="mailto:nobody@example.com" class="external free" title="mailto:nobody@example.com" rel="nofollow">mailto:nobody@example.com</a></div></div></div>
30343034
30353035 !! end
30363036
@@ -3039,7 +3039,7 @@
30403040 !! input
30413041 [[Image:foobar.jpg|thumb|<math>2+2</math>]]
30423042 !! result
3043 -<div class="thumb tright"><div class="thumbinner" style="width:182px;"><a href="https://www.mediawiki.org/wiki/Image:Foobar.jpg" class="internal" title="&lt;math&gt;2+2&lt;/math&gt;"><img alt="&lt;math&gt;2+2&lt;/math&gt;" longdesc="/wiki/Image:Foobar.jpg" class="thumbimage" src="http://example.com/images/thumb/3/3a/Foobar.jpg/180px-Foobar.jpg" width="180" height="20" /></a> <div class="thumbcaption"><div class="magnify" style="float:right"><a href="https://www.mediawiki.org/wiki/Image:Foobar.jpg" class="internal" title="Enlarge"><img src="/skins/common/images/magnify-clip.png" width="15" height="11" alt="" /></a></div>&lt;math&gt;2+2&lt;/math&gt;</div></div></div>
 3043+<div class="thumb tright"><div class="thumbinner" style="width:182px;"><a href="https://www.mediawiki.org/wiki/Image:Foobar.jpg" class="image" title="&lt;math&gt;2+2&lt;/math&gt;"><img alt="&lt;math&gt;2+2&lt;/math&gt;" src="http://example.com/images/thumb/3/3a/Foobar.jpg/180px-Foobar.jpg" width="180" height="20" border="0" class="thumbimage" /></a> <div class="thumbcaption"><div class="magnify" style="float:right"><a href="https://www.mediawiki.org/wiki/Image:Foobar.jpg" class="internal" title="Enlarge"><img src="/skins/common/images/magnify-clip.png" width="15" height="11" alt="" /></a></div>&lt;math&gt;2+2&lt;/math&gt;</div></div></div>
30443044
30453045 !! end
30463046
@@ -3050,7 +3050,7 @@
30513051 !! input
30523052 [[Image:foobar.jpg|thumb|<math>2+2</math>]]
30533053 !! result
3054 -<div class="thumb tright"><div class="thumbinner" style="width:182px;"><a href="https://www.mediawiki.org/wiki/Image:Foobar.jpg" class="internal" title="2 + 2"><img alt="2 + 2" longdesc="/wiki/Image:Foobar.jpg" class="thumbimage" src="http://example.com/images/thumb/3/3a/Foobar.jpg/180px-Foobar.jpg" width="180" height="20" /></a> <div class="thumbcaption"><div class="magnify" style="float:right"><a href="https://www.mediawiki.org/wiki/Image:Foobar.jpg" class="internal" title="Enlarge"><img src="/skins/common/images/magnify-clip.png" width="15" height="11" alt="" /></a></div><span class="texhtml">2 + 2</span></div></div></div>
 3054+<div class="thumb tright"><div class="thumbinner" style="width:182px;"><a href="https://www.mediawiki.org/wiki/Image:Foobar.jpg" class="image" title="2 + 2"><img alt="2 + 2" src="http://example.com/images/thumb/3/3a/Foobar.jpg/180px-Foobar.jpg" width="180" height="20" border="0" class="thumbimage" /></a> <div class="thumbcaption"><div class="magnify" style="float:right"><a href="https://www.mediawiki.org/wiki/Image:Foobar.jpg" class="internal" title="Enlarge"><img src="/skins/common/images/magnify-clip.png" width="15" height="11" alt="" /></a></div><span class="texhtml">2 + 2</span></div></div></div>
30553055
30563056 !! end
30573057
@@ -3060,7 +3060,7 @@
30613061 !! input
30623062 [[Image:foobar.jpg|text with a [[link]] in it]]
30633063 !! result
3064 -<p><a href="https://www.mediawiki.org/wiki/Image:Foobar.jpg" class="image" title="text with a link in it"><img alt="text with a link in it" longdesc="/wiki/Image:Foobar.jpg" src="http://example.com/images/3/3a/Foobar.jpg" width="1941" height="220" /></a>
 3064+<p><a href="https://www.mediawiki.org/wiki/Image:Foobar.jpg" class="image" title="text with a link in it"><img alt="text with a link in it" src="http://example.com/images/3/3a/Foobar.jpg" width="1941" height="220" border="0" /></a>
30653065 </p>
30663066 !! end
30673067
@@ -3069,7 +3069,7 @@
30703070 !! input
30713071 [[Image:foobar.jpg|text with a [[link]]foo in it]]
30723072 !! result
3073 -<p><a href="https://www.mediawiki.org/wiki/Image:Foobar.jpg" class="image" title="text with a linkfoo in it"><img alt="text with a linkfoo in it" longdesc="/wiki/Image:Foobar.jpg" src="http://example.com/images/3/3a/Foobar.jpg" width="1941" height="220" /></a>
 3073+<p><a href="https://www.mediawiki.org/wiki/Image:Foobar.jpg" class="image" title="text with a linkfoo in it"><img alt="text with a linkfoo in it" src="http://example.com/images/3/3a/Foobar.jpg" width="1941" height="220" border="0" /></a>
30743074 </p>
30753075 !! end
30763076
@@ -3078,7 +3078,7 @@
30793079 !! input
30803080 [[Image:foobar.jpg|text with a [[MeatBall:Link]] in it]]
30813081 !! result
3082 -<p><a href="https://www.mediawiki.org/wiki/Image:Foobar.jpg" class="image" title="text with a MeatBall:Link in it"><img alt="text with a MeatBall:Link in it" longdesc="/wiki/Image:Foobar.jpg" src="http://example.com/images/3/3a/Foobar.jpg" width="1941" height="220" /></a>
 3082+<p><a href="https://www.mediawiki.org/wiki/Image:Foobar.jpg" class="image" title="text with a MeatBall:Link in it"><img alt="text with a MeatBall:Link in it" src="http://example.com/images/3/3a/Foobar.jpg" width="1941" height="220" border="0" /></a>
30833083 </p>
30843084 !! end
30853085
@@ -3087,7 +3087,7 @@
30883088 !! input
30893089 [[Image:foobar.jpg|text with a [[MeatBall:Link|link]] in it]]
30903090 !! result
3091 -<p><a href="https://www.mediawiki.org/wiki/Image:Foobar.jpg" class="image" title="text with a link in it"><img alt="text with a link in it" longdesc="/wiki/Image:Foobar.jpg" src="http://example.com/images/3/3a/Foobar.jpg" width="1941" height="220" /></a>
 3091+<p><a href="https://www.mediawiki.org/wiki/Image:Foobar.jpg" class="image" title="text with a link in it"><img alt="text with a link in it" src="http://example.com/images/3/3a/Foobar.jpg" width="1941" height="220" border="0" /></a>
30923092 </p>
30933093 !! end
30943094
@@ -3096,7 +3096,7 @@
30973097 !! input
30983098 [[Image:foobar.jpg|& < > "]]
30993099 !! result
3100 -<p><a href="https://www.mediawiki.org/wiki/Image:Foobar.jpg" class="image" title="&amp; &lt; &gt; &quot;"><img alt="&amp; &lt; &gt; &quot;" longdesc="/wiki/Image:Foobar.jpg" src="http://example.com/images/3/3a/Foobar.jpg" width="1941" height="220" /></a>
 3100+<p><a href="https://www.mediawiki.org/wiki/Image:Foobar.jpg" class="image" title="&amp; &lt; &gt; &quot;"><img alt="&amp; &lt; &gt; &quot;" src="http://example.com/images/3/3a/Foobar.jpg" width="1941" height="220" border="0" /></a>
31013101 </p>
31023102 !! end
31033103
@@ -3105,7 +3105,7 @@
31063106 !! input
31073107 [[Image:foobar.jpg|&#9792;]]
31083108 !! result
3109 -<p><a href="https://www.mediawiki.org/wiki/Image:Foobar.jpg" class="image" title="♀"><img alt="♀" longdesc="/wiki/Image:Foobar.jpg" src="http://example.com/images/3/3a/Foobar.jpg" width="1941" height="220" /></a>
 3109+<p><a href="https://www.mediawiki.org/wiki/Image:Foobar.jpg" class="image" title="♀"><img alt="♀" src="http://example.com/images/3/3a/Foobar.jpg" width="1941" height="220" border="0" /></a>
31103110 </p>
31113111 !! end
31123112
@@ -3123,7 +3123,7 @@
31243124 !! input
31253125 [[Image:Foobar.jpg|thumb|This is a caption with another [[Image:icon.png|image]] inside it!]]
31263126 !! result
3127 -<div class="thumb tright"><div class="thumbinner" style="width:182px;"><a href="https://www.mediawiki.org/wiki/Image:Foobar.jpg" class="internal" title="This is a caption with another Image:Icon.png inside it!"><img alt="This is a caption with another Image:Icon.png inside it!" longdesc="/wiki/Image:Foobar.jpg" class="thumbimage" src="http://example.com/images/thumb/3/3a/Foobar.jpg/180px-Foobar.jpg" width="180" height="20" /></a> <div class="thumbcaption"><div class="magnify" style="float:right"><a href="https://www.mediawiki.org/wiki/Image:Foobar.jpg" class="internal" title="Enlarge"><img src="/skins/common/images/magnify-clip.png" width="15" height="11" alt="" /></a></div>This is a caption with another <a href="https://www.mediawiki.org/index.php?title=Special:Upload&amp;wpDestFile=Icon.png" class="new" title="Image:Icon.png">Image:Icon.png</a> inside it!</div></div></div>
 3127+<div class="thumb tright"><div class="thumbinner" style="width:182px;"><a href="https://www.mediawiki.org/wiki/Image:Foobar.jpg" class="image" title="This is a caption with another Image:Icon.png inside it!"><img alt="This is a caption with another Image:Icon.png inside it!" src="http://example.com/images/thumb/3/3a/Foobar.jpg/180px-Foobar.jpg" width="180" height="20" border="0" class="thumbimage" /></a> <div class="thumbcaption"><div class="magnify" style="float:right"><a href="https://www.mediawiki.org/wiki/Image:Foobar.jpg" class="internal" title="Enlarge"><img src="/skins/common/images/magnify-clip.png" width="15" height="11" alt="" /></a></div>This is a caption with another <a href="https://www.mediawiki.org/index.php?title=Special:Upload&amp;wpDestFile=Icon.png" class="new" title="Image:Icon.png">Image:Icon.png</a> inside it!</div></div></div>
31283128
31293129 !! end
31303130
@@ -3133,7 +3133,7 @@
31343134 [[Image:Foobar.jpg|This
31353135 *is some text]]
31363136 !! result
3137 -<p><a href="https://www.mediawiki.org/wiki/Image:Foobar.jpg" class="image" title="This *is some text"><img alt="This *is some text" longdesc="/wiki/Image:Foobar.jpg" src="http://example.com/images/3/3a/Foobar.jpg" width="1941" height="220" /></a>
 3137+<p><a href="https://www.mediawiki.org/wiki/Image:Foobar.jpg" class="image" title="This *is some text"><img alt="This *is some text" src="http://example.com/images/3/3a/Foobar.jpg" width="1941" height="220" border="0" /></a>
31383138 </p>
31393139 !!end
31403140
@@ -3143,7 +3143,7 @@
31443144 !! input
31453145 [[Image:Foobar.jpg|thumb|200px|This caption has [irc://example.net irc] and [https://example.com Secure] ext links in it.]]
31463146 !! result
3147 -<div class="thumb tright"><div class="thumbinner" style="width:202px;"><a href="https://www.mediawiki.org/wiki/Image:Foobar.jpg" class="internal" title="This caption has irc and Secure ext links in it."><img alt="This caption has irc and Secure ext links in it." longdesc="/wiki/Image:Foobar.jpg" class="thumbimage" src="http://example.com/images/thumb/3/3a/Foobar.jpg/200px-Foobar.jpg" width="200" height="23" /></a> <div class="thumbcaption"><div class="magnify" style="float:right"><a href="https://www.mediawiki.org/wiki/Image:Foobar.jpg" class="internal" title="Enlarge"><img src="/skins/common/images/magnify-clip.png" width="15" height="11" alt="" /></a></div>This caption has <a href="irc://example.net" class="external text" title="irc://example.net" rel="nofollow">irc</a> and <a href="https://example.com" class="external text" title="https://example.com" rel="nofollow">Secure</a> ext links in it.</div></div></div>
 3147+<div class="thumb tright"><div class="thumbinner" style="width:202px;"><a href="https://www.mediawiki.org/wiki/Image:Foobar.jpg" class="image" title="This caption has irc and Secure ext links in it."><img alt="This caption has irc and Secure ext links in it." src="http://example.com/images/thumb/3/3a/Foobar.jpg/200px-Foobar.jpg" width="200" height="23" border="0" class="thumbimage" /></a> <div class="thumbcaption"><div class="magnify" style="float:right"><a href="https://www.mediawiki.org/wiki/Image:Foobar.jpg" class="internal" title="Enlarge"><img src="/skins/common/images/magnify-clip.png" width="15" height="11" alt="" /></a></div>This caption has <a href="irc://example.net" class="external text" title="irc://example.net" rel="nofollow">irc</a> and <a href="https://example.com" class="external text" title="https://example.com" rel="nofollow">Secure</a> ext links in it.</div></div></div>
31483148
31493149 !! end
31503150
@@ -3503,7 +3503,7 @@
35043504 !! input
35053505 http://example.com [[Image:foobar.jpg]]
35063506 !! result
3507 -<p><a href="http://example.com" class="external free" title="http://example.com" rel="nofollow">http://example.com</a> <a href="https://www.mediawiki.org/wiki/Image:Foobar.jpg" class="image" title="Image:foobar.jpg"><img alt="Image:foobar.jpg" longdesc="/wiki/Image:Foobar.jpg" src="http://example.com/images/3/3a/Foobar.jpg" width="1941" height="220" /></a>
 3507+<p><a href="http://example.com" class="external free" title="http://example.com" rel="nofollow">http://example.com</a> <a href="https://www.mediawiki.org/wiki/Image:Foobar.jpg" class="image" title="Image:foobar.jpg"><img alt="Image:foobar.jpg" src="http://example.com/images/3/3a/Foobar.jpg" width="1941" height="220" border="0" /></a>
35083508 </p>
35093509 !!end
35103510
@@ -3512,7 +3512,7 @@
35133513 !! input
35143514 http://example.com[[Image:foobar.jpg]]
35153515 !! result
3516 -<p><a href="http://example.com" class="external free" title="http://example.com" rel="nofollow">http://example.com</a><a href="https://www.mediawiki.org/wiki/Image:Foobar.jpg" class="image" title="Image:foobar.jpg"><img alt="Image:foobar.jpg" longdesc="/wiki/Image:Foobar.jpg" src="http://example.com/images/3/3a/Foobar.jpg" width="1941" height="220" /></a>
 3516+<p><a href="http://example.com" class="external free" title="http://example.com" rel="nofollow">http://example.com</a><a href="https://www.mediawiki.org/wiki/Image:Foobar.jpg" class="image" title="Image:foobar.jpg"><img alt="Image:foobar.jpg" src="http://example.com/images/3/3a/Foobar.jpg" width="1941" height="220" border="0" /></a>
35173517 </p>
35183518 !!end
35193519
@@ -4787,7 +4787,7 @@
47884788 !!input
47894789 [[Image:foobar.jpg|thumbnail= ]]
47904790 !!result
4791 -<div class="thumb tright"><div class="thumbinner" style="width:182px;"><a href="https://www.mediawiki.org/wiki/Image:Foobar.jpg" class="internal" title=""><img alt="" longdesc="/wiki/Image:Foobar.jpg" class="thumbimage" src="http://example.com/images/3/3a/Foobar.jpg" width="180" height="20" /></a> <div class="thumbcaption"><div class="magnify" style="float:right"><a href="https://www.mediawiki.org/wiki/Image:Foobar.jpg" class="internal" title="Enlarge"><img src="/skins/common/images/magnify-clip.png" width="15" height="11" alt="" /></a></div></div></div></div>
 4791+<div class="thumb tright"><div class="thumbinner" style="width:1943px;">Error creating thumbnail: <div class="thumbcaption"></div></div></div>
47924792
47934793 !!end
47944794
@@ -6080,7 +6080,7 @@
60816081 !! input
60826082 [[Image:foobar.jpg|centre]]
60836083 !! result
6084 -<div class="center"><div class="floatnone"><span><a href="https://www.mediawiki.org/wiki/Image:Foobar.jpg" class="image" title=""><img alt="" longdesc="/wiki/Image:Foobar.jpg" src="http://example.com/images/3/3a/Foobar.jpg" width="1941" height="220" /></a></span></div></div>
 6084+<div class="center"><div class="floatnone"><span><a href="https://www.mediawiki.org/wiki/Image:Foobar.jpg" class="image" title="Foobar.jpg"><img alt="" src="http://example.com/images/3/3a/Foobar.jpg" width="1941" height="220" border="0" /></a></span></div></div>
60856085
60866086 !!end
60876087
@@ -6089,7 +6089,7 @@
60906090 !! input
60916091 [[Image:foobar.jpg|none]]
60926092 !! result
6093 -<div class="floatnone"><span><a href="https://www.mediawiki.org/wiki/Image:Foobar.jpg" class="image" title=""><img alt="" longdesc="/wiki/Image:Foobar.jpg" src="http://example.com/images/3/3a/Foobar.jpg" width="1941" height="220" /></a></span></div>
 6093+<div class="floatnone"><span><a href="https://www.mediawiki.org/wiki/Image:Foobar.jpg" class="image" title="Foobar.jpg"><img alt="" src="http://example.com/images/3/3a/Foobar.jpg" width="1941" height="220" border="0" /></a></span></div>
60946094
60956095 !!end
60966096
@@ -6098,7 +6098,7 @@
60996099 !! input
61006100 [[Image:foobar.jpg|640x480px]]
61016101 !! result
6102 -<p><a href="https://www.mediawiki.org/wiki/Image:Foobar.jpg" class="image" title=""><img alt="" longdesc="/wiki/Image:Foobar.jpg" src="http://example.com/images/thumb/3/3a/Foobar.jpg/640px-Foobar.jpg" width="640" height="73" /></a>
 6102+<p><a href="https://www.mediawiki.org/wiki/Image:Foobar.jpg" class="image" title="Foobar.jpg"><img alt="" src="http://example.com/images/thumb/3/3a/Foobar.jpg/640px-Foobar.jpg" width="640" height="73" border="0" /></a>
61036103 </p>
61046104 !!end
61056105
@@ -6136,7 +6136,7 @@
61376137 !! input
61386138 [[image:Foobar.jpg|thumb|An [http://test/?param1=|left|&param2=|x external] URL]]
61396139 !! result
6140 -<div class="thumb tright"><div class="thumbinner" style="width:182px;"><a href="https://www.mediawiki.org/wiki/Image:Foobar.jpg" class="internal" title="An external URL"><img alt="An external URL" longdesc="/wiki/Image:Foobar.jpg" class="thumbimage" src="http://example.com/images/thumb/3/3a/Foobar.jpg/180px-Foobar.jpg" width="180" height="20" /></a> <div class="thumbcaption"><div class="magnify" style="float:right"><a href="https://www.mediawiki.org/wiki/Image:Foobar.jpg" class="internal" title="Enlarge"><img src="/skins/common/images/magnify-clip.png" width="15" height="11" alt="" /></a></div>An <a href="http://test/?param1=|left|&amp;param2=|x" class="external text" title="http://test/?param1=|left|&amp;param2=|x" rel="nofollow">external</a> URL</div></div></div>
 6140+<div class="thumb tright"><div class="thumbinner" style="width:182px;"><a href="https://www.mediawiki.org/wiki/Image:Foobar.jpg" class="image" title="An external URL"><img alt="An external URL" src="http://example.com/images/thumb/3/3a/Foobar.jpg/180px-Foobar.jpg" width="180" height="20" border="0" class="thumbimage" /></a> <div class="thumbcaption"><div class="magnify" style="float:right"><a href="https://www.mediawiki.org/wiki/Image:Foobar.jpg" class="internal" title="Enlarge"><img src="/skins/common/images/magnify-clip.png" width="15" height="11" alt="" /></a></div>An <a href="http://test/?param1=|left|&amp;param2=|x" class="external text" title="http://test/?param1=|left|&amp;param2=|x" rel="nofollow">external</a> URL</div></div></div>
61416141
61426142 !!end
61436143
Index: trunk/phase3/includes/ImagePage.php
@@ -242,14 +242,13 @@
243243 $wgOut->addHTML( '<table class="multipageimage"><tr><td>' );
244244 }
245245
246 - $imgAttribs = array(
247 - 'border' => 0,
248 - 'alt' => $this->img->getTitle()->getPrefixedText()
249 - );
250 -
251246 if ( $thumbnail ) {
 247+ $options = array(
 248+ 'alt' => $this->img->getTitle()->getPrefixedText(),
 249+ 'file-link' => true,
 250+ );
252251 $wgOut->addHTML( '<div class="fullImageLink" id="file">' .
253 - $thumbnail->toHtml( $imgAttribs, $linkAttribs ) .
 252+ $thumbnail->toHtml( $options ) .
254253 $anchorclose . '</div>' );
255254 }
256255
@@ -297,9 +296,9 @@
298297 if ($this->img->isSafeFile()) {
299298 $icon= $this->img->iconThumb();
300299
301 - $wgOut->addHTML( '<div class="fullImageLink" id="file"><a href="' . $full_url . '">' .
302 - $icon->toHtml() .
303 - '</a></div>' );
 300+ $wgOut->addHTML( '<div class="fullImageLink" id="file">' .
 301+ $icon->toHtml( array( 'desc-link' => true ) ) .
 302+ '</div>' );
304303 }
305304
306305 $showLink = true;
Index: trunk/phase3/includes/Linker.php
@@ -566,33 +566,13 @@
567567 $thumb = false;
568568 }
569569
570 - if ( $page ) {
571 - $query = 'page=' . urlencode( $page );
572 - } else {
573 - $query = '';
574 - }
575 - $url = $title->getLocalURL( $query );
576 - $imgAttribs = array(
577 - 'alt' => $fp['alt'],
578 - 'longdesc' => $url
579 - );
580 -
581 - if ( isset( $fp['valign'] ) ) {
582 - $imgAttribs['style'] = "vertical-align: {$fp['valign']}";
583 - }
584 - if ( isset( $fp['border'] ) ) {
585 - $imgAttribs['class'] = "thumbborder";
586 - }
587 - $linkAttribs = array(
588 - 'href' => $url,
589 - 'class' => 'image',
590 - 'title' => $fp['alt']
591 - );
592 -
593570 if ( !$thumb ) {
594571 $s = $this->makeBrokenImageLinkObj( $title );
595572 } else {
596 - $s = $thumb->toHtml( $imgAttribs, $linkAttribs );
 573+ $s = $thumb->toHtml( array(
 574+ 'desc-link' => true,
 575+ 'alt' => $fp['alt'],
 576+ 'valign' => isset( $fp['valign'] ) ? $fp['valign'] : false ) );
597577 }
598578 if ( '' != $fp['align'] ) {
599579 $s = "<div class=\"float{$fp['align']}\"><span>{$s}</span></div>";
@@ -684,18 +664,10 @@
685665 $s .= htmlspecialchars( wfMsg( 'thumbnail_error', '' ) );
686666 $zoomicon = '';
687667 } else {
688 - $imgAttribs = array(
 668+ $s .= $thumb->toHtml( array(
689669 'alt' => $fp['alt'],
690 - 'longdesc' => $url,
691 - 'class' => 'thumbimage'
692 - );
693 - $linkAttribs = array(
694 - 'href' => $url,
695 - 'class' => 'internal',
696 - 'title' => $fp['alt']
697 - );
698 -
699 - $s .= $thumb->toHtml( $imgAttribs, $linkAttribs );
 670+ 'img-class' => 'thumbimage',
 671+ 'desc-link' => true ) );
700672 if ( isset( $fp['framed'] ) ) {
701673 $zoomicon="";
702674 } else {
Index: trunk/phase3/includes/filerepo/File.php
@@ -559,7 +559,7 @@
560560 $path = '/common/images/icons/' . $icon;
561561 $filepath = $wgStyleDirectory . $path;
562562 if( file_exists( $filepath ) ) {
563 - return new ThumbnailImage( $wgStylePath . $path, 120, 120 );
 563+ return new ThumbnailImage( $this, $wgStylePath . $path, 120, 120 );
564564 }
565565 }
566566 return null;
Index: trunk/phase3/includes/SpecialUpload.php
@@ -481,8 +481,8 @@
482482 $file->getName(), 'right', array(), false, true );
483483 } elseif ( !$file->allowInlineDisplay() && $file->isSafeFile() ) {
484484 $icon = $file->iconThumb();
485 - $dlink2 = '<div style="float:right" id="mw-media-icon"><a href="' . $file->getURL() . '">' .
486 - $icon->toHtml() . '</a><br />' . $dlink . '</div>';
 485+ $dlink2 = '<div style="float:right" id="mw-media-icon">' .
 486+ $icon->toHtml( array( 'desc-link' => true ) ) . '<br />' . $dlink . '</div>';
487487 } else {
488488 $dlink2 = '';
489489 }
@@ -498,8 +498,8 @@
499499 $nt_lc->getText(), 'right', array(), false, true );
500500 } elseif ( !$file_lc->allowInlineDisplay() && $file_lc->isSafeFile() ) {
501501 $icon = $file_lc->iconThumb();
502 - $dlink2 = '<div style="float:right" id="mw-media-icon"><a href="' . $file_lc->getURL() . '">' .
503 - $icon->toHtml() . '</a><br />' . $dlink . '</div>';
 502+ $dlink2 = '<div style="float:right" id="mw-media-icon">' .
 503+ $icon->toHtml( array( 'desc-link' => true ) ) . '<br />' . $dlink . '</div>';
504504 } else {
505505 $dlink2 = '';
506506 }
@@ -522,8 +522,8 @@
523523 $nt_thb->getText(), 'right', array(), false, true );
524524 } elseif ( !$file_thb->allowInlineDisplay() && $file_thb->isSafeFile() ) {
525525 $icon = $file_thb->iconThumb();
526 - $dlink2 = '<div style="float:right" id="mw-media-icon"><a href="' .
527 - $file_thb->getURL() . '">' . $icon->toHtml() . '</a><br />' .
 526+ $dlink2 = '<div style="float:right" id="mw-media-icon">' .
 527+ $icon->toHtml( array( 'desc-link' => true ) ) . '<br />' .
528528 $dlink . '</div>';
529529 } else {
530530 $dlink2 = '';
Index: trunk/phase3/includes/media/Bitmap.php
@@ -58,7 +58,7 @@
5959 if ( $physicalWidth == $srcWidth && $physicalHeight == $srcHeight ) {
6060 # normaliseParams (or the user) wants us to return the unscaled image
6161 wfDebug( __METHOD__.": returning unscaled image\n" );
62 - return new ThumbnailImage( $image->getURL(), $clientWidth, $clientHeight, $srcPath );
 62+ return new ThumbnailImage( $image, $image->getURL(), $clientWidth, $clientHeight, $srcPath );
6363 }
6464
6565 if ( !$dstPath ) {
@@ -77,11 +77,11 @@
7878 if ( $scaler == 'client' ) {
7979 # Client-side image scaling, use the source URL
8080 # Using the destination URL in a TRANSFORM_LATER request would be incorrect
81 - return new ThumbnailImage( $image->getURL(), $clientWidth, $clientHeight, $srcPath );
 81+ return new ThumbnailImage( $image, $image->getURL(), $clientWidth, $clientHeight, $srcPath );
8282 }
8383
8484 if ( $flags & self::TRANSFORM_LATER ) {
85 - return new ThumbnailImage( $dstUrl, $clientWidth, $clientHeight, $dstPath );
 85+ return new ThumbnailImage( $image, $dstUrl, $clientWidth, $clientHeight, $dstPath );
8686 }
8787
8888 if ( !wfMkdirParents( dirname( $dstPath ) ) ) {
@@ -201,7 +201,7 @@
202202 wfHostname(), $retval, trim($err), $cmd ) );
203203 return new MediaTransformError( 'thumbnail_error', $clientWidth, $clientHeight, $err );
204204 } else {
205 - return new ThumbnailImage( $dstUrl, $clientWidth, $clientHeight, $dstPath );
 205+ return new ThumbnailImage( $image, $dstUrl, $clientWidth, $clientHeight, $dstPath );
206206 }
207207 }
208208
Index: trunk/phase3/includes/media/Generic.php
@@ -349,7 +349,8 @@
350350 return false;
351351 }
352352 $url = $script . '&' . wfArrayToCGI( $this->getScriptParams( $params ) );
353 - return new ThumbnailImage( $url, $params['width'], $params['height'] );
 353+ $page = isset( $params['page'] ) ? $params['page'] : false;
 354+ return new ThumbnailImage( $image, $url, $params['width'], $params['height'], $page );
354355 }
355356
356357 /**
Index: trunk/phase3/includes/media/SVG.php
@@ -49,7 +49,7 @@
5050 $srcPath = $image->getPath();
5151
5252 if ( $flags & self::TRANSFORM_LATER ) {
53 - return new ThumbnailImage( $dstUrl, $clientWidth, $clientHeight, $dstPath );
 53+ return new ThumbnailImage( $image, $dstUrl, $clientWidth, $clientHeight, $dstPath );
5454 }
5555
5656 if ( !wfMkdirParents( dirname( $dstPath ) ) ) {
@@ -80,7 +80,7 @@
8181 wfHostname(), $retval, trim($err), $cmd ) );
8282 return new MediaTransformError( 'thumbnail_error', $clientWidth, $clientHeight, $err );
8383 } else {
84 - return new ThumbnailImage( $dstUrl, $clientWidth, $clientHeight, $dstPath );
 84+ return new ThumbnailImage( $image, $dstUrl, $clientWidth, $clientHeight, $dstPath );
8585 }
8686 }
8787
Index: trunk/phase3/includes/media/DjVu.php
@@ -83,7 +83,7 @@
8484 }
8585
8686 if ( $flags & self::TRANSFORM_LATER ) {
87 - return new ThumbnailImage( $dstUrl, $width, $height, $dstPath );
 87+ return new ThumbnailImage( $image, $dstUrl, $width, $height, $dstPath, $page );
8888 }
8989
9090 if ( !wfMkdirParents( dirname( $dstPath ) ) ) {
@@ -110,7 +110,7 @@
111111 wfHostname(), $retval, trim($err), $cmd ) );
112112 return new MediaTransformError( 'thumbnail_error', $width, $height, $err );
113113 } else {
114 - return new ThumbnailImage( $dstUrl, $width, $height, $dstPath );
 114+ return new ThumbnailImage( $image, $dstUrl, $width, $height, $dstPath, $page );
115115 }
116116 }
117117
Index: trunk/phase3/includes/MediaTransformOutput.php
@@ -6,6 +6,8 @@
77 * @addtogroup Media
88 */
99 abstract class MediaTransformOutput {
 10+ var $file, $width, $height, $url, $page, $path;
 11+
1012 /**
1113 * Get the width of the output box
1214 */
@@ -36,12 +38,23 @@
3739
3840 /**
3941 * Fetch HTML for this transform output
40 - * @param array $attribs Advisory associative array of HTML attributes supplied
41 - * by the linker. These can be incorporated into the output in any way.
42 - * @param array $linkAttribs Attributes of a suggested enclosing <a> tag.
43 - * May be ignored.
 42+ *
 43+ * @param array $options Associative array of options. Boolean options
 44+ * should be indicated with a value of true for true, and false or
 45+ * absent for false.
 46+ *
 47+ * alt Alternate text or caption
 48+ * desc-link Boolean, show a description link
 49+ * file-link Boolean, show a file download link
 50+ * valign vertical-align property, if the output is an inline element
 51+ * img-class Class applied to the <img> tag, if there is such a tag
 52+ *
 53+ * For images, desc-link and file-link are implemented as a click-through. For
 54+ * sounds and videos, they may be displayed in other ways.
 55+ *
 56+ * @return string
4457 */
45 - abstract function toHtml( $attribs = array() , $linkAttribs = false );
 58+ abstract function toHtml( $options = array() );
4659
4760 /**
4861 * This will be overridden to return true in error classes
@@ -60,6 +73,19 @@
6174 return $contents;
6275 }
6376 }
 77+
 78+ function getDescLinkAttribs( $alt = false ) {
 79+ $query = $this->page ? ( 'page=' . urlencode( $this->page ) ) : '';
 80+ $title = $this->file->getTitle();
 81+ if ( strval( $alt ) === '' ) {
 82+ $alt = $title->getText();
 83+ }
 84+ return array(
 85+ 'href' => $this->file->getTitle()->getLocalURL( $query ),
 86+ 'class' => 'image',
 87+ 'title' => $alt
 88+ );
 89+ }
6490 }
6591
6692
@@ -74,7 +100,8 @@
75101 * @param string $url URL path to the thumb
76102 * @private
77103 */
78 - function ThumbnailImage( $url, $width, $height, $path = false ) {
 104+ function ThumbnailImage( $file, $url, $width, $height, $path = false, $page = false ) {
 105+ $this->file = $file;
79106 $this->url = $url;
80107 # These should be integers when they get here.
81108 # If not, there's a bug somewhere. But let's at
@@ -82,28 +109,56 @@
83110 $this->width = round( $width );
84111 $this->height = round( $height );
85112 $this->path = $path;
 113+ $this->page = $page;
86114 }
87115
88116 /**
89117 * Return HTML <img ... /> tag for the thumbnail, will include
90118 * width and height attributes and a blank alt text (as required).
 119+ *
 120+ * @param array $options Associative array of options. Boolean options
 121+ * should be indicated with a value of true for true, and false or
 122+ * absent for false.
91123 *
92 - * You can set or override additional attributes by passing an
93 - * associative array of name => data pairs. The data will be escaped
94 - * for HTML output, so should be in plaintext.
 124+ * alt Alternate text or caption
 125+ * desc-link Boolean, show a description link
 126+ * file-link Boolean, show a file download link
 127+ * valign vertical-align property, if the output is an inline element
 128+ * img-class Class applied to the <img> tag, if there is such a tag
95129 *
96 - * If $linkAttribs is given, the image will be enclosed in an <a> tag.
 130+ * For images, desc-link and file-link are implemented as a click-through. For
 131+ * sounds and videos, they may be displayed in other ways.
97132 *
98 - * @param array $attribs
99 - * @param array $linkAttribs
100133 * @return string
101134 * @public
102135 */
103 - function toHtml( $attribs = array(), $linkAttribs = false ) {
104 - $attribs['src'] = $this->url;
105 - $attribs['width'] = $this->width;
106 - $attribs['height'] = $this->height;
107 - if( !isset( $attribs['alt'] ) ) $attribs['alt'] = '';
 136+ function toHtml( $options = array() ) {
 137+ if ( count( func_get_args() ) == 2 ) {
 138+ throw new MWException( __METHOD__ .' called in the old style' );
 139+ }
 140+
 141+ $alt = empty( $options['alt'] ) ? '' : $options['alt'];
 142+ if ( !empty( $options['desc-link'] ) ) {
 143+ $linkAttribs = $this->getDescLinkAttribs( $alt );
 144+ } elseif ( !empty( $options['file-link'] ) ) {
 145+ $linkAttribs = array( 'href' => $this->file->getURL() );
 146+ } else {
 147+ $linkAttribs = false;
 148+ }
 149+
 150+ $attribs = array(
 151+ 'alt' => $alt,
 152+ 'src' => $this->url,
 153+ 'width' => $this->width,
 154+ 'height' => $this->height,
 155+ 'border' => 0,
 156+ );
 157+ if ( !empty( $options['valign'] ) ) {
 158+ $attribs['style'] = "vertical-align: {$options['valign']}";
 159+ }
 160+ if ( !empty( $options['img-class'] ) ) {
 161+ $attribs['class'] = $options['img-class'];
 162+ }
108163 return $this->linkWrap( $linkAttribs, Xml::element( 'img', $attribs ) );
109164 }
110165
@@ -130,7 +185,7 @@
131186 $this->path = false;
132187 }
133188
134 - function toHtml( $attribs = array(), $linkAttribs = false ) {
 189+ function toHtml( $options = array() ) {
135190 return "<table class=\"MediaTransformError\" style=\"" .
136191 "width: {$this->width}px; height: {$this->height}px;\"><tr><td>" .
137192 $this->htmlMsg .
Index: trunk/phase3/includes/ImageGallery.php
@@ -261,13 +261,14 @@
262262 . htmlspecialchars( $img->getLastError() ) . '</div>';
263263 } else {
264264 $vpad = floor( ( 1.25*$this->mHeights - $thumb->height ) /2 ) - 2;
265 - $linkAttribs = array(
266 - 'href' => $nt->getLocalURL(),
267 - 'title' => $nt->getPrefixedText(),
268 - );
269265
270 - $thumbhtml = "\n\t\t\t".'<div class="thumb" style="padding: ' . $vpad . 'px 0; width: '.($this->mWidths+30).'px;">'
271 - . $thumb->toHtml( array(), $linkAttribs ) . '</div>';
 266+ $thumbhtml = "\n\t\t\t".
 267+ '<div class="thumb" style="padding: ' . $vpad . 'px 0; width: ' .($this->mWidths+30).'px;">'
 268+ # Auto-margin centering for block-level elements. Needed now that we have video
 269+ # handlers since they may emit block-level elements as opposed to simple <img> tags.
 270+ # ref http://css-discuss.incutio.com/?page=CenteringBlockElement
 271+ . '<div style="margin-left: auto; margin-right: auto; width: ' .$this->mWidths.'px;">'
 272+ . $thumb->toHtml( array( 'desc-link' => true ) ) . '</div></div>';
272273
273274 // Call parser transform hook
274275 if ( $this->mParser && $img->getHandler() ) {
@@ -350,3 +351,4 @@
351352
352353 } //class
353354
 355+
Index: trunk/extensions/OggHandler/OggPlayer.js
@@ -1,4 +1,3 @@
2 -
32 // This is a global configuration object which can embed multiple video instances
43 var wgOggPlayer = {
54 'detectionDone': false,
@@ -8,7 +7,8 @@
98 // Downpreffed VLC because it crashes my browser all the damn time -- TS
109 'players': ['videoElement', 'oggPlugin', 'cortado', 'quicktime-mozilla', 'quicktime-activex', 'vlc-mozilla', 'vlc-activex'],
1110
12 - 'clientSupports': {},
 11+ 'clientSupports': { 'thumbnail' : true },
 12+ 'savedThumbs': {},
1313
1414 // Configuration from MW
1515 'msg': {},
@@ -20,9 +20,16 @@
2121 // Main entry point: initialise a video player
2222 // Player will be created as a child of the given ID
2323 // There may be multiple players in a document
24 - 'init': function ( player, id, videoUrl, width, height, length ) {
25 - var elt = document.getElementById( id );
 24+ 'init': function ( player, id, videoUrl, width, height, length, linkUrl ) {
 25+ elt = document.getElementById( id );
2626
 27+ // Save still image HTML
 28+ if ( !(id in this.savedThumbs) ) {
 29+ var thumb = document.createDocumentFragment();
 30+ thumb.appendChild( elt.cloneNode( true ) );
 31+ this.savedThumbs[id] = thumb;
 32+ }
 33+
2734 this.detect( elt );
2835
2936 if ( !player ) {
@@ -34,6 +41,10 @@
3542 var semicolon = player.indexOf( ";" );
3643 if ( semicolon > -1 ) {
3744 player = player.substr( cookiePos, semicolon );
 45+ if ( player == 'thumbnail' ) {
 46+ // Can't select this one permanently
 47+ player = false;
 48+ }
3849 }
3950 }
4051 }
@@ -48,7 +59,7 @@
4960 }
5061
5162 elt.innerHTML = '';
52 -
 63+
5364 switch ( player ) {
5465 case 'videoElement':
5566 this.embedVideoElement( elt, videoUrl, width, height, length );
@@ -68,17 +79,23 @@
6980 case 'quicktime-mozilla':
7081 this.embedQuicktimePlugin( elt, videoUrl, width, height, length );
7182 break;
 83+ case 'thumbnail':
 84+ if ( id in this.savedThumbs ) {
 85+ elt.appendChild( this.savedThumbs[id].cloneNode( true ) );
 86+ } else {
 87+ elt.appendChild( document.createTextNode( 'Missing saved thumbnail for ' + id ) );
 88+ }
 89+ break;
7290 default:
7391 elt.innerHTML = this.msg['ogg-no-player'] + '<br/>';
7492 player = 'none';
7593 }
76 - if ( this.showPlayerSelect ) {
 94+ if ( player != 'thumbnail' ) {
 95+ var optionsBox = this.makeOptionsBox( player, id, videoUrl, width, height, length, linkUrl );
 96+ var optionsLink = this.makeOptionsLink( id );
7797 elt.appendChild( document.createElement( 'br' ) );
78 - var label = document.createElement( 'label' );
79 - label.setAttribute( 'class', 'ogg_player_using' );
80 - label.appendChild( document.createTextNode( ' ' + this.msg['ogg-using-player'] ) );
81 - label.appendChild( this.makePlayerSelect( player, id, videoUrl, width, height, length ) );
82 - elt.appendChild( label );
 98+ elt.appendChild( optionsBox );
 99+ elt.appendChild( optionsLink );
83100 }
84101 },
85102
@@ -99,7 +116,7 @@
100117 this.clientSupports['vlc-activex'] = true;
101118 }
102119 // Java
103 - if ( javaEnabled && this.testActiveX( 'JavaPlugin' ) ) {
 120+ if ( javaEnabled && this.testActiveX( 'JavaWebStart.isInstalled' ) ) {
104121 this.clientSupports['cortado'] = true;
105122 }
106123 // QuickTime
@@ -180,23 +197,136 @@
181198 }
182199 },
183200
184 - 'makePlayerSelect' : function ( selectedPlayer, id, videoUrl, width, height, length ) {
185 - var select = document.createElement( 'select' );
186 - if ( selectedPlayer == 'none' ) {
187 - this.addOption( select, 'none', this.msg['ogg-player-none'], true );
 201+ 'makeOptionsBox' : function ( selectedPlayer, id, videoUrl, width, height, length, linkUrl ) {
 202+ var div, p, a, ul, li, button;
 203+
 204+ div = document.createElement( 'div' );
 205+ div.style.cssText = "width: " + ( width - 10 ) + "px; display: none;";
 206+ div.className = 'ogg-player-options';
 207+ div.id = id + '_options_box';
 208+ div.align = 'center';
 209+
 210+ ul = document.createElement( 'ul' );
 211+
 212+ // Description page link
 213+ if ( linkUrl ) {
 214+ li = document.createElement( 'li' );
 215+ a = document.createElement( 'a' );
 216+ a.href = linkUrl;
 217+ a.appendChild( document.createTextNode( this.msg['ogg-desc-link'] ) );
 218+ li.appendChild( a );
 219+ ul.appendChild( li );
188220 }
189 - for ( var player in this.clientSupports ) {
190 - this.addOption( select, player, this.getMsg( 'ogg-player-' + player ), selectedPlayer == player );
 221+
 222+ // Download link
 223+ li = document.createElement( 'li' );
 224+ a = document.createElement( 'a' );
 225+ a.href = videoUrl;
 226+ a.appendChild( document.createTextNode( this.msg['ogg-download'] ) );
 227+ li.appendChild( a );
 228+ ul.appendChild( li );
 229+
 230+ div.appendChild( ul );
 231+
 232+ // Player list caption
 233+ p = document.createElement( 'p' );
 234+ p.appendChild( document.createTextNode( this.msg['ogg-use-player'] ) );
 235+ div.appendChild( p );
 236+
 237+ // Make player list
 238+ ul = document.createElement( 'ul' );
 239+ for ( var i = 0; i < this.players.length + 1; i++ ) {
 240+ var player;
 241+ if ( i == this.players.length ) {
 242+ player = 'thumbnail';
 243+ } else {
 244+ player = this.players[i];
 245+ // Skip unsupported players
 246+ if ( ! this.clientSupports[player] ) {
 247+ continue;
 248+ }
 249+ }
 250+
 251+ // Make list item
 252+ li = document.createElement( 'li' );
 253+ if ( player == selectedPlayer ) {
 254+ var strong = document.createElement( 'strong' );
 255+ strong.appendChild( document.createTextNode(
 256+ this.msg['ogg-player-' + player] + ' ' + this.msg['ogg-player-selected'] ) );
 257+ li.appendChild( strong );
 258+ } else {
 259+ a = document.createElement( 'a' );
 260+ a.href = 'javascript:void("' + player + '")';
 261+ a.onclick = this.makePlayerFunction( player, id, videoUrl, width, height, length, linkUrl );
 262+ a.appendChild( document.createTextNode( this.msg['ogg-player-' + player] ) );
 263+ li.appendChild( a );
 264+ }
 265+ ul.appendChild( li );
191266 }
192 - select.value = selectedPlayer;
 267+ div.appendChild( ul );
 268+
 269+ div2 = document.createElement( 'div' );
 270+ div2.style.cssText = 'text-align: center;';
 271+ button = document.createElement( 'button' );
 272+ button.appendChild( document.createTextNode( this.msg['ogg-dismiss'] ) );
 273+ button.onclick = this.makeDismissFunction( id );
 274+ div2.appendChild( button );
 275+ div.appendChild( div2 );
193276
194 - var me = this;
195 - select.onchange = function () {
196 - var player = select.value;
197 - document.cookie = "ogg_player=" + player;
198 - me.init( player, id, videoUrl, width, height, length );
 277+ return div;
 278+ },
 279+
 280+ 'makeOptionsLink' : function ( id ) {
 281+ var a = document.createElement( 'a' );
 282+ a.href = 'javascript:void("options")';
 283+ a.id = id + '_options_link';
 284+ a.onclick = this.makeDisplayOptionsFunction( id );
 285+ a.appendChild( document.createTextNode( this.msg['ogg-more'] ) );
 286+ return a;
 287+ },
 288+
 289+ 'setCssProperty' : function ( elt, prop, value ) {
 290+ // Could use style.setProperty() here if it worked in IE
 291+ var re = new RegExp( prop + ':[^;](;|$)' );
 292+ if ( elt.style.cssText.search( re ) > -1 ) {
 293+ elt.style.cssText = elt.style.cssText.replace( re, prop + ':' + value + '$1' );
 294+ } else if ( elt.style.cssText == '' ) {
 295+ elt.style.cssText = prop + ':' + value + ';';
 296+ } else if ( elt.style.cssText[elt.style.cssText.length - 1] == ';' ) {
 297+ elt.style.cssText += prop + ':' + value + ';';
 298+ } else {
 299+ elt.style.cssText += ';' + prop + ':' + value + ';';
 300+ }
 301+ },
 302+
 303+ 'makeDismissFunction' : function ( id ) {
 304+ var this_ = this;
 305+ return function () {
 306+ var optionsLink = document.getElementById( id + '_options_link' );
 307+ var optionsBox = document.getElementById( id + '_options_box' );
 308+ this_.setCssProperty( optionsLink, 'display', 'inline' );
 309+ this_.setCssProperty( optionsBox, 'display', 'none' );
 310+ }
 311+ },
 312+
 313+ 'makeDisplayOptionsFunction' : function ( id ) {
 314+ var this_ = this;
 315+ return function () {
 316+ var optionsLink = document.getElementById( id + '_options_link' );
 317+ var optionsBox = document.getElementById( id + '_options_box' );
 318+ this_.setCssProperty( optionsLink, 'display', 'none' );
 319+ this_.setCssProperty( optionsBox, 'display', 'block' );
 320+ }
 321+ },
 322+
 323+ 'makePlayerFunction' : function ( player, id, videoUrl, width, height, length, linkUrl ) {
 324+ var this_ = this;
 325+ return function () {
 326+ if ( player != 'thumbnail' ) {
 327+ document.cookie = "ogg_player=" + player;
 328+ }
 329+ this_.init( player, id, videoUrl, width, height, length, linkUrl );
199330 };
200 - return select;
201331 },
202332
203333 'newButton': function ( caption, callback ) {
@@ -350,11 +480,11 @@
351481 "</object>";
352482
353483 // Disable autoplay on back button
354 - var me = this;
 484+ var this_ = this;
355485 window.setTimeout(
356486 function () {
357487 var videoElt = document.getElementById( id );
358 - me.setParam( videoElt, 'AUTOPLAY', 'False' );
 488+ this_.setParam( videoElt, 'AUTOPLAY', 'False' );
359489 }, 3000 );
360490 },
361491
@@ -376,6 +506,4 @@
377507 this.addParam( elt, name, value );
378508 }
379509 };
380 -
381510 // vim: ts=4 sw=4 noet cindent :
382 -
Index: trunk/extensions/OggHandler/OggHandler_body.php
@@ -143,11 +143,11 @@
144144 $width = $params['width'];
145145 }
146146 $height = $icon->getHeight();
147 - return new OggAudioDisplay( $file->getURL(), $icon->getUrl(), $width, $height, $length );
 147+ return new OggAudioDisplay( $file, $file->getURL(), $icon->getUrl(), $width, $height, $length );
148148 }
149149
150150 if ( $flags & self::TRANSFORM_LATER ) {
151 - return new OggVideoDisplay( $file->getURL(), $dstUrl, $width, $height, $length );
 151+ return new OggVideoDisplay( $file, $file->getURL(), $dstUrl, $width, $height, $length );
152152 }
153153
154154 wfMkdirParents( dirname( $dstPath ) );
@@ -180,7 +180,7 @@
181181 // Return error box
182182 return new MediaTransformError( 'thumbnail_error', $width, $height, implode( "\n", $lines ) );
183183 }
184 - return new OggVideoDisplay( $file->getURL(), $dstUrl, $width, $height, $length );
 184+ return new OggVideoDisplay( $file, $file->getURL(), $dstUrl, $width, $height, $length );
185185 }
186186
187187 function canRender() { return true; }
@@ -319,7 +319,8 @@
320320 $msgNames = array( 'ogg-play', 'ogg-pause', 'ogg-stop', 'ogg-no-player',
321321 'ogg-player-videoElement', 'ogg-player-oggPlugin', 'ogg-player-cortado', 'ogg-player-vlc-mozilla',
322322 'ogg-player-vlc-activex', 'ogg-player-quicktime-mozilla', 'ogg-player-quicktime-activex',
323 - 'ogg-player-none', 'ogg-using-player' );
 323+ 'ogg-player-thumbnail', 'ogg-player-selected', 'ogg-use-player', 'ogg-more', 'ogg-download',
 324+ 'ogg-desc-link', 'ogg-dismiss' );
324325 $msgValues = array_map( 'wfMsg', $msgNames );
325326 $jsMsgs = Xml::encodeJsVar( (object)array_combine( $msgNames, $msgValues ) );
326327 $cortadoUrl = $wgCortadoJarFile;
@@ -337,6 +338,14 @@
338339 wgOggPlayer.cortadoUrl = $encCortadoUrl;
339340 wgOggPlayer.smallFileUrl = $encSmallFileUrl;
340341 </script>
 342+<style type="text/css">
 343+.ogg-player-options {
 344+ border: solid 1px #ccc;
 345+ padding: 2pt;
 346+ text-align: left;
 347+ font-size: 10pt;
 348+}
 349+</style>
341350 EOT
342351 );
343352
@@ -361,7 +370,8 @@
362371 class OggTransformOutput extends MediaTransformOutput {
363372 static $serial = 0;
364373
365 - function __construct( $videoUrl, $thumbUrl, $width, $height, $length, $isVideo ) {
 374+ function __construct( $file, $videoUrl, $thumbUrl, $width, $height, $length, $isVideo ) {
 375+ $this->file = $file;
366376 $this->videoUrl = $videoUrl;
367377 $this->url = $thumbUrl;
368378 $this->width = round( $width );
@@ -370,24 +380,25 @@
371381 $this->isVideo = $isVideo;
372382 }
373383
374 - function toHtml( $attribs = array() , $linkAttribs = false ) {
 384+ function toHtml( $options = array() ) {
375385 wfLoadExtensionMessages( 'OggHandler' );
 386+ if ( count( func_get_args() ) == 2 ) {
 387+ throw new MWException( __METHOD__ .' called in the old style' );
 388+ }
376389
377390 OggTransformOutput::$serial++;
378391
379 - $encThumbUrl = htmlspecialchars( $this->url );
380 -
381392 if ( substr( $this->videoUrl, 0, 4 ) != 'http' ) {
382393 global $wgServer;
383394 $encUrl = Xml::encodeJsVar( $wgServer . $this->videoUrl );
384395 } else {
385396 $encUrl = Xml::encodeJsVar( $this->videoUrl );
386397 }
387 - #$encUrl = htmlspecialchars( $encUrl );
388398 $length = intval( $this->length );
389399 $width = intval( $this->width );
390400 $height = intval( $this->height );
391 - $attribs['src'] = $this->url;
 401+ $alt = empty( $options['alt'] ) ? '' : $options['alt'];
 402+ $attribs = array( 'src' => $this->url );
392403 if ( $this->isVideo ) {
393404 $msgStartPlayer = wfMsg( 'ogg-play-video' );
394405 $attribs['width'] = $width;
@@ -400,18 +411,23 @@
401412 }
402413
403414 $thumb = Xml::element( 'img', $attribs, null );
404 - if ( $linkAttribs ) {
 415+ if ( !empty( $options['desc-link'] ) ) {
 416+ $linkAttribs = $this->getDescLinkAttribs( $alt );
405417 $thumb = Xml::tags( 'a', $linkAttribs, $thumb );
 418+ $encLink = Xml::encodeJsVar( $linkAttribs['href'] );
 419+ } else {
 420+ // We don't respect the file-link option, click-through to download is not appropriate
 421+ $encLink = 'false';
406422 }
407423 $thumb .= "<br/>\n";
408424
409425 $id = "ogg_player_" . OggTransformOutput::$serial;
410426
411 - $s = Xml::tags( 'div', array( 'id' => $id ),
 427+ $s = Xml::tags( 'div', array( 'id' => $id, /*'align' => 'center',*/ 'style' => 'width: ' . $width . 'px' ),
412428 $thumb .
413429 Xml::element( 'button',
414430 array(
415 - 'onclick' => "wgOggPlayer.init(false, '$id', $encUrl, $width, $playerHeight, $length);",
 431+ 'onclick' => "wgOggPlayer.init(false, '$id', $encUrl, $width, $playerHeight, $length, $encLink);",
416432 ),
417433 $msgStartPlayer
418434 )
@@ -421,14 +437,14 @@
422438 }
423439
424440 class OggVideoDisplay extends OggTransformOutput {
425 - function __construct( $videoUrl, $thumbUrl, $width, $height, $length ) {
426 - parent::__construct( $videoUrl, $thumbUrl, $width, $height, $length, true );
 441+ function __construct( $file, $videoUrl, $thumbUrl, $width, $height, $length ) {
 442+ parent::__construct( $file, $videoUrl, $thumbUrl, $width, $height, $length, true );
427443 }
428444 }
429445
430446 class OggAudioDisplay extends OggTransformOutput {
431 - function __construct( $videoUrl, $iconUrl, $width, $height, $length ) {
432 - parent::__construct( $videoUrl, $iconUrl, $width, $height, $length, false );
 447+ function __construct( $file, $videoUrl, $iconUrl, $width, $height, $length ) {
 448+ parent::__construct( $file, $videoUrl, $iconUrl, $width, $height, $length, false );
433449 }
434450 }
435451
Index: trunk/extensions/OggHandler/OggHandler.i18n.php
@@ -24,8 +24,13 @@
2525 'ogg-player-vlc-activex' => 'VLC (ActiveX)', # only translate this message to other languages if you have to change it
2626 'ogg-player-quicktime-mozilla' => 'QuickTime', # only translate this message to other languages if you have to change it
2727 'ogg-player-quicktime-activex' => 'QuickTime (ActiveX)', # only translate this message to other languages if you have to change it
28 - 'ogg-player-none' => '(none)',
29 - 'ogg-using-player' => 'Using player:',
 28+ 'ogg-player-thumbnail' => 'Still image only',
 29+ 'ogg-player-selected' => '(selected)',
 30+ 'ogg-use-player' => 'Use player: ',
 31+ 'ogg-more' => 'More...',
 32+ 'ogg-dismiss' => 'Close',
 33+ 'ogg-download' => 'Download file',
 34+ 'ogg-desc-link' => 'About this file',
3035 ),
3136
3237 'de' => array(
@@ -45,8 +50,6 @@
4651 'ogg-no-player' => 'Dein System scheint über keine Abspielsoftware zu verfügen. Bitte installiere <a href="http://www.java.com/de/download/manual.jsp">Java</a>',
4752 'ogg-player-videoElement' => '<video>-Element',
4853 'ogg-player-oggPlugin' => 'Ogg-Plugin',
49 - 'ogg-player-none' => '(keiner)',
50 - 'ogg-using-player' => 'Verwende Player:',
5154 ),
5255
5356 'nl' => array(
@@ -67,7 +70,5 @@
6871 'Installeer alstublieft <a href="http://www.java.com/nl/download/manual.jsp">Java</a>.',
6972 'ogg-player-videoElement' => '<video>-element',
7073 'ogg-player-oggPlugin' => 'Ogg-plugin',
71 - 'ogg-player-none' => '(geen)',
72 - 'ogg-using-player' => 'Gebruikte speler:',
7374 ),
7475 );

Follow-up revisions

RevisionCommit summaryAuthorDate
r25338Merged revisions 25303-25337 via svnmerge from...david04:55, 31 August 2007

Status & tagging log