Skip to content

Commit

Permalink
Merge pull request #442 from JeroenDeDauw/fixparams
Browse files Browse the repository at this point in the history
 Fix circles and rectangles paremeters
  • Loading branch information
JeroenDeDauw authored Jul 4, 2018
2 parents f0874eb + 547ed4d commit 7810137
Show file tree
Hide file tree
Showing 5 changed files with 50 additions and 5 deletions.
2 changes: 1 addition & 1 deletion Maps.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@
);
}

define( 'Maps_VERSION', '5.5.0' );
define( 'Maps_VERSION', '5.5.1' );
define( 'SM_VERSION', Maps_VERSION );

if ( $GLOBALS['egMapsGMaps3Language'] === '' ) {
Expand Down
9 changes: 9 additions & 0 deletions RELEASE-NOTES.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,15 @@ different releases and which versions of PHP and MediaWiki they support, see the
[platform compatibility tables](INSTALL.md#platform-compatibility-and-release-status).


## Maps 5.5.1

Released on July 4th, 2018.

* Fixed fatal error when using `#display_map` parameter `circles`
* Fixed fatal error when using `#display_map` parameter `rectangles`
* Fixed `#display_map` parameter `rectangles` fill color modifier (it is no longer ignored)
* Fixed `#display_map` parameter `rectangles` fill opacity modifier (it is no longer ignored)

## Maps 5.5.0

Released on July 3rd, 2018.
Expand Down
4 changes: 2 additions & 2 deletions includes/parsers/CircleParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ class CircleParser implements ValueParser {

private $geocoder;

public function __construct( Geocoder $geocoder = null ) {
$this->geocoder = $geocoder ?? MapsFactory::newDefault()->newGeocoder();
public function __construct( $geocoder = null ) {
$this->geocoder = $geocoder instanceof Geocoder ? $geocoder : MapsFactory::newDefault()->newGeocoder();
}

/**
Expand Down
12 changes: 10 additions & 2 deletions includes/parsers/RectangleParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ class RectangleParser implements ValueParser {

private $geocoder;

public function __construct( Geocoder $geocoder = null ) {
$this->geocoder = $geocoder ?? MapsFactory::newDefault()->newGeocoder();
public function __construct( $geocoder = null ) {
$this->geocoder = $geocoder instanceof Geocoder ? $geocoder : MapsFactory::newDefault()->newGeocoder();
}

/**
Expand Down Expand Up @@ -63,6 +63,14 @@ public function parse( $value ) {
$rectangle->setStrokeWeight( array_shift( $metaData ) );
}

if ( $metaData !== [] ) {
$rectangle->setFillColor( array_shift( $metaData ) );
}

if ( $metaData !== [] ) {
$rectangle->setFillOpacity( array_shift( $metaData ) );
}

return $rectangle;
}

Expand Down
28 changes: 28 additions & 0 deletions tests/Integration/Parser/DisplayMapTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -107,4 +107,32 @@ public function testLocationDescriptionGetsIncluded() {
);
}

public function testRectangleDisplay() {
$this->assertContains(
'"title":"title',
$this->parse( '{{#display_map:rectangles=1,1:2,2~title}}' )
);
}

public function testCircleDisplay() {
$this->assertContains(
'"title":"title',
$this->parse( '{{#display_map:circles=1,1:2~title}}' )
);
}

public function testRectangleFillOpacityIsUsed() {
$this->assertContains(
'"fillOpacity":"fill opacity"',
$this->parse( '{{#display_map:rectangles=1,1:2,2~title~text~color~opacity~thickness~fill color~fill opacity}}' )
);
}

public function testRectangleFillColorIsUsed() {
$this->assertContains(
'"fillColor":"fill color"',
$this->parse( '{{#display_map:rectangles=1,1:2,2~title~text~color~opacity~thickness~fill color~fill opacity}}' )
);
}

}

0 comments on commit 7810137

Please sign in to comment.