r70736 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r70735‎ | r70736 | r70737 >
Date:03:13, 9 August 2010
Author:laner
Status:deferred
Tags:
Comment:
* Fixed bug when sgallery was used as a tag
* Fixed bug with use of the parser to recursively parse tags
* Fixed bug with comments. Comments can now be displayed, and wikitext can be used in them.
Modified paths:
  • /trunk/extensions/SmoothGallery/SmoothGallery.php (modified) (history)
  • /trunk/extensions/SmoothGallery/SmoothGalleryClass.php (modified) (history)
  • /trunk/extensions/SmoothGallery/SmoothGalleryParser.php (modified) (history)

Diff [purge]

Index: trunk/extensions/SmoothGallery/SmoothGallery.php
@@ -65,14 +65,14 @@
6666 function efSmoothGallery() {
6767 global $wgParser;
6868
69 - $wgParser->setHook( 'sgallery', 'initSmoothGallery' );
70 - $wgParser->setHook( 'sgalleryset', 'initSmoothGallerySet' );
 69+ $wgParser->setHook( 'sgallery', 'initSmoothGalleryTag' );
 70+ $wgParser->setHook( 'sgalleryset', 'initSmoothGalleryTagSet' );
7171
7272 $wgParser->setFunctionHook( 'sgallery', 'initSmoothGalleryPF' );
7373 }
7474
7575 // FIXME: split off to a hook file and use $wgHooks['ParserFirstCallInit'] to init tags
76 -function initSmoothGalleryPF( &$parser ) {
 76+function initSmoothGalleryPF( $parser ) {
7777 global $wgSmoothGalleryDelimiter;
7878
7979 $numargs = func_num_args();
@@ -109,7 +109,13 @@
110110 return array( $output, 'noparse' => true, 'isHTML' => true );
111111 }
112112
113 -function initSmoothGallery( $input, $argv, &$parser, $calledAsSet = false ) {
 113+function initSmoothGalleryTag( $input, $argv, $parser ) {
 114+ $output = initSmoothGallery( $input, $args, $parser );
 115+
 116+ return $output;
 117+}
 118+
 119+function initSmoothGallery( $input, $argv, $parser, $calledAsSet = false ) {
114120 $sgParser = new SmoothGalleryParser( $input, $argv, $parser, $calledAsSet );
115121 $sgGallery = new SmoothGallery();
116122
@@ -126,7 +132,7 @@
127133 }
128134 }
129135
130 -function initSmoothGallerySet( $input, $args, &$parser ) {
 136+function initSmoothGalleryTagSet( $input, $args, $parser ) {
131137 $output = initSmoothGallery( $input, $args, $parser, true );
132138
133139 return $output;
@@ -136,7 +142,7 @@
137143 * Hook callback that injects messages and things into the <head> tag
138144 * Does nothing if $parserOutput->mSmoothGalleryTag is not set
139145 */
140 -function smoothGalleryParserOutput( &$outputPage, &$parserOutput ) {
 146+function smoothGalleryParserOutput( $outputPage, $parserOutput ) {
141147 if ( !empty( $parserOutput->mSmoothGalleryTag ) ) {
142148 SmoothGallery::setGalleryHeaders( $outputPage );
143149 }
@@ -150,7 +156,7 @@
151157 * We ignore langCode - parser function names can be translated but
152158 * we are not using this feature
153159 */
154 -function smoothGalleryLanguageGetMagic( &$magicWords, $langCode ) {
 160+function smoothGalleryLanguageGetMagic( $magicWords, $langCode ) {
155161 $magicWords['sgallery'] = array( 0, 'sgallery' );
156162 return true;
157163 }
Index: trunk/extensions/SmoothGallery/SmoothGalleryClass.php
@@ -56,7 +56,7 @@
5757 $this->galleriesArray = $galleriesArray;
5858 }
5959
60 - function setParser( &$parser ) {
 60+ function setParser( $parser ) {
6161 $this->parser = $parser;
6262 }
6363
@@ -274,7 +274,7 @@
275275 return $output;
276276 }
277277
278 - static function setGalleryHeaders( &$outputPage ) {
 278+ static function setGalleryHeaders( $outputPage ) {
279279 global $wgSmoothGalleryExtensionPath;
280280
281281 $extensionpath = $wgSmoothGalleryExtensionPath;
@@ -304,7 +304,7 @@
305305 return true;
306306 }
307307
308 - static function setGallerySetHeaders( &$outputPage ) {
 308+ static function setGallerySetHeaders( $outputPage ) {
309309 global $wgSmoothGalleryExtensionPath;
310310
311311 $extensionpath = $wgSmoothGalleryExtensionPath;
Index: trunk/extensions/SmoothGallery/SmoothGalleryParser.php
@@ -89,7 +89,7 @@
9090 // collect the fallback output
9191 $i = 0;
9292 foreach ( $galleries as $galleryInput ) {
93 - // TOFIX:
 93+ // FIXME:
9494 // This couldn't possibly be right... If these are different
9595 // galleries in a gallery set, shouldn't they have unique names?
9696 $name = "MediaWikiSGallery" . $i;
@@ -241,16 +241,6 @@
242242 // Get the text from the image page's description, if it exists
243243 $description = $img_obj->getDescriptionText();
244244 }
245 -
246 - // convert wikitext to HTML
247 - // TODO: find out why this doesn't work with special pages
248 - if ( $parser ) {
249 - $pout = $parser->recursiveTagParse( $description, $title, $parser->mOptions, true );
250 - $description = strip_tags( $pout );
251 - # $fulldesc = strip_tags( $pout->getText() );
252 - } else { // fall back to HTML-escaping
253 - $description = htmlspecialchars( $description );
254 - }
255245 }
256246
257247 $skin = $wgUser->getSkin();
@@ -258,7 +248,7 @@
259249 // Everything is checked, and converted; add to the array and return
260250 $imageArray["title"] = $title;
261251
262 - # We need the following for the image's div
 252+ // We need the following for the image's div
263253 $imageArray["heading"] = $skin->makeKnownLinkObj( $img_obj->getTitle(), $img_obj->getName() );
264254 $imageArray["description"] = $description;
265255 $imageArray["full_url"] = $title->getFullURL();
@@ -266,7 +256,7 @@
267257 $imageArray["full_thumb_url"] = $full_thumb;
268258 $imageArray["icon_thumb_url"] = $icon_thumb;
269259
270 - # We need the image object for plain galleries
 260+ // We need the image object for plain galleries
271261 $imageArray["image_object"] = $img_obj;
272262
273263 $galleryArray["images"][] = $imageArray;

Status & tagging log