Die Dokumentation für dieses Modul kann unter Modul:Quickbar Nationalpark/Doku erstellt werden
--[=[ Quickbar Nationalpark 2024-01-26 ]=] local yesno = require( 'Modul:Yesno' ) local pnumber = require( 'Module:GetNumber' ) local pstring = require( 'Module:GetString' ) local p856 = require( 'Module:GetP856' ) local images = require( 'Module:GetImage' ) local items = require( 'Module:GetItem' ) -- default values local defaultValues = { -- logo hoheitszeichen = 'L' } -- 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 qbNationalPark = {} function qbNationalPark.qb_nationalpark ( 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 = '' -- contains some site.infos -- will be filled with content later and only, if needed local page = {} -- getting or determining (if needed) the wikidata-ID if templateArgs.id == '' then templateArgs.id = nil end local qbID = templateArgs.id or mw.wikibase.getEntityIdForCurrentPage() or '' -- 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 if wdIso3166[1].mainsnak.snaktype == 'value' then qbIso3166 = string.lower(wdIso3166[1].mainsnak.datavalue.value) qbIso3166Class = ' voy-qb-' .. qbIso3166 else qbIso3166Class = '' end 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 .. '<table cellspacing="0" class="voy-qb voy-qb-right voy-qb-region' .. qbIso3166Class .. '">' -- Adding the emblems (logo), if wanted if templateArgs["hoheitszeichen"] ~= nil then local qbEmblems = '' if templateArgs["hoheitszeichen"] ~= '' then qbEmblems = templateArgs["hoheitszeichen"] else qbEmblems = defaultValues["hoheitszeichen"] end if yesno ( templateArgs["hoheitszeichen"], true ) then display = display .. images.GetImage().getEmblemsQuickbar ( qbID, qbEmblems ) end end -- the logo of the national parls associoation -- adding a logo of the national park association of a country -- taken from Wikidata, if not provided if templateArgs["logo"] ~= nil then if yesno ( coalesce ( templateArgs["logo"], '' ), true ) then display = display .. images.GetImage().getMainImageQuickbar ( qbID, coalesce ( templateArgs["logo"], '' ) ) end end -- the main image -- adding a picture, if wanted instead of the emblems, even both (emblems and image) are possible -- main image is standard, if no emblems are requested -- taken from Wikidata, if not provided if ( templateArgs["bild"] ~= nil ) then if yesno ( coalesce ( templateArgs["bild"], '' ), true ) then display = display .. images.GetImage().getMainImageQuickbar ( qbID, coalesce ( templateArgs["bild"], '' ) ) end end -- 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 -- getting the siteinfo -- no test necessary, its the first use here page = mw.title.getCurrentTitle() qbNamen = page.text 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 ) -- province -- hardly used (only in a few district articles in South Africa) -- will be reprogrammed later for the Quickbar for cities -- general information: -- an entry is onl 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" deactvates the entry -- province (hardly used, just in one district regions) if templateArgs["provinz"] ~= nil then local qbProvince = '' if templateArgs["provinz"] ~= '' then qbProvince = templateArgs["provinz"] end if yesno ( templateArgs["provinz"], true ) then display = display .. province.GetProvince().getProvinceQuickbar ( qbID, qbProvince ) end end -- area display = display .. pnumber.GetNumber().getNumbersWithUnitQuickbar ( qbID, 'P2046', nil, 0, coalesce ( templateArgs["fläche"], '' ) ) -- website display = display .. p856.GetP856().getUrlAsLinkWithHostQuickbar ( qbID, coalesce ( templateArgs["webseite"], '' ) ) -- adding social media display = display .. pstring.GetString().getSocialMediaQuickbar ( qbID ) -- tourist info -- it has two parameters: phone number and webseite -- they can used both or single -- Wikidata-ID of the tourist info local wdTouristInfo = {} local touristInfoID = '' -- tourist info: phone number -- it contains the wiki markup of the whole row local touristInfoPhone = '' local touristInfoWeb = '' -- table row for the entries local trTouristInfo = '' if templateArgs["touriinfotel"] ~= nil then -- displaying only, if its not switched off if ( yesno ( templateArgs["touriinfotel"], true ) ) then -- trying to find it on Wikidata, if empty if templateArgs["touriinfotel"] == '' then wdTouristInfo = mw.wikibase.getBestStatements( qbID, 'P2872' ) if #wdTouristInfo > 0 then touristInfoID = wdTouristInfo[1].mainsnak.datavalue.value["id"] end -- Found it on Wikidata? > showing the phone number if touristInfoID ~= '' then touristInfoPhone = pstring.GetString().getStringsQuickbar ( touristInfoID, 'P1329', nil, nil, 'Tourist-Info' ) end -- if provided locally then just showing it else -- displaying the given info trTouristInfo = mw.html.create ( 'tr' ) trTouristInfo:addClass('voy-qb-item voy-qb-tourist-info' ) :tag('th') :addClass('voy-qb-item-key') :wikitext('Tourist-Info') trTouristInfo:tag('td') :addClass( 'voy-qb-item-value1' ) :wikitext( templateArgs["touriinfotel"] ) touristInfoPhone = tostring ( trTouristInfo ) end -- showing the entry display = display .. touristInfoPhone end end -- tourist info: website if templateArgs["touriinfoweb"] ~= nil then -- displaying only, if its not switched off if ( yesno ( templateArgs["touriinfoweb"], true ) ) then -- if there is a row for the phone number, then no label in the second row local trLabel if touristInfoPhone == '' then trLabel = 'Tourist-Info' else trLabel = '' end -- trying to find it on Wikidata, if empty if templateArgs["touriinfoweb"] == '' then -- is the WikidataID known already (from above)? if touristInfoID == '' then wdTouristInfo = mw.wikibase.getBestStatements( qbID, 'P2872' ) if #wdTouristInfo > 0 then touristInfoID = wdTouristInfo[1].mainsnak.datavalue.value["id"] end end -- Found it on Wikidata? > showing the phone number if touristInfoID ~= '' then touristInfoWeb = p856.GetP856().getUrlAsLinkWithHostQuickbar ( touristInfoID, nil, trLabel ) end -- if provided just showing it else -- displaying the given info trTouristInfo = mw.html.create ( 'tr' ) trTouristInfo:addClass('voy-qb-item voy-qb-tourist-information' ) :tag('th') :addClass('voy-qb-item-key') :wikitext(trLabel) trTouristInfo:tag('td') :addClass( 'voy-qb-item-value1' ) :wikitext( templateArgs["touriinfoweb"] ) touristInfoWeb = tostring ( trTouristInfo ) end -- showing the entry display = display .. touristInfoWeb end end -- position map local qbPositionMap = coalesce ( templateArgs["lagekarte"], '' ) local qbPositionMapWidth = coalesce ( templateArgs["breitelagekarte"], '' ) local qbImageMap = coalesce ( templateArgs["imagemap"], '' ) if yesno ( qbPositionMap, true ) then if yesno ( qbImageMap, true ) then display = display .. images.GetImage().getPositionMapQuickbar ( qbID, nil, qbPositionMapWidth, qbPositionMap, qbImageMap, frame ) else display = display .. images.GetImage().getPositionMapQuickbar ( qbID, nil, qbPositionMapWidth, qbPositionMap ) end end -- the detail map if ( templateArgs["karte"] ~= nil ) then if yesno ( coalesce ( templateArgs["karte"], '' ), true ) then display = display .. images.GetImage().getMainImageQuickbar ( qbID, coalesce ( templateArgs["karte"], '' ), 'P1621' ) end end -- finishing the HTML table display = display .. '</table>' return display .. categories end return qbNationalPark