jenkins-bot has submitted this change and it was merged. Change subject: rename MultiMapsServices to \MultiMaps\MapServices ......................................................................
rename MultiMapsServices to \MultiMaps\MapServices Change-Id: I11c604ce5fd57e225bd30efda5e665c0c436cd63 --- M MultiMaps.body.php M MultiMaps.php M Settings.php A includes/MapServices.php D includes/Services.php 5 files changed, 71 insertions(+), 70 deletions(-) Approvals: Pastakhov: Verified; Looks good to me, approved jenkins-bot: Verified diff --git a/MultiMaps.body.php b/MultiMaps.body.php index 2197970..7c95f7a 100644 --- a/MultiMaps.body.php +++ b/MultiMaps.body.php @@ -28,7 +28,7 @@ break; } } - $service = MultiMapsServices::getServiceInstance( 'showmap', $nameService ); + $service = \MultiMaps\MapServices::getServiceInstance( 'showmap', $nameService ); if( !($service instanceof \MultiMaps\BaseMapService) ) { if( is_string($service) ) { diff --git a/MultiMaps.php b/MultiMaps.php index 3b258ce..39ea189 100644 --- a/MultiMaps.php +++ b/MultiMaps.php @@ -50,7 +50,7 @@ //Preparing classes for autoloading // TODO: $wgAutoloadClasses = array_merge( $wgAutoloadClasses, include 'MultiMaps.classes.php' ); $wgAutoloadClasses['MultiMaps'] = $dir . '/MultiMaps.body.php'; -$wgAutoloadClasses['MultiMapsServices'] = $dir . '/includes/Services.php'; +$wgAutoloadClasses['MultiMaps\\MapServices'] = $dir . '/includes/MapServices.php'; $wgAutoloadClasses['MultiMaps\\BaseMapService'] = $dir . '/includes/BaseMapService.php'; $wgAutoloadClasses['MultiMaps\\Bounds'] = $dir . '/includes/Bounds.php'; diff --git a/Settings.php b/Settings.php index ef5fc00..b7dfbc8 100644 --- a/Settings.php +++ b/Settings.php @@ -22,7 +22,7 @@ // Array of String. Array containing all the mapping services that will be made available to the user. // Firs value - default service, which will be used if the service is not in the parameters // Values may be a valid name of class based on class BaseMapService -$egMultiMapsServices_showmap = array( +$egMultiMaps_MapServices = array( 'Leaflet', 'Google', 'Yandex', diff --git a/includes/MapServices.php b/includes/MapServices.php new file mode 100644 index 0000000..d68f130 --- /dev/null +++ b/includes/MapServices.php @@ -0,0 +1,68 @@ +<?php +namespace MultiMaps; +/** + * This class allows you to work with a collection of defined services + * + * @file MapServices.php + * @ingroup MultiMaps + * @author Pavel Astakhov <pastak...@yandex.ru> + * @licence GNU General Public Licence 2.0 or later + */ + +class MapServices { + + /** + * Returns the instance of a service class. + * If the service is not specified or is not available, the service returns the specified default + * On error returns error message + * @global array $egMultiMaps_MapServices + * @param string $action + * @param string $servicename + * @return MultiMaps\BaseMapService return class extends \MultiMaps\BaseService or string of error message + */ + public static function getServiceInstance( $action, $servicename ) { + global $egMultiMaps_MapServices; + + //default error message + $returnservice = \wfMessage( 'multimaps-method-error-unexpected-result', __METHOD__ . " ( $action, $servicename ) " )->escaped(); + + switch ($action) { + case 'showmap': + if( is_array($egMultiMaps_MapServices) === false || count($egMultiMaps_MapServices) == 0 ) { + throw new \MWException('$egMultiMaps_MapServices must not be an empty array'); + } + $errormessage = ''; + $classkey = array_search(strtolower($servicename),array_map('strtolower',$egMultiMaps_MapServices)); + if( $classkey === false ) { // a user-specified service can not be found + $classname = $egMultiMaps_MapServices[0]; + $errormessage = \wfMessage( 'multimaps-passed-unavailable-service', $servicename, implode(', ', $egMultiMaps_MapServices), $classname )->escaped(); + } else { + $classname = $egMultiMaps_MapServices[$classkey]; + } + + $newclassname="MultiMaps\\$classname"; + if( !class_exists($newclassname) ) { + if ( $errormessage != '' ) { + $errormessage .= '<br />'; + } + return $errormessage . \wfMessage( 'multimaps-unknown-class-for-service', $newclassname )->escaped(); + } + + $returnservice = new $newclassname(); + if( !($returnservice instanceof BaseMapService) ) { + return \wfMessage( 'multimaps-error-incorrect-class-for-service', $newclassname )->escaped(); + } + + if ( $errormessage != '' ) { + $returnservice->pushErrorMessage( $errormessage ); + } + break; + + default: + return \wfMessage( 'multimaps-method-error-unknown-action', __METHOD__ . " ( $action )" )->escaped(); + } + + return $returnservice; + } + +} \ No newline at end of file diff --git a/includes/Services.php b/includes/Services.php deleted file mode 100644 index 6c105be..0000000 --- a/includes/Services.php +++ /dev/null @@ -1,67 +0,0 @@ -<?php -/** - * This class allows you to work with a collection of defined services - * - * @file Services.php - * @ingroup MultiMaps - * @author Pavel Astakhov <pastak...@yandex.ru> - * @licence GNU General Public Licence 2.0 or later - */ - -class MultiMapsServices { - - /** - * Returns the instance of a service class. - * If the service is not specified or is not available, the service returns the specified default - * On error returns error message - * @global array $egMultiMapsServices_showmap - * @param string $action - * @param string $servicename - * @return MultiMaps\BaseMapService return class extends \MultiMaps\BaseService or string of error message - */ - public static function getServiceInstance( $action, $servicename ) { - global $egMultiMapsServices_showmap; - - //default error message - $returnservice = wfMessage( 'multimaps-method-error-unexpected-result', __METHOD__ . " ( $action, $servicename ) " )->escaped(); - - switch ($action) { - case 'showmap': - if( is_array($egMultiMapsServices_showmap) === false || count($egMultiMapsServices_showmap) == 0 ) { - throw new MWException('$egMultiMapsServices_showmap must not be an empty array'); - } - $errormessage = ''; - $classkey = array_search(strtolower($servicename),array_map('strtolower',$egMultiMapsServices_showmap)); - if( $classkey === false ) { // a user-specified service can not be found - $classname = $egMultiMapsServices_showmap[0]; - $errormessage = \wfMessage( 'multimaps-passed-unavailable-service', $servicename, implode(', ', $egMultiMapsServices_showmap), $classname )->escaped(); - } else { - $classname = $egMultiMapsServices_showmap[$classkey]; - } - - $newclassname="MultiMaps\\$classname"; - if( !class_exists($newclassname) ) { - if ( $errormessage != '' ) { - $errormessage .= '<br />'; - } - return $errormessage . wfMessage( 'multimaps-unknown-class-for-service', $newclassname )->escaped(); - } - - $returnservice = new $newclassname(); - if( !($returnservice instanceof \MultiMaps\BaseMapService) ) { - return wfMessage( 'multimaps-error-incorrect-class-for-service', $newclassname )->escaped(); - } - - if ( $errormessage != '' ) { - $returnservice->pushErrorMessage( $errormessage ); - } - break; - - default: - return wfMessage( 'multimaps-method-error-unknown-action', __METHOD__ . " ( $action )" )->escaped(); - } - - return $returnservice; - } - -} \ No newline at end of file -- To view, visit https://gerrit.wikimedia.org/r/49979 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: I11c604ce5fd57e225bd30efda5e665c0c436cd63 Gerrit-PatchSet: 2 Gerrit-Project: mediawiki/extensions/MultiMaps Gerrit-Branch: master Gerrit-Owner: Pastakhov <pastak...@yandex.ru> Gerrit-Reviewer: Pastakhov <pastak...@yandex.ru> Gerrit-Reviewer: jenkins-bot _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits