r32974 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r32973‎ | r32974 | r32975 >
Date:18:44, 8 April 2008
Author:emiller
Status:old
Tags:
Comment:
* Use quotation marks in "define" statements for PHP4 compat.
* Drop use of recursiveTagParse--can't get it work and we have to support the old-fashioned way anyway.
Modified paths:
  • /trunk/extensions/GoogleMaps/GoogleMaps.body.php (modified) (history)
  • /trunk/extensions/GoogleMaps/SpecialGoogleMapsKML.php (modified) (history)

Diff [purge]

Index: trunk/extensions/GoogleMaps/GoogleMaps.body.php
@@ -5,9 +5,9 @@
66 die( );
77 }
88
9 -define(GOOGLE_MAPS_PARSE_INCLUDES, 0);
10 -define(GOOGLE_MAPS_PARSE_ADD_MARKER, 1);
11 -define(GOOGLE_MAPS_PARSE_POINTS, 2);
 9+define('GOOGLE_MAPS_PARSE_INCLUDES', 0);
 10+define('GOOGLE_MAPS_PARSE_ADD_MARKER', 1);
 11+define('GOOGLE_MAPS_PARSE_POINTS', 2);
1212 /**
1313 * This is a class for adding Google maps to Mediawiki articles. The class
1414 * takes care of all hook registration and output of both the map editing
@@ -359,7 +359,7 @@
360360 global $wgGoogleMaps;
361361 // pass through to the main render function, creating a new parser
362362 // for parsing the local content
363 - return $wgGoogleMaps->render( $pContent, $pArgv, $pParser, new Parser() );
 363+ return $wgGoogleMaps->render( $pContent, $pArgv, $pParser, new Parser() );
364364 }
365365
366366 /**
@@ -376,7 +376,6 @@
377377 function render ( $pContent, $pArgv, &$pParser, &$pLocalParser ) {
378378 $pLocalParser->mTitle = $this->mTitle;
379379 $pLocalParser->mOptions = $pParser->mOptions;
380 - $pLocalParser->clearState();
381380
382381 // Keep a count of how many <googlemap> tags were used for unique ids
383382 if( !isset( $this->mGoogleMapsOnThisPage ) ) {
@@ -574,12 +573,9 @@
575574 }
576575
577576 static function parseWikiText(&$pParser, &$pLocalParser, $pText, $pTitle, &$pOptions) {
578 - if (method_exists($pLocalParser, 'recursiveTagParse')) {
579 - $html = $pLocalParser->recursiveTagParse($pText);
580 - } else {
581 - $parsed = $pLocalParser->parse( $pText, $pTitle, $pOptions, false );
582 - $html = $parsed->getText();
583 - }
 577+ // recursiveTagParse seems broken, so do it the old-fashioned way.
 578+ $parsed = $pLocalParser->parse( $pText, $pTitle, $pOptions, false );
 579+ $html = $parsed->getText();
584580 return preg_replace('/<script.*?<\/script>/', '', $html);
585581 }
586582
Index: trunk/extensions/GoogleMaps/SpecialGoogleMapsKML.php
@@ -33,22 +33,21 @@
3434 $wgParser->mOptions = ParserOptions::newFromUser( $wgUser );
3535 $wgParser->mOptions->setEditSection( false );
3636 $wgParser->mTitle = $wgTitle;
 37+ $wgParser->clearState();
3738
3839 $localParser = new Parser();
3940 $localParser->mTitle = $title;
4041 $localParser->mOptions = $wgParser->mOptions;
41 - $localParser->clearState();
4242
43 -
4443 if (preg_match_all("/<googlemap( .*?|)>(.*?)<\/googlemap>/s", $revision->getText(), $matches)) {
4544 $exporter->addFileHeader();
4645 for($i=0;$i<count($matches[2]);$i++) {
47 - $attrs = Sanitizer::decodeTagAttributes($matches[1][$i]);
48 - $mapOptions['version'] = isset($attrs['version']) ? $attrs['version'] : "0";
49 - $exporter->addHeader(isset($attrs['title']) ? $attrs['title'] : "Map #".($i+1));
50 - GoogleMaps::renderContent($matches[2][$i], $wgParser, $localParser, $exporter, $mapOptions);
51 - $exporter->addTrailer();
52 - }
 46+ $attrs = Sanitizer::decodeTagAttributes($matches[1][$i]);
 47+ $mapOptions['version'] = isset($attrs['version']) ? $attrs['version'] : "0";
 48+ $exporter->addHeader(isset($attrs['title']) ? $attrs['title'] : "Map #".($i+1));
 49+ GoogleMaps::renderContent($matches[2][$i], $wgParser, $localParser, $exporter, $mapOptions);
 50+ $exporter->addTrailer();
 51+ }
5352 $exporter->addFileTrailer();
5453 echo $exporter->render();
5554 } else {

Status & tagging log