Modul:Lebensdaten
Modul:Lebensdaten
| Vorlagenprogrammierung | Diskussionen | Lua | Unterseiten | ||
| Modul | Deutsch
|
Modul: | Dokumentation | ||
Diese Seite enthält Code in der Programmiersprache Lua. Einbindungszahl Cirrus
--[=[ 2016-01-10
Lebensdaten
]=]
local TemplUtl;
local function fault( alert )
-- Format message with class="error"
-- alert -- string, with message
-- Returns message with markup
return string.format( "<span class=\"error\">%s</span>", alert );
end -- fault()
local furnishPersonendaten = function ( above )
-- Retrieve template parameters
-- Precondition:
-- above -- object; Title of current top page
-- TemplUtl has been loaded.
-- Postcondition:
-- Returns table with information, or false
local story = above:getContent();
local joint = TemplUtl.find( story, "Personendaten" );
local r;
if joint then
story = mw.ustring.sub( story, joint );
if story then
r = { };
r.GEBURTSDATUM = TemplUtl.fetch( story, "GEBURTSDATUM" );
r.GEBURTSORT = TemplUtl.fetch( story, "GEBURTSORT" );
r.STERBEDATUM = TemplUtl.fetch( story, "STERBEDATUM" );
r.STERBEORT = TemplUtl.fetch( story, "STERBEORT" );
end
end
return r;
end -- furnishPersonendaten()
local fire = function ( aim, frame, absent, assembly, allocate )
-- Personendaten auslesen
-- Precondition:
-- aim -- string; Modus "PD" oder "tot"
-- frame -- object
-- absent -- optional string; Titel Wartungskat für verstorben
-- assembly -- (PD) string; Titel der Lebensdaten-Muttervorlage
-- allocate -- (PD) optional string; GEBURTSORT
local skate = "[[Kategorie:Wikipedia:Vorlagenfehler/Vorlage:%s/%s]]";
local title = mw.title.getCurrentTitle();
local r, scream;
if title and title.namespace == 0 then
local lucky;
lucky, TemplUtl = pcall( require, "Module:TemplUtl" );
if type( TemplUtl ) == "table" then
local pd;
TemplUtl = TemplUtl.TemplUtl();
pd = furnishPersonendaten( title );
if pd then
if allocate and allocate ~= "" then
pd.GEBURTSORT = allocate;
end
local shift = pd.STERBEDATUM or pd.STERBEORT;
if aim == "PD" then
local sub = string.format( "%s/Lebensdaten",
assembly );
r = frame:expandTemplate{ title = sub, args = pd };
elseif aim == "tot" then
if shift then
r = shift;
end
end
if not shift then
local entity = mw.wikibase.getEntityObject();
if type( entity ) == "table" and
type( entity.claims ) == "table" then
local value = entity.claims.P570;
if type( value ) == "string" then
if mw.text.trim( value ) ~= "" then
if absent then
local scheme = "[[Category:%s]]";
scheme = string.format( scheme,
absent );
if r then
r = r .. scheme;
else
r = scheme;
end
else
scream = "Sterbedatum auf Wikidata";
end
end
end
end
end
else
scream = "Personendaten fehlen";
end
else
scream = "Modul TemplUtl fehlt";
end
else
r = "";
end
if scream then
if not r then
r = fault( scream );
end
r = r .. string.format( skate, assembly, scream );
end
return r;
end -- fire()
-- Export
local p = { };
p.test = function ( aim, args )
local r;
local stuff = args[ 1 ];
local starb = args.starb;
local seed = args.GEBURTSORT;
if stuff then
local frame = mw.getCurrentFrame();
r = fire( aim, frame, starb, stuff, seed );
end
return r;
end
p.PD = function ( frame )
local r;
local stuff = frame.args[ 1 ];
local starb = frame.args.starb;
local seed = frame.args.GEBURTSORT;
if stuff then
stuff = mw.text.trim( stuff );
r = fire( "PD", frame, starb, stuff, seed );
else
r = fault( "Lebensdaten.PD * Muttervorlage nicht angegeben" );
end
return r;
end
p.tot = function ( frame )
return fire( "tot", frame, frame.args.starb ) or "";
end
return p
Content Disclaimer
Informasi ini disarikan dari Wikipedia dan disajikan kembali untuk tujuan edukasi. Konten tersedia di bawah lisensi CC BY-SA 3.0. Kami tidak bertanggung jawab atas ketidakakuratan data yang bersumber dari kontribusi publik tersebut.
- The information displayed on this website is sourced in part or in whole from Wikipedia and has been adapted for the purpose of restating it. We strive to provide accurate and relevant information, however:
- There is no guarantee of absolute accuracy. Wikipedia is an open, collaborative project that can be edited by anyone, so information is subject to change.
- It is not intended to constitute professional advice. The content displayed is for informational and educational purposes only. For important decisions (e.g., medical, legal, or financial), please consult a professional.
- Content copyright. Wikipedia is licensed under the Creative Commons Attribution-ShareAlike License (CC BY-SA). This means that content may be reused with appropriate attribution and shared under a similar license.
- Responsible use. Any risk arising from the use of information from this website is entirely the responsibility of the user.