Пример #1
0
 /**
  * Handles the request from the parser hook by doing the work that's common for all
  * mapping services, calling the specific methods and finally returning the resulting output.
  *
  * @param array $params
  * @param Parser $parser
  *
  * @return html
  */
 public final function renderMap(array $params, Parser $parser)
 {
     $this->handleMarkerData($params, $parser);
     $mapName = $this->service->getMapId();
     $output = $this->getMapHTML($params, $parser, $mapName);
     $configVars = Skin::makeVariablesScript($this->service->getConfigVariables());
     $this->service->addDependencies($parser);
     $parser->getOutput()->addHeadItem($configVars);
     return $output;
 }
 /**
  * Returns the JSON with the maps data.
  *
  * @since 1.0
  *
  * @param array $params
  * @param Parser $parser
  * @param string $mapName
  * 
  * @return string
  */
 protected function getJSON(array $params, Parser $parser, $mapName)
 {
     $object = $this->getJSONObject($params, $parser);
     if ($object === false) {
         return '';
     }
     return Html::inlineScript(MapsMapper::getBaseMapJSON($this->service->getName()) . "mwmaps.{$this->service->getName()}.{$mapName}=" . FormatJson::encode($object) . ';');
 }
Пример #3
0
 /**
  * Translates the coordinates field to the centre field and makes sure it's set to it's default when invalid. 
  * 
  * @since 1.0
  * 
  * @param array &$params
  */
 protected function setCentre(array &$params)
 {
     // If it's false, the coordinate was invalid, or geocoding failed. Either way, the default's should be used.
     if ($params['coordinates'] === false) {
         global $egMapsDefaultMapCentre;
         $centre = MapsGeocoders::attemptToGeocode($egMapsDefaultMapCentre, $params['geoservice'], $this->service->getName());
         if ($centre === false) {
             throw new Exception('Failed to parse the default centre for the map. Please check the value of $egMapsDefaultMapCentre.');
         } else {
             $params['centre'] = $centre;
         }
     } else {
         $params['centre'] = $params['coordinates'];
     }
     unset($params['coordinates']);
 }
Пример #4
0
 /**
  * Returns the internationalized name of the mapping service.
  * 
  * @return string
  */
 public final function getName()
 {
     return wfMessage('maps_' . $this->service->getName())->text();
 }
	/**
	 * Returns the internationalized name of the mapping service.
	 * 
	 * @return string
	 */
	public final function getName() {
		return wfMsg( 'maps_' . $this->service->getName() );
	}
Пример #6
0
 /**
  * Returns the HTML to display the map input.
  * 
  * @since 1.0
  * 
  * @param array $params
  * @param Parser $parser
  * @param string $mapName
  * 
  * @return string
  */
 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'), FormatJson::encode($this->getJSONObject($params, $parser))));
 }