Modul:Verwaltungseinheit
Die Dokumentation für dieses Modul kann unter Modul:Verwaltungseinheit/Doku erstellt werden
local p = {}
local getArgs = require('Modul:Arguments').getArgs
local cfg = mw.loadData('Modul:Verwaltungseinheit/Liste');
local function einheit(frame)
local args = getArgs(frame)
local staat = args[1]
local info = cfg.div[staat] or staat
return info
end
function p.erste(frame)
local args = getArgs(frame)
local name = einheit(frame)
return name[1]
end
function p.inter(frame)
local args = getArgs(frame)
local name = einheit(frame)
return name['b']
end
function p.special(frame)
local args = getArgs(frame)
local division = args[2]
local special = cfg.altname[division]
if special then
if special[2] then return special[2]
else return special[1]
end
end
end
function p.zweite(frame)
local args = getArgs(frame)
local name = einheit(frame)
local division = args[2]
local subtype = args[3]
local special = p.special(frame)
local subname = cfg.altdiv[subtype]
if special then return '[['..special..']]'
elseif subname then return subname[1]
else return name[2]
end
end
function p.dritte(frame)
local args = getArgs(frame)
local name = einheit(frame)
local second = args[3]
local thirdlink = cfg.altdiv[second]
if thirdlink then return thirdlink[2]
else return name[3]
end
end
function p.vierte(frame)
local args = getArgs(frame)
local name = einheit(frame)
local second = args[3]
local special = p.special(frame)
local thirdlink = cfg.altdiv[second]
if special then return special
elseif thirdlink then return thirdlink[3]
else return name[4]
end
end
local function link(frame)
local args = getArgs(frame)
local staat = args[1]
local info = cfg.add[staat]
return info
end
function p.intermed(frame)
local args = getArgs(frame)
local name = link(frame)
return '[['..name['b']..' '..args[2]..'|'..args[2]..']]'
end
function p.zweitelink(frame)
local args = getArgs(frame)
local staat = args[1]
local second = args[2]
local first = args[3]
local begriff = args[4]
local level = cfg.altadd[first]
local special = p.special(frame)
local name = link(frame)
if special then division = special
elseif level then division = level['danach'] or level[1]
elseif name then division = name['danach'] or name[1]
end
local element = cfg.add[staat]
if element then
local level = element[1]
local control = element['f1'] or element['f2']
if control and ((mw.ustring.find(second, element['f1']) or (mw.ustring.find(second, element['f2']))) ~= nil) then return '[['..second..']]'
elseif division == name['danach'] then
if begriff then return '[['..second..' '..division..' ('..begriff..')|'..second..']]'
else return '[['..second..' '..division..'|'..second..']]'
end
else
if begriff then return '[['..division..' '..second..' ('..begriff..')'..'|'..second..']]'
else return '[['..division..' '..second..'|'..second..']]'
end
end
else if begriff then return '[['..second..' ('..begriff..')'..'|'..args[2]..']]'
else return '[['..second..']]'
end
end
end
function p.drittelink(frame)
local args = getArgs(frame)
local staat = args[1]
local second = args[2]
local first = args[3]
local begriff = args[4]
local level = cfg.altadd[first]
if level then division = level['danach2'] or level[2] end
if division then
if division == level['danach2'] then
if begriff then return '[['..second..' '..division..' ('..begriff..')|'..second..']]'
else return '[['..second..' '..division..'|'..second..']]'
end
else
if begriff then return '[['..division..' '..second..' ('..begriff..')|'..second..']]'
else return '[['..division..' '..second..'|'..second..']]'
end
end
else
if begriff then return '[['..second..' ('..begriff..')|'..second..']]'
else return '[['..second..']]'
end
end
end
function p.viertelink(frame)
local args = getArgs(frame)
local staat = args[1]
local second = args[2]
local first = args[3]
local begriff = args[4]
local level = cfg.altadd[first]
local special = p.special(frame)
if level then division = level['danach3'] or level[3] end
if special then return '[['..second..']]'
else
if division then
if division == level['danach3'] then
if begriff then return '[['..second..' '..division..' ('..begriff..')|'..second..']]'
else return '[['..second..' '..division..'|'..second..']]'
end
else
if begriff then return '[['..division..' '..second..' ('..begriff..')|'..second..']]'
else return '[['..division..' '..second..'|'..second..']]'
end
end
else
if begriff then return '[['..second..' ('..begriff..')|'..second..']]'
else return '[['..second..']]'
end
end
end
end
return p