Dokumentation für das Modul Quickbar Fluggesellschaft[Ansicht] [Bearbeiten] [Versionsgeschichte] [Aktualisieren]

Dieses Modul erzeugt eine Quickbar für Fluggesellschaften. Es gibt nur eine Funktion, die Erzeugung der gewünschten Infobox (Quickbar). Eine detaillierte Dokumentation findest du auf der Vorlage Quickbar Fluggesellschaft.

Das Modul erzeugt indirekt auch eine Reihe von Wartungskategorien durch die verwendeten Wikidata-Module. Diese kannst du auf den Modulseiten der Getxxx-Module einsehen.

Verwandte Module

Verwendung

  • Quickbar Fluggesellschaft – Die Vorlage dient zur Ausgabe von Kurzdaten für Fluggesellschaft. Die Anzeige erfolgt als umflossene Box am rechten Rand, die Box ist 300px breit. Alle angezeigten Infos sind optional und zum großen Teil in der Lage, ihre Werte auch von Wikidata zu beziehen.

Benötigte weitere Module

Dieses Modul benötigt folgende weitere Module: GetString • GetImage • GetP856 • GetItem
Hinweise
local pstring  = require( 'Module:GetString' ) local p856     = require( 'Module:GetP856' ) local images   = require( 'Module:GetImage' ) local items    = require( 'Module:GetItem' )  -- 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  -- returns a manually created quickbar row local function createTr ( text, label, trClass )     -- check for valid text    -- if there is no text, then display nothing    if text == '' then         return ''     else        -- displaying the given info       local tr = mw.html.create ( 'tr' )       tr:addClass('voy-qb-item ' .. trClass )          :tag('th')          :addClass('voy-qb-item-key')          :wikitext( label )       tr:tag('td')          :addClass( 'voy-qb-item-value1' )          :wikitext( text )       return tostring ( tr )    end  end  local qbAirline = {}  function qbAirline.qb_airline ( 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 = ''        -- 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 ''     -- starting the quickbar table    display = display .. '<table cellspacing="0" class="voy-qb voy-qb-right voy-qb-airline">'     -- Logo    -- always taken from Wikidata    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       local page = {}       page = mw.title.getCurrentTitle()         if qbID ~= '' then           qbNamen = coalesce ( mw.wikibase.getSitelink( qbID, 'dewikivoyage' ), page.text, 'Fluggesellschaft')       else          qbNamen = coalesce ( page.text, 'Fluggesellschaft')       end    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 )     -- variable for a single quickbar row    local tr = ''        -- 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     -- IATA Code    -- always shown and take from Wikidata    display = display .. pstring.GetString().getStringsQuickbar ( qbID, 'P229', nil, coalesce ( templateArgs["iata"], '' ) )     -- headquarters    display = display .. items.GetItem().getItemsQuickbar ( qbID, 'P159', coalesce ( templateArgs["sitz"], ''), 'Sitz' )     -- main hub    display = display .. items.GetItem().getItemsQuickbar ( qbID, 'P113', coalesce ( templateArgs["drehkreuz"], '' ) )     -- passengers    display = display .. createTr ( coalesce ( templateArgs["passagieraufkommen"], '' ), 'Passagiere', 'voy-qb-item-passengers' )     -- destinations    display = display .. createTr ( coalesce ( templateArgs["ziele"], '' ), 'Ziele', 'voy-qb-item-destinations' )     -- alliance    display = display .. items.GetItem().getItemsQuickbar ( qbID, 'P114', coalesce ( templateArgs["allianz"], '' ) )     -- reward program    display = display .. items.GetItem().getItemsQuickbar ( qbID, 'P4446', coalesce ( templateArgs["bonusprogramm"], '' ) )        -- subsidiaries    display = display .. items.GetItem().getItemsQuickbar ( qbID, 'P355', coalesce ( templateArgs["tochtergesellschaften"], '' ) )        -- website    display = display .. p856.GetP856().getUrlAsLinkWithHostQuickbar ( qbID, coalesce ( templateArgs["webseite"], '' ) )     -- phone number    -- not from Wikidata because it's country specific    display = display .. createTr ( coalesce ( templateArgs["telefon"], '' ), 'Telefon', 'voy-qb-item-phone' )     -- finishing the HTML table    display = display .. '</table>'     return display     end  return qbAirline