Index: branches/SemanticMaps0.8/includes/queryprinters/SM_MapPrinter.php |
— | — | @@ -133,6 +133,7 @@ |
134 | 134 | New CriterionNotEmpty() |
135 | 135 | ) |
136 | 136 | ); |
| 137 | + $params['template']->setDoManipulationOfDefault( false ); |
137 | 138 | |
138 | 139 | $params['title'] = new Parameter( |
139 | 140 | 'title', |
— | — | @@ -166,6 +167,7 @@ |
167 | 168 | |
168 | 169 | $queryHandler = new SMQueryHandler( $res, $outputmode ); |
169 | 170 | $queryHandler->setShowSubject( $params['showtitle'] ); |
| 171 | + $queryHandler->setTemplate( $params['template'] ); |
170 | 172 | |
171 | 173 | $this->handleMarkerData( $params, $queryHandler->getLocations() ); |
172 | 174 | $locationAmount = count( $params['locations'] ); |
Index: branches/SemanticMaps0.8/includes/queryprinters/SM_QueryHandler.php |
— | — | @@ -17,7 +17,14 @@ |
18 | 18 | |
19 | 19 | protected $locations = false; |
20 | 20 | |
21 | | - public $template = false; |
| 21 | + /** |
| 22 | + * The template to use for the text, or false if there is none. |
| 23 | + * |
| 24 | + * @since 0.7.3 |
| 25 | + * |
| 26 | + * @var false or string |
| 27 | + */ |
| 28 | + protected $template = false; |
22 | 29 | |
23 | 30 | /** |
24 | 31 | * The global icon. |
— | — | @@ -118,6 +125,17 @@ |
119 | 126 | } |
120 | 127 | |
121 | 128 | /** |
| 129 | + * Sets the template. |
| 130 | + * |
| 131 | + * @since 0.8 |
| 132 | + * |
| 133 | + * @param string $template |
| 134 | + */ |
| 135 | + public function setTemplate( $template ) { |
| 136 | + $this->template = $template == '' ? false : $template; |
| 137 | + } |
| 138 | + |
| 139 | + /** |
122 | 140 | * Sets the global icon. |
123 | 141 | * |
124 | 142 | * @since 0.8 |
— | — | @@ -253,10 +271,9 @@ |
254 | 272 | $text .= $this->subjectSeparator; |
255 | 273 | } |
256 | 274 | |
257 | | - $text .= implode( '<br />', $properties ); |
258 | 275 | $icon = $this->getLocationIcon( $row ); |
259 | 276 | |
260 | | - return $this->buildLocationsList( $coords, $title, $text, $icon ); |
| 277 | + return $this->buildLocationsList( $coords, $title, $text, $icon, $properties ); |
261 | 278 | } |
262 | 279 | |
263 | 280 | /** |
— | — | @@ -316,6 +333,14 @@ |
317 | 334 | protected function handleResultProperty( SMWDataValue $object, SMWPrintRequest $printRequest ) { |
318 | 335 | global $wgUser; |
319 | 336 | |
| 337 | + if ( $this->template ) { |
| 338 | + if ( $object instanceof SMWWikiPageValue ) { |
| 339 | + return $object->getTitle()->getPrefixedText(); |
| 340 | + } else { |
| 341 | + return $object->getLongText( SMW_OUTPUT_WIKI, NULL ); |
| 342 | + } |
| 343 | + } |
| 344 | + |
320 | 345 | if ( $this->linkAbsolute ) { |
321 | 346 | $t = Title::newFromText( $printRequest->getHTMLText( NULL ), SMW_NS_PROPERTY ); |
322 | 347 | |
— | — | @@ -369,18 +394,36 @@ |
370 | 395 | * @param string $title |
371 | 396 | * @param string $text |
372 | 397 | * @param string $icon |
| 398 | + * @param array $properties |
373 | 399 | * |
374 | 400 | * @return array of MapsLocation |
375 | 401 | */ |
376 | | - protected function buildLocationsList( array $coords, $title, $text, $icon ) { |
| 402 | + protected function buildLocationsList( array $coords, $title, $text, $icon, array $properties ) { |
377 | 403 | $locations = array(); |
378 | 404 | |
| 405 | + if ( $this->template ) { |
| 406 | + $parser = new Parser(); |
| 407 | + global $wgTitle; |
| 408 | + } |
| 409 | + else { |
| 410 | + $text .= implode( '<br />', $properties ); |
| 411 | + } |
| 412 | + |
379 | 413 | foreach ( $coords as $coord ) { |
380 | 414 | if ( count( $coord ) >= 2 ) { |
381 | 415 | $location = new MapsLocation(); |
382 | 416 | $location->setCoordinates( $coord ); |
383 | 417 | |
384 | 418 | if ( $location->isValid() ) { |
| 419 | + if ( $this->template ) { |
| 420 | + $segments = array_merge( |
| 421 | + array( $this->template, 'title=' . $title, 'latitude=' . $location->getLatitude(), 'longitude=' . $location->getLongitude() ), |
| 422 | + $properties |
| 423 | + ); |
| 424 | + |
| 425 | + $text .= $parser->parse( '{{' . implode( '|', $segments ) . '}}', $wgTitle, new ParserOptions() )->getText(); |
| 426 | + } |
| 427 | + |
385 | 428 | $location->setTitle( $title ); |
386 | 429 | $location->setText( $text ); |
387 | 430 | $location->setIcon( $icon ); |