
Verwendung
Das Submodul ist eine Testversion des Moduls Quickbar Flughafen und nicht für den Produktivbetrieb geeignet. Es dient der Weiterentwicklung des Moduls Quickbar Flughafen, damit sich Änderungen nicht auf alle Artikel auswirken, die das Modul benutzen.
![]() | Derzeit arbeitet der Benutzer DerFussi an diesem Testmodul. Bitte wende dich an ihn um dich bei der Programmierung abzustimmen. |
Neu- und Weiterentwicklung des Moduls für die {{Quickbar Flughafen}}.
Testobjekte
Flughafen Frankfurt am Main | |
Bundesland | Hessen |
---|---|
Höhe | 111 m |
IATA | FRA |
ICAO | EDDF |
Passagierzahl | 48.918.482 (2022) |
![]() ![]() Flughafen Frankfurt am Main |
Hinweise
- Die obige Dokumentation wurde aus der Seite Modul:Quickbar Flughafen/Test/Doku eingefügt. (bearbeiten | Versionsgeschichte) Die Kategorien für dieses Modul sollten in der Dokumentation eingetragen werden. Die Interwiki-Links sollten auf Wikidata eingepflegt werden.
- Liste der Unterseiten
local yesno = require( 'Modul:Yesno' ) local pnumber = require( 'Module:GetNumber' ) local pstring = require( 'Module:GetString' ) local p36 = require( 'Module:GetP36' ) local p856 = require( 'Module:GetP856' ) local images = require( 'Module:GetImage' ) local province = require( 'Module:GetProvince' ) -- returns nil, if both values are equal, otherwise the value -- similar to the SQL function nullif() local function nilIf ( value, equalValue ) if ( value == nil ) then return nil elseif ( tostring ( value ) == tostring ( equalValue ) ) then return nil else return value end end -- returns the first value that is not nil -- similar to the SQL function coalesce() local function coalesce ( value1, value2, value3 ) return value1 or value2 or value3 end local function checkMapObject ( id ) local region = require ( 'Modul:Location map data ' .. id ) if ( region ~= nil ) and ( region.data ~= nil ) then region.data['id'] = id return region else return nil end end local qbAirport = {} function qbAirport.qb_airport ( frame ) -- copying and lowering the given parameters local templateArgs = {} for key,value in pairs ( frame.args ) do templateArgs[string.lower(key)] = value end for key,value in pairs ( frame:getParent().args ) do templateArgs[string.lower(key)] = value end -- variables for the whole quickbar content and the categories local display = '' local categories = '' -- province information are used twice -- variables for saving information local provinceName = '' local provinceCode = '' -- contains some site.infos -- needed as fallback for the parameter "Namen" and the location map local page = {} page = mw.title.getCurrentTitle() -- getting or determining (if needed) the wikidata-ID if templateArgs.id == '' then templateArgs.id = nil end local qbID = nilIf ( nilIf ( templateArgs.id, 'self' ), '' ) or mw.wikibase.getEntityIdForCurrentPage() or '' -- getting object name -- uses WD sitelink and the page name as fallback local destinationName if qbID ~= '' then destinationName = coalesce ( mw.wikibase.getSitelink( qbID, 'dewikivoyage' ), page.text, 'Ort') else destinationName = coalesce ( page.text, 'Ort') end -- determining the country -- (not urgently needed, but if someone wants to develop country- specific quickbars) -- getting from Wikidata, if not provided -- if you want to save processing time, you should provide it -- e.g. in country specific infobox tables local qbIso3166 = templateArgs["iso-3166"] or '' local qbIso3166Class = '' if qbIso3166 == '' then if qbID ~= '' then local wdCountry = mw.wikibase.getBestStatements( qbID, 'P17' ) local wdIso3166 = {} if #wdCountry > 0 then -- there where empty values if wdCountry[1].mainsnak.datavalue ~= nil then wdIso3166 = mw.wikibase.getBestStatements( wdCountry[1].mainsnak.datavalue.value["id"], 'P297' ) if #wdIso3166 > 0 then qbIso3166 = string.lower(wdIso3166[1].mainsnak.datavalue.value) qbIso3166Class = ' voy-qb-' .. qbIso3166 else qbIso3166Class = '' end else qbIso3166Class = '' end end end else qbIso3166Class = ' voy-qb-' .. qbIso3166 end -- DEBUG: showing the parameters -- it was just for development -- display = display .. '<br />Parameter:<br />' .. mw.dumpObject(templateArgs) -- starting the quickbar table display = display .. '<div class="voy-qb-rightdiv"><table cellspacing="0" class="voy-qb voy-qb-airport' .. qbIso3166Class .. '">' -- Logo display = display .. images.GetImage().getEmblemsQuickbar ( qbID, 'L' ) -- the main image -- taken from Wikidata, if not provided display = display .. images.GetImage().getMainImageQuickbar ( qbID, coalesce ( templateArgs["bild"], '' ) ) -- heading -- is mandatory, even if you do not provide it, its shown (with the sitename) -- initialising with given heading local qbNamen = coalesce ( templateArgs["namen"], '' ) -- if no heading is provided, get the sitename if qbNamen == '' then qbNamen = destinationName end -- creating the row with the heading local trHeader = mw.html.create ( 'tr' ) trHeader:addClass( 'voy-qb-item' ) trHeader:tag('td') :attr('colspan', 2 ) :addClass('voy-qb-header' ) :wikitext(qbNamen) -- adding it to the quickbar display = display .. tostring ( trHeader ) -- general information: -- an entry is only added when the parameter is used -- if the parameter is empty, the information is fetched from Wikidata -- if the parameter is not empty, the local information is used, but mostly compared Wikidata, and maintenance categories are used -- the parameter with the value "no" deactivates the entry -- province local displayString = '' displayString, provinceCode = province.GetProvince().getProvinceQuickbar ( qbID, coalesce ( templateArgs["provinz"], '' ), coalesce ( templateArgs["provinzlabel"], '' ), coalesce ( templateArgs["staatok"], 'no' ) ) display = display .. displayString -- altitude display = display .. pnumber.GetNumber().getNumbersWithUnitQuickbar ( qbID, 'P2044', nil, 0, coalesce ( templateArgs["höhe"], '' ) ) -- IATA Code display = display .. pstring.GetString().getStringsQuickbar ( qbID, 'P238', nil, coalesce ( templateArgs["iata"], '' ) ) -- ICAO Code display = display .. pstring.GetString().getStringsQuickbar ( qbID, 'P239', nil, coalesce ( templateArgs["icao"], '' ) ) -- passengers display = display .. pnumber.GetNumber().getNumbersWithDateQuickbar ( qbID, 'P3872', coalesce ( templateArgs["passagiere"], '' ) ) -- terminals, not available at Wikidata if templateArgs["terminals"] ~= nil then -- displaying the given info trTerminals = mw.html.create ( 'tr' ) trTerminals:addClass('voy-qb-item voy-qb-terminals' ) :tag('th') :addClass('voy-qb-item-key') :wikitext('Terminals') trTerminals:tag('td') :addClass( 'voy-qb-item-value1' ) :wikitext( templateArgs["terminals"] ) display = display .. tostring ( trTerminals ) end -- location map -- the location maop is always shown -- reading latitude and longitude from Wikidata local breite local laenge breite, laenge = pnumber.GetNumber().getCoordinate( qbID ) -- got coordinates? then creating the map if breite ~= 0 and laenge ~= 0 then -- loading the configuration fopr the location maps local cfgLocmaps = mw.loadData('Modul:Quickbar Ort/Locmaps') provinceCode = string.lower ( coalesce ( provinceCode, '' ) ) -- determining the locmap, starting with the country code local locmapCode = qbIso3166 -- some countries alays use province maps (see Modul:Quickbar_Ort/Locmaps) if cfgLocmaps.LocMapLevel[qbIso3166] ~= nil and provinceCode ~= '' then locmapCode = provinceCode end -- some province maps differ from the 3166 Code if cfgLocmaps.LocMapNoProvince[provinceCode] ~= nil and provinceCode ~= '' then locmapCode = cfgLocmaps.LocMapNoProvince[provinceCode] end -- some province maps are individually wanted although normally the country map is used if cfgLocmaps.ForceProvinceMap[provinceCode] ~= nil and provinceCode ~= '' then locmapCode = cfgLocmaps.ForceProvinceMap[provinceCode] end -- is a map-code given manually in the QB? then if nilIf ( templateArgs["karte"], '' ) ~= nil then locmapCode = templateArgs["karte"] end locmapCode = string.lower ( locmapCode ) -- creating the location map if locmapCode ~= '' then local locMap = require('Modul:Location map') local success, mData = pcall(checkMapObject, locmapCode) -- location map available? if success then -- collecting all parameters local locMapArgs = { args = { map = locmapCode, lat = breite, long = laenge, maptype = coalesce ( nilIf ( templateArgs["kartentyp"], '' ), 'quickbar' ), label = '<b>' .. mw.text.trim(mw.ustring.gsub(destinationName, '%s%(.*%)', '' )) .. '</b>' } } -- creating the row and adding to the quickbar local trLocMap = mw.html.create ( 'tr' ) trLocMap:addClass( 'voy-qb-locmap' ) trLocMap:tag('td') :attr('colspan', 2 ) :wikitext(locMap.locationMap(locMapArgs)) display = display .. tostring ( trLocMap ) else categories = categories .. '[[Kategorie:Provinz ohne Location map]]' end end end -- finishing the HTML table display = display .. '</table></div>' return display .. categories end return qbAirport