Skip to content
This repository has been archived by the owner on Mar 29, 2019. It is now read-only.

Commit

Permalink
Merge pull request #63 from SemanticMediaWiki/shortarray
Browse files Browse the repository at this point in the history
Switched arrays to short syntax
  • Loading branch information
JeroenDeDauw committed Apr 9, 2016
2 parents 5abac30 + 94a51d6 commit 8d561f3
Show file tree
Hide file tree
Showing 17 changed files with 137 additions and 137 deletions.
4 changes: 2 additions & 2 deletions SemanticMaps.i18n.php
Expand Up @@ -10,10 +10,10 @@
*
* This shim maintains compatibility back to MediaWiki 1.17.
*/
$messages = array();
$messages = [];
if ( !function_exists( 'wfJsonI18nShim10057dcaad891c84' ) ) {
function wfJsonI18nShim10057dcaad891c84( $cache, $code, &$cachedData ) {
$codeSequence = array_merge( array( $code ), $cachedData['fallbackSequence'] );
$codeSequence = array_merge( [ $code ], $cachedData['fallbackSequence'] );
foreach ( $codeSequence as $csCode ) {
$fileName = dirname( __FILE__ ) . "/i18n/$csCode.json";
if ( is_readable( $fileName ) ) {
Expand Down
22 changes: 11 additions & 11 deletions SemanticMaps.php
Expand Up @@ -33,41 +33,41 @@
throw new Exception( 'You need to have Maps installed in order to use Semantic Maps' );
}

$GLOBALS['wgExtensionCredits']['semantic'][] = array(
$GLOBALS['wgExtensionCredits']['semantic'][] = [
'path' => __FILE__,
'name' => 'Semantic Maps',
'version' => SM_VERSION,
'author' => array(
'author' => [
'[https://www.mediawiki.org/wiki/User:Jeroen_De_Dauw Jeroen De Dauw]'
),
],
'url' => 'https://github.com/SemanticMediaWiki/SemanticMaps/blob/master/README.md#semantic-maps',
'descriptionmsg' => 'semanticmaps-desc',
'license-name' => 'GPL-2.0+'
);
];

// Include the settings file.
require_once 'SM_Settings.php';

include_once __DIR__ . '/src/queryprinters/SM_QueryPrinters.php';

$GLOBALS['wgResourceModules']['ext.sm.forminputs'] = array(
'dependencies' => array( 'ext.maps.coord' ),
$GLOBALS['wgResourceModules']['ext.sm.forminputs'] = [
'dependencies' => [ 'ext.maps.coord' ],
'position' => 'bottom',
'localBasePath' => __DIR__ . '/src/forminputs',
'remoteExtPath' => 'SemanticMaps/src/forminputs',
'group' => 'ext.semanticmaps',
'scripts' => array(
'scripts' => [
'jquery.mapforminput.js'
),
'messages' => array(
],
'messages' => [
'semanticmaps_enteraddresshere',
'semanticmaps-updatemap',
'semanticmaps_lookupcoordinates',
'semanticmaps-forminput-remove',
'semanticmaps-forminput-add',
'semanticmaps-forminput-locations'
)
);
]
];


include_once __DIR__ . '/src/services/GoogleMaps3/SM_GoogleMaps3.php';
Expand Down
6 changes: 3 additions & 3 deletions src/SM_AreaValueDescription.php
Expand Up @@ -142,7 +142,7 @@ public function getSQLCondition( $tableName, array $fieldNames, DatabaseBase $db

$isEq = $this->getComparator() == SMW_CMP_EQ;

$conditions = array();
$conditions = [];

$smallerThen = $isEq ? '<' : '>=';
$biggerThen = $isEq ? '>' : '<=';
Expand Down Expand Up @@ -172,12 +172,12 @@ protected function getBoundingBox() {
$south = MapsGeoFunctions::findDestination( $center, 180, $this->radius );
$west = MapsGeoFunctions::findDestination( $center, 270, $this->radius );

return array(
return [
'north' => $north['lat'],
'east' => $east['lon'],
'south' => $south['lat'],
'west' => $west['lon'],
);
];
}

/**
Expand Down
18 changes: 9 additions & 9 deletions src/SM_GeoCoordsValue.php
Expand Up @@ -56,9 +56,9 @@ protected function loadDataItem( SMWDataItem $dataItem ) {
protected function getFormattedCoord( SMWDIGeoCoord $dataItem, $format = null ) {
global $smgQPCoodFormat;

$options = new \ValueFormatters\FormatterOptions( array(
$options = new \ValueFormatters\FormatterOptions( [
GeoCoordinateFormatter::OPT_FORMAT => $format === null ? $smgQPCoodFormat : $format, // TODO
) );
] );

// TODO: $smgQPCoodDirectional

Expand Down Expand Up @@ -141,7 +141,7 @@ protected function parseUserValue( $value ) {
$this->tryParseAndSetDataItem( $coordinates );
}

return array( $distance, $comparator );
return [ $distance, $comparator ];
}

protected function findValueParts( $value ) {
Expand All @@ -150,7 +150,7 @@ protected function findValueParts( $value ) {
$coordinates = trim( array_shift( $parts ) );
$distance = count( $parts ) > 0 ? trim( array_shift( $parts ) ) : false;

return array( $coordinates, $distance );
return [ $coordinates, $distance ];
}

/**
Expand All @@ -169,7 +169,7 @@ protected function tryParseAndSetDataItem( $coordinates ) {

// Make sure this is always set
// TODO: Why is this needed?!
$this->m_dataitem = new SMWDIGeoCoord( array( 'lat' => 0, 'lon' => 0 ) );
$this->m_dataitem = new SMWDIGeoCoord( [ 'lat' => 0, 'lon' => 0 ] );
}
}

Expand Down Expand Up @@ -215,10 +215,10 @@ public function getLongWikiText( $linked = null ) {

$text = $this->getFormattedCoord( $this->m_dataitem );

$lines = array(
$lines = [
wfMessage( 'semanticmaps-latitude', $coordinateSet['lat'] )->inContentLanguage()->escaped(),
wfMessage( 'semanticmaps-longitude', $coordinateSet['lon'] )->inContentLanguage()->escaped(),
);
];

if ( array_key_exists( 'alt', $coordinateSet ) ) {
$lines[] = wfMessage( 'semanticmaps-altitude', $coordinateSet['alt'] )->inContentLanguage()->escaped();
Expand Down Expand Up @@ -265,12 +265,12 @@ public function getWikiValue() {
*/
protected function getServiceLinkParams() {
$coordinateSet = $this->m_dataitem->getCoordinateSet();
return array(
return [
$this->getFormattedCoord( $this->m_dataitem, 'float' ), // TODO
$this->getFormattedCoord( $this->m_dataitem, 'dms' ), // TODO
$coordinateSet['lat'],
$coordinateSet['lon']
);
];
}

}
2 changes: 1 addition & 1 deletion src/SM_GeoCoordsValueDescription.php
Expand Up @@ -63,7 +63,7 @@ public function getSQLCondition( $tableName, array $fieldNames, DatabaseBase $db
$lat = $dbs->addQuotes( $dataItem->getLatitude() );
$lon = $dbs->addQuotes( $dataItem->getLongitude() );

$conditions = array();
$conditions = [];

$conditions[] = "{$tableName}.$fieldNames[1] $comparator $lat";
$conditions[] = "{$tableName}.$fieldNames[2] $comparator $lon";
Expand Down
14 changes: 7 additions & 7 deletions src/SM_PolygonHandler.php
Expand Up @@ -39,7 +39,7 @@ class PolygonHandler {
*
* @var array
*/
protected $errors = array();
protected $errors = [];

/**
* Array of classes used to validate different Geographic shapes.
Expand All @@ -48,13 +48,13 @@ class PolygonHandler {
*
* @var array
*/
protected $validatorClasses = array(
protected $validatorClasses = [
'locations' => 'LocationValidator',
'lines' => 'LineValidator',
'polygons' => 'PolygonValidator',
'circles' => 'CircleValidator',
'rectangles' => 'RectangleValidator'
);
];

/**
* Array of classes of different Geographic shapes.
Expand All @@ -63,13 +63,13 @@ class PolygonHandler {
*
* @var array
*/
protected $geoClasses = array(
protected $geoClasses = [
'locations' => 'MapsLocation',
'lines' => 'MapsLine',
'polygons' => 'MapsPolygon',
'circles' => 'MapsCircle',
'rectangles' => 'MapsRectanlge'
);
];

/**
* NOTE: These need to be changed as Manipulations are depreceated.
Expand All @@ -79,13 +79,13 @@ class PolygonHandler {
*
* @var array
*/
protected $paramClasses = array(
protected $paramClasses = [
'locations' => 'MapsParamLocation',
'lines' => 'MapsParamLine',
'polygons' => 'MapsParamPolygon',
'circles' => 'MapsParamCircle',
'rectangles' => 'MapsParamRectangle'
);
];

/**
* Constructor.
Expand Down
2 changes: 1 addition & 1 deletion src/forminputs/FormInputsSetup.php
Expand Up @@ -65,7 +65,7 @@ private function initialize() {
*/
private function initFormHook( $inputName, $mainName = '' ) {
// Add the form input hook for the service.
$field_args = array();
$field_args = [];

if ( $mainName !== '' ) {
$field_args['service_name'] = $mainName;
Expand Down
44 changes: 22 additions & 22 deletions src/forminputs/SM_FormInput.php
Expand Up @@ -61,30 +61,30 @@ protected function getParameterInfo() {
protected function getParameterDefinitions() {
global $smgFIFieldSize;

$params = array();
$params = [];

$params['fieldsize'] = array(
$params['fieldsize'] = [
'type' => 'integer',
'default' => $smgFIFieldSize,
'range' => array( 5, 100 ),
);
'range' => [ 5, 100 ],
];

$params['icon'] = array(
$params['icon'] = [
'default' => '',
);
];

$params['locations'] = array(
$params['locations'] = [
'type' => 'mapslocation',
'aliases' => array( 'points' ),
'default' => array(),
'aliases' => [ 'points' ],
'default' => [],
'islist' => true,
'delimiter' => self::SEPARATOR,
);
];

$params['geocodecontrol'] = array(
$params['geocodecontrol'] = [
'type' => 'boolean',
'default' => true,
);
];

// Messages:
// semanticmaps-par-staticlocations, semanticmaps-par-showtitle,
Expand All @@ -109,7 +109,7 @@ protected function getParameterDefinitions() {
* @return string
*/
public function getInputOutput( $coordinates, $inputName, $isMandatory, $isDisabled, array $params ) {
$parameters = array();
$parameters = [];
foreach ( $params as $key => $value ) {
if ( !is_array( $value ) && !is_object( $value ) && !is_null( $value ) ) {
$parameters[$key] = $value;
Expand Down Expand Up @@ -209,19 +209,19 @@ public function getEditorInputOutput( $coordinates, $input_name, $isMandatory, $

$wgOut->addHTML( MapsGoogleMaps3::getApiScript(
'en',
array( 'libraries' => 'drawing' )
[ 'libraries' => 'drawing' ]
) );

$wgOut->addModules( 'mapeditor' );

$html = Html::element(
'div',
array(
[
'id' => 'map-polygon',
'name' => $input_name,
'cols' => 4,
'rows' => 2,
),
],
$coordinates
);

Expand All @@ -245,15 +245,15 @@ public function getEditorInputOutput( $coordinates, $input_name, $isMandatory, $
protected function getInputHTML( array $params, Parser $parser, $mapName ) {
return Html::rawElement(
'div',
array(
[
'id' => $mapName . '_forminput',
'style' => 'display: inline',
'class' => 'sminput sminput-' . $this->service->getName()
),
],
wfMessage( 'semanticmaps-loading-forminput' )->escaped() .
Html::element(
'div',
array( 'style' => 'display:none', 'class' => 'sminputdata' ),
[ 'style' => 'display:none', 'class' => 'sminputdata' ],
FormatJson::encode( $this->getJSONObject( $params, $parser ) )
)
);
Expand Down Expand Up @@ -286,7 +286,7 @@ protected function getJSONObject( array $params, Parser $parser ) {
* @return array of string
*/
protected function getResourceModules() {
return array( 'ext.sm.forminputs' );
return [ 'ext.sm.forminputs' ];
}

/**
Expand All @@ -295,11 +295,11 @@ protected function getResourceModules() {
* @return string
*/
protected function getAttribs(){
return array(
return [
'id' => 'map-canvas',
'context' => 'forminput',
'style' => 'width:600px; height:400px'
);
];
}

}
16 changes: 8 additions & 8 deletions src/queryprinters/SM_KMLPrinter.php
Expand Up @@ -61,26 +61,26 @@ public function getParamDefinitions( array $definitions ) {

$params = parent::getParamDefinitions( $definitions );

$params['text'] = array(
$params['text'] = [
'message' => 'semanticmaps-kml-text',
'default' => $egMapsDefaultLabel,
);
];

$params['title'] = array(
$params['title'] = [
'message' => 'semanticmaps-kml-title',
'default' => $egMapsDefaultTitle,
);
];

$params['linkabsolute'] = array(
$params['linkabsolute'] = [
'message' => 'semanticmaps-kml-linkabsolute',
'type' => 'boolean',
'default' => true,
);
];

$params['pagelinktext'] = array(
$params['pagelinktext'] = [
'message' => 'semanticmaps-kml-pagelinktext',
'default' => wfMessage( 'semanticmaps-default-kml-pagelink' )->text(),
);
];

return $params;
}
Expand Down

0 comments on commit 8d561f3

Please sign in to comment.