For wiki pages representing an image, a new thumb_url is added to the geojson string.
authorphilipp <philipp@7aebc617-e5e2-0310-91dc-80fb5f6d2477>
Sun, 3 Nov 2013 20:42:19 +0000 (20:42 +0000)
committerphilipp <philipp@7aebc617-e5e2-0310-91dc-80fb5f6d2477>
Sun, 3 Nov 2013 20:42:19 +0000 (20:42 +0000)
However, it's not used yet.

git-svn-id: http://www.winterrodeln.org/svn/servermediawiki/mediawiki_extensions/wrmap/trunk@1785 7aebc617-e5e2-0310-91dc-80fb5f6d2477

wrmap.body.php

index 059eab5bc605bf6d9bd2679235ad629a9234edda..73fdf3b64df3d109be62df0be60c89c9b25104f4 100644 (file)
@@ -72,6 +72,23 @@ class WrBaseMap {
        }
 
 
+       /// Takes a page title from the wiki and returns an image (if available)
+       /// or Null. For image wiki pages, the image is the corresponding image,
+       /// for inns it's the image of the "Gasthausbox".
+       public static function wikipage_to_image($title, $width) {
+               $file = false; // File class or false
+               // 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
+               }
+               if ($file === false) return Null;
+               if (!$file->canRender()) return Null;
+               $thumb_url = $file->createThumb($width, $width); // limit width and hight to $width
+               if (strlen($thumb_url) == 0) return Null;
+               return $thumb_url;
+       }
+
+
        // convert sledruns to geojson (http://www.geojson.org/geojson-spec.html)
        // Returns an array of features
        public static function sledruns_to_json_features() {
@@ -137,6 +154,8 @@ class WrBaseMap {
                                        if ($property == 'wiki') {
                                                $title = Title::newFromText($propval);
                                                $propval = $title->getLocalUrl();
+                                               $file_url = WrBaseMap::wikipage_to_image($title, 300);
+                                               if (!is_null($file_url)) $properties['thumb_url'] = $file_url;
                                        }
                                        $properties[$property] = $propval;
                                }