Modul:Saison: Unterschied zwischen den Versionen

Aus LASK Wiki
Zur Navigation springen Zur Suche springen
Keine Bearbeitungszusammenfassung
Keine Bearbeitungszusammenfassung
Zeile 1: Zeile 1:
local p = {}
local p = {}


-- Erstellt eine Zeile der Infobox
local function addRow(box, label, value)
local function addRow(box, label, value)


Zeile 20: Zeile 22:




-- Liste der möglichen Felder
local fields = {
    {"beruf", "Beruf"},
    {"geburt", "Geboren"},
    {"geburtsort", "Geburtsort"},
    {"land", "Land"},
    {"wohnort", "Wohnort"},
    {"website", "Website"}
}
-- Hauptfunktion
function p.main(frame)
function p.main(frame)


    -- Parameter der Vorlage holen
     local args = frame:getParent().args
     local args = frame:getParent().args


    -- Grundparameter
     local titel = args.titel or ""
     local titel = args.titel or ""
     local bild = args.bild or ""
     local bild = args.bild or ""
     local bildbeschreibung = args.bildbeschreibung or ""
     local bildbeschreibung = args.bildbeschreibung or ""


    -- Tabelle erstellen
     local box = mw.html.create("table")
     local box = mw.html.create("table")
         :addClass("infobox")
         :addClass("infobox")
Zeile 34: Zeile 53:
     -- Titel
     -- Titel
     if titel ~= "" then
     if titel ~= "" then
         box
         box
             :tag("caption")
             :tag("caption")
            :wikitext(titel)
                :wikitext(titel)
            :done()
                :done()
 
     end
     end


Zeile 47: Zeile 68:
             :tag("tr")
             :tag("tr")
                 :tag("td")
                 :tag("td")
                :attr("colspan", "2")
                    :attr("colspan", "2")
                :addClass("infobox-bild")
                    :addClass("infobox-bild")
                :wikitext("[[Datei:" .. bild .. "|250px]]")
                    :wikitext("[[Datei:" .. bild .. "|250px]]")
                :done()
                    :done()
             :done()
             :done()


        -- Bildbeschreibung
         if bildbeschreibung ~= "" then
         if bildbeschreibung ~= "" then
             box
             box
                 :tag("tr")
                 :tag("tr")
                     :tag("td")
                     :tag("td")
                    :attr("colspan", "2")
                        :attr("colspan", "2")
                    :addClass("infobox-bild")
                        :addClass("infobox-bild")
                    :wikitext(bildbeschreibung)
                        :wikitext(bildbeschreibung)
                    :done()
                        :done()
                 :done()
                 :done()
         end
         end
     end
     end




     -- Informationen
     -- Alle Felder automatisch hinzufügen
     addRow(box, "Beruf", args.beruf)
     for _, field in ipairs(fields) do
    addRow(box, "Geboren", args.geburt)
    addRow(box, "Geburtsort", args.geburtsort)
    addRow(box, "Land", args.land)
    addRow(box, "Wohnort", args.wohnort)
    addRow(box, "Website", args.website)


        local parameter = field[1]
        local label = field[2]


        local value = args[parameter]
        addRow(box, label, value)
    end
    -- HTML zurückgeben
     return tostring(box)
     return tostring(box)


end
end


return p
return p

Version vom 2. September 2026, 07:50 Uhr

Die Dokumentation für dieses Modul kann unter Modul:Saison/Doku erstellt werden

local p = {}


-- Erstellt eine Zeile der Infobox
local function addRow(box, label, value)

    if value and value ~= "" then

        box
            :tag("tr")
                :tag("th")
                    :wikitext(label)
                    :done()
                :tag("td")
                    :wikitext(value)
                    :done()
            :done()

    end

end


-- Liste der möglichen Felder
local fields = {
    {"beruf", "Beruf"},
    {"geburt", "Geboren"},
    {"geburtsort", "Geburtsort"},
    {"land", "Land"},
    {"wohnort", "Wohnort"},
    {"website", "Website"}
}


-- Hauptfunktion
function p.main(frame)

    -- Parameter der Vorlage holen
    local args = frame:getParent().args


    -- Grundparameter
    local titel = args.titel or ""
    local bild = args.bild or ""
    local bildbeschreibung = args.bildbeschreibung or ""


    -- Tabelle erstellen
    local box = mw.html.create("table")
        :addClass("infobox")


    -- Titel
    if titel ~= "" then

        box
            :tag("caption")
                :wikitext(titel)
                :done()

    end


    -- Bild
    if bild ~= "" then

        box
            :tag("tr")
                :tag("td")
                    :attr("colspan", "2")
                    :addClass("infobox-bild")
                    :wikitext("[[Datei:" .. bild .. "|250px]]")
                    :done()
            :done()


        -- Bildbeschreibung
        if bildbeschreibung ~= "" then

            box
                :tag("tr")
                    :tag("td")
                        :attr("colspan", "2")
                        :addClass("infobox-bild")
                        :wikitext(bildbeschreibung)
                        :done()
                :done()

        end

    end


    -- Alle Felder automatisch hinzufügen
    for _, field in ipairs(fields) do

        local parameter = field[1]
        local label = field[2]

        local value = args[parameter]

        addRow(box, label, value)

    end


    -- HTML zurückgeben
    return tostring(box)

end


return p