[MediaWiki-commits] [Gerrit] update to version 0.4.3 - change (mediawiki...MultiMaps)
jenkins-bot has submitted this change and it was merged. Change subject: update to version 0.4.3 .. update to version 0.4.3 Allow specify an icon for the marker from the directory add two global variables $egMultiMaps_IconAllowFromDirectory $egMultiMaps_IconPath Change-Id: Iebf53396a6a475310caaf7e3bbef7a621c1f2565 --- M MultiMaps.php M Settings.php M includes/mapelements/Marker.php M services/Google/Google.php M services/Yandex/Yandex.php M tests/phpunit/services/Yandex/YandexTest.php 6 files changed, 23 insertions(+), 10 deletions(-) Approvals: Pastakhov: Looks good to me, approved jenkins-bot: Verified diff --git a/MultiMaps.php b/MultiMaps.php index e289f5d..91c54cb 100644 --- a/MultiMaps.php +++ b/MultiMaps.php @@ -15,7 +15,7 @@ die( 'This file is an extension to MediaWiki and thus not a valid entry point.' ); } -define( 'MultiMaps_VERSION' , '0.4.2' ); +define( 'MultiMaps_VERSION' , '0.4.3' ); // Register this extension on Special:Version $wgExtensionCredits['parserhook'][] = array( diff --git a/Settings.php b/Settings.php index c7273a8..2f83461 100644 --- a/Settings.php +++ b/Settings.php @@ -43,6 +43,11 @@ $egMultiMaps_Width = 'auto'; $egMultiMaps_Height = '350px'; +// Boolean. If true, allow specify an icon for the marker from the directory +$egMultiMaps_IconAllowFromDirectory = false; +// String. The URL base path to the directory containing icons for markers +$egMultiMaps_IconPath = "$wgScriptPath/mapicons"; + //TODO //$egMultiMaps_GoogleApiKey = false; //$egMultiMaps_YandexApiKey = false; diff --git a/includes/mapelements/Marker.php b/includes/mapelements/Marker.php index 8e025a2..c4a9dd1 100644 --- a/includes/mapelements/Marker.php +++ b/includes/mapelements/Marker.php @@ -31,13 +31,21 @@ public function setProperty($name, $value) { if( strtolower($name) == 'icon' ) { - $title = \Title::newFromText( $value, NS_FILE ); - if ( !is_null( $title ) && $title->exists() ) { - $imagePage = new \ImagePage( $title ); - $value = $imagePage->getDisplayedFile()->getURL(); + if ( $value[0] == '/' && $GLOBALS['egMultiMaps_IconAllowFromDirectory'] === true ) { + if ( preg_match('#[^0-9a-zA-Zа-яА-Я./_=\+\-]#', $value) || preg_match('#/../#', $value) ) { + $this->errormessages[] = \wfMessage( 'multimaps-marker-incorrect-icon', $value )->escaped(); + return false; + } + $value = $GLOBALS['wgServer'] . $GLOBALS['egMultiMaps_IconPath'] . $value; } else { - $this->errormessages[] = \wfMessage( 'multimaps-marker-incorrect-icon', $value )->escaped(); - return false; + $title = \Title::newFromText( $value, NS_FILE ); + if ( !is_null( $title ) && $title->exists() ) { + $imagePage = new \ImagePage( $title ); + $value = $imagePage->getDisplayedFile()->getURL(); + } else { + $this->errormessages[] = \wfMessage( 'multimaps-marker-incorrect-icon', $value )->escaped(); + return false; + } } } return parent::setProperty($name, $value); diff --git a/services/Google/Google.php b/services/Google/Google.php index 5221f42..425aede 100644 --- a/services/Google/Google.php +++ b/services/Google/Google.php @@ -25,7 +25,7 @@ $urlArgs = array(); $urlArgs['sensor'] = 'false'; - $this->headerItem .= \Html::linkedScript( 'http://maps.googleapis.com/maps/api/js?'.wfArrayToCgi($urlArgs) ) . "\n"; + $this->headerItem .= \Html::linkedScript( 'https://maps.googleapis.com/maps/api/js?'.wfArrayToCgi($urlArgs) ) . "\n"; } } \ No newline at end of file diff --git a/services/Yandex/Yandex.php b/services/Yandex/Yandex.php index d792bef..b7474eb 100644 --- a/services/Yandex/Yandex.php +++ b/services/Yandex/Yandex.php @@ -26,7 +26,7 @@ $urlArgs = array(); $urlArgs['load'] = 'package.standard,package.geoObjects'; $urlArgs['lang'] = 'ru-RU'; - $this->headerItem .= \Html::linkedScript( 'http://api-maps.yandex.ru/2.0-stable/?'.wfArrayToCgi($urlArgs) ) . "\n"; + $this->headerItem .= \Html::linkedScript( 'https://api-maps.yandex.ru/2.0-stable/?'.wfArrayToCgi($urlArgs) ) . "\n"; } } \ No newline at end of file diff --git a/tests/phpunit/services/Yandex/YandexTest.php b/tes
[MediaWiki-commits] [Gerrit] update to version 0.4.3 - change (mediawiki...MultiMaps)
Pastakhov has uploaded a new change for review. https://gerrit.wikimedia.org/r/106216 Change subject: update to version 0.4.3 .. update to version 0.4.3 Allow specify an icon for the marker from the directory add two global variables $egMultiMaps_IconAllowFromDirectory $egMultiMaps_IconPath Change-Id: Iebf53396a6a475310caaf7e3bbef7a621c1f2565 --- M MultiMaps.php M Settings.php M includes/mapelements/Marker.php M services/Google/Google.php M services/Yandex/Yandex.php 5 files changed, 22 insertions(+), 9 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/MultiMaps refs/changes/16/106216/1 diff --git a/MultiMaps.php b/MultiMaps.php index e289f5d..91c54cb 100644 --- a/MultiMaps.php +++ b/MultiMaps.php @@ -15,7 +15,7 @@ die( 'This file is an extension to MediaWiki and thus not a valid entry point.' ); } -define( 'MultiMaps_VERSION' , '0.4.2' ); +define( 'MultiMaps_VERSION' , '0.4.3' ); // Register this extension on Special:Version $wgExtensionCredits['parserhook'][] = array( diff --git a/Settings.php b/Settings.php index c7273a8..2f83461 100644 --- a/Settings.php +++ b/Settings.php @@ -43,6 +43,11 @@ $egMultiMaps_Width = 'auto'; $egMultiMaps_Height = '350px'; +// Boolean. If true, allow specify an icon for the marker from the directory +$egMultiMaps_IconAllowFromDirectory = false; +// String. The URL base path to the directory containing icons for markers +$egMultiMaps_IconPath = "$wgScriptPath/mapicons"; + //TODO //$egMultiMaps_GoogleApiKey = false; //$egMultiMaps_YandexApiKey = false; diff --git a/includes/mapelements/Marker.php b/includes/mapelements/Marker.php index 8e025a2..c4a9dd1 100644 --- a/includes/mapelements/Marker.php +++ b/includes/mapelements/Marker.php @@ -31,13 +31,21 @@ public function setProperty($name, $value) { if( strtolower($name) == 'icon' ) { - $title = \Title::newFromText( $value, NS_FILE ); - if ( !is_null( $title ) && $title->exists() ) { - $imagePage = new \ImagePage( $title ); - $value = $imagePage->getDisplayedFile()->getURL(); + if ( $value[0] == '/' && $GLOBALS['egMultiMaps_IconAllowFromDirectory'] === true ) { + if ( preg_match('#[^0-9a-zA-Zа-яА-Я./_=\+\-]#', $value) || preg_match('#/../#', $value) ) { + $this->errormessages[] = \wfMessage( 'multimaps-marker-incorrect-icon', $value )->escaped(); + return false; + } + $value = $GLOBALS['wgServer'] . $GLOBALS['egMultiMaps_IconPath'] . $value; } else { - $this->errormessages[] = \wfMessage( 'multimaps-marker-incorrect-icon', $value )->escaped(); - return false; + $title = \Title::newFromText( $value, NS_FILE ); + if ( !is_null( $title ) && $title->exists() ) { + $imagePage = new \ImagePage( $title ); + $value = $imagePage->getDisplayedFile()->getURL(); + } else { + $this->errormessages[] = \wfMessage( 'multimaps-marker-incorrect-icon', $value )->escaped(); + return false; + } } } return parent::setProperty($name, $value); diff --git a/services/Google/Google.php b/services/Google/Google.php index 5221f42..425aede 100644 --- a/services/Google/Google.php +++ b/services/Google/Google.php @@ -25,7 +25,7 @@ $urlArgs = array(); $urlArgs['sensor'] = 'false'; - $this->headerItem .= \Html::linkedScript( 'http://maps.googleapis.com/maps/api/js?'.wfArrayToCgi($urlArgs) ) . "\n"; + $this->headerItem .= \Html::linkedScript( 'https://maps.googleapis.com/maps/api/js?'.wfArrayToCgi($urlArgs) ) . "\n"; } } \ No newline at end of file diff --git a/services/Yandex/Yandex.php b/services/Yandex/Yandex.php index d792bef..b7474eb 100644 --- a/services/Yandex/Yandex.php +++ b/services/Yandex/Yandex.php @@ -26,7 +26,7 @@ $urlArgs = array(); $urlArgs['load'] = 'package.standard,package.geoObjects'; $urlArgs['lang'] = 'ru-RU'; - $this->headerItem .= \Html::linkedScript( 'http://api-maps.yandex.ru/2.0-stable/?'.wfArrayToCgi($urlArgs) ) . "\n"; + $this->headerItem .= \Html::linkedScript( 'https://api-maps.yandex.ru/2.0-stable/?'.wfArrayToCgi($urlArgs) ) . "\n"; } } \ No newline at end of file -- To view, visit https://gerrit.wikimedia.org/r/1062