From: philipp Date: Sun, 3 Nov 2013 22:22:26 +0000 (+0000) Subject: Images of inns are shown now if available. X-Git-Url: https://git.toastfreeware.priv.at/philipp/winterrodeln/mediawiki_extensions/wrmap.git/commitdiff_plain/543def8b6399b17f36ac36050fc91cd936f0fefd Images of inns are shown now if available. git-svn-id: http://www.winterrodeln.org/svn/servermediawiki/mediawiki_extensions/wrmap/trunk@1787 7aebc617-e5e2-0310-91dc-80fb5f6d2477 --- diff --git a/wrmap.body.php b/wrmap.body.php index 2245d6e..0cadc82 100644 --- a/wrmap.body.php +++ b/wrmap.body.php @@ -80,6 +80,23 @@ 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 + // TODO + } + $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;