Modul:Stammbaum
Zur Navigation springen
Zur Suche springen
Dokumentation und Testfälle unter Modul:Stammbaum/Doku.
local p = {}
function robusttrim(s)
if s==nil then return '' end
local p=string.gsub(s,'%[%[SMW::on%]%]','')
p=string.gsub(p,'%[%[SMW::off%]%]','')
return mw.text.trim(p)
end
function personlehen(frame,person)
local lehen=frame:callParserFunction('#ask',
'[[-Has subobject::'..person..']]','mainlabel=-','? Herrscher von Lehen#=',
'sort=Herrscher von Detailstufe','limit=1','searchlabel=')
if (lehen=="") then return "" end
local lehenstyp=frame:callParserFunction('#show',lehen,'?Lehenstyp#')
if (lehenstyp=="") then return "" end
local krone=""
if (lehenstyp=="Herrschaft") then krone="Edlenkrone2" end
if (lehenstyp=="Junkertum") then krone="Junkerskrone2" end
if (lehenstyp=="Baronie") then krone="Baronskrone2" end
if (lehenstyp=="Grafschaft") then krone="Grafenkrone2" end
if (lehenstyp=="Provinz") then
krone="Koenigskrone2"
if (string.sub(lehen,1,8)=="Garetien") then krone="Debrekskrone2" end
if (string.sub(lehen,1,8)=="Perricum") then krone="Markgrafenkrone2" end
if (string.sub(lehen,1,11)=="Greifenfurt") then krone="Markgrafenkrone2" end
end
if (lehenstyp=="Reich") then krone="Raulskrone2" end
if krone=="" then return "" end
return "[[Datei:"..krone..".svg|x20px|link="..lehen.."]] "
end
function personeneintrag(frame,person,tsatag,borontag,anzeige)
local titelobject=mw.title.new(person)
local titel=titelobject.text
if(anzeige~="") then
titel=anzeige
end
local tsa=frame:callParserFunction('#show',person,'?Tsatag Index#')
local boron=frame:callParserFunction('#show',person,'?Borontag Index#')
local wappen=frame:callParserFunction('#show',person,'?Familienwappen ist#')
if ((tsa=="99990000")or(tsa=="")) then
if(tsatag~="") then tsa=tsatag.."0000" else tsa="" end
end
if ((boron=="99990000")or(boron=="")) then
if(borontag~="") then boron=borontag.."0000" else boron="" end
end
if (wappen~="") then
wappen="[["..wappen.."|20px|link=]] "
end
local leben=""
if (tsa~="") then
tsan=math.floor(tonumber(tsa)/10000)
leben=tostring(tsan)
end
if (boron~="") then
boronn=math.floor(tonumber(boron)/10000)
leben=leben.."-"..tostring(boronn)
end
if (leben~="") then leben=" ("..leben..")" end
local link="[["..person.."|"..titel.."]]"
leben=personlehen(frame,person)..wappen..link..leben
if (boron=="") then leben="'''"..leben.."'''" end
return leben
end
function familieneintrag(frame,familie)
local titel=mw.title.new(familie).text
local wappen=frame:callParserFunction('#show',familie,'?Wappen ist#')
if (wappen=="") then wappen="Datei:Wappen blanko.svg" end
local result="[["..familie.."|(...) "..titel.."]] [["..wappen.."|x20px|link="..familie.."]]"
return result
end
function p.Eintrag(frame)
if (frame.args[1]==nil) then
return "Personeneintrag fehlt"
end
local person=robusttrim(frame.args[1])
local tsatag=robusttrim(frame.args[2])
local borontag=robusttrim(frame.args[3])
local anzeige=robusttrim(frame.args[4])
return personeneintrag(frame,person,tsatag,borontag,anzeige)
end
function p.Familie(frame)
if (frame.args[1]==nil) then
return "Familieneintrag fehlt"
end
local familie=robusttrim(frame.args[1])
return familieneintrag(frame,familie)
end
return p