Module:Autorité : Différence entre versions

De Lagny-sur-Marne Wiki
Aller à : navigation, rechercher
m
(technique sympathique mais maintenant superfétatoire)
 
(40 révisions intermédiaires par 5 utilisateurs non affichées)
Ligne 1 : Ligne 1 :
local function bneLink( id )
+
local wd = require('Module:Wikidata')
     if not string.match( id, '^XX%d%d%d%d%d%d%d?$' ) then
+
 
 +
local function bneUrl( id )
 +
     if not id:match( '^XX%d%d%d%d%d%d?%d?$' ) then
 
         return false
 
         return false
 
     end
 
     end
Ligne 6 : Ligne 8 :
 
end
 
end
  
local function sbnLink( id )
+
local function sbnUrl( 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
+
     if not id:match( '^IT\\ICCU\\%d%d%d%d%d%d%d%d%d%d$' ) and not id:match( '^IT\\ICCU\\%u%u[%d%u]%u\\%d%d%d%d%d%d$' ) then
 
         return false
 
         return false
 
     end
 
     end
Ligne 13 : Ligne 15 :
 
end
 
end
  
local function ndlLink( id )
+
local function ndlUrl( id )
     if not string.match( id, '^0?%d%d%d%d%d%d%d%d$' ) then
+
     if not id:match( '^0?%d%d%d%d%d%d%d%d$' ) then
 
         return false
 
         return false
 
     end
 
     end
Ligne 20 : Ligne 22 :
 
end
 
end
  
local function leonoreLink( id )
+
local function leonoreUrl( id )
 
-- Identifiants allant de LH/1/1 à LH/2794/54 (légionnaires)
 
-- 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 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)
 
-- 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
+
     if not id:match( '^LH/%d%d?%d?%d?/%d%d?%d?$' ) and
       not string.match( id, '^C/0/%d%d?$' ) and
+
       not id:match( '^C/0/%d%d?$' ) and
  not string.match( id, '^19800035/%d%d?%d?%d?/%d%d?%d?%d?%d?$' ) then
+
      not id:match( '^19800035/%d%d?%d?%d?/%d%d?%d?%d?%d?$' ) and
 +
      not id:match( '^19800035/%d%d?%d?%d?/%d%d?%d?%d?%d?Bis$' ) then
 
         return false
 
         return false
 
     end
 
     end
Ligne 61 : Ligne 64 :
 
end
 
end
  
local function isniLink( id )
+
local function isniUrl( id )
 
     id = validateIsni( id )
 
     id = validateIsni( id )
 
     if not id then
 
     if not id then
Ligne 69 : Ligne 72 :
 
end
 
end
  
local function orcidLink( id )
+
local function orcidUrl( id )
 
     id = validateIsni( id )
 
     id = validateIsni( id )
 
     if not id then
 
     if not id then
Ligne 78 : Ligne 81 :
 
end
 
end
  
local function ciniiLink( id )
+
local function ciniiUrl( id )
     return 'http://ci.nii.ac.jp/author/' .. id .. '?l=en'  
+
     return 'http://ci.nii.ac.jp/author/' .. id .. '?l=en'
 
end
 
end
  
local function ulanLink( id )
+
local function ulanUrl( id )
     if not string.match( id, '^%d%d?%d?%d?%d?%d?%d?%d?%d?$' ) then
+
     if not id:match( '^%d%d?%d?%d?%d?%d?%d?%d?%d?$' ) then
 
         return false
 
         return false
 
     end
 
     end
Ligne 89 : Ligne 92 :
 
end
 
end
  
local function sudocLink( id )
+
local function sudocUrl( id )
     if not string.match( id, '^%d%d%d%d%d%d%d%d[%dxX]$' ) then
+
     if not id:match( '^%d%d%d%d%d%d%d%d[%dxX]$' ) then
 
         return false
 
         return false
 
     end
 
     end
Ligne 96 : Ligne 99 :
 
end
 
end
  
local function bnfLink( id )
+
local function bnfUrls( id )
 
     --Add cb prefix if it has been removed
 
     --Add cb prefix if it has been removed
     if not string.match( id, '^cb.+$' ) then
+
     if not id:match( '^cb.+$' ) then
 
         id = 'cb' .. id
 
         id = 'cb' .. id
 
     end
 
     end
 
+
     return {
     return 'http://catalogue.bnf.fr/ark:/12148/' .. id
+
        'http://catalogue.bnf.fr/ark:/12148/' .. id,
 +
        'http://data.bnf.fr/ark:/12148/' .. id }
 
end
 
end
  
local function viafLink( id )
+
local function viafUrl( id )
     if not string.match( id, '^%d+$' ) then
+
     if not id:match( '^%d+$' ) then
 
         return false
 
         return false
 
     end
 
     end
Ligne 122 : Ligne 126 :
 
end
 
end
  
local function append(str, c, length)
+
local function padLeft( str, c, length )
     while str:len() < length do
+
     return c:rep( length - #str ) .. str
        str = c .. str
 
    end
 
    return str
 
 
end
 
end
  
local function lccnLink( id )
+
local function lccnUrl( id )
 
     local parts = splitLccn( id )
 
     local parts = splitLccn( id )
 
     if not parts then
 
     if not parts then
 
         return false
 
         return false
 
     end
 
     end
     id = parts[1] .. parts[2] .. append( parts[3], '0', 6 )
+
     id = parts[1] .. parts[2] .. padLeft( parts[3], '0', 6 )
 
     return 'http://id.loc.gov/authorities/' .. id
 
     return 'http://id.loc.gov/authorities/' .. id
 
end
 
end
  
local function gndLink( id )
+
local function gndUrl( id )
 
     return 'http://d-nb.info/gnd/' .. id
 
     return 'http://d-nb.info/gnd/' .. id
 
end
 
end
  
local function createRow( id, label, rawValue, link )
+
local function frenchsculptureUrl( id )
     if link then
+
    return 'http://frenchsculpture.org/fr/artist/' .. id
        local text = '<span class="nowrap uid">[' .. link .. ' ' .. label .. ']</span>'
+
end
         return text
+
 
 +
local function makeLink(url, label)
 +
     return '<span class="nowrap uid noarchive">[' .. url .. ' ' .. label .. ']</span>'
 +
end
 +
 
 +
local function createRow( id, label, rawValue, url )
 +
    if type(url) == 'table' then
 +
        return makeLink(url[1], label[1]) .. ' (' .. makeLink(url[2], label[2]) .. ')'
 +
    elseif url then
 +
         return makeLink(url, label)
 
     else
 
     else
    local cat = ''
+
        local cat = ''
    if mw.title.getCurrentTitle().namespace == 0 then
+
        if mw.title.getCurrentTitle().namespace == 0 then
    cat = '[[Catégorie:Page utilisant le modèle Autorité avec un paramètre erroné]]\n'
+
            cat = '[[Catégorie:Page utilisant le modèle Autorité avec un paramètre erroné]]\n'
    end
+
        end
         return '* <span class="error">L\'identifiant ' .. id .. ' ' .. rawValue .. ' n\'est pas valide.</span>' .. cat
+
         return '<span class="error">L\'identifiant ' .. id .. ' ' .. rawValue .. ' n\'est pas valide.</span>' .. cat
 
     end
 
     end
 
end
 
end
Ligne 160 : Ligne 170 :
 
         return ids
 
         return ids
 
     end
 
     end
     for _, statement in pairs( item.claims[property] ) do
+
     for _, statement in ipairs( item.claims[property] ) do
    if type( statement.mainsnak.datavalue ) == 'table' then
+
        if type( statement.mainsnak.datavalue ) == 'table' then
        table.insert( ids, statement.mainsnak.datavalue.value )
+
            table.insert( ids, statement.mainsnak.datavalue.value )
 
         end
 
         end
 
     end
 
     end
Ligne 170 : Ligne 180 :
 
--In this order: name of the parameter, label, propertyId in Wikidata, formatting function
 
--In this order: name of the parameter, label, propertyId in Wikidata, formatting function
 
local conf = {
 
local conf = {
     { 'VIAF', 'Fichier d’autorité international virtuel', 214, viafLink },
+
     { 'VIAF', 'Fichier d\'autorité international virtuel', 214, viafUrl },
     { 'ISNI', 'International Standard Name Identifier', 213, isniLink },
+
     { 'ISNI', 'International Standard Name Identifier', 213, isniUrl },
     { 'ORCID', 'ORCID', 496, orcidLink },  
+
     { 'ORCID', 'ORCID', 496, orcidUrl },
     { 'CINII', 'CiNii', 271, ciniiLink },
+
     { 'CINII', 'CiNii', 271, ciniiUrl },
     { 'ULAN', 'Union List of Artist Names', 245, ulanLink },  
+
     { 'ULAN', 'Union List of Artist Names', 245, ulanUrl },
     { 'BNF', 'Bibliothèque nationale de France', 268, bnfLink },
+
     { 'BNF', { 'Bibliothèque nationale de France', 'données' }, 268, bnfUrls },
     { 'SUDOC', 'Système universitaire de documentation', 269, sudocLink },
+
     { 'SUDOC', 'Système universitaire de documentation', 269, sudocUrl },
     { 'LCCN', 'Bibliothèque du Congrès', 244, lccnLink },
+
     { 'LCCN', 'Bibliothèque du Congrès', 244, lccnUrl },
     { 'GND', 'Gemeinsame Normdatei', 227, gndLink },
+
     { 'GND', 'Gemeinsame Normdatei', 227, gndUrl },
     { 'SBN', 'Institut central pour le registre unique', 396, sbnLink },  
+
     { 'SBN', 'Service bibliothécaire national', 396, sbnUrl },
     { 'NDL', 'Bibliothèque nationale de la Diète', 349, ndlLink },  
+
     { 'NDL', 'Bibliothèque nationale de la Diète', 349, ndlUrl },
     { 'BNE', 'Bibliothèque nationale d\'Espagne', 950, bneLink },  
+
     { 'BNE', 'Bibliothèque nationale d\'Espagne', 950, bneUrl },
     { 'Léonore', 'Base Léonore', 640, leonoreLink }, -- Légion d'honneur de la France
+
     { 'Léonore', 'Base Léonore', 640, leonoreUrl }, -- Légion d'honneur de la France
     { 'SWD', 'Schlagwortnormdatei', 0, swdLink },
+
     { 'French Sculpture Census ID', 'Répertoire de sculpture française', 2380, frenchsculptureUrl },
 
}
 
}
   
+
 
 
local p = {}
 
local p = {}
  
 
function p.authorityControl( frame )
 
function p.authorityControl( frame )
     local parentArgs = frame:getParent().args
+
     local args = frame:getParent().args
     --Create rows
+
 
     local elements = {}
+
     --Build a map of valid local arguments
     local isDepreciated = false --S'il y a un id déprécié
+
     local goodArgs = {}
 +
     for _, params in ipairs( conf ) do
 +
        goodArgs[params[1]] = true
 +
    end
 +
    goodArgs.WORLDCATID = true
 +
    goodArgs.entity = true
  
     --Redirection des identifiants de la Bibliothèque Nationale d'Allemagne vers GND
+
     local hasLocalArgs = false
     if parentArgs.GND == nil or parentArgs.GND == '' then
+
     local hasInvalidArgs = false
         if parentArgs.DNB ~= nil and parentArgs.DNB ~= '' then
+
    for name, value in pairs( args ) do
            parentArgs.GND = parentArgs.DNB
+
         if name ~= 'entity' then --"entity" parameter doesn't add to category
            isDepreciated = true
+
             hasLocalArgs = true
        elseif parentArgs.PND ~= nil and parentArgs.PND ~= '' then
 
            parentArgs.GND = parentArgs.PND
 
            isDepreciated = true
 
        elseif parentArgs.GKD ~= nil and parentArgs.GKD ~= '' then
 
            parentArgs.GND = parentArgs.GKD
 
            isDepreciated = true
 
        elseif parentArgs['GKD-V1'] ~= nil and parentArgs['GKD-V1'] ~= '' then
 
            parentArgs.GND = parentArgs['GKD-V1']
 
             isDepreciated = true
 
 
         end
 
         end
 +
        if not goodArgs[name] then
 +
            hasInvalidArgs = true
 +
        end
 +
    end
 +
 +
    --Get the Wikidata item
 +
    local entity = nil --Current page
 +
    if args.entity and args.entity ~= '' then
 +
        entity = args.entity
 
     end
 
     end
      
+
     local item = mw.wikibase.getEntity(entity)
 +
 
 
     --Wikidata fallback if requested
 
     --Wikidata fallback if requested
    local item = mw.wikibase.getEntityObject()
+
     if item and item.claims then
     if item ~= nil and item.claims ~= nil then
+
         for _, params in ipairs( conf ) do
         for _, params in pairs( conf ) do
 
 
             if params[3] ~= 0 then
 
             if params[3] ~= 0 then
                 local val = parentArgs[params[1]]
+
                 local val = args[params[1]]
 
                 if not val or val == '' then
 
                 if not val or val == '' then
 
                     local wikidataIds = getIdsFromWikidata( item, 'P' .. params[3] )
 
                     local wikidataIds = getIdsFromWikidata( item, 'P' .. params[3] )
 
                     if wikidataIds[1] then
 
                     if wikidataIds[1] then
                         parentArgs[params[1]] = wikidataIds[1]
+
                         args[params[1]] = wikidataIds[1]
 
                     end
 
                     end
 
                 end
 
                 end
Ligne 226 : Ligne 241 :
 
         end
 
         end
 
     end
 
     end
 +
 +
    --Create rows
 +
    local elements = {}
  
 
     --Configured rows
 
     --Configured rows
     for _, params in pairs( conf ) do
+
     for _, params in ipairs( conf ) do
         local val = parentArgs[params[1]]
+
         local val = args[params[1]]
+
 
 
         if val and val ~= '' then
 
         if val and val ~= '' then
             table.insert( elements, createRow( params[1], params[2], val, params[4]( val ) ) )
+
             elements[#elements+1] = createRow( params[1], params[2], val, params[4]( val ) )
 
         end
 
         end
 
     end
 
     end
  
 
     --Worldcat
 
     --Worldcat
     if parentArgs['WORLDCATID'] and parentArgs['WORLDCATID'] ~= '' then
+
     if args['WORLDCATID'] and args['WORLDCATID'] ~= '' then
         table.insert( elements, createRow( 'WORLDCATID', 'WorldCat', parentArgs['WORLDCATID'], 'http://www.worldcat.org/identities/' .. parentArgs['WORLDCATID'] ) ) --Validation?
+
         elements[#elements+1] = createRow( 'WORLDCATID', 'WorldCat', args['WORLDCATID'], 'http://www.worldcat.org/identities/' .. args['WORLDCATID'] ) --Validation?
     elseif parentArgs['LCCN'] and parentArgs['LCCN'] ~= '' then
+
     elseif args['LCCN'] and args['LCCN'] ~= '' then
         local lccnParts = splitLccn( parentArgs['LCCN'] )
+
         local lccnParts = splitLccn( args['LCCN'] )
         if lccnParts then
+
         if lccnParts and lccnParts[1] ~= 'sh' then
             table.insert( elements, createRow( 'LCCN', 'WorldCat', parentArgs['LCCN'], 'http://www.worldcat.org/identities/lccn-' .. lccnParts[1] .. lccnParts[2] .. '-' .. lccnParts[3] ) )
+
             elements[#elements+1] = createRow( 'LCCN', 'WorldCat', args['LCCN'], 'http://www.worldcat.org/identities/lccn-' .. lccnParts[1] .. lccnParts[2] .. '-' .. lccnParts[3] )
 +
        end
 +
    end
 +
 
 +
    local entityInfo = ''
 +
    if entity and item then --Has "entity" parameter, Wikidata item was found
 +
        local label = item:getLabel()
 +
        if label then
 +
            entityInfo = ' (pour [[' .. label .. ']])'
 
         end
 
         end
 
     end
 
     end
  
     local str = ''
+
     local cats = "[[Catégorie:Article de Wikipédia avec notice d'autorité]]"
     if isDepreciated then
+
     if hasLocalArgs then
         str = str .. '[[Catégorie:Page utilisant le modèle Autorité avec un paramètre obsolète]]\n'
+
         cats = cats .. '[[Catégorie:Page utilisant le modèle Autorité avec un paramètre local]]'
 
     end
 
     end
     if next(frame:getParent().args) ~= nil then
+
     if hasInvalidArgs then
         str = str .. '[[Catégorie:Page utilisant le modèle Autorité avec un paramètre local]]\n'
+
         cats = cats .. '[[Catégorie:Page utilisant le modèle Autorité avec un paramètre invalide]]'
 
     end
 
     end
     return "* ''[[Autorité (sciences de l'information)|Notices d’autorité]]'' : " .. table.concat( elements, '&nbsp;• ' ) .. str
+
     return wd.addLinkback( "''[[Autorité (sciences de l'information)|Notices d'autorité]]''" .. entityInfo, entity, "identifiers" ) .. " : " .. table.concat( elements, '&nbsp;• ' ) .. cats
 
end
 
end
  
 
return p
 
return p

Version actuelle datée du 15 janvier 2017 à 02:39

La documentation pour ce module peut être créée à Module:Autorité/doc

local wd = require('Module:Wikidata')

local function bneUrl( id )
    if not id:match( '^XX%d%d%d%d%d%d?%d?$' ) then
        return false
    end
    return 'http://catalogo.bne.es/uhtbin/authoritybrowse.cgi?action=display&authority_id=' .. id
end

local function sbnUrl( id )
    if not id:match( '^IT\\ICCU\\%d%d%d%d%d%d%d%d%d%d$' ) and not id:match( '^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
end

local function ndlUrl( id )
    if not id:match( '^0?%d%d%d%d%d%d%d%d$' ) then
        return false
    end
    return 'http://id.ndl.go.jp/auth/ndlna/' .. id
end

local function leonoreUrl( 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 id:match( '^LH/%d%d?%d?%d?/%d%d?%d?$' ) and
       not id:match( '^C/0/%d%d?$' ) and
       not id:match( '^19800035/%d%d?%d?%d?/%d%d?%d?%d?%d?$' ) and
       not id:match( '^19800035/%d%d?%d?%d?/%d%d?%d?%d?%d?Bis$' ) then
        return false
    end
    return 'http://www.culture.gouv.fr/public/mistral/leonore_fr?ACTION=CHERCHER&FIELD_1=COTE&VALUE_1=' .. id
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 isniUrl( id )
    id = validateIsni( id )
    if not id then
        return false
    end
    return 'http://isni.org/isni/' .. id
end

local function orcidUrl( 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
end

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

local function ulanUrl( id )
    if not id:match( '^%d%d?%d?%d?%d?%d?%d?%d?%d?$' ) then
        return false
    end
    return '//www.getty.edu/vow/ULANFullDisplay?find=&role=&nation=&subjectid=' .. id
end

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

local function bnfUrls( id )
    --Add cb prefix if it has been removed
    if not id:match( '^cb.+$' ) then
        id = 'cb' .. id
    end
    return {
        'http://catalogue.bnf.fr/ark:/12148/' .. id,
        'http://data.bnf.fr/ark:/12148/' .. id }
end

local function viafUrl( id )
    if not id:match( '^%d+$' ) then
        return false
    end
    return 'http://viaf.org/viaf/' .. 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 padLeft( str, c, length )
    return c:rep( length - #str ) .. str
end

local function lccnUrl( id )
    local parts = splitLccn( id )
    if not parts then
        return false
    end
    id = parts[1] .. parts[2] .. padLeft( parts[3], '0', 6 )
    return 'http://id.loc.gov/authorities/' .. id
end

local function gndUrl( id )
    return 'http://d-nb.info/gnd/' .. id
end

local function frenchsculptureUrl( id )
    return 'http://frenchsculpture.org/fr/artist/' .. id
end

local function makeLink(url, label)
    return '<span class="nowrap uid noarchive">[' .. url .. ' ' .. label .. ']</span>'
end

local function createRow( id, label, rawValue, url )
    if type(url) == 'table' then
        return makeLink(url[1], label[1]) .. ' (' .. makeLink(url[2], label[2]) .. ')'
    elseif url then
        return makeLink(url, label)
    else
        local cat = ''
        if mw.title.getCurrentTitle().namespace == 0 then
            cat = '[[Catégorie:Page utilisant le modèle Autorité avec un paramètre erroné]]\n'
        end
        return '<span class="error">L\'identifiant ' .. id .. ' ' .. rawValue .. ' n\'est pas valide.</span>' .. cat
    end
end

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

--In this order: name of the parameter, label, propertyId in Wikidata, formatting function
local conf = {
    { 'VIAF', 'Fichier d\'autorité international virtuel', 214, viafUrl },
    { 'ISNI', 'International Standard Name Identifier', 213, isniUrl },
    { 'ORCID', 'ORCID', 496, orcidUrl },
    { 'CINII', 'CiNii', 271, ciniiUrl },
    { 'ULAN', 'Union List of Artist Names', 245, ulanUrl },
    { 'BNF', { 'Bibliothèque nationale de France', 'données' }, 268, bnfUrls },
    { 'SUDOC', 'Système universitaire de documentation', 269, sudocUrl },
    { 'LCCN', 'Bibliothèque du Congrès', 244, lccnUrl },
    { 'GND', 'Gemeinsame Normdatei', 227, gndUrl },
    { 'SBN', 'Service bibliothécaire national', 396, sbnUrl },
    { 'NDL', 'Bibliothèque nationale de la Diète', 349, ndlUrl },
    { 'BNE', 'Bibliothèque nationale d\'Espagne', 950, bneUrl },
    { 'Léonore', 'Base Léonore', 640, leonoreUrl }, -- Légion d'honneur de la France
    { 'French Sculpture Census ID', 'Répertoire de sculpture française', 2380, frenchsculptureUrl },
}

local p = {}

function p.authorityControl( frame )
    local args = frame:getParent().args

    --Build a map of valid local arguments
    local goodArgs = {}
    for _, params in ipairs( conf ) do
        goodArgs[params[1]] = true
    end
    goodArgs.WORLDCATID = true
    goodArgs.entity = true

    local hasLocalArgs = false
    local hasInvalidArgs = false
    for name, value in pairs( args ) do
        if name ~= 'entity' then --"entity" parameter doesn't add to category
            hasLocalArgs = true
        end
        if not goodArgs[name] then
            hasInvalidArgs = true
        end
    end

    --Get the Wikidata item
    local entity = nil --Current page
    if args.entity and args.entity ~= '' then
        entity = args.entity
    end
    local item = mw.wikibase.getEntity(entity)

    --Wikidata fallback if requested
    if item and item.claims then
        for _, params in ipairs( conf ) do
            if params[3] ~= 0 then
                local val = args[params[1]]
                if not val or val == '' then
                    local wikidataIds = getIdsFromWikidata( item, 'P' .. params[3] )
                    if wikidataIds[1] then
                        args[params[1]] = wikidataIds[1]
                    end
                end
            end
        end
    end

    --Create rows
    local elements = {}

    --Configured rows
    for _, params in ipairs( conf ) do
        local val = args[params[1]]

        if val and val ~= '' then
            elements[#elements+1] = createRow( params[1], params[2], val, params[4]( val ) )
        end
    end

    --Worldcat
    if args['WORLDCATID'] and args['WORLDCATID'] ~= '' then
        elements[#elements+1] = createRow( 'WORLDCATID', 'WorldCat', args['WORLDCATID'], 'http://www.worldcat.org/identities/' .. args['WORLDCATID'] ) --Validation?
    elseif args['LCCN'] and args['LCCN'] ~= '' then
        local lccnParts = splitLccn( args['LCCN'] )
        if lccnParts and lccnParts[1] ~= 'sh' then
            elements[#elements+1] = createRow( 'LCCN', 'WorldCat', args['LCCN'], 'http://www.worldcat.org/identities/lccn-' .. lccnParts[1] .. lccnParts[2] .. '-' .. lccnParts[3] )
        end
    end

    local entityInfo = ''
    if entity and item then --Has "entity" parameter, Wikidata item was found
        local label = item:getLabel()
        if label then
            entityInfo = ' (pour [[' .. label .. ']])'
        end
    end

    local cats = "[[Catégorie:Article de Wikipédia avec notice d'autorité]]"
    if hasLocalArgs then
        cats = cats .. '[[Catégorie:Page utilisant le modèle Autorité avec un paramètre local]]'
    end
    if hasInvalidArgs then
        cats = cats .. '[[Catégorie:Page utilisant le modèle Autorité avec un paramètre invalide]]'
    end
    return wd.addLinkback( "''[[Autorité (sciences de l'information)|Notices d'autorité]]''" .. entityInfo, entity, "identifiers" ) .. " : " .. table.concat( elements, '&nbsp;• ' ) .. cats
end

return p