Diferencia entre revisiones de «Módulo:Control de autoridades»

De Wikipedia, la enciclopedia libre
Contenido eliminado Contenido añadido
Sin resumen de edición
Paso 10: configuraciones locales: filtro para BNC; doble enlace para BNF; enlace especial para INE; reemplazo para NARA; anulación de SELIBR, KVAB, ANMF, ISCO, CABA y SIPCA porque no funcionan; redirección para PND; y enlaces para WorldCat
(No se muestran 9 ediciones intermedias del mismo usuario)
Línea 1: Línea 1:
require('Módulo:No globals')
require('Módulo:No globals')


local function getCatForId( id )
local function generic ( id, link, parameter )
link = mw.ustring.gsub( link, '$1', id )
local title = mw.title.getCurrentTitle()
return '[' .. link .. ' ' .. id .. ']'
local namespace = title.namespace
if namespace == 0 then
return '[[Categoría:Wikipedia:Artículos con identificadores ' .. id .. ']]'
elseif namespace == 2 and not title.isSubpage then
return '[[Categoría:Wikipedia:Páginas de usuario con identificadores ' .. id .. ']]'
else
return '[[Categoría:Wikipedia:Páginas misceláneas con identificadores ' .. id .. ']]'
end
end
end


local function viafLink( id )
local function bncLink ( id, link, parameter )
-- filtro local del BNC, para evadir multitud de identificadores de Wikidata que no se enlazan adecuadamente
if not string.match( id, '^%d+$' ) then
-- véase https://www.wikidata.org/wiki/Wikidata:Database_reports/Constraint_violations/P1890#%22Format%22_violations
return false
if ( string.match( id, '^%d%d%d%d%d%d%d%d%d$' ) ) then
end
return generic ( id, link, parameter )
return '[https://viaf.org/viaf/' .. id .. ' ' .. id .. ']' .. getCatForId( 'VIAF' )
end
return false
end
end


local function bnfLink ( id, link, parameter )

-- representación local del BNF, con doble enlace
local function lccnlcoc ( id )
return '[https://lccn.loc.gov/' .. id .. ' ' .. id .. ']'
return generic( id, link, parameter ) .. ' [http://data.bnf.fr/ark:/12148/cb' .. id .. ' (data)]'
end
end


local function kulturnavLink( id )
local function ineLink ( id, link, parameter )
-- representación especial del INE, enlace no estándar con cinco parámetros utilizados
return '[http://kulturnav.org/language/en/' .. id .. ' id]'
local ineMainRE, ineTailRE = '^(%d%d)(%d%d%d)', '(%d%d)(%d%d)(%d%d)'
local codProv, codMuni, codEC, codES, codNUC = string.match( id, ineMainRE .. ineTailRE .. '$' )
if not codEC or not codES or not codNUC then
codProv, codMuni = string.match( id, ineMainRE .. '$' )
if codProv and codMuni then
codEC, codES, codNUC = '00', '00', '00'
else
codProv, codMuni = string.match( id, ineMainRE )
codEC, codES, codNUC = '', '', ''
end
end
if codProv and codMuni then
link = 'http://www.ine.es/nomen2/inicio_a.do?accion=busquedaAvanzada&inicio=inicio_a&subaccion=&botonBusquedaAvanzada=Consultar+selecci%C3%B3n&numPag=0&ordenAnios=ASC&comunidad=00&entidad_amb=no&poblacion_amb=T&poblacion_op=%3D&poblacion_txt=&denominacion_op=like&denominacion_txt=&codProv=$1&codMuni=$2&codEC=$3&codES=$4&codNUC=$5'
link = link:gsub('$1', codProv):gsub('$2', codMuni):gsub('$3', codEC):gsub('$4', codES):gsub('$5', codNUC)
return generic( id, link, parameter )
end
return id
end
end


local function sikartLink( id )
local conf = {}
--In this order: name of the parameter, label, propertyId in Wikidata, formatting function, category id
return '[http://www.sikart.ch/KuenstlerInnen.aspx?id=' .. id .. '&lng=en ' .. id .. ']'
-- -- name of the parameter: unique name
end
-- -- label: internal link in wiki format
-- -- propertyId in Wikidata: number without 'P' suffix
-- -- formatting function: one of these four options
-- -- -- local function (like 'generic')
-- -- -- string 'y' (yes), to show a default identifier 'ID'
-- -- -- string 'n' (no), to show the real identifier
-- -- -- any other string, to show this string as identifier ('id', 'url', 'link', ...)
-- -- category id: one of these tree options
-- -- -- number 0, to not add category
-- -- -- number 1, to add a category based on the name of the parameter
-- -- -- any string, to add a category based on this string
conf.databases = {
{ 'Wikidata', '[[Archivo:Wikidata-logo.svg|20px|link=https://www.wikidata.org/wiki/Wikidata:Main_Page|alt=Wd|Wikidata]]', 'Wikidata:$1', 'n', 0 },
{ 'ISSN', '[[ISSN]]', 236, 'n', 1 },
{ 'VIAF', '[[Virtual International Authority File|VIAF]]', 214, 'n', 1 },
{ 'ISNI', '[[International Standard Name Identifier|ISNI]]', 213, 'n', 1 },


{ 'BCN', '[[Biblioteca del Congreso de la Nación Argentina|BCN]]', 2879, 'n', 1 },
local function tlsLink( id )
{ 'BNA', '[[Biblioteca Nacional de la República Argentina|BNA]]', 3788, 'n', 1 },
local id2 = mw.ustring.gsub(id, '%s', function(s) return mw.uri.encode(s, 'WIKI') end)
{ 'BNE', '[[Biblioteca Nacional de España|BNE]]', 950, 'n', 1 },
return '[http://tls.theaterwissenschaft.ch/wiki/' .. id2 .. ' ' .. id .. ']'
{ 'BNF', '[[Bibliothèque nationale de France|BNF]]', 268, bnfLink, 1 },
end
{ 'BNM', '[[Biblioteca Nacional de México|BNM]]', 4440, 'n', 1 },
{ 'BNC', '[[Biblioteca Nacional de Chile|BNC]]', 1890, bncLink, 1 },
{ 'CANTIC', '[[Biblioteca de Cataluña|CANTIC]]', 1273, 'n', 1 },
{ 'GND', '[[Integrated Authority File|GND]]', 227, 'n', 1 },
{ 'LCCN', '[[Library of Congress Control Number|LCCN]]', 244, 'n', 1 },
{ 'NCL', '[[National Central Library|NCL]]', 1048, 'n', 0 },
{ 'NDL', '[[National Diet Library|NDL]]', 349, 'n', 0 },
{ 'NKC', '[[National Library of the Czech Republic|NKC]]', 691, 'n', 0 },
{ 'NLA', '[[National Library of Australia|NLA]]', 409, 'n', 1 },
{ 'RLS', '[[Biblioteca del Estado Ruso|BER]]', 947, 'n', 0 },


{ 'CINII', '[[CiNii]]', 271, 'n', 0 },
local function ciniiLink( id )
{ 'NARA', '[[National Archives and Records Administration|NARA]]', 1225, 'n', 0 },
return '[http://ci.nii.ac.jp/author/' .. id .. '?l=en ' .. id .. ']'
{ 'LCCNLCOC', '[[Library of Congress Control Number|LCCN]]', 1144, 'n', 0 },
end
{ 'SNAC', '[[d:Q29861311|SNAC]]', 3430, 'n', 1 },


{ 'SUDOC', '[[Système universitaire de documentation|SUDOC]]', 269, 'n', 0 },
local function SSRNautor ( id )
{ 'ULAN', '[[Union List of Artist Names|ULAN]]', 245, 'n', 1 },
return '[https://ssrn.com/author=' .. id .. ' ' .. id .. ']' .. getCatForId( 'SSRN autor' )
{ 'ORCID', '[[ORCID]]', 496, 'n', 1 },
end
-- { 'SELIBR', '[[LIBRIS|SELIBR]]', 906, 'n', 1 },
{ 'BIBSYS', '[[BIBSYS]]', 1015, 'n', 1 },
{ 'UB', '[[Universidad de Barcelona|UB]]', 1580, 'n', 1 },
{ 'IPNIaut', '[[Índice Internacional de Nombres de las Plantas|IPNI]]', 586, 'n', 'IPNI' },
{ 'MGP', '[[Mathematics Genealogy Project|MGP]]', 549, 'n', 0 },
{ 'autores.uy', '[[autores.uy]]', 2558, 'n', 1 },
{ 'Slovenska biografija', '[[Slovenska biografija]]', 1254, 'n', 0 },
{ 'SBN', '[[Istituto Centrale per il Catalogo Unico|ICCU]]', 396, 'n', 1 },


{ 'CensoGuia', '[[Censo-Guía de Archivos de España e Iberoamérica]]', 3998, 'n', 'Censo-Guía' },
local function dialnetLink ( id )
{ 'Libraries.org', '[[Libraries.org]]', 4848, 'n', 1 },
return '[http://dialnet.unirioja.es/servlet/autor?codigo=' .. id .. ' ' .. id .. ']' .. getCatForId( 'Dialnet' )
end


{ 'BOE', '[[Boletín Oficial del Estado|BOE]]', 4256, 'n', 1 },
local function bcnLink ( id )
return '[http://consulta.bcn.gob.ar/bcn/catalogo.verRegistro?co=' .. id .. ' ' .. id .. ']' .. getCatForId( 'BCN' )
end


{ 'RoyalSociety', '[[Royal Society]]', 2070, 'url', 'Royal Society' },
local function bnaLink ( id )
{ 'HAW', '[[Academia de Ciencias y Humanidades de Heidelberg|HAW]]', 2273, 'n', 1 },
return '[http://catalogo.bn.gov.ar/F/?func=direct&doc_number=' .. id .. '&local_base=BNA10 ' .. id .. ']' .. getCatForId( 'BNA' )
{ 'SAW', '[[Academia Sajona de Ciencias de Leipzig|SAW]]', 3411, 'n', 1 },
end
{ 'KNAW', '[[Real Academia de Artes y Ciencias de los Países Bajos|KNAW]]', 2454, 'n', 1 },
-- { 'KVAB', '[[Real Academia Flamenca de Ciencias y Artes de Bélgica|KVAB]]', 3887, 'n', 1 },
{ 'Leopoldina', '[[Deutsche Akademie der Naturforscher Leopoldina|Leopoldina]]', 3413, 'n', 1 },
{ 'CONICET', '[[CONICET]]', 3900, 'n', 1 },
{ 'Grierson', '[[Directorio de científicos argentinos Dra. Grierson|Grierson]]', 3946, 'n', 1 },
{ 'RANM', '[[Real Academia Nacional de Medicina|RANM]]', 3945, 'n', 1 },
-- { 'ANMF', '[[Académie Nationale de Médecine|ANMF]]', 3956, 'n', 1 },


{ 'Léonore', '[[Base Léonore|Léonore]]', 640, 'n', 0 },
local function conicetLink ( id )
{ 'USCongress', '[[Biographical Directory of the United States Congress|US Congress]]', 1157, 'n', 0 },
return '[http://www.conicet.gov.ar/new_scp/detalle.php?id=' .. id .. '&datos_academicos=yes ' .. id .. ']' .. getCatForId( 'CONICET' )
{ 'Auñamendi', '[[Enciclopedia Auñamendi|Auñamendi]]', 3218, 'n', 1 },
end
{ 'GEA', '[[Gran Enciclopedia Aragonesa|GEA]]', 1807, 'n', 1 },
{ 'DBSE', '[[Diccionario biográfico del socialismo español|DBSE]]', 2985, 'url', 1 },
{ 'DBE', '[[Diccionario biográfico español|DBE]]', 4459, 'url', 1 },
{ 'MNCARS', '[[Museo Nacional Centro de Arte Reina Sofía|MNCARS]]', 4439, 'url', 1 },
{ 'MuseoDelPrado', '[[Museo del Prado]]', 5321, 'n', 'Museo del Prado' },


{ 'BPN', '[[Biografisch Portaal|BPN]]', 651, 'n', 1 },
local function GriersonLink ( id )
{ 'HDS', '[[Historical Dictionary of Switzerland|HDS]]', 902, 'n', 0 },
return '[http://www.caicyt-conicet.gov.ar/cientificos/items/show/' .. id .. ' ' .. id .. ']' .. getCatForId( 'Grierson' )
{ 'LIR', '[[Diccionario histórico de Suiza|LIR]]', 886, 'n', 0 },
end
{ 'TLS', '[[Theaterlexikon der Schweiz|TLS]]', 1362, 'n', 0 },


-- { 'ISCO', '[[d:Q1233766|ISCO]]', 952, 'n', 1 },
local function librariesorg( id )
{ 'AAT', '[[Art & Architecture Thesaurus|AAT]]', 1014, 'n', 1 },
return '[https://librarytechnology.org/library/' .. id .. ' ' .. id .. ']' .. getCatForId( 'Libraries.org ' )
{ 'BDCYL', '[[Biblioteca Digital de Castilla y León|BDCYL]]', 3964, 'n', 1 },
end
{ 'BVPB', '[[d:Q18596294|BVPB]]', 4802, 'n', 1 },
{ 'BivaldiAutor', '[[Biblioteca Valenciana Digital|BiValDi]]', 3932, 'n', 'Bivaldi autor' },


{ 'OpenLibrary', '[[Open Library]]', 648, 'n', 'Open Library' },
local function censoguiaarchivo( id )
{ 'GalicianaAutor', '[[Galiciana]]', 3307, 'n', 'Galiciana autor' },
return '[http://censoarchivos.mcu.es/CensoGuia/archivodetail.htm?id=' .. id .. ' ' .. id .. ']' .. getCatForId( 'Censo-Guía ' )
{ 'PARES', '[[PARES]]', 4813, 'n', 1 },
end
{ 'BVMCpersona', '[[Biblioteca Virtual Miguel de Cervantes|BVMC]]', 2799, 'n', 'BVMC persona' },
{ 'Persée', '[[Persée (portal)|Persée]]', 2732, 'n', 1 },
{ 'Dialnet', '[[Dialnet]]', 1607, 'n', 1 },
{ 'SSRN', '[[Social Science Research Network|SSRN]]', 3747, 'n', 'SSRN autor' },
{ 'GutenbergAutor', '[[Proyecto Gutenberg]]', 1938, 'n', 'Proyecto Gutenberg autor' },
{ 'UNZautor', '[[UNZ.org|UNZ]]', 2734, 'n', 'UNZ' },
{ 'SIKART', '[[SIKART]]', 781, 'n', 0 },
{ 'KULTURNAV', '[[KulturNav]]', 1248, 'id', 0 },
{ 'RKDartists', '[[Rijksbureau voor Kunsthistorische Documentatie|RKD]]', 650, 'n', 1 },
{ 'GoogleScholar', '[[Google Académico]]', 1960, 'n', 'Google Académico' },
{ 'RID', '[[ResearcherID]]', 1053, 'n', 1 },


{ 'BVMCobra', '[[Biblioteca Virtual Miguel de Cervantes|BVMC]]', 3976, 'n', 'BVMC obra' },
local function pares ( id )
{ 'NLM', '[[Biblioteca Nacional de Medicina de los Estados Unidos|NLM]]', 1055, 'n', 1 },
return '[http://pares.mcu.es/ParesBusquedas20/catalogo/autoridad/' .. id .. ' ' .. id .. ']' .. getCatForId( 'PARES' )
{ 'Latindex', '[[Latindex]]', 3127, 'n', 1 },
end
{ 'ERIH PLUS', '[[ERIH PLUS]]', 3434, 'n', 1 },
{ 'IPNIpub', '[[Índice Internacional de Nombres de las Plantas|IPNI]]', 2008, 'n', 1 },
{ 'SUDOCcat', '[[Système universitaire de documentation|SUDOC]]', 1025, 'n', 'SUDOC catálogo' },
{ 'ZDB', '[[Zeitschriftendatenbank|ZDB]]', 1042, 'n', 1 },
{ 'NorwegianRegister', '[[Norsk senter for forskningsdata|Norwegian Register]]', 1270, 'n', 'Norwegian Register' },
{ 'PerséeRevista', '[[Persée (portal)|Persée]]', 2733, 'n', 'Persée revista' },
{ 'DialnetRevista', '[[Dialnet]]', 1609, 'n', 'Dialnet revista' },
{ 'Redalyc', '[[Redalyc]]', 3131, 'n', 1 },
{ 'DOAJ', '[[Directory of Open Access Journals|DOAJ]]', 5115, 'n', 1 },
{ 'UNZrevista', '[[UNZ.org|UNZ]]', 2735, 'n', 0 },
{ 'JSTORrevista', '[[JSTOR]]', 1230, 'n', 'JSTOR revista' },
{ 'HathiTrust', '[[HathiTrust]]', 1844, 'n', 1 },
{ 'HemBNE', '[[Hemeroteca Digital de la Biblioteca Nacional de España|Hemeroteca BNE]]', 2768, 'n', 1 },
{ 'BVPH', '[[Biblioteca Virtual de Prensa Histórica|BVPH]]', 2961, 'n', 1 },
{ 'Galicianaobra', '[[Galiciana]]', 3004, 'n', 'Galiciana obra' },


{ 'INE', '[[Instituto Nacional de Estadística (España)|INE]]', 772, ineLink, 1 },
local function bneLink( id )
{ 'TGN', '[[Getty Thesaurus of Geographic Names|TGN]]', 1667, 'n', 1 },
return '[http://datos.bne.es/resource/' .. id .. ' ' .. id .. ']' .. getCatForId( 'BNE' )
{ 'SNCZI-IPE-EMBALSE', '[[Sistema Nacional de Cartografía de Zonas Inundables|SNCZI]]-[[Inventario de Presas y Embalses de España|IPE]]', 4568, 'n', 'SNCZI-IPE embalse' },
end
{ 'SNCZI-IPE-PRESA', '[[Sistema Nacional de Cartografía de Zonas Inundables|SNCZI]]-[[Inventario de Presas y Embalses de España|IPE]]', 4558, 'n', 'SNCZI-IPE presa' },
{ 'NATURA2000', '[[Red Natura 2000|Natura 2000]]', 3425, 'n', 'Natura 2000' },
{ 'WWF', '[[Fondo Mundial para la Naturaleza|WWF]]', 1294, 'n', 1 },


{ 'HCDN', '[[Cámara de Diputados de la Nación Argentina|Estadísticas HCDN]]', 4693, 'n', 1 },
local function bncLink( id )
{ 'HCDNbio', '[[Cámara de Diputados de la Nación Argentina|Biografía HCDN]]', 5225, 'n', 1 },
return '[http://www.bncatalogo.cl/F?func=direct&local_base=red10&doc_number=' .. id .. ' ' .. id .. ']' .. getCatForId( 'BNC' )
-- { 'Legislatura CABA', '[[Legislatura de la Ciudad de Buenos Aires|Legislatura CABA]]', 4667, 'n', 1 },
end
{ 'Asamblea de Madrid', '[[Asamblea de Madrid]]', 4797, 'n', 1 },


{ 'World Heritage Site', '[[Patrimonio de la Humanidad]]', 757, 'n', 'Centro del Patrimonio Mundial' },
local function bnmLink( id )
{ 'CNMLBH', '[[Comisión Nacional de Monumentos, de Lugares y de Bienes Históricos|CNMLBH]]', 4587, 'n', 'cnmlbh' },
return '[http://catalogo.iib.unam.mx/F/-/?func=find-b&find_code=SYS&local_base=BNM10&format=999&request=' .. id .. ' ' .. id .. ']' .. getCatForId( 'BNM' )
{ 'IGESPAR', '[[Instituto de Gestão do Património Arquitectónico e Arqueológico|IGESPAR]]', 1702, 'n', 1 },
end
{ 'SIPA', '[[Sistema de Informação para o Património Arquitectónico|SIPA]]', 1700, 'n', 1 },
{ 'Infopatrimonio', '[[Infopatrimônio]]', 4372, 'n', 'Infopatrimônio' },
{ 'AustriaObjektID', '[[Austria ObjektID]]', 2951, 'n', 'Austria ObjektID' },
{ 'FBBID', '[[Fredede og Bevaringsværdige Bygninger|FBB]]', 2783, 'n', 'FBB' },
{ 'Fornminnesregistret', '[[Fornminnesregistret|FMIS]]', 1260, 'n', 'FMIS' },
{ 'BerlinerKulturdenkmal', 'Berliner Kulturdenkmal', 2424, 'n', 'Berliner Kulturdenkmal' },
{ 'NHLE', '[[National Heritage List for England|NHLE]]', 1216, 'n', 1 },
{ 'NRHP', '[[Registro Nacional de Lugares Históricos|NRHP]]', 649, 'n', 1 },
{ 'KULTURMINNE', '[[Riksantikvaren|Kulturminne]]', 758, 'n', 'Kulturminne' },
{ 'CRHP', '[[Canadian Register of Historic Places|CRHP]]', 477, 'n', 1 },
{ 'MERIMEE', '[[Base Mérimée|Mérimée]]', 380, 'n', 'Mérimée' },
{ 'CADW', '[[Cadw]]', 1459, 'n', 'Cadw' },
{ 'Památkový Katalog', '[[Památkový katalog]]', 762, 'n', 'Památkový katalog' },
{ 'PatrimonioIran', 'Patrimonio Nacional de Irán', 1369, 'n', 'Patrimonio Nacional de Irán' },
{ 'BIC', '[[Bien de Interés Cultural (España)|BIC]]', 808, 'n', 1 },
{ 'BCIN', '[[Bien Cultural de Interés Nacional|BCIN]]', 1586, 'n', 1 },
{ 'IPAC', '[[Inventario del Patrimonio Arquitectónico de Cataluña|IPAC]]', 1600, 'n', 1 },
{ 'IGPCV', '[[Inventario General del Patrimonio Cultural Valenciano|IGPCV]]', 2473, 'n', 1 },
{ 'BDI-IAPH', '[[Instituto Andaluz del Patrimonio Histórico|IAPH]]', 3318, 'n', 1 },
-- { 'SIPCA', '[[SIPCA]]', 3580, 'n', 1 },
{ 'PWJCYL', '[[Junta de Castilla y León|Patrimonio Web JCyL]]', 3177, 'n', 'Patrimonio Web JCyL' },
{ 'DocomomoIberico', '[[Fundación Docomomo Ibérico|Docomomo Ibérico]]', 3758, 'n', 'Docomomo Ibérico' },
{ 'COAMinmueble', '[[Colegio Oficial de Arquitectos de Madrid|COAM]]', 2917, 'n', 'COAM inmueble' },
{ 'HispaniaNostra', '[[Lista roja de patrimonio en peligro|Lista Roja Hispania Nostra]]', 4868, 'url', 'Lista Roja Hispania Nostra' },
{ 'COAMpersona', '[[Colegio Oficial de Arquitectos de Madrid|COAM]]', 4488, 'n', 'COAM persona' },
{ 'DOI', '[[Identificador de objeto digital|DOI]]', 356, 'n', 1 },
{ 'Handle', '[[Sistema Handle|Handle]]', 1184, 'url', 1 },
{ 'Europeana', '[[Europeana]]', 727, 'url', 1 },
}
--In this order: alternate name, name of parameter from databases table
conf.aliases = {
{ 'Wd', 'Wikidata' },
{ 'PND', 'GND' },
}


local function openlibrary ( id )
local function getCatForId( parameter, category )
local title = mw.title.getCurrentTitle()
return '[https://openlibrary.org/works/' .. id .. ' ' .. id .. ']' .. getCatForId( 'Open Library' )
local namespace = title.namespace
end
if category == 0 then

return ''
local function bvmcpersona ( id )
elseif category == 1 then
return '[http://data.cervantesvirtual.com/person/' .. id .. ' ' .. id .. ']' .. getCatForId( 'BVMC persona' )
category = parameter
end
end

if namespace == 0 then
local function bvpb ( id )
return '[[Categoría:Wikipedia:Artículos con identificadores ' .. category .. ']]\n'
return '[http://bvpb.mcu.es/es/consulta_aut/registro.cmd?id=' .. id .. ' ' .. id .. ']' .. getCatForId( 'BVPB' )
elseif namespace == 2 and not title.isSubpage then
end
return '[[Categoría:Wikipedia:Páginas de usuario con identificadores ' .. category .. ']]\n'

else
local function bdcyl ( id )
return '[[Categoría:Wikipedia:Páginas misceláneas con identificadores ' .. category .. ']]\n'
return '[http://bibliotecadigital.jcyl.es/es/consulta_aut/registro.cmd?id=' .. id .. ' ' .. id .. ']' .. getCatForId( 'BDCYL' )
end
end

local function galicianaautor ( id )
return '[http://biblioteca.galiciana.gal/es/consulta_aut/registro.cmd?id=' .. id .. ' ' .. id .. ']' .. getCatForId( 'Galiciana autor' )
end

local function bivaldiAutor ( id )
return '[http://bivaldi.gva.es/en/consulta_aut/registro.cmd?id=' .. id .. ' ' .. id .. ']' .. getCatForId( 'Bivaldi autor' )
end

local function gutenbergAutor ( id )
return '[http://www.gutenberg.org/ebooks/author/' .. id .. ' ' .. id .. ']' .. getCatForId( 'Proyecto Gutenberg autor' )
end

local function canticLink( id )
return '[http://cantic.bnc.cat/registres/CUCId/' .. id .. ' ' .. id .. ']' .. getCatForId( 'CANTIC' )
end

local function uscongressLink( id )
return '[http://bioguide.congress.gov/scripts/biodisplay.pl?index=' .. id .. ' ' .. id .. ']'
end

local function UBautoridad ( id )
return '[http://www.bib.ub.edu/fileadmin/autoritats/permanent/' .. id .. ' ' .. id .. ']' .. getCatForId( 'UB' )
end

local function ipniAuthor( id )
return '[http://www.ipni.org/ipni/idAuthorSearch.do?id=' .. id .. ' ' .. id .. ']' .. getCatForId( 'IPNI' )
end

local function autoresuy( id )
return '[http://autores.uy/autor/' .. id .. ' ' .. id .. ']' .. getCatForId( 'autores.uy' )
end

local function royalsociety( id )
return '[https://royalsociety.org/people/' .. id .. ' url ]' .. getCatForId( 'Royal Society' )
end

local function hawmiembro( id )
return '[http://www.haw.uni-heidelberg.de/akademie/member.en.html?' .. id .. ' ' .. id .. ']' .. getCatForId( 'HAW' )
end

local function sawmiembro( id )
return '[https://www.saw-leipzig.de/de/mitglieder/' .. id .. ' ' .. id .. ']' .. getCatForId( 'SAW' )
end

local function knawmiembro( id )
return '[http://www.dwc.knaw.nl/biografie/pmknaw/?pagetype=authorDetail&aId=' .. id .. ' ' .. id .. ']' .. getCatForId( 'KNAW' )
end

local function kvabmiembro( id )
return id .. getCatForId( 'KVAB' )
end

local function narapersonLink( id )
return '[https://research.archives.gov/person/' .. id .. ' ' .. id .. ']'
end

local function naraorganizationLink( id )
return '[https://research.archives.gov/organization/' .. id .. ' ' .. id .. ']'
end

local function mgpLink( id )
-- TODO Implement some sanity checking regex
return '[http://www.genealogy.ams.org/id.php?id=' .. id .. ' ' .. id .. ']'
end

local function rslLink( id )
-- TODO Implement some sanity checking regex
return '[http://aleph.rsl.ru/F?func=find-b&find_code=SYS&adjacent=Y&local_base=RSL11&request=' .. id .. '&CON_LNG=ENG ' .. id .. ']'
end

local function leonoreLink( id )
-- Identifiants allant de LH/1/1 à LH/2794/54 (légionnaires)
-- Identifiants allant de C/0/1 à C/0/84 (84 légionnaires célèbres)
-- Identifiants allant de 19800035/1/1 à 19800035/385/51670 (légionnaires décédés entre 1954 et 1977, et quelques dossiers de légionnaires décédés avant 1954)
if not string.match( id, '^LH/%d%d?%d?%d?/%d%d?%d?$' ) and
not string.match( id, '^C/0/%d%d?$' ) and
not string.match( id, '^19800035/%d%d?%d?%d?/%d%d?%d?%d?%d?$' ) then
return false
end
return '[//www.culture.gouv.fr/public/mistral/leonore_fr?ACTION=CHERCHER&FIELD_1=COTE&VALUE_1=' .. id .. ' ' .. id .. ']'
end

local function sbiLink( id )
if not string.match( id, '^%d+$' ) then
return false
end
return '[http://www.slovenska-biografija.si/oseba/sbi' .. id .. ' ' .. id .. ']'
end

local function sbnLink( id )
if not string.match( id, '^IT\\ICCU\\%d%d%d%d%d%d%d%d%d%d$' ) and not string.match( id, '^IT\\ICCU\\%u%u[%d%u]%u\\%d%d%d%d%d%d$' ) then
return false
end
return '[http://opac.sbn.it/opacsbn/opac/iccu/scheda_authority.jsp?bid=' .. id .. ' ' .. id .. ']' .. getCatForId( 'SBN' )
end

local function nkcLink( id )
return '[http://aleph.nkp.cz/F/?func=find-c&local_base=aut&ccl_term=ica=' .. id .. '&CON_LNG=ENG ' .. id .. ']'
end

local function nclLink( id )
if not string.match( id, '^%d+$' ) then
return false
end
return '[http://aleweb.ncl.edu.tw/F/?func=accref&acc_sequence=' .. id .. '&CON_LNG=ENG ' .. id .. ']'
end

local function ndlLink( id )
return '[http://id.ndl.go.jp/auth/ndlna/' .. id .. ' ' .. id .. ']'
end

local function perseeLink( id )
return '[http://www.persee.fr/author/persee_' .. id .. ' ' .. id .. ']' .. getCatForId( 'Persée' )
end

local function sudocLink( id )
if not string.match( id, '^%d%d%d%d%d%d%d%d[%dxX]$' ) then
return false
end
return '[http://www.idref.fr/' .. id .. ' ' .. id .. ']'
end

local function sudocCat( id )
return '[http://www.sudoc.fr/' .. id .. ' ' .. id .. ']' .. getCatForId( 'SUDOC catálogo' )
end

local function googleScholar ( id )
return '[https://scholar.google.com/citations?user=' .. id .. ' ' .. id .. ']' .. getCatForId( 'Google Académico' )
end

local function boe( id )
return '[http://www.boe.es/buscar/doc.php?id=' .. id .. ' ' .. id .. ']' .. getCatForId( 'BOE ' )
end

local function hlsLink( id )
if not string.match( id, '^%d+$' ) then
return false
end
return '[http://www.hls-dhs-dss.ch/textes/f/F' .. id .. '.php ' .. id .. ']'
end

local function lirLink( id )
if not string.match( id, '^%d+$' ) then
return false
end
return '[http://www.e-lir.ch/e-LIR___Lexicon.' .. id .. '.450.0.html ' .. id .. ']'
end

local function splitLccn( id )
if id:match( '^%l%l?%l?%d%d%d%d%d%d%d%d%d?%d?$' ) then
id = id:gsub( '^(%l+)(%d+)(%d%d%d%d%d%d)$', '%1/%2/%3' )
end
if id:match( '^%l%l?%l?/%d%d%d?%d?/%d+$' ) then
return mw.text.split( id, '/' )
end
return false
end

local function append(str, c, length)
while str:len() < length do
str = c .. str
end
return str
end

local function lccnLink( id )
local parts = splitLccn( id )
if not parts then
return false
end
local lccnType = parts[1] ~= 'sh' and 'names' or 'subjects'
id = parts[1] .. parts[2] .. append( parts[3], '0', 6 )
return '[http://id.loc.gov/authorities/' .. lccnType .. '/' .. id .. ' ' .. id .. ']' .. getCatForId( 'LCCN' )
end

--Returns the ISNI check digit isni must be a string where the 15 first elements are digits
local function getIsniCheckDigit( isni )
local total = 0
for i = 1, 15 do
local digit = isni:byte( i ) - 48 --Get integer value
total = (total + digit) * 2
end
local remainder = total % 11
local result = (12 - remainder) % 11
if result == 10 then
return "X"
end
return tostring( result )
end

--Validate ISNI (and ORCID) and retuns it as a 16 characters string or returns false if it's invalid
--See http://support.orcid.org/knowledgebase/articles/116780-structure-of-the-orcid-identifier
local function validateIsni( id )
id = id:gsub( '[ %-]', '' ):upper()
if not id:match( '^%d%d%d%d%d%d%d%d%d%d%d%d%d%d%d[%dX]$' ) then
return false
end
if getIsniCheckDigit( id ) ~= string.char( id:byte( 16 ) ) then
return false
end
return id
end

local function isniLink( id )
id = validateIsni( id )
if not id then
return false
end
return '[http://isni.org/isni/' .. id .. ' ' .. id:sub( 1, 4 ) .. ' ' .. id:sub( 5, 8 ) .. ' ' .. id:sub( 9, 12 ) .. ' ' .. id:sub( 13, 16 ) .. ']' .. getCatForId( 'ISNI' )
end

local function orcidLink( id )
id = validateIsni( id )
if not id then
return false
end
id = id:sub( 1, 4 ) .. '-' .. id:sub( 5, 8 ) .. '-' .. id:sub( 9, 12 ) .. '-' .. id:sub( 13, 16 )
return '[http://orcid.org/' .. id .. ' ' .. id .. ']' .. getCatForId( 'ORCID' )
end

local function gndLink( id )
return '[http://d-nb.info/gnd/' .. id .. ' ' .. id .. ']' .. getCatForId( 'GND' )
end

local function selibrLink( id )
if not string.match( id, '^%d+$' ) then
return false
end
return '[//libris.kb.se/auth/' .. id .. ' ' .. id .. ']' .. getCatForId( 'SELIBR' )
end

local function bnfLink( id )
--Add cb prefix if it has been removed
if not string.match( id, '^cb.+$' ) then
id = 'cb' .. id
end

return '[http://catalogue.bnf.fr/ark:/12148/' .. id .. ' ' .. id .. '] [http://data.bnf.fr/ark:/12148/' .. id .. ' (data)]' .. getCatForId( 'BNF' )
end

local function bpnLink( id )
if not string.match( id, '^%d+$' ) then
return false
end
return '[http://www.biografischportaal.nl/en/persoon/' .. id .. ' ' .. id .. ']' .. getCatForId( 'BPN' )
end

local function ridLink( id )
return '[http://www.researcherid.com/rid/' .. id .. ' ' .. id .. ']' .. getCatForId( 'RID' )
end

local function bibsysLink( id )
return '[http://ask.bibsys.no/ask/action/result?cmd=&kilde=biblio&cql=bs.autid+%3D+' .. id .. '&feltselect=bs.autid ' .. id .. ']' .. getCatForId( 'BIBSYS' )
end

local function ulanLink( id )
return '[//www.getty.edu/vow/ULANFullDisplay?find=&role=&nation=&subjectid=' .. id .. ' ' .. id .. ']' .. getCatForId( 'ULAN' )
end

local function nlaLink( id )
return '[//nla.gov.au/anbd.aut-an' .. id .. ' ' .. id .. ']' .. getCatForId( 'NLA' )
end

local function rkdartistsLink( id )
return '[https://rkd.nl/en/explore/artists/' .. id .. ' ' .. id .. ']' .. getCatForId( 'RKDartists' )
end

local function UNZauthorLink( id )
return '[http://www.unz.org/Author/' .. id .. ' ' .. id .. ']' .. getCatForId( 'UNZ' )
end

local function aatLink( id )
return '[http://vocab.getty.edu/page/aat/' .. id .. ' ' .. id .. ']' .. getCatForId( 'AAT' )
end

local function snacLink( id )
return '[http://socialarchive.iath.virginia.edu/ark:/99166/' .. id .. ' ' .. id .. ']' .. getCatForId( 'SNAC' )
end

-- ********* Identificadores de miembros de academias, etc *********

local function leopoldina ( id )
return '[http://www.leopoldina.org/de/mitglieder/mitgliederverzeichnis/member/' .. id .. ' ' .. id .. ']' .. getCatForId( 'Leopoldina' )
end

local function ranm ( id )
return '[http://www.ranm.es/academicos/' .. id .. ' ' .. id .. ']' .. getCatForId( 'RANM' )
end

local function anmf ( id )
return '[http://bibliotheque.academie-medecine.fr/membres/membre/?mbreid=' .. id .. ' ' .. id .. ']' .. getCatForId( 'ANMF' )
end

local function isco( id )
return id .. getCatForId( 'ISCO' )
end

-- ********* Patrimonio cultural, monumentos, edificios *********
local function WHSunesco( id )
return '[http://whc.unesco.org/es/list/' .. id .. ' ' .. id .. ']' .. getCatForId( 'Centro del Patrimonio Mundial' )
end

local function cnmlbh( id )
return '[https://monumentos.cultura.gob.ar/inventario/' .. id .. ' ' .. id .. ']' .. getCatForId( 'cnmlbh' )
end

local function igespar( id )
return '[http://www.patrimoniocultural.pt/en/patrimonio/patrimonio-imovel/pesquisa-do-patrimonio/classificado-ou-em-vias-de-classificacao/geral/view/' .. id .. ' ' .. id .. ']' .. getCatForId( 'IGESPAR' )
end

local function sipa( id )
return '[http://www.monumentos.gov.pt/Site/APP_PagesUser/SIPA.aspx?id=' .. id .. ' ' .. id .. ']' .. getCatForId( 'SIPA' )
end

local function infopatrimonioID( id )
return '[http://www.infopatrimonio.org/?p=' .. id .. ' ' .. id .. ']' .. getCatForId( 'Infopatrimônio' )
end

local function austriaobjektID( id )
return '[https://tools.wmflabs.org/denkmalliste/index.php?action=EinzelID&ID=' .. id .. ' ' .. id .. ']' .. getCatForId( 'Austria ObjektID' )
end

local function fbbid( id )
return '[https://www.kulturarv.dk/fbb/sagvis.pub?sag=' .. id .. ' ' .. id .. ']' .. getCatForId( 'FBB' )
end

local function fmisid( id )
return '[http://kulturarvsdata.se/' .. id .. ' ' .. id .. ']' .. getCatForId( 'FMIS' )
end

local function berlinerkulturdenkmal( id )
return '[http://www.stadtentwicklung.berlin.de/denkmal/liste_karte_datenbank/de/denkmaldatenbank/daobj.php?obj_dok_nr=' .. id .. ' ' .. id .. ']' .. getCatForId( 'Berliner Kulturdenkmal' )
end

local function nhle( id )
return '[https://www.historicengland.org.uk/listing/the-list/list-entry/' .. id .. ' ' .. id .. ']' .. getCatForId( 'NHLE' )
end

local function nrhp( id )
return '[http://focus.nps.gov/AssetDetail/NRIS/' .. id .. ' ' .. id .. ']' .. getCatForId( 'NRHP' )
end

local function kulturminne( id )
return '[http://www.kulturminnesok.no/kulturminnesok/kulturminne/?LOK_ID=' .. id .. ' ' .. id .. ']' .. getCatForId( 'Kulturminne' )
end

local function crhp( id )
return '[http://www.historicplaces.ca/en/rep-reg/place-lieu.aspx?id=' .. id .. ' ' .. id .. ']' .. getCatForId( 'CRHP' )
end

local function merimee( id )
return '[http://www.culture.gouv.fr/public/mistral/merimee_fr?ACTION=CHERCHER&FIELD_1=REF&VALUE_1=' .. id .. ' ' .. id .. ']' .. getCatForId( 'Mérimée' )
end

local function pamatkovykatalog( id )
return '[http://pamatkovykatalog.cz/?mode=parametric&indexId=' .. id .. '&presenter=ElementsResults ' .. id .. ']' .. getCatForId( 'Památkový katalog' )
end

local function patrimonioiranID( id )
return id .. getCatForId( 'Patrimonio Nacional de Irán' )
end

local function bic( id )
return id .. getCatForId( 'BIC' )
end

local function bcin( id )
return id .. getCatForId( 'BCIN' )
end

local function igpcv( id )
return id .. getCatForId( 'IGPCV' )
end

local function ipac( id )
return '[http://invarquit.cultura.gencat.cat/Cerca/Fitxa?index=0&consulta=&codi=' .. id .. ' ' .. id .. ']' .. getCatForId( 'IPAC' )
end

local function bdiIAPH( id )
return '[http://www.iaph.es/patrimonio-inmueble-andalucia/resumen.do?id=' .. id .. ' ' .. id .. ']' .. getCatForId( 'BDI-IAPH' )
end

local function sipca( id )
return '[http://www.sipca.es/censo/' .. id .. '/.html ' .. id .. ']' .. getCatForId( 'SIPCA' )
end

local function idPWJCYL( id )
return '[http://servicios.jcyl.es/pweb/datos.do?numero=' .. id .. '&tipo=inmueble&ruta= ' .. id .. ']' .. getCatForId( 'Patrimonio Web JCyL' )
end

local function COAMinmueble( id )
return '[http://212.145.146.10/biblioteca/fondos/ingra2014/index.htm#inm.' .. id .. ' ' .. id .. ']' .. getCatForId( 'COAM inmueble' )
end

local function COAMpersona( id )
return '[http://212.145.146.10/biblioteca/fondos/ingra2014/index.htm#aut.' .. id .. ' ' .. id .. ']' .. getCatForId( 'COAM persona' )
end

local function docomomoiberico( id )
return id .. getCatForId( 'Docomomo Ibérico' )
end

local function hispanianostra ( id )
return '[http://listarojapatrimonio.org/ficha/' .. id .. ' url ]' .. getCatForId( 'Lista Roja Hispania Nostra' )
end

local function cadwID( id )
return '[http://cadwpublic-api.azurewebsites.net/reports/listedbuilding/FullReport?lang=en&id=' .. id .. ' ' .. id .. ']' .. getCatForId( 'Cadw' )
end

-- ********* Identificadores geográficos, estadísticos, etc *********
local function codigoine( id )
return id .. getCatForId( 'INE' )
end

local function tgnlink( id )
return '[http://vocab.getty.edu/page/tgn/' .. id .. ' ' .. id .. ']' .. getCatForId( 'TGN' )
end

local function sncziipeembalse( id )
return '[http://sig.mapama.es/93/ClienteWS/snczi/default.aspx?nombre=EMBALSE&claves=REF_CEH&valores=' .. id .. ' ' .. id .. ']' .. getCatForId( 'SNCZI-IPE embalse' )
end

local function sncziipepresa( id )
return '[http://sig.mapama.es/93/ClienteWS/snczi/default.aspx?nombre=PRESA&claves=DGAGUA.PRESAS.CODPRESA&valores=' .. id .. ' ' .. id .. ']' .. getCatForId( 'SNCZI-IPE presa' )
end

local function natura2000 ( id )
return '[http://natura2000.eea.europa.eu/Natura2000/SDF.aspx?site=' .. id .. ' ' .. id .. ']' .. getCatForId( 'Natura 2000' )
end

local function wwf ( id )
return '[http://www.worldwildlife.org/ecoregions/' .. id .. ' ' .. id .. ']' .. getCatForId( 'WWF' )
end

-- ********* Política y gobierno *********

local function hcdnlink( id )
return '[https://votaciones.hcdn.gob.ar/diputado/perfil/' .. id .. ' ' .. id .. ']' .. getCatForId( 'HCDN' )
end

local function hcdnbiolink( id )
return '[https://apym.hcdn.gob.ar/biografias/' .. id .. ' ' .. id .. ']' .. getCatForId( 'HCDNbio' )
end

local function legcaba( id )
return '[https://www.legislatura.gov.ar/legislador.php?id=' .. id .. ' ' .. id .. ']' .. getCatForId( 'Legislatura CABA' )
end

local function asambleamadrid ( id )
return '[http://www.asambleamadrid.es/ES/QueEsLaAsamblea/ComposiciondelaAsamblea/Distribuciondeescanos/Paginas/curriculum.aspx?IdDip=' .. id .. ' ' .. id .. ']' .. getCatForId( 'Asamblea de Madrid' )
end

-- ********* Identificadores de enciclopedias online *********
local function aunamendiLink ( id )
return '[http://aunamendi.eusko-ikaskuntza.eus/artikuluak/artikulua.php?id=es&ar=' .. id .. ' ' .. id .. ']' .. getCatForId( 'Auñamendi' )
end

local function geaLink ( id )
return '[http://www.enciclopedia-aragonesa.com/voz.asp?voz_id=' .. id .. ' ' .. id .. ']' .. getCatForId( 'GEA' )
end

local function dbse ( id )
return '[http://www.fpabloiglesias.es/archivo-y-biblioteca/diccionario-biografico/biografias/' .. id .. ' url ]' .. getCatForId( 'DBSE' )
end

local function diccionariobiograficoespanol ( id )
return '[http://dbe.rah.es/biografias/' .. id .. ' url ]' .. getCatForId( 'DBE' )
end

local function mncars ( id )
return '[http://www.museoreinasofia.es/coleccion/autor/' .. id .. ' url ]' .. getCatForId( 'MNCARS' )
end

local function museodelprado ( id )
return '[https://www.museodelprado.es/coleccion/artista/wd/' .. id .. ' ' .. id .. ']' .. getCatForId( 'Museo del Prado' )
end

-- ********* Identificadores de revistas, obra, edición *********
local function NLM ( id )
return '[http://locatorplus.gov/cgi-bin/Pwebrecon.cgi?DB=local&v1=1&ti=1,1&Search_Arg=' .. id .. '&Search_Code=0359&CNT=25&SID=1 ' .. id .. ']' .. getCatForId( 'NLM' )
end

local function bvmcobra ( id )
return '[http://data.cervantesvirtual.com/work/' .. id .. ' ' .. id .. ']' .. getCatForId( 'BVMC obra' )
end

local function latindexfolio ( id )
return '[http://www.latindex.org/latindex/ficha?folio=' .. id .. ' ' .. id .. ']' .. getCatForId( 'Latindex' )
end

local function erihplus ( id )
return '[https://dbh.nsd.uib.no/publiseringskanaler/erihplus/periodical/info.action?id=' .. id .. ' ' .. id .. ']' .. getCatForId( 'ERIH PLUS' )
end

local function ipniPublication( id )
return '[http://www.ipni.org/ipni/idPublicationSearch.do?id=' .. id .. ' ' .. id .. ']' .. getCatForId( 'IPNIpub' )
end

local function zdb( id )
return '[http://ld.zdb-services.de/resource/' .. id .. ' ' .. id .. ']' .. getCatForId( 'ZDB' )
end

local function NorwegianRegisterJournal( id )
return '[https://dbh.nsd.uib.no/publiseringskanaler/KanalTidsskriftInfo?id=' .. id .. ' ' .. id .. ']' .. getCatForId( 'Norwegian Register' )
end

local function hathitrustLink ( id )
return '[https://catalog.hathitrust.org/Record/' .. id .. ' ' .. id .. ']' .. getCatForId( 'HathiTrust' )
end

local function jstorRevista( id )
return id .. getCatForId( 'JSTOR revista' )
end

local function HemBNE( id )
return '[http://hemerotecadigital.bne.es/details.vm?q=id:' .. id .. ' ' .. id .. ']' .. getCatForId( 'HemBNE' )
end

local function bvph ( id )
return '[http://prensahistorica.mcu.es/consulta/registro.cmd?id=' .. id .. ' ' .. id .. ']' .. getCatForId( 'BVPH' )
end

local function galicianaobra ( id )
return '[http://www.galiciana.bibliotecadegalicia.xunta.es/consulta/registro.cmd?id=' .. id .. ' ' .. id .. ']' .. getCatForId( 'Galiciana obra' )
end

local function dialnetRevista ( id )
return '[http://dialnet.unirioja.es/servlet/revista?codigo=' .. id .. ' ' .. id .. ']' .. getCatForId( 'Dialnet revista' )
end

local function redalyc ( id )
return '[http://www.redalyc.org/revista.oa?id=' .. id .. ' ' .. id .. ']' .. getCatForId( 'Redalyc' )
end

local function doaj ( id )
return '[https://doaj.org/toc/' .. id .. ' ' .. id .. ']' .. getCatForId( 'DOAJ' )
end

local function issn ( id )
return '[https://www.worldcat.org/issn/' .. id .. ' ' .. id .. ']' .. getCatForId( 'ISSN' )
end

local function doi ( id )
return '[https://dx.doi.org/' .. id .. ' ' .. id .. ']' .. getCatForId( 'DOI' )
end

local function handle ( id )
return '[http://hdl.handle.net/' .. id .. ' ' .. id .. ']' .. getCatForId( 'Handle' )
end

local function europeana ( id )
return '[http://data.europeana.eu/item/' .. id .. ' url ]' .. getCatForId( 'Europeana' )
end

local function perseeRevista( id )
return '[http://www.persee.fr/collection/' .. id .. ' ' .. id .. ']' .. getCatForId( 'Persée revista' )
end

local function UNZjournalLink( id )
return '[http://www.unz.org/Pub/' .. id .. ' ' .. id .. ']'
end
end


local function getIdsFromWikidata( item, property )
local function getIdsFromWikidata( item, property )
local ids = {}
local ids = {}
if not item.claims[property] then
if not item.claims[property] then
return ids
return ids
end
end
for _, statement in pairs( item:getBestStatements( property )) do
for _, statement in pairs( item:getBestStatements( property )) do
if statement.mainsnak.datavalue then
if statement.mainsnak.datavalue then
table.insert( ids, statement.mainsnak.datavalue.value )
table.insert( ids, statement.mainsnak.datavalue.value )
end
end
end
end
return ids
return ids
end
end


local function matchesWikidataRequirements( item, reqs )
local function getLink( property, val, mask )
local link = ''
for _, group in pairs( reqs ) do
if mw.ustring.find( val, '//' ) then
local property = 'p' .. group[1]
link = val
local qid = group[2]
else
if item.claims[property] ~= nil then
if type(property) == 'number' then
for _, statement in pairs ( item.claims[property] ) do
local entityObject = mw.wikibase.getEntityObject('P'..property)
if statement.mainsnak.datavalue ~= nil then
local dataType = entityObject.datatype
if statement.mainsnak.datavalue.value['numeric-id'] == qid then
if dataType == 'external-id' then
return true
local allStatements = entityObject:getAllStatements('P1630')
end
if allStatements then
end
for pos = 1, #allStatements, 1
end
do
end
local q = allStatements[pos].qualifiers
end
if q and q.P407 and q.P407[1].datavalue.value.id == 'Q1321' then
return false
link = allStatements[pos].mainsnak.datavalue.value
end
end
end
if link == '' then
local formatterURL = entityObject:getBestStatements('P1630')[1]
if formatterURL then
link = formatterURL.mainsnak.datavalue.value
else
local formatterURL = entityObject:getBestStatements('P3303')[1]
if formatterURL then link = formatterURL.mainsnak.datavalue.value end
end
end
elseif dataType == 'url' then
local subjectItem = entityObject:getBestStatements('P1629')[1]
if subjectItem then
local officialWebsite = mw.wikibase.getEntityObject(subjectItem.mainsnak.datavalue.value.id):getBestStatements('P856')[1]
if officialWebsite then
link = officialWebsite.mainsnak.datavalue.value
end
end
elseif dataType == 'string' then
local formatterURL = entityObject:getBestStatements('P1630')[1]
if formatterURL then
link = formatterURL.mainsnak.datavalue.value
else
local formatterURL = entityObject:getBestStatements('P3303')[1]
if formatterURL then
link = formatterURL.mainsnak.datavalue.value
else
local subjectItem = entityObject:getBestStatements('P1629')[1]
if subjectItem then
local officialWebsite = mw.wikibase.getEntityObject(subjectItem.mainsnak.datavalue.value.id):getBestStatements('P856')[1]
if officialWebsite then
link = officialWebsite.mainsnak.datavalue.value
end
end
end
end
end
elseif type(property) == 'string' then
link = property
end
end
link = mw.ustring.gsub(link, '^[Hh][Tt][Tt][Pp]([Ss]?)&#58;//', 'http%1://') -- fix wikidata URL
if type(mask) == 'function' then
return mask( val, link, property )
end
link = mw.ustring.gsub(link, '$1', mw.ustring.gsub( val, ' ', '%%%%20' ) or val )
if mw.ustring.find( link, '//' ) then
if type(mask) == 'string' then
if mask == 'y' then
return '['..link..' ID]'
elseif mask == 'n' then
return '['..link..' '..val..']'
end
return '['..link..' '..mask..']'
end
elseif link == '' then
return val
else
return '[['..link..'|'..val..']]'
end
end
end


local function createRow( id, label, rawValue, link, withUid )
local function createRow( id, label, rawValue, link, withUid )
if link then
if link then
if label and label ~= '' then label = label .. ': ' end
if withUid then
if withUid then
return '* ' .. label .. ' <span class="uid">' .. link .. '</span>\n'
return '* ' .. label .. '<span class="uid">' .. link .. '</span>\n'
else
else
return '* ' .. label .. ' ' .. link .. '\n'
end
return '* ' .. label .. link .. '\n'
end
else
else
return '* <span class="error">El ' .. id .. ' id ' .. rawValue .. ' no es válido</span>[[Category:Wikipedia articles with faulty authority control identifiers (' .. id .. ')]]\n'
return '* <span class="error">El ' .. id .. ' id ' .. rawValue .. ' no es válido</span>[[Categoría:Wikipedia:Páginas con problemas en el control de autoridades]]\n'
end
end
end
end


local function copyTable(inTable)
--In this order: name of the parameter, label, propertyId in Wikidata, formatting function
if type(inTable) ~= 'table' then return inTable end
local conf = {
local outTable = setmetatable({}, getmetatable(inTable))
{ 'ISSN', '[[ISSN]]', 236, issn },
for key, value in pairs (inTable) do outTable[copyTable(key)] = copyTable(value) end
{ 'VIAF', '[[Virtual International Authority File|VIAF]]', 214, viafLink },
return outTable
{ 'ISNI', '[[International Standard Name Identifier|ISNI]]', 213, isniLink },
end
{ 'BCN', '[[Biblioteca del Congreso de la Nación Argentina|BCN]]', 2879, bcnLink },
{ 'BNA', '[[Biblioteca Nacional de la República Argentina|BNA]]', 3788, bnaLink },
{ 'BNE', '[[Biblioteca Nacional de España|BNE]]', 950, bneLink },
{ 'BNF', '[[Bibliothèque nationale de France|BNF]]', 268, bnfLink },
{ 'BNM', '[[Biblioteca Nacional de México|BNM]]', 4440, bnmLink },
{ 'BNC', '[[Biblioteca Nacional de Chile|BNC]]', 1890, bncLink },
{ 'CANTIC', '[[Biblioteca de Cataluña|CANTIC]]', 1273, canticLink },
{ 'GND', '[[Integrated Authority File|GND]]', 227, gndLink },
{ 'LCCN', '[[Library of Congress Control Number|LCCN]]', 244, lccnLink },
{ 'NCL', '[[National Central Library|NCL]]', 1048, nclLink },
{ 'NDL', '[[National Diet Library|NDL]]', 349, ndlLink },
{ 'NKC', '[[National Library of the Czech Republic|NKC]]', 691, nkcLink },
{ 'NLA', '[[National Library of Australia|NLA]]', 409, nlaLink },
{ 'RLS', '[[Biblioteca del Estado Ruso|BER]]', 947, rslLink },


local function splitLccn( id )
{ 'CINII', '[[CiNii]]', 271, ciniiLink },
if id:match( '^%l%l?%l?%d%d%d%d%d%d%d%d%d?%d?$' ) then
{ 'NARA-organization', '[[National Archives and Records Administration|NARA]]', 1223, naraorganizationLink },
id = id:gsub( '^(%l+)(%d+)(%d%d%d%d%d%d)$', '%1/%2/%3' )
{ 'LCCNLCOC', '[[Library of Congress Control Number|LCCN]]', 1144, lccnlcoc },
end
{ 'SNAC', '[[d:Q29861311|SNAC]]', 3430, snacLink },
if id:match( '^%l%l?%l?/%d%d%d?%d?/%d+$' ) then
return mw.text.split( id, '/' )
end
return false
end


local p = {}
{ 'SUDOC', '[[Système universitaire de documentation|SUDOC]]', 269, sudocLink },
{ 'ULAN', '[[Union List of Artist Names|ULAN]]', 245, ulanLink },
{ 'ORCID', '[[ORCID]]', 496, orcidLink },
{ 'SELIBR', '[[LIBRIS|SELIBR]]', 906, selibrLink },
{ 'BIBSYS', '[[BIBSYS]]', 1015, bibsysLink },
{ 'UB', '[[Universidad de Barcelona|UB]]', 1580, UBautoridad },
{ 'IPNIaut', '[[Índice Internacional de Nombres de las Plantas|IPNI]]', 586, ipniAuthor },
{ 'MGP', '[[Mathematics Genealogy Project|MGP]]', 549, mgpLink },
{ 'autores.uy', '[[autores.uy]]', 2558, autoresuy },
{ 'Slovenska biografija', '[[Slovenska biografija]]', 1254, sbiLink },
{ 'SBN', '[[Istituto Centrale per il Catalogo Unico|ICCU]]', 396, sbnLink },


function p.authorityControl( frame )
{ 'NARA-person', '[[National Archives and Records Administration|NARA]]', 1222, narapersonLink },
local parentArgs = copyTable(frame:getParent().args)
{ 'CensoGuia', '[[Censo-Guía de Archivos de España e Iberoamérica]]', 3998, censoguiaarchivo },
local stringArgs = false
{ 'Libraries.org', '[[Libraries.org]]', 4848, librariesorg },
local fromForCount, firstRow, rowCount = 1, 0, 0
--Cleanup args
{ 'BOE', '[[Boletín Oficial del Estado|BOE]]', 4256, boe },
for k, v in pairs( frame:getParent().args ) do
if type(k) == 'string' then
--make args case insensitive
local lowerk = mw.ustring.lower(k)
if not parentArgs[lowerk] or parentArgs[lowerk] == '' then
parentArgs[lowerk] = v
parentArgs[k] = nil
end
--remap abc to abc1
if not mw.ustring.find(lowerk, '%d$') then --if no number at end of param
if not parentArgs[lowerk..'1'] or parentArgs[lowerk..'1'] == '' then
parentArgs[lowerk..'1'] = v
parentArgs[lowerk] = nil
end
end
if v and v ~= '' then
--find highest from param
if mw.ustring.sub(lowerk,1,4) == 'from' then
local fromNumber = tonumber(mw.ustring.sub(lowerk,5,-1))
if fromNumber and fromNumber >= fromForCount then fromForCount = fromNumber end
elseif mw.ustring.sub(lowerk,1,3) == 'for' then
local forNumber = tonumber(mw.ustring.sub(lowerk,4,-1))
if forNumber and forNumber >= fromForCount then fromForCount = forNumber end
elseif mw.ustring.lower(v) ~= 'no' and lowerk ~= 'for' then
stringArgs = true
end
end
end
end


--Setup navbox
{ 'RoyalSociety', '[[Royal Society]]', 2070, royalsociety },
local navboxParams = {
{ 'HAW', '[[Academia de Ciencias y Humanidades de Heidelberg|HAW]]', 2273, hawmiembro },
name = 'Control de autoridades',
{ 'SAW', '[[Academia Sajona de Ciencias de Leipzig|SAW]]', 3411, sawmiembro },
bodyclass = 'hlist',
{ 'KNAW', '[[Real Academia de Artes y Ciencias de los Países Bajos|KNAW]]', 2454, knawmiembro },
groupstyle = 'width: 12%; text-align:center;',
{ 'KVAB', '[[Real Academia Flamenca de Ciencias y Artes de Bélgica|KVAB]]', 3887, kvabmiembro },
}
{ 'Leopoldina', '[[Deutsche Akademie der Naturforscher Leopoldina|Leopoldina]]', 3413, leopoldina },
local itemCount = 0
{ 'CONICET', '[[CONICET]]', 3900, conicetLink },
for f = 1,fromForCount,1
{ 'Grierson', '[[Directorio de científicos argentinos Dra. Grierson|Grierson]]', 3946, GriersonLink },
do
{ 'RANM', '[[Real Academia Nacional de Medicina|RANM]]', 3945, ranm },
local elements, title = {}, {}
{ 'ANMF', '[[Académie Nationale de Médecine|ANMF]]', 3956, anmf },
--cleanup parameters
if parentArgs['from'..f] == '' then parentArgs['from'..f] = nil end
{ 'Léonore', '[[Base Léonore|Léonore]]', 640, leonoreLink },
if parentArgs['for'..f] == '' then parentArgs['for'..f] = nil end
{ 'USCongress', '[[Biographical Directory of the United States Congress|US Congress]]', 1157, uscongressLink },
--remap aliases
{ 'Auñamendi', '[[Enciclopedia Auñamendi|Auñamendi]]', 3218, aunamendiLink },
for _, a in pairs( conf.aliases ) do
{ 'GEA', '[[Gran Enciclopedia Aragonesa|GEA]]', 1807, geaLink },
local alias, name = mw.ustring.lower(a[1]), mw.ustring.lower(a[2])
{ 'DBSE', '[[Diccionario biográfico del socialismo español|DBSE]]', 2985, dbse },
if parentArgs[alias..f] and not parentArgs[name..f] then
{ 'DBE', '[[Diccionario biográfico español|DBE]]', 4459, diccionariobiograficoespanol },
parentArgs[name..f] = parentArgs[alias..f]
{ 'MNCARS', '[[Museo Nacional Centro de Arte Reina Sofía|MNCARS]]', 4439, mncars },
parentArgs[alias..f] = nil
{ 'MuseoDelPrado', '[[Museo del Prado]]', 5321, museodelprado },
end
end
{ 'BPN', '[[Biografisch Portaal|BPN]]', 651, bpnLink },
{ 'HDS', '[[Historical Dictionary of Switzerland|HDS]]', 902, hlsLink },
{ 'LIR', '[[Diccionario histórico de Suiza|LIR]]', 886, lirLink },
{ 'TLS', '[[Theaterlexikon der Schweiz|TLS]]', 1362, tlsLink },


--Fetch Wikidata item
{ 'ISCO', '[[d:Q1233766|ISCO]]', 952, isco },
local item = mw.wikibase.getEntity(parentArgs['from'..f])
{ 'AAT', '[[Art & Architecture Thesaurus|AAT]]', 1014, aatLink },
local label = item and item:getLabel()
{ 'BDCYL', '[[Biblioteca Digital de Castilla y León|BDCYL]]', 3964, bdcyl },
if label and label ~= '' then
{ 'BVPB', '[[d:Q18596294|BVPB]]', 4802, bvpb },
title = mw.title.new(label)
{ 'BivaldiAutor', '[[Biblioteca Valenciana Digital|BiValDi]]', 3932, bivaldiAutor },
if not title then title = mw.title.getCurrentTitle() end
else
{ 'OpenLibrary', '[[Open Library]]', 648, openlibrary },
title = mw.title.getCurrentTitle()
{ 'GalicianaAutor', '[[Galiciana]]', 3307, galicianaautor },
end
{ 'PARES', '[[PARES]]', 4813, pares },
{ 'BVMCpersona', '[[Biblioteca Virtual Miguel de Cervantes|BVMC]]', 2799, bvmcpersona },
{ 'Persée', '[[Persée (portal)|Persée]]', 2732, perseeLink },
{ 'Dialnet', '[[Dialnet]]', 1607, dialnetLink },
{ 'SSRN', '[[Social Science Research Network|SSRN]]', 3747, SSRNautor },
{ 'GutenbergAutor', '[[Proyecto Gutenberg]]', 1938, gutenbergAutor },
{ 'UNZautor', '[[UNZ.org|UNZ]]', 2734, UNZauthorLink },
{ 'SIKART', '[[SIKART]]', 781, sikartLink },
{ 'KULTURNAV', '[[KulturNav]]', 1248, kulturnavLink },
{ 'RKDartists', '[[Rijksbureau voor Kunsthistorische Documentatie|RKD]]', 650, rkdartistsLink },
{ 'GoogleScholar', '[[Google Académico]]', 1960, googleScholar },
{ 'RID', '[[ResearcherID]]', 1053, ridLink },
{ 'BVMCobra', '[[Biblioteca Virtual Miguel de Cervantes|BVMC]]', 3976, bvmcobra },
{ 'NLM', '[[Biblioteca Nacional de Medicina de los Estados Unidos|NLM]]', 1055, NLM },
{ 'Latindex', '[[Latindex]]', 3127, latindexfolio },
{ 'ERIH PLUS', '[[ERIH PLUS]]', 3434, erihplus },
{ 'IPNIpub', '[[Índice Internacional de Nombres de las Plantas|IPNI]]', 2008, ipniPublication },
{ 'SUDOCcat', '[[Système universitaire de documentation|SUDOC]]', 1025, sudocCat},
{ 'ZDB', '[[Zeitschriftendatenbank|ZDB]]', 1042, zdb },
{ 'NorwegianRegister', '[[Norsk senter for forskningsdata|Norwegian Register]]', 1270, NorwegianRegisterJournal },
{ 'PerséeRevista', '[[Persée (portal)|Persée]]', 2733, perseeRevista },
{ 'DialnetRevista', '[[Dialnet]]', 1609, dialnetRevista },
{ 'Redalyc', '[[Redalyc]]', 3131, redalyc },
{ 'DOAJ', '[[Directory of Open Access Journals|DOAJ]]', 5115, doaj },
{ 'UNZrevista', '[[UNZ.org|UNZ]]', 2735, UNZjournalLink },
{ 'JSTORrevista', '[[JSTOR]]', 1230, jstorRevista },
{ 'HathiTrust', '[[HathiTrust]]', 1844, hathitrustLink },
{ 'HemBNE', '[[Hemeroteca Digital de la Biblioteca Nacional de España|Hemeroteca BNE]]', 2768, HemBNE },
{ 'BVPH', '[[Biblioteca Virtual de Prensa Histórica|BVPH]]', 2961, bvph },
{ 'Galicianaobra', '[[Galiciana]]', 3004, galicianaobra },


if (not parentArgs['wikidata'..f] or parentArgs['wikidata'..f] == '') and (title.namespace == 0) then
{ 'INE', '[[Instituto Nacional de Estadística (España)|INE]]', 772, codigoine },
if parentArgs['from'..f] then parentArgs['wikidata'..f] = parentArgs['from'..f] elseif item then parentArgs['wikidata'..f] = item.id end
{ 'TGN', '[[Getty Thesaurus of Geographic Names|TGN]]', 1667, tgnlink },
end
{ 'SNCZI-IPE-EMBALSE', '[[Sistema Nacional de Cartografía de Zonas Inundables|SNCZI]]-[[Inventario de Presas y Embalses de España|IPE]]', 4568, sncziipeembalse },
if title.namespace == 0 or stringArgs then --Only in the main namespace or if there are manual overrides
{ 'SNCZI-IPE-PRESA', '[[Sistema Nacional de Cartografía de Zonas Inundables|SNCZI]]-[[Inventario de Presas y Embalses de España|IPE]]', 4558, sncziipepresa },
for _, params in pairs( conf.databases ) do
{ 'NATURA2000', '[[Red Natura 2000|Natura 2000]]', 3425, natura2000 },
local id = mw.ustring.lower( params[1] )
{ 'WWF', '[[Fondo Mundial para la Naturaleza|WWF]]', 1294, wwf },
--Wikidata fallback if requested
if (item ~= nil and item.claims ~= nil) and params[3] ~= 0 and (not parentArgs[id..f] or parentArgs[id..f] == '') then
{ 'HCDN', '[[Cámara de Diputados de la Nación Argentina|Estadísticas HCDN]]', 4693, hcdnlink },
local wikidataIds = getIdsFromWikidata( item, 'P' .. params[3] )
{ 'HCDNbio', '[[Cámara de Diputados de la Nación Argentina|Biografía HCDN]]', 5225, hcdnbiolink },
if wikidataIds[1] then
{ 'Legislatura CABA', '[[Legislatura de la Ciudad de Buenos Aires|Legislatura CABA]]', 4667, legcaba},
parentArgs[id..f] = wikidataIds[1]
{ 'Asamblea de Madrid', '[[Asamblea de Madrid]]', 4797, asambleamadrid},
end
end
{ 'World Heritage Site', '[[Patrimonio de la Humanidad]]', 757, WHSunesco },
{ 'CNMLBH', '[[Comisión Nacional de Monumentos, de Lugares y de Bienes Históricos|CNMLBH]]', 4587, cnmlbh},
{ 'IGESPAR', '[[Instituto de Gestão do Património Arquitectónico e Arqueológico|IGESPAR]]', 1702, igespar },
{ 'SIPA', '[[Sistema de Informação para o Património Arquitectónico|SIPA]]', 1700, sipa },
{ 'Infopatrimonio', '[[Infopatrimônio]]', 4372, infopatrimonioID },
{ 'AustriaObjektID', '[[Austria ObjektID]]', 2951, austriaobjektID },
{ 'FBBID', '[[Fredede og Bevaringsværdige Bygninger|FBB]]', 2783, fbbid },
{ 'Fornminnesregistret', '[[Fornminnesregistret|FMIS]]', 1260, fmisid },
{ 'BerlinerKulturdenkmal', 'Berliner Kulturdenkmal', 2424, berlinerkulturdenkmal },
{ 'NHLE', '[[National Heritage List for England|NHLE]]', 1216, nhle },
{ 'NRHP', '[[Registro Nacional de Lugares Históricos|NRHP]]', 649, nrhp },
{ 'KULTURMINNE', '[[Riksantikvaren|Kulturminne]]', 758, kulturminne },
{ 'CRHP', '[[Canadian Register of Historic Places|CRHP]]', 477, crhp },
{ 'MERIMEE', '[[Base Mérimée|Mérimée]]', 380, merimee },
{ 'CADW', '[[Cadw]]', 1459, cadwID },
{ 'Památkový Katalog', '[[Památkový katalog]]', 762, pamatkovykatalog },
{ 'PatrimonioIran', 'Patrimonio Nacional de Irán', 1369, patrimonioiranID },
{ 'BIC', '[[Bien de Interés Cultural (España)|BIC]]', 808, bic },
{ 'BCIN', '[[Bien Cultural de Interés Nacional|BCIN]]', 1586, bcin },
{ 'IPAC', '[[Inventario del Patrimonio Arquitectónico de Cataluña|IPAC]]', 1600, ipac },
{ 'IGPCV', '[[Inventario General del Patrimonio Cultural Valenciano|IGPCV]]', 2473, igpcv },
{ 'BDI-IAPH', '[[Instituto Andaluz del Patrimonio Histórico|IAPH]]', 3318, bdiIAPH },
{ 'SIPCA', '[[SIPCA]]', 3580, sipca },
{ 'PWJCYL', '[[Junta de Castilla y León|Patrimonio Web JCyL]]', 3177, idPWJCYL },
{ 'DocomomoIberico', '[[Fundación Docomomo Ibérico|Docomomo Ibérico]]', 3758, docomomoiberico },
{ 'COAMinmueble', '[[Colegio Oficial de Arquitectos de Madrid|COAM]]', 2917, COAMinmueble },
{ 'HispaniaNostra', '[[Lista roja de patrimonio en peligro|Lista Roja Hispania Nostra]]', 4868, hispanianostra },
{ 'COAMpersona', '[[Colegio Oficial de Arquitectos de Madrid|COAM]]', 4488, COAMpersona },
{ 'DOI', '[[Identificador de objeto digital|DOI]]', 356, doi },
{ 'Handle', '[[Sistema Handle|Handle]]', 1184, handle },
{ 'Europeana', '[[Europeana]]', 727, europeana },
}


--Worldcat
if id == 'issn' and parentArgs[id..f] and parentArgs[id..f] ~= '' then -- 'issn' is the first element following the 'wikidata' item
table.insert( elements, createRow( id, '', parentArgs[id..f], '[//www.worldcat.org/identities/' .. parentArgs['worldcatid'..f] .. ' WorldCat]', false ) ) --Validation?
elseif id == 'viaf' and parentArgs[id..f] and string.match( parentArgs[id..f], '^%d+$' ) and not parentArgs['worldcatid'..f] then -- Hackishly copy the validation code; this should go away when we move to using P1793 and P1630
table.insert( elements, createRow( id, '', parentArgs[id..f], '[//www.worldcat.org/identities/containsVIAFID/' .. parentArgs[id..f] .. ' WorldCat]', false ) )
elseif id == 'lccn' and parentArgs[id..f] and parentArgs[id..f] ~= '' and not parentArgs['viaf'..f] and not parentArgs['worldcatid'..f] then
local lccnParts = splitLccn( parentArgs[id..f] )
if lccnParts and lccnParts[1] ~= 'sh' then
table.insert( elements, createRow( id, '', parentArgs[id..f], '[//www.worldcat.org/identities/lccn-' .. lccnParts[1] .. lccnParts[2] .. '-' .. lccnParts[3] .. ' WorldCat]', false ) )
end
end


local val = parentArgs[id..f]
-- Check that the Wikidata item has this property-->value before adding it
if val and val ~= '' and mw.ustring.lower(val) ~= 'no' and params[3] ~= 0 then
local reqs = {}
local link = getLink( params[3], val, params[4] )
if link and link ~= '' then
table.insert( elements, createRow( id, params[2], val, link, true ) .. getCatForId( params[1], params[5] or 0 ) )
if id ~= 'wikidata' then
itemCount = itemCount + 1
end
end
end
end


--Generate navbox title
local p = {}


if itemCount > 0 then
function p.authorityControl( frame )
rowCount = rowCount + 1
local parentArgs = frame:getParent().args
if firstRow == 0 then firstRow = f end
--Create rows
if parentArgs['for'..f] and parentArgs['for'..f] ~= '' then
local elements = {}
navboxParams['group'..f] = "''" .. parentArgs['for'..f] .. "''"
else
local withLocalArgs = false
navboxParams['group'..f] = ''
for _,_ in pairs( parentArgs ) do
end
withLocalArgs = true
navboxParams['list'..f] = table.concat( elements )
end
end
end
if withLocalArgs then
end
table.insert(elements,'[[Categoría:Wikipedia:Páginas que utilizan control de autoridades con parámetros]]')
end


if rowCount > 0 then
--redirect PND to GND
local Navbox = require('Módulo:Navbox')
if (parentArgs.GND == nil or parentArgs.GND == '') and parentArgs.PND ~= nil and parentArgs.PND ~= '' then
if rowCount > 1 then
parentArgs.GND = parentArgs.PND
navboxParams['title'] = '[[Ayuda:Control de autoridades|Control de autoridades]]'
end
--add missing names

for f = 1,fromForCount,1
--Wikidata fallback if requested
do
local item = mw.wikibase.getEntityObject()
if navboxParams['group'..f] == '' then
if item ~= nil and item.claims ~= nil then
navboxParams['group'..f] = "''" .. mw.wikibase.getEntity(parentArgs['wikidata'..f]):getLabel().."''"
for _, params in pairs( conf ) do
end
if params[3] ~= 0 then
end
local val = parentArgs[params[1]]
if not val or val == '' then
if rowCount > 2 then
navboxParams['navbar'] = 'plain'
local canUseWikidata = nil
else
if reqs[params[1]] ~= nil then
navboxParams['state'] = 'off'
canUseWikidata = matchesWikidataRequirements( item, reqs[params[1]] )
navboxParams['navbar'] = 'off'
else
end
canUseWikidata = true
else
end
navboxParams['group'..firstRow] = '[[Ayuda:Control de autoridades|Control de autoridades]]<br />' .. navboxParams['group'..firstRow]
if canUseWikidata then
end
local wikidataIds = getIdsFromWikidata( item, 'P' .. params[3] )
if stringArgs then
if wikidataIds[1] then
navboxParams['group1'] = navboxParams['group1'] .. '[[Categoría:Wikipedia:Páginas que utilizan control de autoridades con parámetros]]\n'
parentArgs[params[1]] = wikidataIds[1]
end
end
if itemCount > 13 then
end
navboxParams['group1'] = navboxParams['group1'] .. '[[Categoría:Wikipedia:Control de autoridades con ' .. itemCount .. ' elementos]]\n'
end
end
end
return Navbox._navbox(navboxParams)
end
end
--Wikidata
if item and item.id then
table.insert( elements, createRow(
'WIKIDATA',
'[[Archivo:Wikidata-logo.svg|20px|link=https://www.wikidata.org/wiki/Wikidata:Main_Page|alt=Wd|Wikidata]]:',
'Wikidata',
'[[Wikidata:' .. item.id .. '|' .. item.id .. ']]',
false ) )
end

--Worldcat
if parentArgs['WORLDCATID'] and parentArgs['WORLDCATID'] ~= '' then
table.insert( elements, createRow( 'WORLDCATID', '', parentArgs['WORLDCATID'], '[//www.worldcat.org/identities/' .. parentArgs['WORLDCATID'] .. ' WorldCat]', false ) ) --Validation?
elseif parentArgs['VIAF'] and string.match( parentArgs['VIAF'], '^%d+$' ) then -- Hackishly copy the validation code; this should go away when we move to using P1793 and P1630
table.insert( elements, createRow( 'VIAF', '', parentArgs['VIAF'], '[//www.worldcat.org/identities/containsVIAFID/' .. parentArgs['VIAF'] .. ' WorldCat]', false ) )
elseif parentArgs['LCCN'] and parentArgs['LCCN'] ~= '' then
local lccnParts = splitLccn( parentArgs['LCCN'] )
if lccnParts and lccnParts[1] ~= 'sh' then
table.insert( elements, createRow( 'LCCN', '', parentArgs['LCCN'], '[//www.worldcat.org/identities/lccn-' .. lccnParts[1] .. lccnParts[2] .. '-' .. lccnParts[3] .. ' WorldCat]', false ) )
end
end

--Configured rows
local rct = 0
for k, params in pairs( conf ) do
local val = parentArgs[params[1]]
if val and val ~= '' then
table.insert( elements, createRow( params[1], params[2] .. ':', val, params[4]( val ), true ) )
rct = rct + 1
end
end
local Navbox = require('Módulo:Navbox')
local elementscats = ''
if rct > 13 then
elementscats = '[[Categoría:Wikipedia:Control de autoridades con ' .. rct .. ' elementos]]'
end
if #elements ~= 0 then
return Navbox._navbox( {
name = 'Authority control',
bodyclass = 'hlist',
group1 = '[[Ayuda:Control de autoridades|Control de autoridades]]' .. elementscats,
list1 = table.concat( elements )
} )
else
else
return ""
return ''
end
end
end
end

Revisión del 03:04 5 jul 2018

Icono de documentación de módulo Documentación del módulo[ver] [editar] [historial] [purgar]

A continuación se muestra la documentación transcluida desde la subpágina /doc. [salta a la caja de código]


Uso



Esta documentación está transcluida desde Módulo:Control de autoridades/doc.
Por favor, añade las categorías en la subpágina de documentación y los interwikis en Wikidata. Subpáginas de este módulo.

require('Módulo:No globals')

local function generic ( id, link, parameter )
	link = mw.ustring.gsub( link, '$1', id )
	return '[' .. link .. ' ' .. id .. ']'
end

local function bncLink ( id, link, parameter )
	-- filtro local del BNC, para evadir multitud de identificadores de Wikidata que no se enlazan adecuadamente
	-- véase https://www.wikidata.org/wiki/Wikidata:Database_reports/Constraint_violations/P1890#%22Format%22_violations
	if ( string.match( id, '^%d%d%d%d%d%d%d%d%d$' ) ) then
		return generic ( id, link, parameter )
	end
	return false
end

local function bnfLink ( id, link, parameter )
	-- representación local del BNF, con doble enlace
	return generic( id, link, parameter ) .. ' [http://data.bnf.fr/ark:/12148/cb' .. id .. ' (data)]'
end

local function ineLink ( id, link, parameter )
	-- representación especial del INE, enlace no estándar con cinco parámetros utilizados
	local ineMainRE, ineTailRE = '^(%d%d)(%d%d%d)', '(%d%d)(%d%d)(%d%d)'
	local codProv, codMuni, codEC, codES, codNUC = string.match( id, ineMainRE .. ineTailRE .. '$' )
	if not codEC or not codES or not codNUC then
		codProv, codMuni = string.match( id, ineMainRE .. '$' )
		if codProv and codMuni then
			codEC, codES, codNUC = '00', '00', '00'
		else
			codProv, codMuni = string.match( id, ineMainRE )
			codEC, codES, codNUC = '', '', ''
		end
	end
	if codProv and codMuni then
		link = 'http://www.ine.es/nomen2/inicio_a.do?accion=busquedaAvanzada&inicio=inicio_a&subaccion=&botonBusquedaAvanzada=Consultar+selecci%C3%B3n&numPag=0&ordenAnios=ASC&comunidad=00&entidad_amb=no&poblacion_amb=T&poblacion_op=%3D&poblacion_txt=&denominacion_op=like&denominacion_txt=&codProv=$1&codMuni=$2&codEC=$3&codES=$4&codNUC=$5'
		link = link:gsub('$1', codProv):gsub('$2', codMuni):gsub('$3', codEC):gsub('$4', codES):gsub('$5', codNUC)
		return generic( id, link, parameter )
	end
	return id
end

local conf = {}
--In this order: name of the parameter, label, propertyId in Wikidata, formatting function, category id
-- -- name of the parameter: unique name
-- -- label: internal link in wiki format
-- -- propertyId in Wikidata: number without 'P' suffix
-- -- formatting function: one of these four options
-- -- -- local function (like 'generic')
-- -- -- string 'y' (yes), to show a default identifier 'ID'
-- -- -- string 'n' (no), to show the real identifier
-- -- -- any other string, to show this string as identifier ('id', 'url', 'link', ...)
-- -- category id: one of these tree options
-- -- -- number 0, to not add category
-- -- -- number 1, to add a category based on the name of the parameter
-- -- -- any string, to add a category based on this string
conf.databases = {
	{ 'Wikidata', '[[Archivo:Wikidata-logo.svg|20px|link=https://www.wikidata.org/wiki/Wikidata:Main_Page|alt=Wd|Wikidata]]', 'Wikidata:$1', 'n', 0 },
	{ 'ISSN', '[[ISSN]]', 236, 'n', 1 },
	{ 'VIAF', '[[Virtual International Authority File|VIAF]]', 214, 'n', 1 },
	{ 'ISNI', '[[International Standard Name Identifier|ISNI]]', 213, 'n', 1 },

	{ 'BCN', '[[Biblioteca del Congreso de la Nación Argentina|BCN]]', 2879, 'n', 1 },
	{ 'BNA', '[[Biblioteca Nacional de la República Argentina|BNA]]', 3788, 'n', 1 },
	{ 'BNE', '[[Biblioteca Nacional de España|BNE]]', 950, 'n', 1 },
	{ 'BNF', '[[Bibliothèque nationale de France|BNF]]', 268, bnfLink, 1 },
	{ 'BNM', '[[Biblioteca Nacional de México|BNM]]', 4440, 'n', 1 },
	{ 'BNC', '[[Biblioteca Nacional de Chile|BNC]]', 1890, bncLink, 1 },
	{ 'CANTIC', '[[Biblioteca de Cataluña|CANTIC]]', 1273, 'n', 1 },
	{ 'GND', '[[Integrated Authority File|GND]]', 227, 'n', 1 },
	{ 'LCCN', '[[Library of Congress Control Number|LCCN]]', 244, 'n', 1 },
	{ 'NCL', '[[National Central Library|NCL]]', 1048, 'n', 0 },
	{ 'NDL', '[[National Diet Library|NDL]]', 349, 'n', 0 },
	{ 'NKC', '[[National Library of the Czech Republic|NKC]]', 691, 'n', 0 },
	{ 'NLA', '[[National Library of Australia|NLA]]', 409, 'n', 1 },
	{ 'RLS', '[[Biblioteca del Estado Ruso|BER]]', 947, 'n', 0 },

	{ 'CINII', '[[CiNii]]', 271, 'n', 0 },
	{ 'NARA', '[[National Archives and Records Administration|NARA]]', 1225, 'n', 0 },
	{ 'LCCNLCOC', '[[Library of Congress Control Number|LCCN]]', 1144, 'n', 0 },
	{ 'SNAC', '[[d:Q29861311|SNAC]]', 3430, 'n', 1 },

	{ 'SUDOC', '[[Système universitaire de documentation|SUDOC]]', 269, 'n', 0 },
	{ 'ULAN', '[[Union List of Artist Names|ULAN]]', 245, 'n', 1 },
	{ 'ORCID', '[[ORCID]]', 496, 'n', 1 },
	-- { 'SELIBR', '[[LIBRIS|SELIBR]]', 906, 'n', 1 },
	{ 'BIBSYS', '[[BIBSYS]]', 1015, 'n', 1 },
	{ 'UB', '[[Universidad de Barcelona|UB]]', 1580, 'n', 1 },
	{ 'IPNIaut', '[[Índice Internacional de Nombres de las Plantas|IPNI]]', 586, 'n', 'IPNI' },
	{ 'MGP', '[[Mathematics Genealogy Project|MGP]]', 549, 'n', 0 },
	{ 'autores.uy', '[[autores.uy]]', 2558, 'n', 1 },
	{ 'Slovenska biografija', '[[Slovenska biografija]]', 1254, 'n', 0 },
	{ 'SBN', '[[Istituto Centrale per il Catalogo Unico|ICCU]]', 396, 'n', 1 },

	{ 'CensoGuia', '[[Censo-Guía de Archivos de España e Iberoamérica]]', 3998, 'n', 'Censo-Guía' },
	{ 'Libraries.org', '[[Libraries.org]]', 4848, 'n', 1 },

	{ 'BOE', '[[Boletín Oficial del Estado|BOE]]', 4256, 'n', 1 },

	{ 'RoyalSociety', '[[Royal Society]]', 2070, 'url', 'Royal Society' },
	{ 'HAW', '[[Academia de Ciencias y Humanidades de Heidelberg|HAW]]', 2273, 'n', 1 },
	{ 'SAW', '[[Academia Sajona de Ciencias de Leipzig|SAW]]', 3411, 'n', 1 },
	{ 'KNAW', '[[Real Academia de Artes y Ciencias de los Países Bajos|KNAW]]', 2454, 'n', 1 },
	-- { 'KVAB', '[[Real Academia Flamenca de Ciencias y Artes de Bélgica|KVAB]]', 3887, 'n', 1 },
	{ 'Leopoldina', '[[Deutsche Akademie der Naturforscher Leopoldina|Leopoldina]]', 3413, 'n', 1 },
	{ 'CONICET', '[[CONICET]]', 3900, 'n', 1 },
	{ 'Grierson', '[[Directorio de científicos argentinos Dra. Grierson|Grierson]]', 3946, 'n', 1 },
	{ 'RANM', '[[Real Academia Nacional de Medicina|RANM]]', 3945, 'n', 1 },
	-- { 'ANMF', '[[Académie Nationale de Médecine|ANMF]]', 3956, 'n', 1 },

	{ 'Léonore', '[[Base Léonore|Léonore]]', 640, 'n', 0 },
	{ 'USCongress', '[[Biographical Directory of the United States Congress|US Congress]]', 1157, 'n', 0 },
	{ 'Auñamendi', '[[Enciclopedia Auñamendi|Auñamendi]]', 3218, 'n', 1 },
	{ 'GEA', '[[Gran Enciclopedia Aragonesa|GEA]]', 1807, 'n', 1 },
	{ 'DBSE', '[[Diccionario biográfico del socialismo español|DBSE]]', 2985, 'url', 1 },
	{ 'DBE', '[[Diccionario biográfico español|DBE]]', 4459, 'url', 1 },
	{ 'MNCARS', '[[Museo Nacional Centro de Arte Reina Sofía|MNCARS]]', 4439, 'url', 1 },
	{ 'MuseoDelPrado', '[[Museo del Prado]]', 5321, 'n', 'Museo del Prado' },

	{ 'BPN', '[[Biografisch Portaal|BPN]]', 651, 'n', 1 },
	{ 'HDS', '[[Historical Dictionary of Switzerland|HDS]]', 902, 'n', 0 },
	{ 'LIR', '[[Diccionario histórico de Suiza|LIR]]', 886, 'n', 0 },
	{ 'TLS', '[[Theaterlexikon der Schweiz|TLS]]', 1362, 'n', 0 },

	-- { 'ISCO', '[[d:Q1233766|ISCO]]', 952, 'n', 1 },
	{ 'AAT', '[[Art & Architecture Thesaurus|AAT]]', 1014, 'n', 1 },
	{ 'BDCYL', '[[Biblioteca Digital de Castilla y León|BDCYL]]', 3964, 'n', 1 },
	{ 'BVPB', '[[d:Q18596294|BVPB]]', 4802, 'n', 1 },
	{ 'BivaldiAutor', '[[Biblioteca Valenciana Digital|BiValDi]]', 3932, 'n', 'Bivaldi autor' },

	{ 'OpenLibrary', '[[Open Library]]', 648, 'n', 'Open Library' },
	{ 'GalicianaAutor', '[[Galiciana]]', 3307, 'n', 'Galiciana autor' },
	{ 'PARES', '[[PARES]]', 4813, 'n', 1 },
	{ 'BVMCpersona', '[[Biblioteca Virtual Miguel de Cervantes|BVMC]]', 2799, 'n', 'BVMC persona' },
	{ 'Persée', '[[Persée (portal)|Persée]]', 2732, 'n', 1 },
	{ 'Dialnet', '[[Dialnet]]', 1607, 'n', 1 },
	{ 'SSRN', '[[Social Science Research Network|SSRN]]', 3747, 'n', 'SSRN autor' },
	{ 'GutenbergAutor', '[[Proyecto Gutenberg]]', 1938, 'n', 'Proyecto Gutenberg autor' },
	{ 'UNZautor', '[[UNZ.org|UNZ]]', 2734, 'n', 'UNZ' },
	{ 'SIKART', '[[SIKART]]', 781, 'n', 0 },
	{ 'KULTURNAV', '[[KulturNav]]', 1248, 'id', 0 },
	{ 'RKDartists', '[[Rijksbureau voor Kunsthistorische Documentatie|RKD]]', 650, 'n', 1 },
	{ 'GoogleScholar', '[[Google Académico]]', 1960, 'n', 'Google Académico' },
	{ 'RID', '[[ResearcherID]]', 1053, 'n', 1 },

	{ 'BVMCobra', '[[Biblioteca Virtual Miguel de Cervantes|BVMC]]', 3976, 'n', 'BVMC obra' },
	{ 'NLM', '[[Biblioteca Nacional de Medicina de los Estados Unidos|NLM]]', 1055, 'n', 1 },
	{ 'Latindex', '[[Latindex]]', 3127, 'n', 1 },
	{ 'ERIH PLUS', '[[ERIH PLUS]]', 3434, 'n', 1 },
	{ 'IPNIpub', '[[Índice Internacional de Nombres de las Plantas|IPNI]]', 2008, 'n', 1 },
	{ 'SUDOCcat', '[[Système universitaire de documentation|SUDOC]]', 1025, 'n', 'SUDOC catálogo' },
	{ 'ZDB', '[[Zeitschriftendatenbank|ZDB]]', 1042, 'n', 1 },
	{ 'NorwegianRegister', '[[Norsk senter for forskningsdata|Norwegian Register]]', 1270, 'n', 'Norwegian Register' },
	{ 'PerséeRevista', '[[Persée (portal)|Persée]]', 2733, 'n', 'Persée revista' },
	{ 'DialnetRevista', '[[Dialnet]]', 1609, 'n', 'Dialnet revista' },
	{ 'Redalyc', '[[Redalyc]]', 3131, 'n', 1 },
	{ 'DOAJ', '[[Directory of Open Access Journals|DOAJ]]', 5115, 'n', 1 },
	{ 'UNZrevista', '[[UNZ.org|UNZ]]', 2735, 'n', 0 },
	{ 'JSTORrevista', '[[JSTOR]]', 1230, 'n', 'JSTOR revista' },
	{ 'HathiTrust', '[[HathiTrust]]', 1844, 'n', 1 },
	{ 'HemBNE', '[[Hemeroteca Digital de la Biblioteca Nacional de España|Hemeroteca BNE]]', 2768, 'n', 1 },
	{ 'BVPH', '[[Biblioteca Virtual de Prensa Histórica|BVPH]]', 2961, 'n', 1 },
	{ 'Galicianaobra', '[[Galiciana]]', 3004, 'n', 'Galiciana obra' },

	{ 'INE', '[[Instituto Nacional de Estadística (España)|INE]]', 772, ineLink, 1 },
	{ 'TGN', '[[Getty Thesaurus of Geographic Names|TGN]]', 1667, 'n', 1 },
	{ 'SNCZI-IPE-EMBALSE', '[[Sistema Nacional de Cartografía de Zonas Inundables|SNCZI]]-[[Inventario de Presas y Embalses de España|IPE]]', 4568, 'n', 'SNCZI-IPE embalse' },
	{ 'SNCZI-IPE-PRESA', '[[Sistema Nacional de Cartografía de Zonas Inundables|SNCZI]]-[[Inventario de Presas y Embalses de España|IPE]]', 4558, 'n', 'SNCZI-IPE presa' },
	{ 'NATURA2000', '[[Red Natura 2000|Natura 2000]]', 3425, 'n', 'Natura 2000' },
	{ 'WWF', '[[Fondo Mundial para la Naturaleza|WWF]]', 1294, 'n', 1 },

	{ 'HCDN', '[[Cámara de Diputados de la Nación Argentina|Estadísticas HCDN]]', 4693, 'n', 1 },
	{ 'HCDNbio', '[[Cámara de Diputados de la Nación Argentina|Biografía HCDN]]', 5225, 'n', 1 },
	-- { 'Legislatura CABA', '[[Legislatura de la Ciudad de Buenos Aires|Legislatura CABA]]', 4667, 'n', 1 },
	{ 'Asamblea de Madrid', '[[Asamblea de Madrid]]', 4797, 'n', 1 },

	{ 'World Heritage Site', '[[Patrimonio de la Humanidad]]', 757, 'n', 'Centro del Patrimonio Mundial' },
	{ 'CNMLBH', '[[Comisión Nacional de Monumentos, de Lugares y de Bienes Históricos|CNMLBH]]', 4587, 'n', 'cnmlbh' },
	{ 'IGESPAR', '[[Instituto de Gestão do Património Arquitectónico e Arqueológico|IGESPAR]]', 1702, 'n', 1 },
	{ 'SIPA', '[[Sistema de Informação para o Património Arquitectónico|SIPA]]', 1700, 'n', 1 },
	{ 'Infopatrimonio', '[[Infopatrimônio]]', 4372, 'n', 'Infopatrimônio' },
	{ 'AustriaObjektID', '[[Austria ObjektID]]', 2951,  'n', 'Austria ObjektID' },
	{ 'FBBID', '[[Fredede og Bevaringsværdige Bygninger|FBB]]', 2783,  'n', 'FBB' },
	{ 'Fornminnesregistret', '[[Fornminnesregistret|FMIS]]', 1260,  'n', 'FMIS' },
	{ 'BerlinerKulturdenkmal', 'Berliner Kulturdenkmal', 2424, 'n', 'Berliner Kulturdenkmal' },
	{ 'NHLE', '[[National Heritage List for England|NHLE]]', 1216, 'n', 1 },
	{ 'NRHP', '[[Registro Nacional de Lugares Históricos|NRHP]]', 649, 'n', 1 },
	{ 'KULTURMINNE', '[[Riksantikvaren|Kulturminne]]', 758, 'n', 'Kulturminne' },
	{ 'CRHP', '[[Canadian Register of Historic Places|CRHP]]', 477, 'n', 1 },
	{ 'MERIMEE', '[[Base Mérimée|Mérimée]]', 380, 'n', 'Mérimée' },
	{ 'CADW', '[[Cadw]]', 1459, 'n', 'Cadw' },
	{ 'Památkový Katalog', '[[Památkový katalog]]', 762, 'n', 'Památkový katalog' },
	{ 'PatrimonioIran', 'Patrimonio Nacional de Irán', 1369, 'n', 'Patrimonio Nacional de Irán' },
	{ 'BIC', '[[Bien de Interés Cultural (España)|BIC]]', 808, 'n', 1 },
	{ 'BCIN', '[[Bien Cultural de Interés Nacional|BCIN]]', 1586, 'n', 1 },
	{ 'IPAC', '[[Inventario del Patrimonio Arquitectónico de Cataluña|IPAC]]', 1600, 'n', 1 },
	{ 'IGPCV', '[[Inventario General del Patrimonio Cultural Valenciano|IGPCV]]', 2473, 'n', 1 },
	{ 'BDI-IAPH', '[[Instituto Andaluz del Patrimonio Histórico|IAPH]]', 3318, 'n', 1 },
	-- { 'SIPCA', '[[SIPCA]]', 3580, 'n', 1 },
	{ 'PWJCYL', '[[Junta de Castilla y León|Patrimonio Web JCyL]]', 3177, 'n', 'Patrimonio Web JCyL' },
	{ 'DocomomoIberico', '[[Fundación Docomomo Ibérico|Docomomo Ibérico]]', 3758, 'n', 'Docomomo Ibérico' },
	{ 'COAMinmueble', '[[Colegio Oficial de Arquitectos de Madrid|COAM]]', 2917, 'n', 'COAM inmueble' },
	{ 'HispaniaNostra', '[[Lista roja de patrimonio en peligro|Lista Roja Hispania Nostra]]', 4868, 'url', 'Lista Roja Hispania Nostra' },
	{ 'COAMpersona', '[[Colegio Oficial de Arquitectos de Madrid|COAM]]', 4488, 'n', 'COAM persona' },
	{ 'DOI', '[[Identificador de objeto digital|DOI]]', 356, 'n', 1 },
	{ 'Handle', '[[Sistema Handle|Handle]]', 1184, 'url', 1 },
	{ 'Europeana', '[[Europeana]]', 727, 'url', 1 },
}
--In this order: alternate name, name of parameter from databases table
conf.aliases = {
	{ 'Wd', 'Wikidata' },
	{ 'PND', 'GND' },
}

local function getCatForId( parameter, category )
	local title = mw.title.getCurrentTitle()
	local namespace = title.namespace
	if category == 0 then
		return ''
	elseif category == 1 then
		category = parameter
	end
	if namespace == 0 then
		return '[[Categoría:Wikipedia:Artículos con identificadores ' .. category .. ']]\n'
	elseif namespace == 2 and not title.isSubpage then
		return '[[Categoría:Wikipedia:Páginas de usuario con identificadores ' .. category .. ']]\n'
	else
		return '[[Categoría:Wikipedia:Páginas misceláneas con identificadores ' .. category .. ']]\n'
	end
end

local function getIdsFromWikidata( item, property )
	local ids = {}
	if not item.claims[property] then
		return ids
	end
	for _, statement in pairs( item:getBestStatements( property )) do
		if statement.mainsnak.datavalue then
			table.insert( ids, statement.mainsnak.datavalue.value )
		end
	end
	return ids
end

local function getLink( property, val, mask )
	local link = ''
	if mw.ustring.find( val, '//' ) then
		link = val
	else
		if type(property) == 'number' then
			local entityObject = mw.wikibase.getEntityObject('P'..property)
			local dataType = entityObject.datatype
			if dataType == 'external-id' then
				local allStatements = entityObject:getAllStatements('P1630')
				if allStatements then
					for pos = 1, #allStatements, 1
					do
						local q = allStatements[pos].qualifiers
						if q and q.P407 and q.P407[1].datavalue.value.id == 'Q1321' then
							link = allStatements[pos].mainsnak.datavalue.value
						end
					end
				end
				if link == '' then
					local formatterURL = entityObject:getBestStatements('P1630')[1]
					if formatterURL then
						link = formatterURL.mainsnak.datavalue.value
					else
						local formatterURL = entityObject:getBestStatements('P3303')[1]
						if formatterURL then link = formatterURL.mainsnak.datavalue.value end
					end
				end
			elseif dataType == 'url' then
				local subjectItem = entityObject:getBestStatements('P1629')[1]
				if subjectItem then
					local officialWebsite = mw.wikibase.getEntityObject(subjectItem.mainsnak.datavalue.value.id):getBestStatements('P856')[1]
					if officialWebsite then
						link = officialWebsite.mainsnak.datavalue.value 
					end
				end
			elseif dataType == 'string' then
				local formatterURL = entityObject:getBestStatements('P1630')[1]
				if formatterURL then
					link = formatterURL.mainsnak.datavalue.value
				else
					local formatterURL = entityObject:getBestStatements('P3303')[1]
					if formatterURL then
						link = formatterURL.mainsnak.datavalue.value
					else
						local subjectItem = entityObject:getBestStatements('P1629')[1]
						if subjectItem then
							local officialWebsite = mw.wikibase.getEntityObject(subjectItem.mainsnak.datavalue.value.id):getBestStatements('P856')[1]
							if officialWebsite then
								link = officialWebsite.mainsnak.datavalue.value
							end
						end
					end
				end
			end
		elseif type(property) == 'string' then
			link = property
		end
	end
	link = mw.ustring.gsub(link, '^[Hh][Tt][Tt][Pp]([Ss]?)&#58;//', 'http%1://') -- fix wikidata URL
	if type(mask) == 'function' then
		return mask( val, link, property )
	end
	link = mw.ustring.gsub(link, '$1', mw.ustring.gsub( val, ' ', '%%%%20' ) or val )
	if mw.ustring.find( link, '//' ) then
		if type(mask) == 'string' then
			if mask == 'y' then
				return '['..link..' ID]'
			elseif mask == 'n' then
				return '['..link..' '..val..']'
			end
			return '['..link..' '..mask..']'
		end
	elseif link == '' then
		return val
	else
		return '[['..link..'|'..val..']]'
	end
end

local function createRow( id, label, rawValue, link, withUid )
	if link then
		if label and label ~= '' then label = label  .. ': ' end
		if withUid then
			return '* ' .. label .. '<span class="uid">' .. link .. '</span>\n'
		else
			return '* ' .. label .. link .. '\n'
		end
	else
		return '* <span class="error">El ' .. id .. ' id ' .. rawValue .. ' no es válido</span>[[Categoría:Wikipedia:Páginas con problemas en el control de autoridades]]\n'
	end
end

local function copyTable(inTable)
	if type(inTable) ~= 'table' then return inTable end
	local outTable = setmetatable({}, getmetatable(inTable))
	for key, value in pairs (inTable) do outTable[copyTable(key)] = copyTable(value) end
	return outTable
end

local function splitLccn( id )
	if id:match( '^%l%l?%l?%d%d%d%d%d%d%d%d%d?%d?$' ) then
		id = id:gsub( '^(%l+)(%d+)(%d%d%d%d%d%d)$', '%1/%2/%3' )
	end
	if id:match( '^%l%l?%l?/%d%d%d?%d?/%d+$' ) then
		return mw.text.split( id, '/' )
	end
	return false
end

local p = {}

function p.authorityControl( frame )
	local parentArgs = copyTable(frame:getParent().args)
	local stringArgs = false
	local fromForCount, firstRow, rowCount = 1, 0, 0
	--Cleanup args
	for k, v in pairs( frame:getParent().args ) do
		if type(k) == 'string' then
			--make args case insensitive
			local lowerk = mw.ustring.lower(k)
			if not parentArgs[lowerk] or parentArgs[lowerk] == '' then
				parentArgs[lowerk] = v
				parentArgs[k] = nil
			end
			--remap abc to abc1
			if not mw.ustring.find(lowerk, '%d$') then --if no number at end of param
				if not parentArgs[lowerk..'1'] or parentArgs[lowerk..'1'] == '' then
					parentArgs[lowerk..'1'] = v
					parentArgs[lowerk] = nil
				end
			end
			if v and v ~= '' then
				--find highest from param
				if mw.ustring.sub(lowerk,1,4) == 'from' then
					local fromNumber = tonumber(mw.ustring.sub(lowerk,5,-1))
					if fromNumber and fromNumber >= fromForCount then fromForCount = fromNumber end
				elseif mw.ustring.sub(lowerk,1,3) == 'for' then
					local forNumber = tonumber(mw.ustring.sub(lowerk,4,-1))
					if forNumber and forNumber >= fromForCount then fromForCount = forNumber end
				elseif mw.ustring.lower(v) ~= 'no' and lowerk ~= 'for' then
					stringArgs = true
				end
			end
		end
	end

	--Setup navbox
	local navboxParams = {
		name  = 'Control de autoridades',
		bodyclass = 'hlist',
		groupstyle = 'width: 12%; text-align:center;',
	}
	local itemCount = 0
	for f = 1,fromForCount,1
	do
		local elements, title = {}, {}
		--cleanup parameters
		if parentArgs['from'..f] == '' then parentArgs['from'..f] = nil end
		if parentArgs['for'..f] == '' then parentArgs['for'..f] = nil end
		--remap aliases
		for _, a in pairs( conf.aliases ) do
			local alias, name = mw.ustring.lower(a[1]), mw.ustring.lower(a[2])
			if parentArgs[alias..f] and not parentArgs[name..f] then
				parentArgs[name..f] = parentArgs[alias..f]
				parentArgs[alias..f] = nil
			end
		end

		--Fetch Wikidata item
		local item = mw.wikibase.getEntity(parentArgs['from'..f])
		local label = item and item:getLabel()
		if label and label ~= '' then
			title = mw.title.new(label)
			if not title then title = mw.title.getCurrentTitle() end
		else
			title = mw.title.getCurrentTitle()
		end

		if (not parentArgs['wikidata'..f] or parentArgs['wikidata'..f] == '') and (title.namespace == 0) then
			if parentArgs['from'..f] then parentArgs['wikidata'..f] = parentArgs['from'..f] elseif item then parentArgs['wikidata'..f] = item.id end
		end
		if title.namespace == 0 or stringArgs then --Only in the main namespace or if there are manual overrides
			for _, params in pairs( conf.databases ) do
				local id = mw.ustring.lower( params[1] )
				--Wikidata fallback if requested
				if (item ~= nil and item.claims ~= nil) and params[3] ~= 0 and (not parentArgs[id..f] or parentArgs[id..f] == '') then
					local wikidataIds = getIdsFromWikidata( item, 'P' .. params[3] )
					if wikidataIds[1] then
						parentArgs[id..f] = wikidataIds[1]
					end
				end

				--Worldcat
				if id == 'issn' and parentArgs[id..f] and parentArgs[id..f] ~= '' then -- 'issn' is the first element following the 'wikidata' item
					table.insert( elements, createRow( id, '', parentArgs[id..f], '[//www.worldcat.org/identities/' .. parentArgs['worldcatid'..f] .. ' WorldCat]', false ) ) --Validation?
				elseif id == 'viaf' and parentArgs[id..f] and string.match( parentArgs[id..f], '^%d+$' ) and not parentArgs['worldcatid'..f] then -- Hackishly copy the validation code; this should go away when we move to using P1793 and P1630
					table.insert( elements, createRow( id, '', parentArgs[id..f], '[//www.worldcat.org/identities/containsVIAFID/' .. parentArgs[id..f] .. ' WorldCat]', false ) )
				elseif id == 'lccn' and parentArgs[id..f] and parentArgs[id..f] ~= '' and not parentArgs['viaf'..f] and not parentArgs['worldcatid'..f] then
					local lccnParts = splitLccn( parentArgs[id..f] )
					if lccnParts and lccnParts[1] ~= 'sh' then
						table.insert( elements, createRow( id, '', parentArgs[id..f], '[//www.worldcat.org/identities/lccn-' .. lccnParts[1] .. lccnParts[2] .. '-' .. lccnParts[3] .. ' WorldCat]', false ) )
					end
				end

				local val = parentArgs[id..f]
				if val and val ~= '' and mw.ustring.lower(val) ~= 'no' and params[3] ~= 0 then
					local link = getLink( params[3], val, params[4] )
					if link and link ~= '' then
						table.insert( elements, createRow( id, params[2], val, link, true ) .. getCatForId( params[1], params[5] or 0 ) )
						if id ~= 'wikidata' then
							itemCount = itemCount + 1
						end
					end
				end
			end

			--Generate navbox title

			if itemCount > 0 then
				rowCount = rowCount + 1
				if firstRow == 0 then firstRow = f end
				if parentArgs['for'..f] and parentArgs['for'..f] ~= '' then
					navboxParams['group'..f] = "''" .. parentArgs['for'..f] .. "''"
				else
					navboxParams['group'..f] = ''
				end
				navboxParams['list'..f] = table.concat( elements )
			end
		end
	end

	if rowCount > 0 then
		local Navbox = require('Módulo:Navbox')
		if rowCount > 1 then
			navboxParams['title'] = '[[Ayuda:Control de autoridades|Control de autoridades]]'
			--add missing names
			for f = 1,fromForCount,1
			do
				if navboxParams['group'..f] == '' then
					navboxParams['group'..f] = "''" .. mw.wikibase.getEntity(parentArgs['wikidata'..f]):getLabel().."''"
				end
			end
			if rowCount > 2 then
				navboxParams['navbar'] = 'plain'
			else
				navboxParams['state'] = 'off'
				navboxParams['navbar'] = 'off'
			end
		else
			navboxParams['group'..firstRow] = '[[Ayuda:Control de autoridades|Control de autoridades]]<br />' .. navboxParams['group'..firstRow]
		end
		if stringArgs then
			navboxParams['group1'] = navboxParams['group1'] .. '[[Categoría:Wikipedia:Páginas que utilizan control de autoridades con parámetros]]\n'
		end
		if itemCount > 13 then
			navboxParams['group1'] = navboxParams['group1'] .. '[[Categoría:Wikipedia:Control de autoridades con ' .. itemCount .. ' elementos]]\n'
		end
		return Navbox._navbox(navboxParams)
	else
		return ''
	end
end

return p