tag and the tag. /// This class would be the only class needed but as the function render() toes not provide an argument /// telling which tag name called the function, a trick with two inherited classes has to be used. /// @param $content string - the content of the tag /// @param $args array - the array of attribute name/value pairs for the tag /// @param $parser Parser - the MW Parser object for the current page /// /// @return string - the html for rendering the map public static function render($content, $args, $parser, $frame) { // Unfortunately, $tagname is no argument of this function, therefore we have to use a trick with derived classes. $tagname = strtolower(get_called_class()); // either wrmap or wrgmap assert(in_array($tagname, 'wrmap', 'wrgmap')); // Get center and zoom level from $args if (isset($args['lat'])) $latitude = floatval($args['lat']); else $latitude = 47.267648; // latitude as float value if (isset($args['lon'])) $longitude = floatval($args['lon']); else $longitude = 11.404655; // longitude as float value if (isset($args['zoom'])) $zoom = intval($args['zoom']); else $zoom = 10; // Google Zoom Level if (isset($args['width'])) $width = intval($args['width']); else $width = null; // null corresponds to 100% if (isset($args['height'])) $height = intval($args['height']); else $height = 450; $latitude_s = sprintf('%.6F', $latitude); $longitude_s = sprintf('%.6F', $longitude); $width_s = is_null($width) ? '100%' : $width . 'px'; $height_s = $height . 'px'; // Query database $dbr = wfGetDB(DB_SLAVE); $res = $dbr->select(array('wrsledruncache', 'wrreportcache'), array('wrsledruncache.page_title', 'position_latitude', 'position_longitude', 'date_report', '`condition`'), array('show_in_overview', 'not under_construction'), __METHOD__, array(), array('wrreportcache' => array('left outer join', 'wrsledruncache.page_id=wrreportcache.page_id'))); $sledruns = array(); while ($sledrun = $dbr->fetchRow($res)) $sledruns[] = $sledrun; $dbr->freeResult($res); $parserOutput = $parser->getOutput(); $parserOutput->addHeadItem('', 'googlemaps'); $parserOutput->addModules('ext.wrmap'); // Create
element where the map is placed in global $wgExtensionAssetsPath; $output = "
\n"; // create layeer showing sledruns as icons (note: why not use WFS?) foreach ($sledruns as $sledrun) { $lat = $sledrun['position_latitude']; $lon = $sledrun['position_longitude']; if (!$lat || !$lon) continue; $title = Title::newFromText($sledrun['page_title']); $title_text = htmlspecialchars($title->getText()); $title_url = htmlspecialchars($title->getLocalUrl()); $output .= "

tag class WrMap extends WrBaseMap { } // tag class WrGMap extends WrBaseMap { } ?>