예제 #1
0
 /**
  * Returns the KML for the query result.
  *
  * @since 0.7.3
  *
  * @param SMWQueryResult $res
  * @param integer $outputmode
  *
  * @return string
  */
 protected function getKML(SMWQueryResult $res, $outputmode)
 {
     $queryHandler = new SMQueryHandler($res, $outputmode, $this->params['linkabsolute'], $this->params['pagelinktext'], false);
     $queryHandler->setText($this->params['text']);
     $queryHandler->setTitle($this->params['title']);
     $queryHandler->setSubjectSeparator('');
     $formatter = new MapsKMLFormatter($this->params);
     $formatter->addPlacemarks($queryHandler->getLocations());
     return $formatter->getKML();
 }
	/**
	 * Builds up and returns the HTML for the map, with the queried coordinate data on it.
	 *
	 * @param SMWQueryResult $res
	 * @param $outputmode
	 * 
	 * @return array or string
	 */
	public final function getResultText( SMWQueryResult $res, $outputmode ) {
		if ( $this->fatalErrorMsg === false ) {
			global $wgParser;
			
			$params = $this->params;
			
			$queryHandler = new SMQueryHandler( $res, $outputmode );
			$queryHandler->setShowSubject( $params['showtitle'] );
			$queryHandler->setTemplate( $params['template'] );
			
			$this->handleMarkerData( $params, $queryHandler->getLocations() );
			$locationAmount = count( $params['locations'] );
			
			if ( $params['forceshow'] || $locationAmount > 0 ) {
				// We can only take care of the zoom defaulting here, 
				// as not all locations are available in whats passed to Validator.
				if ( $params['zoom'] === false && $locationAmount <= 1 ) {
					$params['zoom'] = $this->service->getDefaultZoom();
				}
				
				$mapName = $this->service->getMapId();
				
				// MediaWiki 1.17 does not play nice with addScript, so add the vars via the globals hook.
				if ( version_compare( $GLOBALS['wgVersion'], '1.18', '<' ) ) {
					$GLOBALS['egMapsGlobalJSVars'] += $this->service->getConfigVariables();
				}
				
				SMWOutputs::requireHeadItem(
					$mapName,
					$this->service->getDependencyHtml() . 
					$configVars = Skin::makeVariablesScript( $this->service->getConfigVariables() )
				);
				
				foreach ( $this->service->getResourceModules() as $resourceModule ) {
					SMWOutputs::requireResource( $resourceModule );
				}
				
				$result = $this->getMapHTML( $params, $wgParser, $mapName ) . $this->getJSON( $params, $wgParser, $mapName );
				
				return array(
					$result,
					'noparse' => true, 
					'isHTML' => true
				);				
			}
			else {
				return '';
			}
		}
		else {
			return $this->fatalErrorMsg;
		}
	}