మాడ్యూల్:Authority control: కూర్పుల మధ్య తేడాలు

Content deleted Content added
Undid revision 569546376 by Gabbe (talk): Seems to have caused errors to some articles, reverted.
imported>Tpt
Wikidata support should work now
పంక్తి 123:
function ulanLink( id )
return '[http://www.getty.edu/vow/ULANFullDisplay?find=&role=&nation=&subjectid=' .. id .. ' ' .. id .. ']' .. getCatForId( 'ULAN' )
end
 
 
function getIdsFromWikidata( item, property )
local ids = {}
if not item.claims[property] then
return ids
end
for _, statement in pairs( item.claims[property] ) do
table.insert( ids, statement.mainsnak.datavalue.value )
end
return ids
end
 
Line 144 ⟶ 156:
{ 'ORCID', '[[ORCID]]', 496, orcidLink },
{ 'GND', '[[Integrated Authority File|GND]]', 227, gndLink },
{ 'PND', '[[Integrated Authority File|GND]]', 0, gndLink },
{ 'SELIBR', '[[LIBRIS]]', 0, selibrLink },
{ 'BNF', '[[Bibliothèque nationale de France|BNF]]', 268, bnfLink },
Line 159 ⟶ 170:
--Create rows
local elements = {}
 
--redirect PND to GND
if (parentArgs.GND == nil or parentArgs.GND == '') and parentArgs.PND ~= nil and parentArgs.PND ~= '' then
parentArgs.GND = parentArgs.PND
end
 
--Wikidata fallback if requested
local item = mw.wikibase.getEntity()
if item ~= nil and item.claims ~= nil then
for _, params in pairs( conf ) do
if params[3] ~= 0 then
local val = parentArgs[params[1]]
if not val or val == '' then
local wikidataIds = getIdsFromWikidata( item, 'p' .. params[3] )
if wikidataIds[1] then
parentArgs[params[1]] = wikidataIds[1]
end
end
end
end
end
 
--Worldcat
"https://te.wikipedia.org/wiki/మాడ్యూల్:Authority_control" నుండి వెలికితీశారు