Modul:SmwWikibase: Unterschied zwischen den Versionen
Zur Navigation springen
Zur Suche springen
(Rückgabewert fehlte) |
(wikibase access) |
||
Zeile 12: | Zeile 12: | ||
return result | return result | ||
end | end | ||
+ | |||
+ | function p.getEntity( id ) | ||
+ | local wrongQualifier = false | ||
+ | local entity = nil | ||
+ | |||
+ | if not isSet( id ) then | ||
+ | return '', entity, wrongQualifier | ||
+ | end | ||
+ | if mw.wikibase.isValidEntityId( id ) then | ||
+ | -- expensive function call | ||
+ | -- redirect ids marked false, too | ||
+ | entity = mw.wikibase.getEntity( id ) | ||
+ | end | ||
+ | if not entity then | ||
+ | id = '' | ||
+ | wrongQualifier = true | ||
+ | end | ||
+ | |||
+ | return id, entity, wrongQualifier | ||
+ | end | ||
+ | |||
return p | return p |
Version vom 25. August 2021, 17:06 Uhr
Ausgabe dieses Moduls (mit Aufruf: {{#invoke:SmwWikibase|smwfromwikibase}}): Skriptfehler: Die Funktion „smwfromwikibase“ ist nicht vorhanden.
local p = {}
function p.forloop()
local i
local result
result = ';for\n'
for i = 2, 10, 2 do
result = result .. ":i = " .. i .. '\n'
end
return result
end
function p.getEntity( id )
local wrongQualifier = false
local entity = nil
if not isSet( id ) then
return '', entity, wrongQualifier
end
if mw.wikibase.isValidEntityId( id ) then
-- expensive function call
-- redirect ids marked false, too
entity = mw.wikibase.getEntity( id )
end
if not entity then
id = ''
wrongQualifier = true
end
return id, entity, wrongQualifier
end
return p