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

local p = {}

function p.kategorien(frame)
    local args = frame:getParent().args
    local cats = { "[[Kategorie:ADB]]" }
    table.insert(cats, ({
        ["Biographie"] = "",
        ["Verweisung"] = "[[Kategorie:ADB:Verweisung]] [[Kategorie:ADB:WP-Zuordnung nicht sinnvoll]]",
        ["Sammelartikel"] = "[[Kategorie:ADB:Sammelartikel]]",
        ["Vorrede"] = "[[Kategorie:ADB:Vorrede|" .. math.floor(tonumber(args.BAND) / 10) .. "]] [[Kategorie:ADB:WP-Zuordnung nicht sinnvoll]]",
        ["ZuB"] = "[[Kategorie:ADB:Zusätze und Berichtigungen|" .. math.floor(tonumber(args.BAND) / 10) .. "]] [[Kategorie:ADB:WP-Zuordnung nicht sinnvoll]]",
        ["ADB-BKL"] = "[[Kategorie:ADB:WS-Verweisung]]"
    })[args.ART] or "[[Kategorie:ADB:Vorlagenfehler|T]]")
    
    if args.ART ~= "ADB-BKL" then
        table.insert(cats, "[[Kategorie:ADB:Band " .. args.BAND .. "]]" .. (({
        -- BSB-Abgleich
            JA = "[[Kategorie:ADB:BSB-Abgleich durchgeführt]]",
            NEIN = "[[Kategorie:ADB:BSB-Abgleich nicht durchgeführt]]",
            OFF = "[[Kategorie:ADB:BSB-Abgleich nicht möglich]]"
        })[args["BSB-ABGLEICH"]:upper()] or "[[Kategorie:ADB:Vorlagenfehler|B]]") .. (({
         -- Verlinkunsstand
            ["unverlinkt"] = "[[Kategorie:ADB:Unverlinkt]]",
            ["teilverlinkt"] = "[[Kategorie:ADB:Teilverlinkt]]",
            ["vollständig verlinkt"] = "[[Kategorie:ADB:Vollständig verlinkt]]"
        })[args.VERLINKUNGSSTAND] or "[[Kategorie:ADB:Vorlagenfehler|V]]"))
        if args.ENDSEITE == "" or args.ENDSEITE:upper() == "NONE" then
            table.insert(cats, "[[Kategorie:ADB:Ohne Endseite]]")
        end
        if (args["AUTORENKÜRZEL1"] or "") == "" then
            table.insert(cats, "[[Kategorie:ADB:Vorlagenfehler|A]]")
        end
    end
    
    if args["AUTORENKÜRZEL3"] then
        table.insert(cats, "[[Kategorie:ADB:Drei Autoren]]")
    elseif args["AUTORENKÜRZEL2"] then
        table.insert(cats, "[[Kategorie:ADB:Zwei Autoren]]")
    end
    
    if (args.GND or "") ~= "" then
        table.insert(cats, ({
            OFF = "[[Kategorie:ADB:GND-Zuordnung unmöglich]]",
            NONE = "[[Kategorie:ADB:GND existiert nicht]]"
        })[args.GND:upper()] or "[[Kategorie:ADB:Mit GND-Link|" .. args.GND .. "]]")
    else
        table.insert(cats, "[[Kategorie:ADB:Ohne GND-Link]]")
    end
    
    if (args.WIKIPEDIA or ""):upper() == "OFF" then
        table.insert(cats, "[[Kategorie:ADB:WP-Zuordnung nicht sinnvoll]]")
    elseif tonumber(args.WIKIPEDIA) then
        table.insert(cats, string.format("[[Kategorie:ADB:WP-Artikel existiert nicht|%X%s]]", math.floor(tonumber(args.WIKIPEDIA, 10)), args.TITEL))
    elseif (args.WIKIPEDIA or "") ~= "" then
        table.insert(cats, "[[Kategorie:ADB:Mit WP-Link]]")
    elseif args.ART ~= "Verweisung" and args.ART ~= "ZuB" and args.ART ~= "Vorrede" then
        table.insert(cats, "[[Kategorie:ADB:Ohne WP-Link]]")
    end
    
    if (args.WIKISOURCE or "") ~= "" and not mw.title.new(args.WIKISOURCE).exists then
        table.insert(cats, "[[Kategorie:ADB:Vorlagenfehler|R]]")
    end
    return table.concat(cats, "")
end

return p