Modul:TemplUtl: Unterschied zwischen den Versionen
Zur Navigation springen
Zur Suche springen
2019-06-09
(2019-06-06) |
(2019-06-09) |
||
Zeile 1: | Zeile 1: | ||
local TemplUtl = { suite = "TemplUtl", | local TemplUtl = { suite = "TemplUtl", | ||
serial = "2019-06- | serial = "2019-06-09", | ||
item = 52364930 }; | |||
Zeile 111: | Zeile 112: | ||
TemplUtl.failsafe = function ( | TemplUtl.failsafe = function ( atleast ) | ||
-- Retrieve versioning and check for compliance | |||
-- Precondition: | |||
-- atleast -- string, with required version or "wikidata" | |||
-- or false | |||
-- Postcondition: | |||
-- Returns string with appropriate version, or false | |||
local since = atleast | |||
local r | local r | ||
if not | if since == "wikidata" then | ||
local item = TemplUtl.item | |||
since = false | |||
if type( item ) == "number" and item > 0 then | |||
local entity = mw.wikibase.getEntity( string.format( "Q%d", | |||
item ) ) | |||
if type( entity ) == "table" then | |||
local vsn = entity:formatPropertyValues( "P348" ) | |||
if type( vsn ) == "table" and | |||
type( vsn.value ) == "string" and | |||
vsn.value ~= "" then | |||
r = vsn.value | |||
end | |||
end | |||
end | |||
end | |||
if not r then | |||
if not since or since <= TemplUtl.serial then | |||
r = TemplUtl.serial | |||
else | |||
r = false | |||
end | |||
end | end | ||
return r | return r | ||
Zeile 178: | Zeile 204: | ||
if not mw.title.equals( mw.title.getCurrentTitle(), t ) and | if not mw.title.equals( mw.title.getCurrentTitle(), t ) and | ||
t.exists then | t.exists then | ||
t | t:getContent(); | ||
end | end | ||
end | end |