]> ToastFreeware Gitweb - philipp/winterrodeln/mediawiki_extensions/wrmap.git/blobdiff - wrmap.body.php
Fixed typo in comment.
[philipp/winterrodeln/mediawiki_extensions/wrmap.git] / wrmap.body.php
index 36cba2d0366b617bdac4e37b180428adc12e78ef..e4d03202054c9d36d60ae397cdbc188350b391d4 100644 (file)
@@ -108,7 +108,7 @@ function xml_to_json_features($input) {
                throw new Exception('Die Landkarte enthält folgenden ungültigen Text: "' . trim($xml) . '".');
        }
        $json_features = array(); // output
-       $point_types = array('gasthaus', 'haltestelle', 'parkplatz', 'achtung', 'punkt');
+       $point_types = array('gasthaus', 'haltestelle', 'parkplatz', 'achtung', 'foto', 'punkt');
        $line_types = array('rodelbahn', 'gehweg', 'alternative', 'lift', 'anfahrt', 'linie');
        foreach ($xml as $feature) {
                $given_properties = array();
@@ -183,7 +183,7 @@ function xml_to_json_features($input) {
 
 class WrBaseMap {
        /// Renders the <wrgmap> tag and the <wrmap> tag.
-       /// This class would be the only class needed but as the function render() toes not provide an argument
+       /// This class would be the only class needed but as the function render() does 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 <wrgmap> tag
        /// @param $args array - the array of attribute name/value pairs for the tag
@@ -218,7 +218,9 @@ class WrBaseMap {
                        // append all elements in the XML
                        $json_features = array_merge($json_features, xml_to_json_features('<wrmap>' . $content . '</wrmap>'));
                } catch (Exception $e) {
-                       return '<div class="error">' . htmlspecialchars("Fehler beim Parsen der Landkarte: " . $e->getMessage()) . '</div>';
+                       $doc = new WrMapDOMDocument();
+                       $doc->appendElement('div', array('class' => 'error'))->appendText('Fehler beim Parsen der Landkarte: ' . $e->getMessage());
+                       return array($doc->saveHTML($doc->firstChild), 'markerType' => 'nowiki');
                }
 
                // create final geojson
@@ -231,11 +233,13 @@ class WrBaseMap {
 
                // Create <div/> element where the map is placed in
                global $wgExtensionAssetsPath;
-               $output = "<div class=\"wrmap\" style=\"border-style:none;\" data-img-path=\"$wgExtensionAssetsPath/wrmap/openlayers/img/\">";
-               $output .= htmlspecialchars($json_string, ENT_NOQUOTES);
-               $output .= "</div>\n";
-               
-               return array($output, 'markerType' => 'nowiki');
+               $doc = new WrMapDOMDocument();
+               $div = $doc->appendElement('div', array('class' => 'wrmap', 'style' => 'border-style:none;', 'data-img-path' => "$wgExtensionAssetsPath/wrmap/openlayers/img/"));
+               // progress message
+               $div->appendElement('div', array())->appendText('Die Landkarte wird geladen...');
+               // data
+               $div->appendElement('div', array('style' => 'height: 0px; display:none;'))->appendText($json_string);
+               return array($doc->saveHTML($div), 'markerType' => 'nowiki');
        }
 }