Modul:Verwaltungseinheit
Erscheinungsbild
Vorlagenprogrammierung | Diskussionen | Lua | Unterseiten | |||
Modul | Deutsch | English
|
Modul: | Dokumentation |
Diese Seite enthält Code in der Programmiersprache Lua. Einbindungszahl Cirrus
local p = {}
local getArgs = require('Modul:Arguments').getArgs
local cfg = mw.loadData('Modul:Verwaltungseinheit/Liste');
function p.erste(frame)
local args = getArgs(frame)
local staat = args[1]
local except = args[2]
local name = cfg.div[staat]
local special = cfg.spname[except]
if special and special['n1'] then return special['n1']
elseif name and name[1] then return name[1]
else return 'NAME'
end
end
function p.erstelink(frame)
local args = getArgs(frame)
local staat = args[1]
local unit = args[2]
local name = cfg.add[staat]
if name and name['e1'] then return '[['..name['e1']..' '..unit..'|'..unit..']]'
else return '[['..unit..']]'
end
end
function p.inter(frame)
local args = getArgs(frame)
local staat = args[1]
local name = cfg.div[staat]
if name and name['b'] then return name['b']
else return 'NAME'
end
end
function p.intermed(frame)
local args = getArgs(frame)
local staat = args[1]
local unit = args[2]
local name = cfg.add[staat]
if name and name['b'] then return '[['..name['b']..' '..unit..'|'..unit..']]'
else return unit
end
end
function p.zweite(frame)
local args = getArgs(frame)
local staat = args[1]
local except = args[2]
local first = args[3]
local name = cfg.div[staat]
local special = cfg.spname[except]
local subname = cfg.altdiv[first]
if special then
if special['n2'] then return special['n2']
else return '[['..special['a2']..']]'
end
elseif subname then return subname[1]
else return name[2]
end
end
function p.zweitelink(frame)
local args = getArgs(frame)
local staat = args[1]
local unit = args[2]
local first = args[3]
local begriff = args[4]
local name = cfg.add[staat]
local special = cfg.spname[except]
local altname = cfg.altadd[first]
if special then
if special['a2'] then return '[['..special['a2']..' '..unit..'|'..unit..']]'
else return '[['..unit..']]'
end
elseif altname then
if (altname['f1'] or altname['f2']) and ((mw.ustring.find(unit, name['f1']) or mw.ustring.find(unit, name['f2'])) ~= nil) then return '[['..unit..']]'
elseif altname['danach2'] then
if begriff then return '[['..unit..' '..altname['danach2']..' ('..begriff..')|'..unit..']]'
else return '[['..unit..' '..altname['danach2']..'|'..unit..']]'
end
elseif altname[1] then
if begriff then return '[['..altname[1]..' '..unit..' ('..begriff..')|'..unit..']]'
else return '[['..altname[1]..' '..unit..'|'..unit..']]'
end
end
elseif name then
if (name['f1'] or name['f2']) and ((mw.ustring.find(unit, name['f1']) or mw.ustring.find(unit, name['f2'])) ~= nil) then return '[['..unit..']]'
elseif name['danach2'] then
if begriff then return '[['..unit..' '..name['danach2']..' ('..begriff..')|'..unit..']]'
else return '[['..unit..' '..name['danach2']..'|'..unit..']]'
end
elseif name[1] then
if begriff then return '[['..name[1]..' '..unit..' ('..begriff..')|'..unit..']]'
else return '[['..name[1]..' '..unit..'|'..unit..']]'
end
end
else return '[['..unit..']]'
end
end
function p.dritte(frame)
local args = getArgs(frame)
local staat = args[1]
local except = args[2]
local first = args[3]
local name = cfg.div[staat]
local special = cfg.spname[except]
local subname = cfg.altdiv[first]
if special then
if special['n3'] then return special['n3']
else return '[['..special['a3']..']]'
end
elseif subname then return subname[2]
else return name[3]
end
end
function p.drittelink(frame)
local args = getArgs(frame)
local staat = args[1]
local unit = args[2]
local first = args[3]
local begriff = args[4]
local name = cfg.add[staat]
local special = cfg.spname[except]
local altname = cfg.altadd[first]
if special then
if special['a3'] then return '[['..special['a3']..' '..unit..'|'..unit..']]'
else return '[['..unit..']]'
end
elseif altname then
if altname['danach3'] then
if begriff then return '[['..unit..' '..altname['danach3']..' ('..begriff..')|'..unit..']]'
else return '[['..unit..' '..altname['danach3']..'|'..unit..']]'
end
elseif altname[2] then
if begriff then return '[['..altname[2]..' '..unit..' ('..begriff..')|'..unit..']]'
else return '[['..altname[2]..' '..unit..'|'..unit..']]'
end
end
elseif name then
if name['danach3'] then
if begriff then return '[['..unit..' '..name['danach3']..' ('..begriff..')|'..unit..']]'
else return '[['..unit..' '..name['danach3']..'|'..unit..']]'
end
elseif name[2] then
if begriff then return '[['..name[2]..' '..unit..' ('..begriff..')|'..unit..']]'
else return '[['..name[2]..' '..unit..'|'..unit..']]'
end
end
else return '[['..unit..']]'
end
end
function p.vierte(frame)
local args = getArgs(frame)
local staat = args[1]
local except = args[2]
local first = args[3]
local name = cfg.div[staat]
local special = cfg.spname[except]
local subname = cfg.altdiv[first]
if special then
if special['n4'] then return special['n4']
else return '[['..special['a4']..']]'
end
elseif subname then return subname[3]
else return name[4]
end
end
function p.viertelink(frame)
local args = getArgs(frame)
local staat = args[1]
local unit = args[2]
local first = args[3]
local begriff = args[4]
local name = cfg.add[staat]
local altname = cfg.altadd[first]
local special = cfg.spname[unit]
if special then
if special['a4'] then return '[['..special['a4']..' '..unit..'|'..unit..']]'
else return '[['..unit..']]'
end
elseif altname then
if altname['danach4'] then
if begriff then return '[['..unit..' '..altname['danach4']..' ('..begriff..')|'..unit..']]'
else return '[['..unit..' '..altname['danach4']..'|'..unit..']]'
end
elseif altname[3] then
if begriff then return '[['..altname[3]..' '..unit..' ('..begriff..')|'..unit..']]'
else return '[['..altname[3]..' '..unit..'|'..unit..']]'
end
end
elseif name then
if name['danach4'] then
if begriff then return '[['..unit..' '..name['danach4']..' ('..begriff..')|'..unit..']]'
else return '[['..unit..' '..name['danach4']..'|'..unit..']]'
end
elseif name[3] then
if begriff then return '[['..name[3]..' '..unit..' ('..begriff..')|'..unit..']]'
else return '[['..name[3]..' '..unit..'|'..unit..']]'
end
end
else return '[['..unit..']]'
end
end
function p.liste(frame)
local root = mw.html.create('table'):addClass('wikitable sortable')
root:tag('tr')
:tag('th'):wikitext('Staat'):attr('rowspan', 2):done()
:tag('th'):wikitext('Ebene'):attr('colspan', 4):done()
root:tag('tr')
:tag('th'):wikitext('1. Ebene'):done()
:tag('th'):wikitext('2. Ebene'):done()
:tag('th'):wikitext('3. Ebene'):done()
:tag('th'):wikitext('4. Ebene'):done()
local staat = {}
for k, v in pairs(cfg.div) do
staat[#staat+1] = k
end
table.sort(staat)
for _, value in pairs(staat) do
local ebene = cfg.div[value]
root:tag('tr')
:tag('td'):wikitext('[['..value..']]'):done()
:tag('td'):wikitext(ebene[1]):done()
:tag('td'):wikitext(ebene[2]):done()
:tag('td'):wikitext(ebene[3]):done()
:tag('td'):wikitext(ebene[4]):done()
end
return root
end
return p