Index: trunk/extensions/SemanticMaps/includes/queryprinters/SM_QueryPrinters.php |
— | — | @@ -66,6 +66,13 @@ |
67 | 67 | |
68 | 68 | $params = MapsMapper::getCommonParameters(); |
69 | 69 | |
| 70 | + $params['staticlocations'] = new ListParameter( 'staticlocations', ';' ); |
| 71 | + $params['staticlocations']->addAliases( 'locations' ); |
| 72 | + $params['staticlocations']->addCriteria( new CriterionIsLocation( '~' ) ); |
| 73 | + $params['staticlocations']->addManipulations( new MapsParamCoordSet( '~' ) ); |
| 74 | + $params['staticlocations']->lowerCaseValue = false; |
| 75 | + $params['staticlocations']->setDefault( array() ); |
| 76 | + |
70 | 77 | $params['centre'] = new Parameter( |
71 | 78 | 'centre', |
72 | 79 | Parameter::TYPE_STRING, |
Index: trunk/extensions/SemanticMaps/includes/queryprinters/SM_MapPrinter.php |
— | — | @@ -247,12 +247,72 @@ |
248 | 248 | * @param SMWQueryResult $res |
249 | 249 | * @param $outputmode |
250 | 250 | */ |
251 | | - private function formatResultData( SMWQueryResult $res, $outputmode ) { |
| 251 | + protected function formatResultData( SMWQueryResult $res, $outputmode ) { |
| 252 | + $this->addStaticLocations(); |
| 253 | + |
252 | 254 | while ( ( $row = $res->getNext() ) !== false ) { |
253 | 255 | $this->addResultRow( $outputmode, $row ); |
254 | 256 | } |
255 | 257 | } |
256 | 258 | |
| 259 | + protected function addStaticLocations() { |
| 260 | + global $wgTitle; |
| 261 | + |
| 262 | + // New parser object to render popup contents with. |
| 263 | + $parser = new Parser(); |
| 264 | + |
| 265 | + $this->title = $parser->parse( $this->title, $wgTitle, new ParserOptions() )->getText(); |
| 266 | + $this->label = $parser->parse( $this->label, $wgTitle, new ParserOptions() )->getText(); |
| 267 | + |
| 268 | + // Each $location is an array containg the coordinate set as first element, possibly followed by meta data. |
| 269 | + foreach ( $this->staticlocations as $location ) { |
| 270 | + $markerData = MapsCoordinateParser::parseCoordinates( array_shift( $location ) ); |
| 271 | + |
| 272 | + if ( !$markerData ) continue; |
| 273 | + |
| 274 | + if ( count( $location ) > 0 ) { |
| 275 | + // Parse and add the point specific title if it's present. |
| 276 | + $markerData['title'] = $parser->parse( $location[0], $wgTitle, new ParserOptions() )->getText(); |
| 277 | + |
| 278 | + if ( count( $location ) > 1 ) { |
| 279 | + // Parse and add the point specific label if it's present. |
| 280 | + $markerData['label'] = $parser->parse( $location[1], $wgTitle, new ParserOptions() )->getText(); |
| 281 | + |
| 282 | + if ( count( $location ) > 2 ) { |
| 283 | + // Add the point specific icon if it's present. |
| 284 | + $markerData['icon'] = $location[2]; |
| 285 | + } |
| 286 | + } |
| 287 | + } |
| 288 | + |
| 289 | + // If there is no point specific icon, use the general icon parameter when available. |
| 290 | + if ( !array_key_exists( 'icon', $markerData ) && $this->icon != '' ) { |
| 291 | + $markerData['icon'] = $this->icon; |
| 292 | + } |
| 293 | + |
| 294 | + // Get the url for the icon when there is one, else set the icon to an empty string. |
| 295 | + if ( array_key_exists( 'icon', $markerData ) ) { |
| 296 | + $icon_image_page = new ImagePage( Title::newFromText( $markerData['icon'] ) ); |
| 297 | + $markerData['icon'] = $icon_image_page->getDisplayedFile()->getURL(); |
| 298 | + } |
| 299 | + else { |
| 300 | + $markerData['icon'] = ''; |
| 301 | + } |
| 302 | + |
| 303 | + // Temporary fix, will refactor away later |
| 304 | + // TODO |
| 305 | + $markerData = array_values( $markerData ); |
| 306 | + if ( count( $markerData ) < 5 ) { |
| 307 | + if ( count( $markerData ) < 4 ) { |
| 308 | + $markerData[] = ''; |
| 309 | + } |
| 310 | + $markerData[] = ''; |
| 311 | + } |
| 312 | + |
| 313 | + $this->locations[] = $markerData; |
| 314 | + } |
| 315 | + } |
| 316 | + |
257 | 317 | /** |
258 | 318 | * This function will loop through all properties (fields) of one record (row), |
259 | 319 | * and add the location data, title, label and icon to the m_locations array. |
— | — | @@ -262,7 +322,7 @@ |
263 | 323 | * @param $outputmode |
264 | 324 | * @param array $row The record you want to add data from |
265 | 325 | */ |
266 | | - private function addResultRow( $outputmode, array $row ) { |
| 326 | + protected function addResultRow( $outputmode, array $row ) { |
267 | 327 | global $wgUser, $smgUseSpatialExtensions, $wgTitle; |
268 | 328 | |
269 | 329 | $skin = $wgUser->getSkin(); |
Index: trunk/extensions/SemanticMaps/SemanticMaps.php |
— | — | @@ -40,7 +40,7 @@ |
41 | 41 | if ( defined( 'Maps_VERSION' ) && defined( 'SMW_VERSION' ) ) { |
42 | 42 | define( 'SM_VERSION', '0.7 alpha-7' ); |
43 | 43 | |
44 | | - $useExtensionPath = version_compare( $wgVersion, '1.16', '>=' ) && isset( $wgExtensionAssetsPath ) && $wgExtensionAssetsPath; |
| 44 | + $useExtensionPath = /*version_compare( $wgVersion, '1.16', '>=' ) &&*/ isset( $wgExtensionAssetsPath ) && $wgExtensionAssetsPath; |
45 | 45 | $smgScriptPath = ( $useExtensionPath ? $wgExtensionAssetsPath : $wgScriptPath . '/extensions' ) . '/SemanticMaps'; |
46 | 46 | $smgDir = dirname( __FILE__ ) . '/'; |
47 | 47 | unset( $useExtensionPath ); |