]> ToastFreeware Gitweb - philipp/winterrodeln/mediawiki_extensions/wrmap.git/blobdiff - wrmap.body.php
Now using internal map marker images and no more files from /vorlage.
[philipp/winterrodeln/mediawiki_extensions/wrmap.git] / wrmap.body.php
index 73fdf3b64df3d109be62df0be60c89c9b25104f4..c04aaed95329754be7acc68d7c2360b4e0dda3de 100644 (file)
@@ -80,6 +80,27 @@ class WrBaseMap {
                // for NS_FILE titles, use the corresponding file as image
                if ($title->getNamespace() == NS_FILE) {
                        $file = wfFindFile($title); // $file is a mediawiki File class or false
+               } else {
+                       $categories = $title->getParentCategories(); // e.g. array('Kategorie:Rodelbahn' => 'Juifenalm')
+                       global $wgContLang;
+                       $key_sledrun = $wgContLang->getNSText(NS_CATEGORY) . ':Rodelbahn';
+                       if (array_key_exists($key_sledrun, $categories)) {
+                               // for sledrun titles use the image from the rodelbahnbox
+                               $dbr = wfGetDB(DB_SLAVE);
+                               $res = $dbr->select('wrsledruncache', 'image', array('page_id' => $title->getArticleID()), __METHOD__);
+                               $image = $dbr->fetchRow($res);
+                               if ($image && !is_null($image['image'])) $file = wfFindFile($image['image']);
+                               $dbr->freeResult($res);
+                       }
+                       $key_inn = $wgContLang->getNSText(NS_CATEGORY) . ':Gasthaus';
+                       if (array_key_exists($key_inn, $categories)) {
+                               // for inn titles use the image from the gasthausbox
+                               $dbr = wfGetDB(DB_SLAVE);
+                               $res = $dbr->select('wrinncache', 'image', array('page_id' => $title->getArticleID()), __METHOD__);
+                               $image = $dbr->fetchRow($res);
+                               if ($image && !is_null($image['image'])) $file = wfFindFile($image['image']);
+                               $dbr->freeResult($res);
+                       }
                }
                if ($file === false) return Null;
                if (!$file->canRender()) return Null;
@@ -105,6 +126,8 @@ class WrBaseMap {
                        $properties = array('type' => 'sledrun', 'name' => $title->getText(), 'wiki' => $title->getLocalUrl());
                        if (!is_null($sledrun['date_report'])) $properties['date_report'] = $sledrun['date_report'];
                        if (!is_null($sledrun['condition'])) $properties['condition'] = intval($sledrun['condition']);
+                       $image_url = WrBaseMap::wikipage_to_image($title, 150);
+                       if (!is_null($image_url)) $properties['thumb_url'] = $image_url;
                        $json_feature = array(
                                'type' => 'feature',
                                'geometry' => array(
@@ -154,7 +177,7 @@ class WrBaseMap {
                                        if ($property == 'wiki') {
                                                $title = Title::newFromText($propval);
                                                $propval = $title->getLocalUrl();
-                                               $file_url = WrBaseMap::wikipage_to_image($title, 300);
+                                               $file_url = WrBaseMap::wikipage_to_image($title, 200);
                                                if (!is_null($file_url)) $properties['thumb_url'] = $file_url;
                                        }
                                        $properties[$property] = $propval;
@@ -256,7 +279,7 @@ class WrBaseMap {
                // Create <div/> element where the map is placed in
                global $wgExtensionAssetsPath;
                $doc = new WrMapDOMDocument();
-               $div = $doc->appendElement('div', array('class' => 'wrmap', 'style' => 'border-style:none;', 'data-img-path' => "$wgExtensionAssetsPath/wrmap/openlayers/img/"));
+               $div = $doc->appendElement('div', array('class' => 'wrmap', 'style' => 'border-style:none;', 'data-ext-path' => "$wgExtensionAssetsPath/wrmap"));
                // progress message
                $div->appendElement('div', array())->appendText('Die Landkarte wird geladen...');
                // data