Open main menu

Changes

Module:Authority control

1,140 bytes removed, 14:48, 21 August 2013
Undid revision 569546376 by Gabbe (talk): Seems to have caused errors to some articles, reverted.
return '[[Category:Miscellaneous pages with ' .. id .. ' identifiers]]'
end
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
return '* <span class="error">The ' .. id .. ' id ' .. rawValue .. ' is not valid.</span>[[Category:Wikipedia articles with faulty authority control identifiers (' .. id .. ')]]\n'
end
end
 
function inArray( value, array )
for _, element in pairs( array ) do
if value == element then
return true
end
end
return false
end
{ 'ULAN', '[[Union List of Artist Names|ULAN]]', 245, ulanLink }
}
local p = {}
--Create rows
local elements = {}
 
--Item
local item = mw.wikibase.getEntity()
--Worldcat
for k, params in pairs( conf ) do
local val = parentArgs[params[1]]
local text = ''
 
--Wikidata
if item ~= nil and params[3] ~= 0 then
local wikidataIds = getIdsFromWikidata( item, 'p' .. params[3] )
if wikidataIds[1] then
if val and val ~= '' then
--[[TODO Consistency check
if not inArray( val, wikidataIds ) then
text = text .. '[Category:Inconsistent Authority identifier between Wikidata and Wikipedia]'
end]]--
else
--Fallback
val = wikidataIds[1]
end
end
end
 
if val and val ~= '' then
table.insert( elements, createRow( params[1], params[2] .. ':', val, params[4]( val ), true ) )
Anonymous user