Saltar para o conteúdo

Módulo:Cuntrolo d'outorie

Ourige: Biquipédia, la anciclopédia lhibre.
Rebison de 20h39min de 13 de agosto de 2017 por Athena in Wonderland (cumbersa | cuntrebuiçones)
(defr) ← Berson d'atrás | Ber berson atual (defr) | Berson mais nuoba→ (defr)

La decumentaçon pa este módulo puode ser criada na páigina Módulo:Cuntrolo d'outorie/doc

require('Módulo:No globals')

local function getCatForId( id )
    local title = mw.title.getCurrentTitle()
    local namespace = title.namespace
    if namespace == 0 then
        return '[[Catadorie:!Artigos anciclopédicos cun eidantificadores ' .. id .. ']]'
    elseif namespace == 2 and not title.isSubpage then
        return "[[Catadorie:!Páiginas d'outelizador cun eidantificadores " .. id .. ']]'
    else
        return '[[Catadorie:!Páiginas de teor misto cun eidantificadores ' .. id .. ']]'
    end
end

local function viafLink( id )
    if not string.match( id, '^%d+$' ) then
        return false
    end
    return '[https://viaf.org/viaf/' .. id .. ' ' .. id .. ']' .. getCatForId( 'VIAF' )
end

local function kulturnavLink( id )
    return '[http://kulturnav.org/language/en/' .. id .. ' id]'
end

local function sikartLink( id )
    return '[http://www.sikart.ch/KuenstlerInnen.aspx?id=' .. id .. '&lng=en ' .. id .. ']'
end

local function tlsLink( id )
    local id2 = mw.ustring.gsub(id, '%s', function(s) return mw.uri.encode(s, 'WIKI') end)
    return '[http://tls.theaterwissenschaft.ch/wiki/' .. id2 .. ' ' .. id .. ']'
end


local function ciniiLink( id )
    return '[http://ci.nii.ac.jp/author/' .. id .. '?l=en ' .. id .. ']'
end

local function uscongressLink( id )
    return '[http://bioguide.congress.gov/scripts/biodisplay.pl?index=' .. id .. ' ' .. id .. ']'
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 botanistLink( id )
    local id2 = mw.ustring.gsub(id, '%s', function(s) return mw.uri.encode(s, 'PATH') end)
    return '[http://www.ipni.org/ipni/advAuthorSearch.do?find_abbreviation=' .. id2 .. ' ' .. 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 '[http://www.culture.gouv.fr/public/mistral/leonore_fr?ACTION=CHERCHER&FIELD_1=COTE&VALUE_1=' .. id .. ' ' .. id .. ']'
end

local function dbnlLink( id )
	return '[http://www.dbnl.org/auteurs/auteur.php?id=' .. id .. ' ' .. id .. ']' .. getCatForId( 'DBNL' )
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 cbdbLink( id )
	return '[http://db1.ihp.sinica.edu.tw/cbdbc/cbdbkmeng?~~AAA' .. id .. ' ' .. id .. ']' .. getCatForId( 'CBDB' )
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 nukatLink( id )
	return id .. getCatForId( 'NUKAT' )
	-- linking format not currently available on Wikidata and cannot find anything suitable as http://www.nukat.edu.pl/
end

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

local function ptbnpLink( id )
	return '[http://purl.pt/index/geral/aut/PT/' .. id .. '.html ' .. id .. ']' .. getCatForId( 'PTBNP' )
end

local function ntaLink( id )
	-- Nationale Thesaurus Auteursnamen
	return '[http://opc4.kb.nl/PPN?PPN=' .. id .. ' ' .. id .. ']' .. getCatForId( 'NTA' )
end

local function bavLink( id )
	return id .. getCatForId( 'BAV' )
	-- there may not be an online catalogue for the Vatican Library (Wikidata is not currently linking to anything)
end
local function nliLink( id )
	return '[http://a20.libnet.ac.il/F?func=find-b&REQUEST=' .. id .. '&find_code=SYS&local_base=NNL10 ' .. id .. ']' .. getCatForId( 'NLI' )
end

local function nlcLink( id )
	return '[http://opac.nlc.gov.cn/F/?func=accref&acc_sequence=' .. id .. ' ' .. id .. ']' .. getCatForId( 'NLC' )
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 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

local function mbLink( id )
    -- TODO Implement some sanity checking regex
    return '[//musicbrainz.org/artist/' .. id .. ' ' .. id .. ']' .. getCatForId( 'MusicBrainz' )
end

local function calisLink( id )
	return '[http://opac.calis.edu.cn/aopac/ajsp/detail.jsp?actionfrom=1&actl=CAL++' .. id .. ' ' .. id .. ']' .. getCatForId( 'CALIS' )
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 '[https://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/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 naraIdLink( id )
	return '[http://research.archives.gov/person/' .. id .. ' ' .. id .. ']' .. getCatForId( 'NARA' )
end

local function ibdbLink( id )
	return '[http://www.ibdb.com/person.php?id=' .. id .. ' ' .. id .. ']' .. getCatForId( 'IBDB' )
end

local function isfdbIdLink( id )
	return '[http://www.isfdb.org/cgi-bin/ea.cgi?' .. id .. ' ' .. id .. ']' .. getCatForId( 'ISFDB' )
end

local function findGraveLink( id )
	return '[http://www.findagrave.com/cgi-bin/fg.cgi?page=gr&GRid=' .. id .. ' ' .. id .. ']' .. getCatForId( 'Find a Grave' )
end

local function rkdLink( id )
	return '[http://explore.rkd.nl/nl/artists/' .. id .. ' ' .. id .. ']' .. getCatForId( 'RKD' )
end

local function bneLink( id )
	return '[http://catalogo.bne.es/uhtbin/authoritybrowse.cgi?action=display&authority_id=' .. id .. ' ' .. id .. ']' .. getCatForId( 'BNE' )
end

local function nlrLink( id )
	return '[http://alephnew.bibnat.ro:8991/F?func=find-b&request=' .. id .. '&find_code=SYS&adjacent=Y&local_base=NLR10 ' .. id .. ']' .. getCatForId( 'NLR' )
end

local function chLink( id )
	-- Catholic Hierarchy (database of bishops)
	return '[http://www.catholic-hierarchy.org/bishop/b' .. id .. '.html ' .. id .. ']' .. getCatForId( 'Catholic Hierarchy' )
end

local function sycomoreLink( id )
	return '[http://www.assemblee-nationale.fr/sycomore/fiche.asp?num_dept=' .. id .. ' ' .. id .. ']' .. getCatForId( 'Sycomore' )
end

local function PrdlLink( id )
	return '[http://prdl.org/author_view.php?a_id=' .. id .. ' ' .. id .. ']' .. getCatForId( 'PRDL' )
end

local function NupillALink( id )
	return '[http://www.literaturabrasileira.ufsc.br/autores/?id=' .. id .. ' ' .. id .. ']' .. getCatForId( 'NUPILL' )
end

local function MacTutorBLink( id )
	return '[http://www-history.mcs.st-andrews.ac.uk/Biographies/' .. id .. '.html ' .. id .. ']' 
end
 
local function AtclLink( id )
	return '[http://www.victorianresearch.org/atcl/show_author.php?aid=' .. id .. ' ' .. id .. ']' 
end

local function ElemLink( id )
	return '[http://www.elem.mx/autor/datos/' .. id .. ' ' .. id .. ']' 
end

local function ImslpLink( id )
	id2 = mw.ustring.gsub(id, '%s', function(s) return mw.uri.encode(s, 'WIKI') end)
    return '[http://imslp.org/wiki/' .. id2 .. ' ' .. id .. ']' 
end

local function OdnbLink( id )
	return '[http://www.oxforddnb.com/index/' .. id .. '/ ' .. id .. ']' 
end

local function GecLink( id )
	return '[http://www.enciclopedia.cat/enciclop%C3%A8dies/gran-enciclop%C3%A8dia-catalana/EC-GEC-' .. id .. '.xml ' .. id .. ']' 
end

-- ** Subject related or general authority controls follow **

local function imdbLink( id )
	return '[http://www.imdb.com/Name?' .. id .. ' ' .. id .. ']' .. getCatForId( 'IMDB' )
end

local function freebaseLink( id )
	return '[http://www.freebase.com' .. id .. ' ' .. id .. ']' .. getCatForId( 'Freebase' )
end

local function naraOrgLink( id )
	return '[http://research.archives.gov/organization/' .. id .. ' ' .. id .. ']' .. getCatForId( 'NARA' )
end

local function naraGeoLink( id )
	return '[http://research.archives.gov/geographic-reference/' .. id .. ' ' .. id .. ']' .. getCatForId( 'NARA' )
end

local function naraSubLink( id )
	return '[http://research.archives.gov/topical-subject/' .. id .. ' ' .. id .. ']' .. getCatForId( 'NARA' )
end

local function naraTypeLink( id )
	return '[http://research.archives.gov/specific-records-type/' .. id .. ' ' .. id .. ']' .. getCatForId( 'NARA' )
end

local function isfdbPubLink( id )
	return '[http://www.isfdb.org/cgi-bin/publisher.cgi?' .. id .. ' ' .. id .. ']' .. getCatForId( 'ISFDB' )
end

local function isfdbConLink( id )
	return '[http://www.isfdb.org/cgi-bin/pl.cgi?' .. id .. ' ' .. id .. ']' .. getCatForId( 'ISFDB' )
end

local function lembpLink( id )
	--Lista de Encabezamientos de materia para las Bibliotecas Públicas = List of Subject Headings for Public Libraries (Spanish)
	return '[http://id.sgcb.mcu.es/lem/ver/Autoridades/' .. id .. '/concept ' .. id .. ']' .. getCatForId( 'LEMBP' )
end

local function ddcLink( id )
	return '[http://dewey.info/class/' .. id .. '/about ' .. id .. ']' .. getCatForId( 'DDC' )
end

local function libriVoxAuthorLink( id )
        return '[https://librivox.org/author/' .. id .. ' ' .. id .. ']' .. getCatForId( 'LVA' )
end

local function GutenbergLink( id )
	return '[https://www.gutenberg.org/ebooks/author/' .. id .. ' ' .. id .. ']' .. getCatForId( 'Gutenberg' )
end

-- Entry for Wikipedia using 'wgArticleID' as an authority. Should always be last

local function wkmwlLink( id )
    if id and wkmwlpid ~= '' then
	return false
    end
    return '[//mwl.wikipedia.org/w/index.php?curid=' .. id .. ' ' .. id .. ']' .. getCatForId( 'WKMWL' )
end

local function wkpLink( id )
    if id and wkpid ~= '' then
	return false
    end
    return '[//pt.wikipedia.org/w/index.php?curid=' .. id .. ' ' .. id .. ']' .. getCatForId( 'WKP' )
end

-- End of authority control link format

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 matchesWikidataRequirements( item, reqs )
    for _, group in pairs( reqs ) do
        local property = 'p' .. group[1]
        local qid = group[2]
        if item.claims[property] ~= nil then
            for _, statement in pairs ( item.claims[property] ) do
                if statement.mainsnak.datavalue ~= nil then
                    if statement.mainsnak.datavalue.value['numeric-id'] == qid then
                        return true
                    end
                end
            end
        end
    end
    return false
end

local function createRow( id, label, rawValue, link, withUid )
    if link then
        if withUid then
            return '*<span style="white-space:nowrap;">' .. label .. ' <span class="uid">' .. link .. '</span></span>\n'
        else
            return '*<span style="white-space:nowrap;">' .. label .. ' ' .. link .. '</span>\n'
        end
    else
        return '* <span class="error">L id ' .. id .. ' ' .. rawValue .. ' ye ambálido.</span>[[Catadorie:!Artigos anciclopédicos cun erros ne ls eidantificadores (' .. id .. ')]]\n'
    end
end

--In this order: name of the parameter, label, propertyId in Wikidata, formatting function
local conf = {
    { 'VIAF', '[[Virtual International Authority File|VIAF]]', 214, viafLink },
    { 'LCCN', '[[Library of Congress Control Number|LCCN]]', 244, lccnLink },
    { 'ISNI', '[[International Standard Name Identifier|ISNI]]', 213, isniLink },
    { 'ORCID', '[[ORCID]]', 496, orcidLink },
    { 'GND', '[[Gemeinsame Normdatei|GND]]', 227, gndLink },
    { 'SELIBR', '[[LIBRIS|SELIBR]]', 906, selibrLink },
    { 'SUDOC', '[[Système universitaire de documentation|SUDOC]]', 269, sudocLink },
    { 'BNF', '[[Biblioteca Nacional de la Fráncia|BNF]]', 268, bnfLink },
    { 'BPN', '[[Biografisch Portaal|BPN]]', 651, bpnLink },
    { 'RID', '[[ResearcherID|ResearcherID]]', 1053, ridLink },
    { 'BIBSYS', '[[Bibsys|BIBSYS]]', 1015, bibsysLink },
    { 'ULAN', '[[Union List of Artist Names|ULAN]]', 245, ulanLink },
    { 'HDS', '[[Dicionairo Stórico de la Suíça|HDS]]', 902, hlsLink },
    { 'LIR', '[[Dicionairo Stórico de la Suíça|LIR]]', 886, lirLink },
    { 'MBA', '[[MusicBrainz]]', 434, mbLink },
    { 'MGP', '[[Mathematics Genealogy Project|MGP]]', 549, mgpLink },
    { 'NLA', '[[Biblioteca Nacional de la Oustrália|NLA]]', 409, nlaLink },
    { 'NDL', '[[Biblioteca Nacional de la Dieta|NDL]]', 349, ndlLink },
    { 'NCL', '[[Biblioteca Central de Taiwan|NCL]]', 1048, nclLink },
    { 'NKC', '[[Biblioteca Nacional de la República Checa|NKC]]', 691, nkcLink },
    { 'CALIS', 'CALIS', 270, calisLink },
    { 'Léonore', '[[Base Léonore|Léonore]]', 640, leonoreLink },
    { 'DBNL', '[[Biblioteca Digital pa la Lhiteratura Houlandesa|DBNL]]', 723, dbnlLink },
    { 'SBN', '[[Istituto centrale per il catalogo unico delle biblioteche italiane e per le informazioni bibliografiche|ICCU]]', 396, sbnLink },
    { 'CBDB', 'CBDB', 497, cbdbLink },
    { 'RLS', '[[Biblioteca de l Stado Russo|RLS]]', 947, rslLink },
    { 'PTBNP', '[[Biblioteca Nacional de Pertual|PTBNP]]', 1005, ptbnpLink },
    { 'NARA-person', '[[National Archives and Records Administration|NARA]]', 1222, narapersonLink },
    { 'NARA-organization', '[[National Archives and Records Administration|NARA]]', 1223, naraorganizationLink },
       { 'NTA', 'NTA', 1006, ntaLink },
    { 'BAV', '[[Biblioteca Apostólica Baticana|BAV]]', 1017, bavLink },
    { 'NLI', '[[Biblioteca Nacional de Eisrael|NLI]]', 949, nliLink },
    { 'NLC', '[[Biblioteca Nacional de la China|NLC]]', 1213, nlcLink },
    { 'NUKAT', 'NUKAT', 1207, nukatLink },
    { 'Botanist', '[[International Plant Names Index|Botanist]]', 428, botanistLink },
    { 'NARAid', '[[National Archives and Records Administration|NARA]]', 1222, naraIdLink },
    { 'IBDB', '[[Internet Broadway Database|IBDB]]', 1220, ibdbLink },
    { 'ISFDB', '[[Internet Speculative Fiction Database|ISFDB]]', 1233, isfdbIdLink },
    { 'LibriVoxAuth', '[[LibriVox|LibriVox]]', 1899, libriVoxAuthorLink },
    { 'Gutenberg', '[[Porjeto Gutenberg|Porjeto Gutenberg]]', 1938, GutenbergLink },
    { 'Grave', '[[Find a Grave|Find a Grave]]', 535, findGraveLink },
    { 'RKD', '[[RKD-Nederlands Instituut voor Kunstgeschiedenis|RKD]]', 650, rkdLink },
    { 'NLR', '[[Biblioteca Nacional de la Roménia|NLR]]', 1003, nlrLink },
    { 'Sycomore', '[[Assemblé Nacional Francesa|Sycomore]]', 1045, sycomoreLink },
    { 'CH', 'CH', 1047, chLink },
    { 'USCongress', '[[Biographical Directory of the United States Congress|US Congress]]', 1157, uscongressLink },
    { 'TLS', '[[Theaterlexikon der Schweiz|TLS]]', 1362, tlsLink },
    { 'SIKART', '[[SIKART|SIKART]]', 781, sikartLink },
    { 'KULTURNAV', '[[KulturNav]]', 1248, kulturnavLink },
    { 'BNE', '[[Biblioteca Nacional de la Spanha]]', 950, bneLink },
    { 'CINII', '[[CiNii|CiNii]]', 271, ciniiLink },
    { 'RKDartists', '[[RKD-Nederlands Instituut voor Kunstgeschiedenis|RKD]]', 650, rkdartistsLink },
    { 'WKMWL', "[[Biquipédia:Cuntrolo d'outorie|Biquipédia mirandesa]]", 0, wkmwlLink },
    { 'WKP', '[[:pt:Wikipédia:Controle de autoridade|Biquipédia lhusófona]]', 0, wkpLink },
}

-- Check that the Wikidata item has this property-->value before adding it
local reqs = {}

local p = {}

function p.authorityControl( frame )
    local parentArgs = frame:getParent().args
    --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.getEntityObject()
    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 canUseWikidata = nil
                    if reqs[params[1]] ~= nil then
                        canUseWikidata = matchesWikidataRequirements( item, reqs[params[1]] )
                    else
                        canUseWikidata = true
                    end
                    if canUseWikidata then
                        local wikidataIds = getIdsFromWikidata( item, 'P' .. params[3] )
                        if wikidataIds[1] then
                            parentArgs[params[1]] = wikidataIds[1]
                        end
                    end
                end
            end
        end
    end

    --Worldcat
    if parentArgs['WORLDCATID'] and parentArgs['WORLDCATID'] ~= '' then
        table.insert( elements, createRow( 'WORLDCATID', '', parentArgs['WORLDCATID'], '[//www.worldcat.org/identities/' .. parentArgs['WORLDCATID'] .. ' WorldCat Identities]', 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 Identities]', 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 Identities]', 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  = '[[Catadorie:!CA cun ' .. rct .. ' eilemientos]]'
    end

    if #elements ~= 0 then
        return Navbox._navbox( {
        name  = "Cuntrolo d'outorie",
        bodyclass = 'hlist',
        group1 = "[[Ajuda:Cuntrolo d'outorie|Cuntrolo d'outorie]]" .. elementscats,
        list1 = table.concat( elements )
        } )
        else
        return ""
    end
end

return p