مودول:ضبط مخازني

من ويكيپيديا

الوصف[بدل لكود]

هذا القالب يربط مقالات ويكيبيديا بمختلف أنظمة الفهرسة المكتبية، حيث يستخدم هذا القالب معظم بياناته من ويكي بيانات، ولكن ذلك يمكن تجاوزه عند إدخال البيانات في القالب.

أنواع البيانات[بدل لكود]

ملفات الضبط الاستنادي المدعومة
ملف استنادي دولي افتراضي (VIAF)
رقم الضبط في مكتبة الكونغرس (LCCN)
المحدد المعياري الدولي للأسماء (ISNI)
هوية مفتوحة للباحثين والمساهمين (ORCID)
ملف استنادي متكامل (Gemeinsame Normdatei أو GND)
ليبريس by the المكتبة الوطنية السويدية (SELIBR)
النظام الجامعي للتوثيق (Système universitaire de documentation أو SUDOC)
مكتبة فرنسا الوطنية (Bibliothèque nationale de France أو BNF)
موضيل:Ill-WD2 (Biografisch Portaal أو BPN)
معرف الباحث (RID)
BIBSYS (BIBSYS)
قائمة الاتحاد لأسماء الفنانين (ULAN)
ميوزك برينز (MBA)
المكتبة الوطنية الأسترالية (NLA)
مكتبة البرلمان الياباني الوطنية (NDL)
... (بالإضافة إلى أكثر من 30+ مصدر، انظر مودول:ضبط استنادي)

الاستخدام[بدل لكود]

Empty (reliant wholly on Wikidata)
{{ضبط استنادي}}
Full
{{ضبط استنادي|VIAF=xxxxxx |LCCN=n/xx/xxxxxx |ISNI=xxxx xxxx xxxx xxxx |ORCID=xxxx-xxxx-xxxx-xxxx |GND=xxxxxx |SELIBR=xxxxxx |SUDOC=xxxxxxxxx |BNF=xxxxxx |BPN=xxxxx |RID=xxxxx |BIBSYS=xxxxx |ULAN=xxxxx |MBA=xxxxxx |NLA=xxxxxxx |NDL=xxxxxxxx}}
Blank
{{ضبط استنادي|VIAF= |LCCN= |ISNI= |ORCID= |GND= |SELIBR= |SUDOC= |BNF= |BPN= |RID= |BIBSYS= |ULAN= |MBA= |NLA= |NDL=}}

تصانيف[بدل لكود]

تصانيف تتبع

ويكي بيانات[بدل لكود]

The template can get its information from the following properties on ويكي بيانات:

معلمة نوع معرف الخاصية
VIAF ملف استنادي دولي افتراضي إدونتيفيكاتور مخازني ڤيرتوالي دولي (VIAF) (P214)
LCCN رقم الضبط في مكتبة الكونغرس إدونتيفيكاتور د لمكتابة د لكونڭريس (P244)
ISNI المحدد المعياري الدولي للأسماء إدونتيفيكاتور معياري دولي د السميات (ISNI) (P213)
ORCID هوية مفتوحة للباحثين والمساهمين إدونتيفيكاتور د ؤرسيد (ORCID) (P496)
GND ملف استنادي متكامل إدونتيفيكاتور د الضوسي لمخازني لمتكامل (GND) (P227)
SELIBR ليبريس إدونتيفيكاتور ديال لمكتابة لوطنية د السويد (LIBRIS) (P906)
SUDOC النظام الجامعي للتوثيق مُعرِّف النظام الجامعي للتوثيق (IdRef) (P269)
BNF مكتبة فرنسا الوطنية إدونتيفيكاتور د لمكتابة لوطنية لفرانساوية (BnF) (P268)
BPN موضيل:Ill-WD2 إدونتيفيكاتور ديال بوابة السيرة الداتية د هولاندا (P651)
ULAN قائمة الاتحاد لأسماء الفنانين إدونتيفيكاتور ديال الليستة د تيحاد سميات لفنانين (P245)
MBA MBID مُعرِّف فنَّان في موسوعة "ميوزيك برينز" (MusicBrainz) (P434)
NLA المكتبة الوطنية الأسترالية إدونتيفيكاتور ديال لمكتبة لوطنية لؤسطرالية (NLA) (P409)
NDL مكتبة البرلمان الياباني الوطنية مُعرِّف مكتبة البرلمان القومي الياباني (NDL) (P349)
BIBSYS BIBSYS إدونتيفيكاتور ديال نيضام الضبط لمخازني النورڤيجي (BIBSYS) (P1015)
RID RID إدونتيفيكاتور د لباحت (RID) (P1053)
RKDartists معهد هولندا لتاريخ الفن إدونتيفيكاتور د لباحت (RID) (P1053)
AUC AUC إدونتيفيكاتور د لباحت (RID) (P1053)

طالع ايضاً[بدل لكود]

وصلات خارجية[بدل لكود]

Maintenance reports


خواص ويكي بيانات المستخدمة في قالب:ضبط استنادي
الخاصية وصفها تصنيف تتبع الاستخدام
مُعرِّف ملف الضبط الاستنادي الافتراضي الدَّولي (VIAF) (P214) (معرف خارجي) معرف قاعدة بيانات الملف للسلطة الافتراضية الدولية (VIAF) [الصيغة: حتى 22 رقما]

require('Module:No globals')
local p = {}
local properties_id = {}
local function getCatForId( id, cate )
    local title = mw.title.getCurrentTitle()
    local namespace = title.namespace
	local namespace1 = '[[تصنيف:مقالات فيها موحديدات ' .. id .. ']]'
	--local namespace1 = '[[تصنيف:پاجات كاتخدم خاصية ديال ' .. id .. ']]'
	if cate and cate ~='' 
		then namespace1 = '[[category:' .. cate .. ']]'
	else 
		if properties_id[id] then
			namespace1 =   '[[تصنيف:پاجات كاتخدم خاصية ديال ' .. properties_id[id] .. ']]'
		end
	end
    local namespace2= '[[تصنيف:پاجات مستخدمين فيها موحديدات ' .. id .. ']]'
    local namespace3= '[[تصنيف:صفحات متفرقة فيها موحديدات ' .. id .. ']]'
    if namespace == 0 then
        return namespace1
    elseif namespace == 2 and not title.isSubpage then
        return namespace2
    else
        return namespace3
    end
end

local function ntaLink( id )
	--P1006's format regex: \d{8}[\dX] (e.g. 12345678X)
	if not id:match( '^%d%d%d%d%d%d%d%d[%dX]$' ) then
		return false
	end
	return '[http://data.bibliotheken.nl/id/thes/p'..id..' '..id..']'.. getCatForId( 'NTA' )
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 UNdocumentsymbol( id )
    return '[https://undocs.org/' .. id .. ' ' .. id .. ']' .. getCatForId( '', 'رمز د وتيقة د لأمم لمتحدة من ويكيداطا' )
end
local function sikartLink( id )
    return '[http://www.sikart.ch/KuenstlerInnen.aspx?id=' .. id .. '&lng=en ' .. id .. ']' 
end

local function egaxaLink( id )
    return  '[http://viaf.org/processed/EGAXA%7Cvtls' .. id .. ' ' .. id .. ']' .. getCatForId( 'EGAXA' )
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 bneLink( id )
    return '[http://catalogo.bne.es/uhtbin/authoritybrowse.cgi?action=display&authority_id=' .. id .. ' ' .. 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 IPNILink( id )
    return '[http://www.ipni.org/ipni/idAuthorSearch.do?id=' .. 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?$') and
	   not string.match( id, '"%d*') then --added regex due to bug 19.02.2022
        return false
    end
    return '[//www.culture.gouv.fr/public/mistral/leonore_fr?ACTION=CHERCHER&FIELD_1=COTE&VALUE_1=' .. 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 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 LNLLink( id )
	return '[http://viaf.org/processed/LNL%7C'..id..' '..id..']'..getCatForId( 'LNL' )
end
local function aagLink( id )
	--P3372's format regex: \d+ (e.g. 1)
	if not id:match( '^%d+$' ) then
		return false
	end
	return '[https://www.aucklandartgallery.com/explore-art-and-ideas/artist/'..id..'/ '..id..']'..getCatForId( 'AAG' )
end

local function acmLink( id )
	--P864's format regex: \d{11} (e.g. 12345678901)
	if not id:match( '^%d%d%d%d%d%d%d%d%d%d%d$' ) then
		return false
	end
	return '[https://dl.acm.org/profile/'..id..' '..id..']'..getCatForId( 'ACM-DL' )
end

local function adbLink( id )
	--P1907's format regex: [a-z][-a-z]+-([1-2]\d|[1-9])\d{0,3} (e.g. barton-sir-edmund-toby-71)
	if not id:match( '^[a-z][-a-z]+-[1-2]%d%d?%d?%d?$' ) and
	   not id:match( '^[a-z][-a-z]+-[1-9]%d?%d?%d?$' ) then
		return false
	end
	return '[http://adb.anu.edu.au/biography/'..id..' '..id..']'..getCatForId( 'ADB' )
end

local function agsaLink( id )
	--P6804's format regex: [1-9]\d* (e.g. 3625)
	if not id:match( '^[1-9]%d*$' ) then
		return false
	end
	return '[https://www.agsa.sa.gov.au/collection-publications/collection/creators/_/'..id..'/ '..id..']'..getCatForId( 'AGSA' )
end

local function autoresuyLink( id )
	--P2558's format regex: [1-9]\d{0,4} (e.g. 12345)
	if not id:match( '^[1-9]%d?%d?%d?%d?$' ) then
		return false
	end
	return '[https://autores.uy/autor/'..id..' '..id..']'..getCatForId( 'autores.uy' )
end

local function awrLink( id )
	--P4186's format regex: (([A-Z]{3}\d{4})|([A-Z]{2}\d{5}))[a-z] (e.g. PR00768b)
	if not id:match( '^[A-Z][A-Z][A-Z]%d%d%d%d[a-z]$' ) and
	   not id:match( '^[A-Z][A-Z]%d%d%d%d%d[a-z]$' ) then
		return false
	end
	return '[http://www.womenaustralia.info/biogs/'..id..'.htm '..id..']'..getCatForId( 'AWR' )
end

local function balatLink( id )
	--P3293's format regex: \d+ (e.g. 1)
	if not id:match( '^%d+$' ) then
		return false
	end
	return '[http://balat.kikirpa.be/object/104257'..id..' '..id..']'..getCatForId( 'BALaT' ) --no https as of 9/2019
end



local function bildLink( id )
	--P2092's format regex: \d+ (e.g. 1)
	if not id:match( '^%d+$' ) then
		return false
	end
	return '[https://www.bildindex.de/document/obj'..id..' '..id..']'..getCatForId( 'Bildindex' )
end

local function bncLink( id )
	--P1890's format regex: \d{9} (e.g. 123456789)
	if not id:match( '^%d%d%d%d%d%d%d%d%d$' ) then
		return false
	end
	return '[http://www.bncatalogo.cl/F?func=direct&local_base=red10&doc_number='..id..' '..id..']'..getCatForId( 'BNC' )
end

local function canticLink( id )
	--P1273's format regex: a\d{7}[0-9x] (e.g. a10640745)
	if not id:match( '^a%d%d%d%d%d%d%d[%dx]$' ) then
		return false
	end
	return '[http://cantic.bnc.cat/registres/CUCId/'..id..' '..id..']'..getCatForId( 'CANTIC' ) --no https as of 10/2019
end

local function daaoLink( id )
	--P1707's format regex: [a-z\-]+\d* (e.g. rolf-harris)
	if not id:match( '^[a-z%-]+%d*$' ) then
		return false
	end
	return '[https://www.daao.org.au/bio/'..id..' '..id..']'..getCatForId( 'DAAO' )
end

local function dblpLink( id )
	--P2456's format regex: \d{2,3} /\d+(-\d+)?|[a-z] /[a-zA-Z][0-9A-Za-z]*(-\d+)? (e.g. 123/123)
	if not id:match( '^%d%d%d?/%d+$' ) and
	   not id:match( '^%d%d%d?/%d+%-%d+$' ) and
	   not id:match( '^[a-z]/[a-zA-Z][0-9A-Za-z]*$' ) and
	   not id:match( '^[a-z]/[a-zA-Z][0-9A-Za-z]*%-%d+$' ) then
		return false
	end
	return '[https://dblp.org/pid/'..id..' '..id..']'..getCatForId( 'DBLP' )
end

local function dsiLink( id )
	--P2349's format regex: [1-9]\d* (e.g. 1538)
	if not id:match( '^[1-9]%d*$' ) then
		return false
	end
	return '[http://www.uni-stuttgart.de/hi/gnt/dsi2/index.php?table_name=dsi&function=details&where_field=id&where_value='..id..' '..id..']'..getCatForId( 'DSI' )
end

local function fnzaLink( id )
	--P6792's format regex: [1-9]\d* (e.g. 9785)
	if not id:match( '^[1-9]%d*$' ) then
		return false
	end
	return '[https://findnzartists.org.nz/artist/'..id..'/ '..id..']'..getCatForId( 'FNZA' )
end


local function hdsLink( id )
	--P902's format regex: \d{6} (e.g. 050123)
	if not id:match( '^%d%d%d%d%d%d$' ) then
		return false
	end
	return '[https://hls-dhs-dss.ch/fr/articles/'..id..' '..id..']'..getCatForId( 'HDS' )
end

local function iaafLink( id )
	--P1146's format regex: [0-9][0-9]* (e.g. 012)
	if not id:match( '^%d+$' ) then
		return false
	end
	return '[https://www.iaaf.org/athletes/_/'..id..' '..id..']'..getCatForId( 'IAAF' )
end

local function iciaLink( id )
	--P1736's format regex: \d+ (e.g. 1)
	if not id:match( '^%d+$' ) then
		return false
	end
	return '[https://www.imj.org.il/artcenter/newsite/en/?artist='..id..' '..id..']'..getCatForId( 'ICIA' )
end


local function jocondeLink( id )
	--P347's format regex: [\-0-9A-Za-z]{11} (e.g. 12345678901)
	local regex = '^'..string.rep('[%-0-9A-Za-z]', 11)..'$'
	if not id:match( regex ) then
		return false
	end
	return '[https://www.pop.culture.gouv.fr/notice/joconde/'..id..' '..id..']'..getCatForId( 'Joconde' )
end



local function lnbLink( id )
	--P1368's format regex: \d{9} (e.g. 123456789)
	if not id:match( '^%d%d%d%d%d%d%d%d%d$' ) then
		return false
	end
	return '[https://kopkatalogs.lv/F?func=direct&local_base=lnc10&doc_number='..id..'&P_CON_LNG=ENG '..id..']'..getCatForId( 'LNB' )
end

local function aagLink( id )
	--P3372's format regex: \d+ (e.g. 1)
	if not id:match( '^%d+$' ) then
		return false
	end
	return '[https://www.aucklandartgallery.com/explore-art-and-ideas/artist/'..id..'/ '..id..']'.. getCatForId( 'AAG' )
end

local function mbaLink( id )
	--P434's format regex: [0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12} (e.g. 12345678-1234-1234-1234-1234567890AB)
	if not id:match( '^%x%x%x%x%x%x%x%x%-%x%x%x%x%-%x%x%x%x%-%x%x%x%x%-%x%x%x%x%x%x%x%x%x%x%x%x$' ) then
		return false
	end
	return '[https://musicbrainz.org/artist/'..id..' '..id..']'..getCatForId( 'MusicBrainz' ) --special category name
end

local function mbareaLink( id )
	--P982's format regex: [0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12} (e.g. 12345678-1234-1234-1234-1234567890AB)
	if not id:match( '^%x%x%x%x%x%x%x%x%-%x%x%x%x%-%x%x%x%x%-%x%x%x%x%-%x%x%x%x%x%x%x%x%x%x%x%x$' ) then
		return false
	end
	return '[https://musicbrainz.org/area/'..id..' '..id..']'..getCatForId( 'MusicBrainz area' ) --special category name
end

local function mbiLink( id )
	--P1330's format regex: [0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12} (e.g. 12345678-1234-1234-1234-1234567890AB)
	if not id:match( '^%x%x%x%x%x%x%x%x%-%x%x%x%x%-%x%x%x%x%-%x%x%x%x%-%x%x%x%x%x%x%x%x%x%x%x%x$' ) then
		return false
	end
	return '[https://musicbrainz.org/instrument/'..id..' '..id..']'..getCatForId( 'MusicBrainz instrument' ) --special category name
end

local function mblLink( id )
	--P966's format regex: [0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12} (e.g. 12345678-1234-1234-1234-1234567890AB)
	if not id:match( '^%x%x%x%x%x%x%x%x%-%x%x%x%x%-%x%x%x%x%-%x%x%x%x%-%x%x%x%x%x%x%x%x%x%x%x%x$' ) then
		return false
	end
	return '[https://musicbrainz.org/label/'..id..' '..id..']'..getCatForId( 'MusicBrainz label' ) --special category name
end

local function mbpLink( id )
	--P1004's format regex: [0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12} (e.g. 12345678-1234-1234-1234-1234567890AB)
	if not id:match( '^%x%x%x%x%x%x%x%x%-%x%x%x%x%-%x%x%x%x%-%x%x%x%x%-%x%x%x%x%x%x%x%x%x%x%x%x$' ) then
		return false
	end
	return '[https://musicbrainz.org/place/'..id..' '..id..']'..getCatForId( 'MusicBrainz place' ) --special category name
end

local function mbrgLink( id )
	--P436's format regex: [0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12} (e.g. 12345678-1234-1234-1234-1234567890AB)
	if not id:match( '^%x%x%x%x%x%x%x%x%-%x%x%x%x%-%x%x%x%x%-%x%x%x%x%-%x%x%x%x%x%x%x%x%x%x%x%x$' ) then
		return false
	end
	return '[https://musicbrainz.org/release-group/'..id..' '..id..']'..getCatForId( 'MusicBrainz release group' ) --special category name
end

local function mbsLink( id )
	--P1407's format regex: [0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12} (e.g. 12345678-1234-1234-1234-1234567890AB)
	if not id:match( '^%x%x%x%x%x%x%x%x%-%x%x%x%x%-%x%x%x%x%-%x%x%x%x%-%x%x%x%x%x%x%x%x%x%x%x%x$' ) then
		return false
	end
	return '[https://musicbrainz.org/series/'..id..' '..id..']'..getCatForId( 'MusicBrainz series' ) --special category name
end

local function mbwLink( id )
	--P435's format regex: [0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12} (e.g. 12345678-1234-1234-1234-1234567890AB)
	if not id:match( '^%x%x%x%x%x%x%x%x%-%x%x%x%x%-%x%x%x%x%-%x%x%x%x%-%x%x%x%x%x%x%x%x%x%x%x%x$' ) then
		return false
	end
	return '[https://musicbrainz.org/work/'..id..' '..id..']'..getCatForId( 'MusicBrainz work' ) --special category name
end


local function naraLink( id )
	--P1225's format regex: ^([1-9]\d{0,8})$ (e.g. 123456789)
	if not id:match( '^[1-9]%d?%d?%d?%d?%d?%d?%d?%d?$' ) then
		return false
	end
	return '[https://catalog.archives.gov/id/'..id..' '..id..']'..getCatForId( 'NARA' )
end

local function ngvLink( id )
	--P2041's format regex: \d+ (e.g. 12354)
	if not id:match( '^%d+$' ) then
		return false
	end
	return '[https://www.ngv.vic.gov.au/explore/collection/artist/'..id..'/ '..id..']'..getCatForId( 'NGV' )
end

local function nlgLink( id )
	--P3348's format regex: [1-9]\d* (e.g. 1)
	if not id:match( '^[1-9]%d*$' ) then
		return false
	end
	return '[https://data.nlg.gr/resource/authority/record'..id..' '..id..']'..getCatForId( 'NLG' )
end

local function nliLink( id )
	--P949's format regex: \d{9} (e.g. 123456789)
	if not id:match( '^%d%d%d%d%d%d%d%d%d$' ) then
		return false
	end
	return '[http://uli.nli.org.il/F/?func=direct&doc_number='..id..'&local_base=nlx10'..' '..id..']'..getCatForId( 'NLI' )
end

local function nlkLink( id )
	--P5034's format regex: KA.(19|20).{7} (e.g. KAC201501465)
	if not id:match( '^KA.19.......$' ) and
	   not id:match( '^KA.20.......$' ) then
		return false
	end
	return '[https://nl.go.kr/authorities/resource/'..id..' '..id..']'..getCatForId( 'NLK' )
end

local function nlpLink( id )
	--P1695's format regex: 9810[0-9]\d* or A[0-9]{7}[0-9X] (e.g. 9810123456789012345 or A10414836)
	if not id:match( '^9810%d+$' ) and
	   not id:match( '^A%d%d%d%d%d%d%d[%dX]$' ) then
		return false
	end
	return '[https://tools.wmflabs.org/wikidata-externalid-url?p=1695&id='..id..' '..id..']'..getCatForId( 'NLP' )
end

local function nlrLink( id )
	--P1003's format regex: \d{9} (e.g. 123456789)
	if not id:match( '^%d%d%d%d%d%d%d%d%d$' ) then
		return false
	end
	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 nskLink( id )
	--P1375's format regex: \d{9} (e.g. 123456789)
	if not id:match( '^%d%d%d%d%d%d%d%d%d$' ) then
		return false
	end
	return '[http://katalog.nsk.hr/F/?func=direct&doc_number='..id..'&local_base=nsk10 '..id..']'..getCatForId( 'NSK' ) --no https as of 9/2019
end

local function ntaLink( id )
	--P1006's format regex: \d{8}[\dX] (e.g. 12345678X)
	if not id:match( '^%d%d%d%d%d%d%d%d[%dX]$' ) then
		return false
	end
	return '[http://data.bibliotheken.nl/id/thes/p'..id..' '..id..']'..getCatForId( 'NTA' )
end

local function picLink( id )
	--P2750's format regex: [1-9]\d* (e.g. 1)
	if not id:match( '^[1-9]%d*$' ) then
		return false
	end
	return '[https://pic.nypl.org/constituents/'..id..' '..id..']'..getCatForId( 'PIC' )
end

local function rkdidLink( id )
	--P350's format regex: [1-9]\d{0,5} (e.g. 123456)
	if not id:match( '^[1-9]%d?%d?%d?%d?%d?$' ) then
		return false
	end
	return '[https://rkd.nl/nl/explore/images/'..id..' '..id..']'..getCatForId( 'RKDID' )
end

local function snacLink( id )
	--P3430's format regex: \d*[A-Za-z][0-9A-Za-z]* (e.g. A)
	if not id:match( '^%d*[A-Za-z][0-9A-Za-z]*$' ) then
		return false
	end
	return '[https://snaccooperative.org/ark:/99166/'..id..' '..id..']'..getCatForId( 'SNAC-ID' )
end

local function reroLink( id )
	--P3065's format regex: 0[1-2]-[A-Z0-9]{1,10} (e.g. 02-A012345678)
	if not id:match( '^0[1-2]%-[A-Z%d][A-Z%d]?[A-Z%d]?[A-Z%d]?[A-Z%d]?[A-Z%d]?[A-Z%d]?[A-Z%d]?[A-Z%d]?[A-Z%d]?$' ) then
		return false
	end
	return '[http://data.rero.ch/'..id..' '..id..']'.. getCatForId( 'RERO' )
end

local function s2authoridLink( id )
	--P4012's format regex: [1-9]\d* (e.g. 1796130)
	if not id:match( '^[1-9]%d*$' ) then
		return false
	end
	return '[https://www.semanticscholar.org/author/'..id..' '..id..']'..getCatForId( 'Semantic Scholar author' ) --special category name
end

local function ta98Link( id )
	--P1323's format regex: A\d{2}\.\d\.\d{2}\.\d{3}[FM]? (e.g. A12.3.45.678)
	if not id:match( '^A%d%d%.%d%.%d%d%.%d%d%d[FM]?$' ) then
		return false
	end
	return '[http://tools.wmflabs.org/wikidata-externalid-url/?p=1323&url_prefix=https:%2F%2Fwww.unifr.ch%2Fifaa%2FPublic%2FEntryPage%2FTA98%20Tree%2FEntity%20TA98%20EN%2F&url_suffix=%20Entity%20TA98%20EN.htm&id='..id..' '..id..']'..getCatForId( 'TA98' )
end

local function tdviaLink( id )
	--P7314's format regex: [a-z/-]+] (e.g. barkan-omer-lutfi)
	if not id:match( '^[a-zğüşöçİĞÜŞÖÇı/-]+$' ) then
		return false
	end
	return '[https://islamansiklopedisi.org.tr/'..id..' '..id..']'..getCatForId( 'TDVİA' )
end

local function teLink( id )
	--P1693's format regex: E[1-8]\.\d{1,2}\.\d{1,2}\.\d{1,2}\.\d{1}\.\d{1}\.\d{1,3} (e.g. E1.23.45.67.8.9.0)
	local e1, e2 = id:match( '^E([1-8])%.(%d%d?)%.%d%d?%.%d%d?%.%d%.%d%.%d%d?%d?$' )
	if not e1 then
		return false
	end
	local TEnum = 'TEe0'..e1 --no formatter URL in WD, probably due to this complexity
	if e1 == '5' or e1 == '7' then
		if #e2 == 1 then e2 = '0'..e2 end
		TEnum = TEnum..e2
	end
	return '[http://www.unifr.ch/ifaa/Public/EntryPage/ViewTE/'..TEnum..'.html '..id..']'..getCatForId( 'TE' )
end

local function tepapaLink( id )
	--P3544's format regex: \d+ (e.g. 1)
	if not id:match( '^%d+$' ) then
		return false
	end
	return '[https://collections.tepapa.govt.nz/agent/'..id..' '..id..']'..getCatForId( 'TePapa' )
end

local function thLink( id )
	--P1694's format regex: H\d\.\d{2}\.\d{2}\.\d\.\d{5} (e.g. H1.23.45.6.78901)
	local h1, h2 = id:match( '^H(%d)%.(%d%d)%.%d%d%.%d%.%d%d%d%d%d$' )
	if not h1 then
		return false
	end
	local THnum = 'THh'..h1..h2 --no formatter URL in WD, probably due to this complexity
	return '[http://www.unifr.ch/ifaa/Public/EntryPage/ViewTH/'..THnum..'.html '..id..']'..getCatForId( 'TH' )
end


local function troveLink( id )
	--P1315's format regex: [1-9]\d{5,7} (e.g. 12345678)
	if not id:match( '^[1-9]%d%d%d%d%d%d?%d?$' ) then
		return false
	end
	return '[https://trove.nla.gov.au/people/'..id..' '..id..']'..getCatForId( 'Trove' )
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

--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 Ar_Ontology_Link( id )
	return '[///ontology.birzeit.edu/concept/' .. id .. ' ' .. id .. ']' .. getCatForId( 'Arabic Ontology ID' )
end

local function rkdartistsLink( id )
	return '[https://rkd.nl/en/explore/artists/' .. id .. ' ' .. id .. ']' .. getCatForId( 'RKDartists' )
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 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 '* ' .. label .. ' <span class="uid">' .. link .. '</span>\n'
        else
            return '* ' .. label .. ' ' .. link .. '\n'
        end
    else
        return '* <span class="error">The ' .. id .. ' id ' .. rawValue .. ' is not valid.</span>[[تصنيف:مقالات د ويكيپيديا ب إدونتيف فيه شي موشكيل (' .. id .. ')]]\n'
    end
end

--In this order: name of the parameter, label, propertyId in Wikidata, formatting function
local conf = {
	{ 'AAG', '[[:en:Auckland Art Gallery Toi o Tāmaki|لݣاليرية د لفن د ؤكلاند]]', 3372, aagLink },
	{ 'LNL', '[[لمكتابة لوطنية لبنانية]]', 7026, LNLLink },
	{ 'ACM-DL', '[[:en:ACM Digital Library|لمكتابة رقمية ديال جمعية د لماكينات د تحساب]]', 864, acmLink },
	{ 'ADB', '[[:en:Australian Dictionary of Biography|ديكسيونير لؤسطرالي د لبيوݣرافيا]]', 1907, adbLink },
	{ 'AGSA', '[[:en:Art Gallery of South Australia|لݣاليرية د لفن ديال جانوب ؤسطراليا]]', 6804, agsaLink },
	{ 'Arabic Ontology ID', '[[لؤنطولوجيا لعربية]]' , 6771, Ar_Ontology_Link },    
	{ 'autores.uy', '[[:en:autores.uy|سيت ديال autores.uy]]', 2558, autoresuyLink },
	{ 'AWR', '[[:en:Australian Women\'s Register|روجيستر ديال لعيالات لؤسطراليات]]', 4186, awrLink },
	{ 'BALaT', '[[:en:Royal Institute for Cultural Heritage#Online artworks pages|BALaT]]', 3293, balatLink },
	{ 'BIBSYS', '[[:en:Bibsys|بيبسيس (نّورڤيج)]]', 1015, bibsysLink },
	{ 'Bildindex', '[[:en:Marburg Picture Index|Bildindex]]', 2092, bildLink },
	{ 'BNC', '[[:en:Biblioteca Nacional de Chile|BNC]]', 1890, bncLink },
	{ 'BNE', '[[لمكتابة لوطنية سپنيولية]]', 950, bneLink },
	{ 'BNF', '[[لمكتابة لوطنية لفرانساوية]]', 268, bnfLink },
	{ 'Botanist', '[[:en:Author citation (botany)|Botanist]]', 428, botanistLink },
	{ 'BPN', '[[:en:Biografisch Portaal|BPN]]', 651, bpnLink },
	{ 'CANTIC', '[[:en:Name and Title Authority File of Catalonia|ضّوسي لمخازني ديال سّميات ؤ لعناوين د كاطالونيا]]', 1273, canticLink },
	{ 'CINII', '[[سايني|CiNii]]', 271, ciniiLink },
	{ 'DAAO', '[[:en:Dictionary of Australian Artists|ديكسيونير د لفنانا لؤسطراليين]]', 1707, daaoLink },
	{ 'DBLP', '[[:en:DBLP|DBLP]]', 2456, dblpLink },
	{ 'DSI', '[[:en:Stuttgart Database of Scientific Illustrators 1450–1950|لبازدّوني د شتوتݣارت ديال رّسّامين لعلميين 1450 تال 1950]]', 2349, dsiLink },
	{ 'EGAXA', '[[مكتابة لإسكندرية جديدة]]', 1309, egaxaLink },
	{ 'FNZA', '[[:d:Property:P6792|FNZA]]', 6792, fnzaLink },
    { 'GND', '[[ضوسي متكامل ديال ضبط لمخازني]]', 227, gndLink },
    { 'HDS', '[[قاموس سويسرا التاريخي|HDS]]', 902, hlsLink },
	{ 'IAAF', '[[:en:World Athletics|World Athletics]]', 1146, iaafLink },
	{ 'ICIA', '[[:en:Information Center for Israeli Art|ICIA]]', 1736, iciaLink },
    { 'ISNI', '[[لموحديد دولي لمعياري د سميات|لموحدّيد دّولي لمعياري د سّميات]]', 213, isniLink }, 
    { 'IPNI', 'IPNI', 586, IPNILink } ,
	{ 'Joconde', '[[:en:Joconde]]' , 347, jocondeLink },
	{ 'KULTURNAV', '[[:en:KulturNav|KulturNav]]', 1248, kulturnavLink },
    { 'LCCN', '[[نمرة د ضّبط ف لمكتابة د لكونݣرس|لمكتابة د لكونݣرس]]', 244, lccnLink },
    { 'LIR', '[[:en:Historical Dictionary of Switzerland#Lexicon_Istoric_Retic|LIR]]', 886, lirLink },
	{ 'LNB', '[[:en:National Library of Latvia|لمكتابة لوطنية ديال لاتڤيا]]', 1368, lnbLink },
	{ 'Léonore', '[[:en:Base Léonore|Léonore]]', 640, leonoreLink },
	{ 'MBA', '[[ميوزك برينز]]', 434, mbLink },
	{ 'MBAREA', '[[ميوزك برينز]]', 982, mbareaLink }, 
	{ 'MBI', '[[ميوزك برينز]]', 1330, mbiLink }, 
	{ 'MBL', '[[ميوزك برينز]]', 966, mblLink }, 
	{ 'MBP', '[[ميوزك برينز]]', 1004, mbpLink }, 
	{ 'MBRG', '[[ميوزك برينز]] release group', 436, mbrgLink }, 
	{ 'MBS', '[[ميوزك برينز]]', 1407, mbsLink }, 
	{ 'MBW', '[[ميوزك برينز]] work', 435, mbwLink}, 
	{ 'MGP', '[[مشروع لإحصاء د لعولما د لماط]]', 549, mgpLink },    
	{ 'NARA', '[[لإدارة لميريكانية د لأرشيفات ؤ لوتايق]]', 1225, naraLink },
	--{ 'NARA-person', '[[إدارة الأرشيف والوثائق الوطنية|NARA]]', 1222, narapersonLink },
	{ 'NARA-organization', '[[إدارة الأرشيف والوثائق الوطنية|NARA]]', 1225, naraorganizationLink },
	{ 'NCL', '[[:en:National Central Library|NCL]]', 1048, nclLink },
    { 'NDL', '[[مكتابة د لبرلمان جاپوني]]', 349, ndlLink },
    { 'NGV', '[[:en:National Gallery of Victoria|NGV]]', 2041, ngvLink },
    { 'NKC', '[[لمكتابة لوطنية د جمهورية تشيك]]', 691, nkcLink },
    { 'NLA', '[[لمكتابة لوطنية لؤسطرالية]]', 409, nlaLink },
    { 'NLG', '[[:en:National Library of Greece|لمكتابة لوطنية د ليونان]]', 3348, nlgLink },
	{ 'NLI', '[[:en:National Library of Israel|لمكتابة لوطنية د إسرائيل]]', 949, nliLink },
	{ 'NLK', '[[:en:National Library of Korea|لمكتابة لوطنية د كوريا]]', 5034, nlkLink },
	{ 'NLP', '[[:en:National Library of Poland|لمكتابة لوطنية د پولونيا]]', 1695, nlpLink },
	{ 'NLR', '[[:en:National Library of Romania|لمكتابة لوطنية د رومانيا]]', 1003, nlrLink },
	{ 'NSK', '[[:en:National and University Library in Zagreb|NSK]]', 1375, nskLink },
	{ 'NTA', '[[:en:Royal Library of the Netherlands|لمكتابة لملكية د هولاندا]]', 1006, ntaLink },
	{ 'ORCID', '[[هوية مفتوحة للباحثين والمساهمين|ORCID]]', 496, orcidLink },
	{ 'PIC', '[[:d:Q23892012|PIC]]', 2750, picLink },
	{ 'RID', '[[معرف الباحث|ResearcherID]]', 1053, ridLink },
	{ 'RERO', '[[:en:RERO (Library Network of Western Switzerland)|ريزو د لمكتابات ديال غرب سويسرا]]', 3065, reroLink },
	{ 'RKDartists', '[[:en:Netherlands Institute for Art History#Online artist pages|RKD]]', 650, rkdartistsLink },
	{ 'RKDID', '[[:d:Q17299580|RKDimages ID]]', 350, rkdidLink },
	{ 'RLS', '[[المكتبة الوطنية الروسية|RLS]]', 947, rslLink },
	{ 'RSL', '[[:en:Russian State Library|RSL]]', 947, rslLink },
	{ 'SBN', '[[:en:ICCU (identifier)|ICCU]]', 396, sbnLink },
	{ 'SELIBR', '[[ليبريس|SELIBR]]', 906, selibrLink },
	{ 'SIKART', '[[:en:SIKART|SIKART]]', 781, sikartLink },
	{ 'SNAC-ID', '[[:en:SNAC|SNAC]]', 3430, snacLink },
	{ 'SUDOC', '[[:en:SUDOC (identifier)|سّيستيم لجاميعي د تّوتيق (فرانسا)]]', 269, sudocLink },
	{ 'S2AuthorId', '[[:en:Semantic Scholar|S2AuthorId]]', 4012, s2authoridLink}, 
	{ 'TA98', '[[:en:Terminologia Anatomica|TA98]]', 1323, ta98Link },
	{ 'لموسوعة لإسلامية تّركية', '[[:d:Q21527102|TDVİA]]', 7314, tdviaLink },
	{ 'TE', '[[:en:Terminologia Embryologica|TE]]', 1693, teLink },
	{ 'TePapa', '[[:en:Museum of New Zealand Te Papa Tongarewa|TePapa]]', 3544, tepapaLink },
	{ 'TH', '[[:en:Terminologia Histologica|TH]]', 1694, thLink },
	{ 'TLS', '[[:en:Theaterlexikon der Schweiz|TLS]]', 1362, tlsLink },
	{ 'Trove', '[[:en:Trove|Trove]]', 1315, troveLink },
	{ 'ULAN', '[[قائمة الاتحاد لأسماء الفنانين|ULAN]]', 245, ulanLink },
	{ 'USCongress', '[[:en:Biographical Directory of the United States Congress|US Congress]]', 1157, uscongressLink },
	{ 'UNDocument', 'وتيقة د لأمم لمتحدة', 3069, UNdocumentsymbol},
    { 'VIAF', '[[ضوسي مخازني دولي ڤيرتوالي]]', 214, viafLink },
    { 'WORLDCATID', '[[:en:WorldCat Identities|ليدونتيفيكاتور د وورلدكات]]', 7859, nil },
}

-- Legitimate aliases to p.conf, for convenience
-- Format: { 'alias', 'parameter name in p.conf' }
p.aliases = {
	{ 'RLS', 'RSL' },
	{ 'MusicBrainz', 'MBA' },
	{ 'MusicBrainz artist', 'MBA' },
	{ 'MusicBrainz label', 'MBL' },
	{ 'MusicBrainz release group', 'MBRG' },
	{ 'MusicBrainz work', 'MBW' },
	{ 'Leonore', 'Léonore' },
	{ 'TDVIA', 'TDVİA' },
}

-- Deprecated aliases to p.conf; tracked in [[Category:Wikipedia articles with deprecated authority control identifiers]]
-- Format: { 'deprecated parameter name', 'replacement parameter name in p.conf' }
p.deprecated = {
	{ 'GKD', 'GND' },
	{ 'PND', 'GND' },
	{ 'SWD', 'GND' },
	{ 'NARA-organization', 'NARA' },
	{ 'NARA-person', 'NARA' },
}

for _, params in pairs( conf ) do
    if params[3] ~= 0 then
        properties_id[params[1]] = "P" .. params[3]
    end
end

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

function p.authorityControl( frame )
    local parentArgs = frame:getParent().args
    local qid = frame:getParent().args.id or frame.args.id or nil
    --Create rows
    local elements = {}
	local worldcatCat = ''
	local suppressedIdCat = ''
	local deprecatedIdCat = ''

	--Redirect aliases to proper parameter names
	for _, a in pairs( p.aliases ) do
		local alias, param = a[1], a[2]
		
		if (parentArgs[param] == nil or parentArgs[param] == '') and parentArgs[alias] ~= nil and parentArgs[alias] ~= '' then
			parentArgs[param] = parentArgs[alias]
		end
	end
	
	--Redirect deprecated parameters to proper parameter names, and assign tracking cat
	for _, d in pairs( p.deprecated ) do
		local dep, param = d[1], d[2]
		if (parentArgs[param] == nil or parentArgs[param] == '') and parentArgs[dep] ~= nil and parentArgs[dep] ~= '' then
			parentArgs[param] = parentArgs[dep]
			if namespace == 0 then
				deprecatedIdCat = '[[Category:Wikipedia articles with deprecated authority control identifiers|'..dep..']]'
			end
		end
	end

    --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( qid )
    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]', false ) ) --Validation?
    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 _, params in pairs( conf ) do
		local val = parentArgs[params[1]]
		if val and val ~= '' and type(params[4]) == 'function' then
			table.insert( elements, createRow( params[1], params[2]..':', val, params[4]( val ), true, params.category ) )
			rct = rct + 1
		end
	end

    local Navbox = require('Module:Navbox')
    local elementscats = ''
    if rct > 13 then
    	----elementscats  = '[[Category:AC with ' .. rct .. ' elements]]'
	end
	
	if #elements ~= 0 then
		return Navbox._navbox( {
			name  = 'Authority control',
			bodyclass = 'hlist',
			listclass = 'hlist',
			group1 = '[[ضبط مخازني]]' .. elementscats,
			list1style  = 'text-align:right;', 
			list1 = table.concat( elements )
			} )
	else
		return "[[تصنيف:قالب ديال ضبط مخازني بلا موحديدات]]"
	end
end

return p