Änderungen

Modul:WLink

2.077 Bytes hinzugefügt, 18:12, 27. Jan. 2018
https://de.wikipedia.org/w/index.php?title=Wikipedia%3AAdministratoren%2FAnfragen&type=revision&diff=173391765&oldid=173390181#Zweimal_C&P
local WLink = { suite = "WLink",
serial = "20172018-1001-1427" , item = 19363224 };
--[=[
ansiPercent()
getLanguage()
getNamespace()
getNamespaced()
getPlain()
getProject()
return r;
end -- WLink.getNamespace()
 
 
 
function WLink.getNamespaced( area, attempt )
-- Retrieve page in namespace
-- Precondition:
-- area -- string or number, with some namespace spec
-- attempt -- string, with wikilink or page title or page name
-- Postcondition:
-- Returns page prefixed by namespace,
-- false if invalid
local r = false;
local s = type( area );
local room;
if s == "string" then
room = mw.site.namespaces[ tonumber( area ) or area ];
elseif s == "number" then
room = mw.site.namespaces[ area ];
end
if room then
local m;
s, m = WLink.getTarget( attempt );
if not s then
s = attempt;
elseif m ~= 2 then
s = false;
end
if s then
local w = WLink.wikilink( s );
if w and not w.lang and not w.project and
( not w.ns or w.ns == room.id ) then
r = string.format( "%s:%s",
room.name, w.title );
end
end
end
return r;
end -- WLink.getNamespaced()
-- Retrieve versioning and check for compliance
-- Precondition:
-- assert -- string, with required versionor "wikidata", -- or false
-- Postcondition:
-- Returns string with appropriate version, or false
local since = assert;
local r;
if assert since == "wikidata" then local item = WLink.item; since = false; if type( item ) == "number" and assert item > WLink0 then local ent = mw.wikibase.getEntity( string.format( "Q%d", item ) ); if type( ent ) == "table" then local vsn = ent:formatPropertyValues( "P348" ); if type( vsn ) == "table" and type( vsn.value) == "string" and vsn.serial value ~= "" then r = falsevsn.value; end end end elseend if not r then if not since or since <= WLink.serial then r = WLink.serial; else r = false; end
end
return r;
end -- WLink.failsafe()
s = mw.text.trim( v );
end
elseif ( k == 2 and action == "ansiPercentgetNamespaced" ) or ( k == "space" and k action == "spaceansiPercent" ) then
if v ~= "" then
space = v;
p.getNamespace = function ( frame )
return tostring( Template( frame, "getNamespace" ) );
end
p.getNamespaced = function ( frame )
return tostring( Template( frame, "getNamespaced" ) );
end
p.getPlain = function ( frame )
Anonymer Benutzer