- mapsandsemanticmaps0.2.zip
- Maps
- COPYING
- Geocoders
- GoogleMaps
- INSTALL
- Maps.i18n.php
- Maps.php
- Maps_BaseGeocoder.php
- Maps_BaseMap.php
- Maps_Geocoder.php
- Maps_Mapper.php
- Maps_Settings.php
- Maps_Utils.php
- MapUtilityFunctions.js
- OpenLayers
- Maps_OpenLayers.php
- OpenLayerFunctions.js
- OpenLayers
- img
- blank.gif
- cloud-popup-relative.png
- drag-rectangle-off.png
- drag-rectangle-on.png
- east-mini.png
- layer-switcher-maximize.png
- layer-switcher-minimize.png
- marker.png
- marker-blue.png
- marker-gold.png
- marker-green.png
- measuring-stick-off.png
- measuring-stick-on.png
- north-mini.png
- panning-hand-off.png
- panning-hand-on.png
- slider.png
- south-mini.png
- west-mini.png
- zoombar.png
- zoom-minus-mini.png
- zoom-plus-mini.png
- zoom-world-mini.png
- OpenLayers.js
- theme
- default
- framedCloud.css
- google.css
- ie6-style.css
- img
- add_point_off.png
- add_point_on.png
- blank.gif
- close.gif
- drag-rectangle-off.png
- drag-rectangle-on.png
- draw_line_off.png
- draw_line_on.png
- draw_point_off.png
- draw_point_on.png
- draw_polygon_off.png
- draw_polygon_on.png
- editing_tool_bar.png
- move_feature_off.png
- move_feature_on.png
- navigation_history.png
- overview_replacement.gif
- pan_off.png
- pan_on.png
- panning-hand-off.png
- panning-hand-on.png
- pan-panel.png
- pan-panel-NOALPHA.png
- remove_point_off.png
- remove_point_on.png
- ruler.png
- save_features_off.png
- save_features_on.png
- view_next_off.png
- view_next_on.png
- view_previous_off.png
- view_previous_on.png
- zoom-panel.png
- zoom-panel-NOALPHA.png
- style.css
- OSM
- README
- RELEASE-NOTES
- YahooMaps
- SemanticMaps
|
<?php
/**
* Abstract class that provides the common functionallity for all map query printers
*
* @file SM_MapPrinter.php
* @ingroup SemanticMaps
*
* @author Jeroen De Dauw
* @author Robert Buzink
* @author Yaron Koren
*/
if( !defined( 'MEDIAWIKI' ) ) {
die( 'Not an entry point.' );
}
abstract class SMMapPrinter extends SMWResultPrinter {
// TODO: make class and child's more OOP, in a way similair to class MapsBaseMap in Maps
protected $m_locations = array();
public function getResult($results, $params, $outputmode) {
// Skip checks, results with 0 entries are normal
$this->readParameters($params, $outputmode);
return $this->getResultText($results, SMW_OUTPUT_HTML);
}
protected function getResultText($res, $outputmode) {
while ( ($row = $res->getNext()) !== false ) {
$this->addResultRow($outputmode, $row);
}
$this->m_params = MapsMapper::setDefaultParValues($this->m_params, true);
}
/**
* This function will loop through all properties (fields) of one record (row),
* and add the location data, title, label and icon to the m_locations array.
*
* @param unknown_type $outputmode
* @param unknown_type $row The record you want to add data from
*/
private function addResultRow($outputmode, $row) {
global $wgUser;
$skin = $wgUser->getSkin();
$title = '';
$text = '';
$lat = '';
$lon = '';
// Loop throught all fields of the record
foreach ($row as $i => $field) {
$pr = $field->getPrintRequest();
// Loop throught all the parts of the field value
while ( ($object = $field->getNextObject()) !== false ) {
if ($object->getTypeID() == '_wpg' && $i == 0) {
$title = $object->getLongText($outputmode, $skin);
}
if ($object->getTypeID() != '_geo' && $i != 0) {
$text .= $pr->getHTMLText($skin) . ": " . $object->getLongText($outputmode, $skin) . "<br />";
}
if ($pr->getMode() == SMWPrintRequest::PRINT_PROP && $pr->getTypeID() == '_geo') {
list($lat,$lon) = explode(',', $object->getXSDValue());
}
}
}
if (strlen($lat) > 0 && strlen($lon) > 0) {
$icon = $this->getLocationIcon($row);
$this->m_locations[] = array($lat, $lon, $title, $text, $icon);
}
}
/**
* Get the icon for a row
*
* @param unknown_type $row
* @return unknown
*/
private function getLocationIcon($row) {
$icon = '';
$legend_labels = array();
// Look for display_options field, which can be set by Semantic Compound Queries
if (property_exists($row[0], 'display_options')) {
if (array_key_exists('icon', $row[0]->display_options)) {
$icon = $row[0]->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', $row[0]->display_options)) {
$legend_label = $row[0]->display_options['legend label'];
if (! array_key_exists($icon, $legend_labels)) {
$legend_labels[$icon] = $legend_label;
}
}
}
// Icon can be set even for regular, non-compound queries If it is, though, we have to translate the name into a URL here
} elseif (array_key_exists('icon', $this->m_params)) {
$icon_title = Title::newFromText($this->m_params['icon']);
$icon_image_page = new ImagePage($icon_title);
$icon = $icon_image_page->getDisplayedFile()->getURL();
}
return $icon;
}
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
I am a free and open source software enthusiast and freelance software developer with multiple years of experience in both web and desktop development. Currently my primarily focus is on MediaWiki and Semantic MediaWiki work. I'm in the all time top 10 MediaWiki comitters and am one of the WikiWorks consultants. You can contact me at jeroendedauw at gmail for development jobs and questions related to my work.
More info can be found on my website [0] and my blog [1]. You can also follow me on twitter [2] and identi.ca [3].
[0] http://www.jeroendedauw.com/
[1] http://blog.bn2vs.com/
[2] https://twitter.com/#!/JeroenDeDauw
[3] http://identi.ca/jeroendedauw