/**
  * @since 3.1
  *
  * @param string $value
  *
  * @return WmsOverlay
  * @throws ParseException
  */
 protected function stringParse($value)
 {
     $parameters = explode('~', $value);
     $imageParameters = explode(':', $parameters[0], 3);
     if (count($imageParameters) === 3) {
         $boundsNorthEast = $this->stringToLatLongValue($imageParameters[0]);
         $boundsSouthWest = $this->stringToLatLongValue($imageParameters[1]);
         $imageUrl = \MapsMapper::getFileUrl($imageParameters[2]);
         return new ImageOverlay($boundsNorthEast, $boundsSouthWest, $imageUrl);
     }
     throw new ParseException('Need 3 parameters for an image overlay');
 }
Beispiel #2
0
 /**
  * @see MapsLayer::getParameterDefinitions
  *
  * @since 0.7.2
  *
  * @return array
  */
 protected function getParameterDefinitions()
 {
     $params = parent::getParameterDefinitions();
     // map extent for extents bound object:
     $params['topextent'] = array('type' => 'float', 'aliases' => array('upperbound', 'topbound'), 'message' => 'maps-displaymap-par-coordinates');
     $params['rightextent'] = array('type' => 'float', 'aliases' => array('rightbound'), 'message' => 'maps-displaymap-par-coordinates');
     $params['bottomextent'] = array('type' => 'float', 'aliases' => array('lowerbound', 'bottombound'), 'message' => 'maps-displaymap-par-coordinates');
     $params['leftextent'] = array('type' => 'float', 'aliases' => array('leftbound'), 'message' => 'maps-displaymap-par-coordinates');
     // image-source information:
     $params['source'] = array('message' => 'maps-displaymap-par-coordinates', 'post-format' => function ($source) {
         $imageUrl = MapsMapper::getFileUrl($source);
         global $egMapsAllowExternalImages;
         if ($imageUrl === '' && $egMapsAllowExternalImages) {
             return $source;
         }
         return $imageUrl;
     });
     $params['width'] = array('type' => 'float', 'message' => 'maps-displaymap-par-coordinates');
     $params['height'] = array('type' => 'float', 'message' => 'maps-displaymap-par-coordinates');
     return $params;
 }
 /**
  * Converts the data in the coordinates parameter to JSON-ready objects.
  * These get stored in the locations parameter, and the coordinates on gets deleted.
  *
  * @since 1.0
  *
  * @param array &$params
  * @param Parser $parser
  */
 protected function handleMarkerData(array &$params, Parser $parser)
 {
     $parserClone = clone $parser;
     $iconUrl = MapsMapper::getFileUrl($params['icon']);
     $visitedIconUrl = MapsMapper::getFileUrl($params['visitedicon']);
     $params['locations'] = array();
     /**
      * @var MapsLocation $location
      */
     foreach ($params['coordinates'] as $location) {
         if ($location->isValid()) {
             $jsonObj = $location->getJSONObject($params['title'], $params['label'], $iconUrl, '', '', $visitedIconUrl);
             $jsonObj['title'] = $parserClone->parse($jsonObj['title'], $parserClone->getTitle(), new ParserOptions())->getText();
             $jsonObj['text'] = $parserClone->parse($jsonObj['text'], $parserClone->getTitle(), new ParserOptions())->getText();
             $jsonObj['inlineLabel'] = strip_tags($parserClone->parse($jsonObj['inlineLabel'], $parserClone->getTitle(), new ParserOptions())->getText(), '<a><img>');
             $hasTitleAndtext = $jsonObj['title'] !== '' && $jsonObj['text'] !== '';
             $jsonObj['text'] = ($hasTitleAndtext ? '<b>' . $jsonObj['title'] . '</b><hr />' : $jsonObj['title']) . $jsonObj['text'];
             $jsonObj['title'] = strip_tags($jsonObj['title']);
             $params['locations'][] = $jsonObj;
         }
     }
     unset($params['coordinates']);
     $textContainers = array(&$params['lines'], &$params['polygons'], &$params['circles'], &$params['rectangles'], &$params['imageoverlays']);
     foreach ($textContainers as &$textContainer) {
         if (is_array($textContainer)) {
             foreach ($textContainer as &$obj) {
                 $obj['title'] = $parserClone->parse($obj['title'], $parserClone->getTitle(), new ParserOptions())->getText();
                 $obj['text'] = $parserClone->parse($obj['text'], $parserClone->getTitle(), new ParserOptions())->getText();
                 $hasTitleAndtext = $obj['title'] !== '' && $obj['text'] !== '';
                 $obj['text'] = ($hasTitleAndtext ? '<b>' . $obj['title'] . '</b><hr />' : $obj['title']) . $obj['text'];
                 $obj['title'] = strip_tags($obj['title']);
             }
         }
     }
 }
Beispiel #4
0
 /**
  * Returns an object that can directly be converted to JS using json_encode or similar.
  * 
  * @since 1.0
  * 
  * @return object
  */
 public function getJSONObject($defText = '', $defTitle = '', $defIconUrl = '')
 {
     return array('lat' => $this->getLatitude(), 'lon' => $this->getLongitude(), 'alt' => $this->getAltitude(), 'text' => $this->hasText() ? $this->getText() : $defText, 'title' => $this->hasTitle() ? $this->getTitle() : $defTitle, 'address' => $this->getAddress(false), 'icon' => $this->hasIcon() ? MapsMapper::getFileUrl($this->getIcon()) : $defIconUrl);
 }
Beispiel #5
0
 /**
  * Converts the data in the coordinates parameter to JSON-ready objects.
  * These get stored in the locations parameter, and the coordinates on gets deleted.
  * 
  * @since 1.0
  * 
  * @param array &$params
  * @param SMQueryHandler $queryHandler
  */
 protected function handleMarkerData(array &$params, SMQueryHandler $queryHandler)
 {
     if (is_object($params['centre'])) {
         $params['centre'] = $params['centre']->getJSONObject();
     }
     $iconUrl = MapsMapper::getFileUrl($params['icon']);
     $visitedIconUrl = MapsMapper::getFileUrl($params['visitedicon']);
     $params['locations'] = $this->getJsonForStaticLocations($params['staticlocations'], $params, $iconUrl, $visitedIconUrl);
     unset($params['staticlocations']);
     $this->addShapeData($queryHandler->getShapes(), $params, $iconUrl, $visitedIconUrl);
     if ($params['format'] === 'openlayers') {
         $params['layers'] = MapsDisplayMapRenderer::evilOpenLayersHack($params['layers']);
     }
 }
Beispiel #6
0
 /**
  * Returns an object that can directly be converted to JS using json_encode or similar.
  *
  * FIXME: complexity
  *
  * @since 1.0
  *
  * @param string $defText
  * @param string $defTitle
  * @param string $defIconUrl
  * @param string $defGroup
  * @param string $defInlineLabel
  * @param string $defVisitedIcon
  *
  * @return array
  */
 public function getJSONObject($defText = '', $defTitle = '', $defIconUrl = '', $defGroup = '', $defInlineLabel = '', $defVisitedIcon = '')
 {
     $parentArray = parent::getJSONObject($defText, $defTitle);
     $array = array('lat' => $this->coordinates->getLatitude(), 'lon' => $this->coordinates->getLongitude(), 'alt' => 0, 'address' => $this->getAddress(false), 'icon' => $this->hasIcon() ? \MapsMapper::getFileUrl($this->getIcon()) : $defIconUrl, 'group' => $this->hasGroup() ? $this->getGroup() : $defGroup, 'inlineLabel' => $this->hasInlineLabel() ? $this->getInlineLabel() : $defInlineLabel, 'visitedicon' => $this->hasVisitedIcon() ? $this->getVisitedIcon() : $defVisitedIcon);
     return array_merge($parentArray, $array);
 }
	/**
	 * Converts the data in the coordinates parameter to JSON-ready objects.
	 * These get stored in the locations parameter, and the coordinates on gets deleted.
	 * 
	 * @since 1.0
	 * 
	 * @param array &$params
	 * @param array $queryLocations
	 */
	protected function handleMarkerData( array &$params, array $queryLocations ) {
		global $wgParser;

		$parser = version_compare( $GLOBALS['wgVersion'], '1.18', '<' ) ? $wgParser : clone $wgParser;
		
		$iconUrl = MapsMapper::getFileUrl( $params['icon'] );
		$params['locations'] = array();

		foreach ( $params['staticlocations'] as $location ) {
			if ( $location->isValid() ) {
				$jsonObj = $location->getJSONObject( $params['title'], $params['label'], $iconUrl );
				
				$jsonObj['title'] = $parser->parse( $jsonObj['title'], $parser->getTitle(), new ParserOptions() )->getText();
				$jsonObj['text'] = $parser->parse( $jsonObj['text'], $parser->getTitle(), new ParserOptions() )->getText();
				
				$hasTitleAndtext = $jsonObj['title'] !== '' && $jsonObj['text'] !== '';
				$jsonObj['text'] = ( $hasTitleAndtext ? '<b>' . $jsonObj['title'] . '</b><hr />' : $jsonObj['title'] ) . $jsonObj['text'];
				$jsonObj['title'] = strip_tags( $jsonObj['title'] );
				
				$params['locations'][] = $jsonObj;					
			}
		}
		
		foreach ( $queryLocations as $location ) {
			if ( $location->isValid() ) {
				$jsonObj = $location->getJSONObject( $params['title'], $params['label'], $iconUrl );
				
				$jsonObj['title'] = strip_tags( $jsonObj['title'] );
				
				$params['locations'][] = $jsonObj;				
			}
		}
		
		unset( $params['staticlocations'] );
	}	
Beispiel #8
0
 /**
  * @see ItemParameterManipulation::doManipulation
  * 
  * @since 0.7
  */
 public function doManipulation(&$value, Parameter $parameter, array &$parameters)
 {
     $value = MapsMapper::getFileUrl($value);
 }
Beispiel #9
0
 /**
  * Get the icon for a row.
  *
  * @since 0.7.3
  *
  * @param array $row
  *
  * @return string
  */
 protected function getLocationIcon(array $row)
 {
     $icon = '';
     $legend_labels = array();
     // Look for display_options field, which can be set by Semantic Compound Queries
     // the location of this field changed in SMW 1.5
     $display_location = method_exists($row[0], 'getResultSubject') ? $row[0]->getResultSubject() : $row[0];
     if (property_exists($display_location, 'display_options') && is_array($display_location->display_options)) {
         $display_options = $display_location->display_options;
         if (array_key_exists('icon', $display_options)) {
             $icon = $display_options['icon'];
             // This is somewhat of a hack - if a legend label has been set, we're getting it for every point, instead of just once per icon
             if (array_key_exists('legend label', $display_options)) {
                 $legend_label = $display_options['legend label'];
                 if (!array_key_exists($icon, $legend_labels)) {
                     $legend_labels[$icon] = $legend_label;
                 }
             }
         }
     } elseif ($this->icon !== '') {
         $icon = MapsMapper::getFileUrl($this->icon);
     }
     return $icon;
 }
 /**
  * Converts the data in the coordinates parameter to JSON-ready objects.
  * These get stored in the locations parameter, and the coordinates on gets deleted.
  * 
  * @since 1.0
  * 
  * @param array &$params
  * @param Parser $parser
  */
 protected function handleMarkerData(array &$params, Parser $parser)
 {
     $parserClone = clone $parser;
     $iconUrl = MapsMapper::getFileUrl($params['icon']);
     $params['locations'] = array();
     foreach ($params['coordinates'] as $location) {
         if ($location->isValid()) {
             $jsonObj = $location->getJSONObject($params['title'], $params['label'], $iconUrl);
             $jsonObj['title'] = $parserClone->parse($jsonObj['title'], $parserClone->getTitle(), new ParserOptions())->getText();
             $jsonObj['text'] = $parserClone->parse($jsonObj['text'], $parserClone->getTitle(), new ParserOptions())->getText();
             $hasTitleAndtext = $jsonObj['title'] !== '' && $jsonObj['text'] !== '';
             $jsonObj['text'] = ($hasTitleAndtext ? '<b>' . $jsonObj['title'] . '</b><hr />' : $jsonObj['title']) . $jsonObj['text'];
             $jsonObj['title'] = strip_tags($jsonObj['title']);
             $params['locations'][] = $jsonObj;
         }
     }
     unset($params['coordinates']);
 }
 /**
  * Converts the data in the coordinates parameter to JSON-ready objects.
  * These get stored in the locations parameter, and the coordinates on gets deleted.
  *
  * FIXME: complexity
  *
  * @since 1.0
  *
  * @param array &$params
  * @param Parser $parser
  */
 protected function handleMarkerData(array &$params, Parser $parser)
 {
     if (is_object($params['centre'])) {
         $params['centre'] = $params['centre']->getJSONObject();
     }
     $parserClone = clone $parser;
     if (is_object($params['wmsoverlay'])) {
         $params['wmsoverlay'] = $params['wmsoverlay']->getJSONObject();
     }
     $iconUrl = MapsMapper::getFileUrl($params['icon']);
     $visitedIconUrl = MapsMapper::getFileUrl($params['visitedicon']);
     $params['locations'] = array();
     /**
      * @var Location $location
      */
     foreach ($params['coordinates'] as $location) {
         $jsonObj = $location->getJSONObject($params['title'], $params['label'], $iconUrl, '', '', $visitedIconUrl);
         $jsonObj['title'] = $parserClone->parse($jsonObj['title'], $parserClone->getTitle(), new ParserOptions())->getText();
         $jsonObj['text'] = $parserClone->parse($jsonObj['text'], $parserClone->getTitle(), new ParserOptions())->getText();
         $jsonObj['inlineLabel'] = strip_tags($parserClone->parse($jsonObj['inlineLabel'], $parserClone->getTitle(), new ParserOptions())->getText(), '<a><img>');
         $hasTitleAndtext = $jsonObj['title'] !== '' && $jsonObj['text'] !== '';
         $jsonObj['text'] = ($hasTitleAndtext ? '<b>' . $jsonObj['title'] . '</b><hr />' : $jsonObj['title']) . $jsonObj['text'];
         $jsonObj['title'] = strip_tags($jsonObj['title']);
         $params['locations'][] = $jsonObj;
     }
     unset($params['coordinates']);
     $this->handleShapeData($params, $parserClone);
     if ($params['mappingservice'] === 'openlayers') {
         $params['layers'] = self::evilOpenLayersHack($params['layers']);
     }
 }