<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.tiffa.net/w/index.php?action=history&amp;feed=atom&amp;title=Module%3AAuthority_control</id>
	<title>Module:Authority control - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.tiffa.net/w/index.php?action=history&amp;feed=atom&amp;title=Module%3AAuthority_control"/>
	<link rel="alternate" type="text/html" href="https://wiki.tiffa.net/w/index.php?title=Module:Authority_control&amp;action=history"/>
	<updated>2026-04-07T23:37:35Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.43.0</generator>
	<entry>
		<id>https://wiki.tiffa.net/w/index.php?title=Module:Authority_control&amp;diff=3715&amp;oldid=prev</id>
		<title>imported&gt;Fire: Created page with &quot;require(&#039;strict&#039;) local p = {} local title = mw.title.getCurrentTitle() local namespace = title.namespace local testcases = (string.sub(title.subpageText,1,9) == &#039;testcases&#039;)  local function addCat(cat,sortkey) 	if cat and cat ~= &#039;&#039; and (namespace == 0 or testcases) then 		local redlinkcat = &#039;&#039; 		if testcases == false and mw.title.new(cat, 14).exists == false then 			redlinkcat = &#039;Category:Pages with red-linked authority control categories&#039; 		end 		if sortkey then...&quot;</title>
		<link rel="alternate" type="text/html" href="https://wiki.tiffa.net/w/index.php?title=Module:Authority_control&amp;diff=3715&amp;oldid=prev"/>
		<updated>2022-12-30T13:46:47Z</updated>

		<summary type="html">&lt;p&gt;Created page with &amp;quot;require(&amp;#039;strict&amp;#039;) local p = {} local title = mw.title.getCurrentTitle() local namespace = title.namespace local testcases = (string.sub(title.subpageText,1,9) == &amp;#039;testcases&amp;#039;)  local function addCat(cat,sortkey) 	if cat and cat ~= &amp;#039;&amp;#039; and (namespace == 0 or testcases) then 		local redlinkcat = &amp;#039;&amp;#039; 		if testcases == false and mw.title.new(cat, 14).exists == false then 			redlinkcat = &amp;#039;&lt;a href=&quot;/w/index.php?title=Category:Pages_with_red-linked_authority_control_categories&amp;amp;action=edit&amp;amp;redlink=1&quot; class=&quot;new&quot; title=&quot;Category:Pages with red-linked authority control categories (page does not exist)&quot;&gt;Category:Pages with red-linked authority control categories&lt;/a&gt;&amp;#039; 		end 		if sortkey then...&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;require(&amp;#039;strict&amp;#039;)&lt;br /&gt;
local p = {}&lt;br /&gt;
local title = mw.title.getCurrentTitle()&lt;br /&gt;
local namespace = title.namespace&lt;br /&gt;
local testcases = (string.sub(title.subpageText,1,9) == &amp;#039;testcases&amp;#039;)&lt;br /&gt;
&lt;br /&gt;
local function addCat(cat,sortkey)&lt;br /&gt;
	if cat and cat ~= &amp;#039;&amp;#039; and (namespace == 0 or testcases) then&lt;br /&gt;
		local redlinkcat = &amp;#039;&amp;#039;&lt;br /&gt;
		if testcases == false and mw.title.new(cat, 14).exists == false then&lt;br /&gt;
			redlinkcat = &amp;#039;[[Category:Pages with red-linked authority control categories]]&amp;#039;&lt;br /&gt;
		end&lt;br /&gt;
		if sortkey then&lt;br /&gt;
			cat = &amp;#039;[[Category:&amp;#039;..cat..&amp;#039;|&amp;#039; .. sortkey .. mw.title.getCurrentTitle().text .. &amp;#039;]]&amp;#039;&lt;br /&gt;
		else&lt;br /&gt;
			cat = &amp;#039;[[Category:&amp;#039;..cat..&amp;#039;]]&amp;#039;&lt;br /&gt;
		end&lt;br /&gt;
		cat = cat .. redlinkcat&lt;br /&gt;
		return cat&lt;br /&gt;
	else&lt;br /&gt;
		return &amp;#039;&amp;#039;&lt;br /&gt;
	end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
local function redCatCheck( cat ) --cat == &amp;#039;Blah&amp;#039; (not &amp;#039;Category:Blah&amp;#039;, &amp;#039;[[Category:Blah]]&amp;#039;, etc.)&lt;br /&gt;
	if cat and cat ~= &amp;#039;&amp;#039; and mw.title.new(cat, 14).exists == false then&lt;br /&gt;
		return &amp;#039;[[Category:Pages with red-linked authority control categories]]&amp;#039;&lt;br /&gt;
	end&lt;br /&gt;
	return &amp;#039;&amp;#039;&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
local function addCat2( cat, id )&lt;br /&gt;
	if id and id ~= &amp;#039;&amp;#039; then&lt;br /&gt;
		return &amp;#039;[[Category:&amp;#039;..cat..&amp;#039;|&amp;#039;..id..&amp;#039;]]&amp;#039;..redCatCheck(cat)&lt;br /&gt;
	else&lt;br /&gt;
		return &amp;#039;[[Category:&amp;#039;..cat..&amp;#039;]]&amp;#039;..redCatCheck(cat)&lt;br /&gt;
	end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
local function getCatForId(id,faulty)&lt;br /&gt;
	local cat = &amp;#039;Articles with &amp;#039;&lt;br /&gt;
	if faulty then cat = cat .. &amp;#039;faulty &amp;#039; end&lt;br /&gt;
	cat = cat .. id .. &amp;#039; identifiers&amp;#039;&lt;br /&gt;
	return addCat(cat)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
local function getIdsFromWikidata(qid,property)&lt;br /&gt;
	local ids = {}&lt;br /&gt;
	if not mw.wikibase or not qid then&lt;br /&gt;
		return ids&lt;br /&gt;
	end&lt;br /&gt;
	local statements = mw.wikibase.getBestStatements(qid,property)&lt;br /&gt;
	if statements then&lt;br /&gt;
		for _, statement in ipairs( statements ) do&lt;br /&gt;
			if statement.mainsnak.datavalue then&lt;br /&gt;
				table.insert( ids, statement.mainsnak.datavalue.value )&lt;br /&gt;
			end&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
	return ids&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
local function makelink(conf,val,nextid,qid) --validate values and create a link&lt;br /&gt;
	local link&lt;br /&gt;
	if nextid==1 then&lt;br /&gt;
		if conf.prefix then&lt;br /&gt;
			link = &amp;#039;*&amp;#039; .. conf.prefix .. &amp;#039;\n**&amp;#039;&lt;br /&gt;
		else&lt;br /&gt;
			link = &amp;#039;*&amp;#039;&lt;br /&gt;
		end&lt;br /&gt;
	else&lt;br /&gt;
		link = &amp;#039;\n**&amp;#039;&lt;br /&gt;
	end&lt;br /&gt;
	if conf.link2 then -- use function to validate and generate link&lt;br /&gt;
		if conf.link2(val) then&lt;br /&gt;
			link = link .. conf.link2(val)&lt;br /&gt;
		else&lt;br /&gt;
			link = false&lt;br /&gt;
		end&lt;br /&gt;
	else&lt;br /&gt;
		local valid_value&lt;br /&gt;
		if conf.pattern then -- use pattern to determine validity if defined&lt;br /&gt;
			valid_value = val:match(conf.pattern)&lt;br /&gt;
		elseif conf.patterns then&lt;br /&gt;
			for i = 1,#conf.patterns do&lt;br /&gt;
				valid_value = val:match(conf.patterns[i])&lt;br /&gt;
				if valid_value then break end&lt;br /&gt;
			end&lt;br /&gt;
		elseif conf.valid then -- otherwise use function to determine validity&lt;br /&gt;
			valid_value = conf.valid(val)&lt;br /&gt;
		else -- no validation possible&lt;br /&gt;
			valid_value = val&lt;br /&gt;
		end&lt;br /&gt;
		if valid_value then&lt;br /&gt;
			link = link .. &amp;#039;&amp;lt;span class=&amp;quot;uid&amp;quot;&amp;gt;&amp;#039;&lt;br /&gt;
			if not conf.label or nextid&amp;gt;1 then&lt;br /&gt;
				conf.label = tostring(nextid)&lt;br /&gt;
			end&lt;br /&gt;
			if conf.link then&lt;br /&gt;
				valid_value = valid_value:gsub(&amp;#039;%%&amp;#039;, &amp;#039;%%%%&amp;#039;)&lt;br /&gt;
				link = link .. &amp;#039;[&amp;#039; .. mw.ustring.gsub(conf.link,&amp;#039;%$1&amp;#039;,valid_value) .. &amp;#039; &amp;#039; .. conf.label .. &amp;#039;]&amp;#039;&lt;br /&gt;
			else&lt;br /&gt;
				link = link .. valid_value&lt;br /&gt;
			end&lt;br /&gt;
			link = link .. &amp;#039;&amp;lt;/span&amp;gt;&amp;#039;&lt;br /&gt;
		else&lt;br /&gt;
			link = false&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
	if link then&lt;br /&gt;
		link = link .. getCatForId(conf.category or conf[1])&lt;br /&gt;
	else&lt;br /&gt;
		local wdlink = qid and &amp;#039;[[:wikidata:&amp;#039; .. qid .. &amp;#039;#P&amp;#039; .. conf.property .. &amp;#039;]]&amp;#039; or &amp;#039;&amp;#039;&lt;br /&gt;
		link = &amp;#039;[[File:345-409 Ambox warning centered.svg|20px|frameless|link=&amp;#039; .. wdlink ..&amp;#039;|The &amp;#039;..conf[1]..&amp;#039; id &amp;#039;..val..&amp;#039; is not valid.]]&amp;#039;&lt;br /&gt;
		if conf.errorcat then&lt;br /&gt;
			link = link .. addCat(conf.errorcat)&lt;br /&gt;
		else&lt;br /&gt;
			link = link .. getCatForId(conf.category or conf[1],true)&lt;br /&gt;
		end&lt;br /&gt;
		link = link .. addCat(&amp;#039;All articles with faulty authority control information&amp;#039;,conf[1])&lt;br /&gt;
	end&lt;br /&gt;
	return link&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
--[[==========================================================================]]&lt;br /&gt;
--[[                                   Main                                   ]]&lt;br /&gt;
--[[==========================================================================]]&lt;br /&gt;
function p.authorityControl(frame)&lt;br /&gt;
	local config = require(&amp;quot;Module:Authority control/config&amp;quot;)&lt;br /&gt;
	local conf = config.config&lt;br /&gt;
	local sectionNames = config.sectionNames&lt;br /&gt;
	local resolveEntity = require( &amp;#039;Module:ResolveEntityId&amp;#039; )&lt;br /&gt;
	local parentArgs = frame:getParent().args --WD IDs added here later&lt;br /&gt;
	local iParentArgs = 0 --count original/manual parent args only later&lt;br /&gt;
	local iMatches,suppressedIdCount = 0,0&lt;br /&gt;
	local auxCats = &amp;#039;&amp;#039;&lt;br /&gt;
	local rct = 0 -- total number of links returned&lt;br /&gt;
	local numqids = 4 -- support for 4 additional qids&lt;br /&gt;
	local totsect = #sectionNames + numqids&lt;br /&gt;
	local sections = {}&lt;br /&gt;
	for _ = 1,totsect do table.insert(sections,{}) end&lt;br /&gt;
	&lt;br /&gt;
	-- check for suppressed identifiers&lt;br /&gt;
	local suppress = {}&lt;br /&gt;
	if parentArgs.suppress then&lt;br /&gt;
		local suppresslist = mw.text.split(parentArgs.suppress,&amp;quot;%s*,%s*&amp;quot;) -- split parameter by comma&lt;br /&gt;
		for _,v in ipairs(suppresslist) do&lt;br /&gt;
			if v:match(&amp;quot;^%d+$&amp;quot;) then&lt;br /&gt;
				v = &amp;quot;P&amp;quot;..tostring(v)&lt;br /&gt;
			else&lt;br /&gt;
				v = string.upper(v)&lt;br /&gt;
			end&lt;br /&gt;
			suppress[v] = true -- index table by identifier name&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
	&lt;br /&gt;
	local function makeSections(qid,additional)&lt;br /&gt;
		local tval = {}&lt;br /&gt;
		local function parameter_is_used(property)&lt;br /&gt;
			local used = false&lt;br /&gt;
			if property then&lt;br /&gt;
				if tval[property] then&lt;br /&gt;
					if tval[property][1] then&lt;br /&gt;
						used = true&lt;br /&gt;
					end&lt;br /&gt;
				elseif tval[property] == false then -- property has been manually suppressed&lt;br /&gt;
					used = true&lt;br /&gt;
				end&lt;br /&gt;
			end&lt;br /&gt;
			return used&lt;br /&gt;
		end&lt;br /&gt;
		for _, params in ipairs(conf) do&lt;br /&gt;
			tval[params.property] = getIdsFromWikidata(qid, &amp;#039;P&amp;#039; .. params.property) -- setup table for values with property number as key&lt;br /&gt;
			if additional then&lt;br /&gt;
				if suppress[&amp;quot;P&amp;quot;..tostring(params.property)] or suppress[string.upper(params[1])] then&lt;br /&gt;
					tval[params.property] = false -- indicates the identifier is suppressed&lt;br /&gt;
				end&lt;br /&gt;
			else&lt;br /&gt;
				local val = parentArgs[mw.ustring.lower(params[1])] or parentArgs[params[1]]&lt;br /&gt;
				if suppress[&amp;quot;P&amp;quot;..tostring(params.property)] or suppress[string.upper(params[1])] or val == &amp;#039;&amp;#039; then&lt;br /&gt;
					if tval[params.property][1] and (namespace == 0 or testcases) then&lt;br /&gt;
						suppressedIdCount = suppressedIdCount + 1&lt;br /&gt;
						if parentArgs[&amp;#039;arts&amp;#039;] ~= &amp;#039;arts&amp;#039; then&lt;br /&gt;
							auxCats = auxCats .. &amp;#039;[[Category:Articles with suppressed authority control identifiers|&amp;#039;..params[1]..&amp;#039;]]&amp;#039;&lt;br /&gt;
						end&lt;br /&gt;
					end&lt;br /&gt;
					tval[params.property] = false -- indicates the identifier is suppressed&lt;br /&gt;
				elseif val then -- add local parameter to wikidata &lt;br /&gt;
					iParentArgs = iParentArgs + 1&lt;br /&gt;
					local bnew = true&lt;br /&gt;
					for _, w in pairs(tval[params.property]) do&lt;br /&gt;
						if val == w then&lt;br /&gt;
							bnew = false&lt;br /&gt;
						end&lt;br /&gt;
					end&lt;br /&gt;
					if bnew then -- add new value to table&lt;br /&gt;
						if tval[params.property][1] then&lt;br /&gt;
							auxCats = auxCats .. &amp;#039;[[Category:Pages using authority control with parameters different on Wikidata|&amp;#039;..params[1]..&amp;#039;]]&amp;#039;&lt;br /&gt;
						end&lt;br /&gt;
						table.insert(tval[params.property],val)&lt;br /&gt;
					else&lt;br /&gt;
						iMatches = iMatches+1&lt;br /&gt;
					end&lt;br /&gt;
				end&lt;br /&gt;
			end&lt;br /&gt;
			local suppress = false&lt;br /&gt;
			if params.suppressedbyproperty then&lt;br /&gt;
				for _,sc in ipairs(params.suppressedbyproperty) do&lt;br /&gt;
					if parameter_is_used(sc) then&lt;br /&gt;
						suppress = true&lt;br /&gt;
					end&lt;br /&gt;
				end&lt;br /&gt;
			end&lt;br /&gt;
			if not tval[params.property] == false and not suppress then&lt;br /&gt;
				local tlinks = {} -- setup table for links&lt;br /&gt;
				local nextIdVal = 1&lt;br /&gt;
				local row = &amp;#039;&amp;#039;&lt;br /&gt;
				for _,val in ipairs(tval[params.property]) do&lt;br /&gt;
					local link = makelink(params,val,nextIdVal,qid)&lt;br /&gt;
					row = row .. link&lt;br /&gt;
					table.insert(tlinks,link)&lt;br /&gt;
					nextIdVal = nextIdVal + 1&lt;br /&gt;
				end&lt;br /&gt;
				if nextIdVal&amp;gt;=2 then&lt;br /&gt;
					row = row..&amp;#039;\n&amp;#039;&lt;br /&gt;
					local sec = additional or params.section -- uses section 9 for qid2, section 10 for qid3, etc.&lt;br /&gt;
					table.insert(sections[sec],row)&lt;br /&gt;
					rct = rct + 1&lt;br /&gt;
				end&lt;br /&gt;
			end&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
	local function pencil(qid)&lt;br /&gt;
		if not qid then&lt;br /&gt;
			return &amp;#039;&amp;#039;&lt;br /&gt;
		end&lt;br /&gt;
		local args = { pid = &amp;#039;identifiers&amp;#039; } -- #target the list of identifiers&lt;br /&gt;
		args.qid = qid&lt;br /&gt;
		return require(&amp;#039;Module:EditAtWikidata&amp;#039;)._showMessage(args)&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	local function resolveQID(qid)&lt;br /&gt;
		if qid then&lt;br /&gt;
			qid = &amp;#039;Q&amp;#039;..mw.ustring.gsub(qid, &amp;#039;^[Qq]&amp;#039;, &amp;#039;&amp;#039;)&lt;br /&gt;
			qid = resolveEntity._id(qid) --nil if unresolvable&lt;br /&gt;
		end&lt;br /&gt;
		return qid&lt;br /&gt;
	end&lt;br /&gt;
	local qids = {}&lt;br /&gt;
	if namespace == 0 then&lt;br /&gt;
		qids[1] = mw.wikibase.getEntityIdForCurrentPage()&lt;br /&gt;
	end&lt;br /&gt;
	if not qids[1] then&lt;br /&gt;
		qids[1] = resolveQID(parentArgs[&amp;#039;qid&amp;#039;]) --use qid parameter if no wikidata item is connected&lt;br /&gt;
	end&lt;br /&gt;
	makeSections(qids[1],false)&lt;br /&gt;
	for c = 2,5 do&lt;br /&gt;
		qids[c] = resolveQID(parentArgs[&amp;#039;qid&amp;#039; .. c])&lt;br /&gt;
		if qids[c] then makeSections(qids[c],totsect-numqids+c-1) end&lt;br /&gt;
	end&lt;br /&gt;
	if iMatches &amp;gt; 0 and iMatches == iParentArgs then&lt;br /&gt;
		auxCats = auxCats .. &amp;#039;[[Category:Pages using authority control with parameters all matching Wikidata]]&amp;#039;&lt;br /&gt;
	end&lt;br /&gt;
	if parentArgs[&amp;#039;arts&amp;#039;] == &amp;#039;arts&amp;#039; and suppressedIdCount &amp;gt; 0 then&lt;br /&gt;
		if namespace == 0 or testcases then&lt;br /&gt;
			local s = &amp;#039;s&amp;#039;&lt;br /&gt;
			if suppressedIdCount == 1 then s = &amp;#039;&amp;#039; end&lt;br /&gt;
			auxCats = auxCats .. addCat(&amp;#039;ACArt with &amp;#039;..suppressedIdCount..&amp;#039; suppressed element&amp;#039;..s)&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	--configure Navbox&lt;br /&gt;
	local outString = &amp;#039;&amp;#039;&lt;br /&gt;
	if rct &amp;gt; 0 then -- there is at least one link to display&lt;br /&gt;
		local Navbox = require(&amp;#039;Module:Navbox&amp;#039;)&lt;br /&gt;
		local sect,lastsect = 0,0&lt;br /&gt;
		local navboxArgs = {&lt;br /&gt;
			name  = &amp;#039;Authority control&amp;#039;,&lt;br /&gt;
			navboxclass = &amp;#039;authority-control&amp;#039;,&lt;br /&gt;
			bodyclass = &amp;#039;hlist&amp;#039;,&lt;br /&gt;
			state = parentArgs.state or &amp;#039;autocollapse&amp;#039;,&lt;br /&gt;
			navbar = &amp;#039;off&amp;#039;&lt;br /&gt;
		}&lt;br /&gt;
		for c=1,totsect do&lt;br /&gt;
			if #sections[c] ~= 0 then -- section is non-empty&lt;br /&gt;
				sect = sect + 1&lt;br /&gt;
				lastsect = c&lt;br /&gt;
				local sectname&lt;br /&gt;
				if c &amp;lt;= totsect - numqids then -- regular section&lt;br /&gt;
					sectname = sectionNames[c]&lt;br /&gt;
				else -- section from additional qid&lt;br /&gt;
					sectname = mw.wikibase.getLabel(qids[c-totsect+numqids+1]) .. pencil(qids[c-totsect+numqids +1])&lt;br /&gt;
				end&lt;br /&gt;
				navboxArgs[&amp;#039;group&amp;#039; .. c] = sectname&lt;br /&gt;
				navboxArgs[&amp;#039;list&amp;#039; .. c] = table.concat(sections[c])&lt;br /&gt;
			end&lt;br /&gt;
		end&lt;br /&gt;
		local aclink = &amp;#039;[[Help:Authority control|Authority control]]&amp;#039;&lt;br /&gt;
		if sect == 1 then -- special display when only one section&lt;br /&gt;
			if lastsect == 1 or lastsect == 8 then -- no special label when only general or other IDs are present&lt;br /&gt;
				navboxArgs[&amp;#039;group&amp;#039; .. lastsect] = aclink .. pencil(qids[1])&lt;br /&gt;
			elseif lastsect &amp;lt;= totsect - numqids  then -- other regular section&lt;br /&gt;
				navboxArgs[&amp;#039;group&amp;#039; .. lastsect] = aclink .. &amp;#039;: &amp;#039; .. sectionNames[lastsect] .. pencil(qids[1])&lt;br /&gt;
			else -- section from additional qid&lt;br /&gt;
				navboxArgs[&amp;#039;group&amp;#039; .. lastsect] = aclink .. &amp;#039;: &amp;#039; .. navboxArgs[&amp;#039;group&amp;#039; .. lastsect]&lt;br /&gt;
			end&lt;br /&gt;
		else -- add title to navbox&lt;br /&gt;
			navboxArgs.title = aclink .. pencil(qids[1])&lt;br /&gt;
		end&lt;br /&gt;
		outString = Navbox._navbox(navboxArgs)&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	--auxCats&lt;br /&gt;
	if rct == 0 or rct &amp;gt;= 25 then&lt;br /&gt;
		if namespace == 0 or testcases then&lt;br /&gt;
			auxCats = auxCats .. addCat(&amp;#039;AC with &amp;#039;..rct..&amp;#039; elements&amp;#039;)&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
	if parentArgs.state then&lt;br /&gt;
		if namespace == 0 or testcases then&lt;br /&gt;
			local sCat&lt;br /&gt;
			if parentArgs.state == &amp;#039;collapsed&amp;#039; then sCat = &amp;#039;AC using state parameter: collapsed&amp;#039;&lt;br /&gt;
			elseif parentArgs.state == &amp;#039;expanded&amp;#039; then sCat = &amp;#039;AC using state parameter: expanded&amp;#039;&lt;br /&gt;
			elseif parentArgs.state == &amp;#039;autocollapse&amp;#039; then sCat = &amp;#039;AC using state parameter: autocollapse&amp;#039;&lt;br /&gt;
			else sCat = &amp;#039;AC using state parameter: other&amp;#039;&lt;br /&gt;
			end&lt;br /&gt;
			auxCats = auxCats .. addCat(sCat)&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
	if testcases then&lt;br /&gt;
		auxCats = mw.ustring.gsub(auxCats, &amp;#039;(%[%[)(Category)&amp;#039;, &amp;#039;%1:%2&amp;#039;) --for easier checking&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	--out&lt;br /&gt;
	outString = outString..auxCats&lt;br /&gt;
	if namespace ~= 0 then&lt;br /&gt;
		outString = mw.ustring.gsub(outString,&amp;#039;(%[%[)(Category:Articles)([^%|%]]+)%|?[^%|%]]*(%]%])&amp;#039;,&amp;#039;%1:%2%3%4&amp;#039;)&lt;br /&gt;
		outString = mw.ustring.gsub(outString,&amp;#039;(%[%[)(Category:All articles)([^%|%]]+)%|?[^%|%]]*(%]%])&amp;#039;,&amp;#039;%1:%2%3%4&amp;#039;)&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	return outString&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
-- Creates a human-readable standalone wikitable version of conf, and tracking categories with page counts, for use in the documentation&lt;br /&gt;
function p.docConfTable(frame)&lt;br /&gt;
	local wikiTable = &amp;#039;&amp;lt;table class=&amp;quot;wikitable sortable&amp;quot;&amp;gt;&amp;#039;..&lt;br /&gt;
	  &amp;#039;&amp;lt;tr&amp;gt;&amp;lt;th&amp;gt;Code&amp;lt;/th&amp;gt;&amp;#039;..&lt;br /&gt;
	  &amp;#039;&amp;lt;th&amp;gt;Identifier&amp;lt;/th&amp;gt;&amp;#039;..&lt;br /&gt;
	  &amp;#039;&amp;lt;th data-sort-type=number&amp;gt;Wikidata property&amp;lt;/th&amp;gt;&amp;#039;..&lt;br /&gt;
	  &amp;#039;&amp;lt;th&amp;gt;Section&amp;lt;/th&amp;gt;&amp;#039;..&lt;br /&gt;
	  &amp;#039;&amp;lt;th&amp;gt;Appears as&amp;lt;/th&amp;gt;&amp;#039;..&lt;br /&gt;
	  &amp;#039;&amp;lt;th&amp;gt;[[:Category:Articles with authority control information|Articles]]&amp;lt;/th&amp;gt;&amp;#039;..&lt;br /&gt;
	  &amp;#039;&amp;lt;th&amp;gt;[[:Category:Articles with faulty authority control information|Faulty IDs]]&amp;lt;/th&amp;gt;&amp;lt;/tr&amp;gt;&amp;#039;&lt;br /&gt;
	local columns = 7&lt;br /&gt;
	local lang = mw.getContentLanguage()&lt;br /&gt;
	local a, f, P = 0, 0, 0 --cumulative sums&lt;br /&gt;
	local config = require(&amp;quot;Module:Authority control/config&amp;quot;)&lt;br /&gt;
	local getlink = require(&amp;quot;Module:Wikidata table&amp;quot;)._getLink&lt;br /&gt;
	local function checkcat(category,label)&lt;br /&gt;
		local ret=&amp;#039;[[:Category:&amp;#039;..category..&amp;#039;|&amp;#039;..label..&amp;#039;]]&amp;#039;&lt;br /&gt;
		if mw.title.new(category, 14).exists == false then&lt;br /&gt;
			ret = ret..&amp;#039; &amp;lt;span class=&amp;quot;plainlinks&amp;quot; style=&amp;quot;font-size:85%;&amp;quot;&amp;gt;&amp;amp;#91;[&amp;#039;..tostring(mw.uri.fullUrl(&amp;#039;Category:&amp;#039;..category,&amp;#039;action=edit&amp;amp;preload=Template:Authority_control/preload&amp;#039;))..&amp;#039; create]&amp;amp;#93;&amp;lt;/span&amp;gt;&amp;#039;&lt;br /&gt;
		end&lt;br /&gt;
		return ret&lt;br /&gt;
	end&lt;br /&gt;
	for _, conf in pairs(config.config) do&lt;br /&gt;
		local category = conf.category or conf[1]&lt;br /&gt;
		local articleCat = &amp;#039;Articles with &amp;#039;..category..&amp;#039; identifiers&amp;#039;&lt;br /&gt;
		local wpl = frame:expandTemplate{ title = &amp;#039;Wikidata property link&amp;#039;, args = { id = &amp;#039;f&amp;#039;, conf.property } }&lt;br /&gt;
		local faultyCat =  conf.errorcat or &amp;#039;Articles with faulty &amp;#039;.. (conf.errorcat or category) ..&amp;#039; identifiers&amp;#039;&lt;br /&gt;
		local articleCount = lang:formatNum( mw.site.stats.pagesInCategory(articleCat, &amp;#039;pages&amp;#039;) )&lt;br /&gt;
		local faultyCount =  lang:formatNum( mw.site.stats.pagesInCategory(faultyCat, &amp;#039;pages&amp;#039;) )&lt;br /&gt;
		P = P + 1 --property count&lt;br /&gt;
		a = a + lang:parseFormattedNumber(articleCount)&lt;br /&gt;
		f = f + lang:parseFormattedNumber(faultyCount)&lt;br /&gt;
		local name = mw.wikibase.getBestStatements(&amp;#039;P&amp;#039;..conf.property,&amp;quot;P9073&amp;quot;)&lt;br /&gt;
		if name then&lt;br /&gt;
			if name[1] then&lt;br /&gt;
				name = name[1].mainsnak.datavalue.value.id&lt;br /&gt;
				if name then&lt;br /&gt;
					name = getlink(name)&lt;br /&gt;
				end&lt;br /&gt;
			else&lt;br /&gt;
				name = false&lt;br /&gt;
			end&lt;br /&gt;
		end&lt;br /&gt;
		if conf.remark then&lt;br /&gt;
			wikiTable = wikiTable..&amp;#039;&amp;lt;tr&amp;gt;&amp;lt;td rowspan=2&amp;gt;&amp;#039;&lt;br /&gt;
		else&lt;br /&gt;
			wikiTable = wikiTable..&amp;#039;&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;&amp;#039;&lt;br /&gt;
		end&lt;br /&gt;
		wikiTable = wikiTable..&amp;#039;[[&amp;#039;..(conf.idlink or conf[1]..&amp;#039; (identifier)&amp;#039;)..&amp;#039;|&amp;#039;..conf[1]..&amp;#039;]]&amp;lt;/td&amp;gt;&amp;#039;&lt;br /&gt;
		wikiTable = wikiTable..&amp;#039;&amp;lt;td&amp;gt;&amp;#039;..(name or &amp;#039;&amp;#039;)..&amp;#039;&amp;lt;/td&amp;gt;&amp;#039;..&lt;br /&gt;
			&amp;#039;&amp;lt;td data-sort-value=&amp;#039;..conf.property..&amp;#039;&amp;gt;&amp;#039;..wpl..&amp;#039;&amp;lt;/td&amp;gt;&amp;#039;..&lt;br /&gt;
			&amp;#039;&amp;lt;td&amp;gt;&amp;#039;..config.sectionNames[conf.section]..&amp;#039;&amp;lt;/td&amp;gt;&amp;#039;..&lt;br /&gt;
			&amp;#039;&amp;lt;td&amp;gt;&amp;#039; .. mw.getCurrentFrame():expandTemplate{title = &amp;quot;Hlist&amp;quot;, args = {&amp;#039;\n&amp;#039; .. makelink(conf,conf.example,1)}} .. &amp;#039;\n&amp;lt;/td&amp;gt;&amp;#039;..&lt;br /&gt;
			&amp;#039;&amp;lt;td style=&amp;quot;text-align: right;&amp;quot;&amp;gt;&amp;#039;..checkcat(articleCat,articleCount)..&amp;#039;&amp;lt;/td&amp;gt;&amp;#039;..&lt;br /&gt;
			&amp;#039;&amp;lt;td style=&amp;quot;text-align: right;&amp;quot;&amp;gt;&amp;#039;..checkcat(faultyCat,faultyCount)..&amp;#039;&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&amp;#039;&lt;br /&gt;
		if conf.remark then&lt;br /&gt;
			wikiTable = wikiTable..&amp;quot;&amp;lt;tr&amp;gt;&amp;lt;td colspan=&amp;quot; .. columns-1 .. &amp;quot;6&amp;gt;&amp;#039;&amp;#039;&amp;#039;Remarks:&amp;#039;&amp;#039;&amp;#039; &amp;quot;..conf.remark..&amp;quot;&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&amp;quot;&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
	wikiTable = wikiTable..&amp;#039;&amp;lt;tr&amp;gt;&amp;lt;th style=&amp;quot;text-align: right;&amp;quot; colspan=&amp;#039; .. columns-3 .. &amp;#039;&amp;gt;Totals&amp;lt;/th&amp;gt;&amp;#039;..&lt;br /&gt;
		&amp;#039;&amp;lt;th style=&amp;quot;text-align: right;&amp;quot;&amp;gt;&amp;#039;..lang:formatNum(P)..&amp;#039;&amp;lt;/th&amp;gt;&amp;#039;..&lt;br /&gt;
		&amp;#039;&amp;lt;th style=&amp;quot;text-align: right;&amp;quot;&amp;gt;&amp;#039;..lang:formatNum(a)..&amp;#039;&amp;lt;/th&amp;gt;&amp;#039;..&lt;br /&gt;
		&amp;#039;&amp;lt;th style=&amp;quot;text-align: right;&amp;quot;&amp;gt;&amp;#039; .. &amp;#039;[[:Category:All articles with faulty authority control information|&amp;#039; .. lang:formatNum(f) .. &amp;#039;]]&amp;lt;/th&amp;gt;&amp;lt;/tr&amp;gt;&amp;lt;/table&amp;gt;&amp;#039;&lt;br /&gt;
	return require(&amp;#039;Module:Suppress categories&amp;#039;).main(wikiTable)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
-- Local Utility Functions&lt;br /&gt;
local function whichTOC( frame )&lt;br /&gt;
	-- standardize TOC behavior via {{CatAutoTOC}}&lt;br /&gt;
	return frame:expandTemplate{ title = &amp;#039;CatAutoTOC&amp;#039;, args = { align = &amp;#039;center&amp;#039; } }&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
-- Main/External Call for Pages with authority control identifiers&lt;br /&gt;
function p.autoDetect( frame )&lt;br /&gt;
	local ac_conf = require(&amp;#039;Module:Authority control/config&amp;#039;).config&lt;br /&gt;
	local rmCats = require(&amp;#039;Module:Suppress categories&amp;#039;).main&lt;br /&gt;
	local currentTitle = mw.title.getCurrentTitle()&lt;br /&gt;
	local title = currentTitle.text&lt;br /&gt;
	--For use in [[Category:Articles with faulty authority control information]], i.e. on [[Category:Articles with faulty VIAF identifiers]]&lt;br /&gt;
	local function wpfaulty( frame, id )&lt;br /&gt;
		for _, conf in pairs( ac_conf ) do&lt;br /&gt;
			if conf.category == id or conf[1] == id then&lt;br /&gt;
				local linktarget = conf.idlink or conf[1]..&amp;#039; (identifier)&amp;#039;&lt;br /&gt;
				local wdpl       = &amp;#039;:d:Property:P&amp;#039;..conf.property&lt;br /&gt;
				local txCatMore  = frame:expandTemplate{ title = &amp;#039;Cat more&amp;#039;, args = {&amp;#039;Wikipedia:Authority control&amp;#039;, linktarget, wdpl} }&lt;br /&gt;
				local txEmptyCat = frame:expandTemplate{ title = &amp;#039;Possibly empty category&amp;#039; }&lt;br /&gt;
				local txWPCat    = frame:expandTemplate{ title = &amp;#039;Wikipedia category&amp;#039;, args = { hidden = &amp;#039;yes&amp;#039;, tracking = &amp;#039;yes&amp;#039; } }&lt;br /&gt;
				local txDirtyCat = frame:expandTemplate{ title = &amp;#039;Polluted category&amp;#039; }&lt;br /&gt;
				local txTOC = whichTOC( frame )&lt;br /&gt;
				local idCat = &amp;#039;Articles with &amp;#039;..id..&amp;#039; identifiers&amp;#039;&lt;br /&gt;
				local wpfCat = &amp;#039;Articles with faulty authority control information&amp;#039;&lt;br /&gt;
				local outString = txCatMore..txEmptyCat..txWPCat..txDirtyCat..txTOC..&amp;#039;\n&amp;#039;..&lt;br /&gt;
					&amp;#039;Pages in this category should only be added by [[Module:Authority control]].&amp;#039;..&lt;br /&gt;
					addCat2(idCat)..addCat2(wpfCat, id)&lt;br /&gt;
				return outString&lt;br /&gt;
			end&lt;br /&gt;
		end&lt;br /&gt;
		return &amp;#039;&amp;#039;&lt;br /&gt;
	end&lt;br /&gt;
	--For use in [[Category:Articles with authority control information]], i.e. on [[Category:Articles with VIAF identifiers]]&lt;br /&gt;
	local function wp( frame, id )&lt;br /&gt;
		for _, conf in pairs( ac_conf ) do&lt;br /&gt;
			if conf.category == id or conf[1] == id then&lt;br /&gt;
				local linktarget = conf.idlink or conf[1]..&amp;#039; (identifier)&amp;#039;&lt;br /&gt;
				local link    = &amp;#039;[[&amp;#039;..linktarget..&amp;#039;|&amp;#039;..conf[1]..&amp;#039;]]&amp;#039;&lt;br /&gt;
				local wdpl    = &amp;#039;:d:Property:P&amp;#039;..conf.property&lt;br /&gt;
				--local example = &amp;#039;The &amp;#039;..conf[1]..&amp;#039; identifier appears as &amp;#039;.. rmCats(conf[3](conf[5]))..&amp;#039; in the &amp;#039;..conf[4]..&amp;#039; section.&amp;#039;&lt;br /&gt;
				local txCatExplain = frame:expandTemplate{ title = &amp;#039;Category explanation&amp;#039;, args = {&amp;#039;articles with &amp;#039;..link..&amp;#039; identifiers.&amp;#039;..&amp;#039; Please do not add [[Wikipedia:Categorization#Subcategorization|subcategories]].&amp;#039;} }&lt;br /&gt;
				local txCatMore    = frame:expandTemplate{ title = &amp;#039;Cat more&amp;#039;, args = {&amp;#039;Wikipedia:Authority control&amp;#039;, wdpl} }&lt;br /&gt;
				local txEmptyCat   = frame:expandTemplate{ title = &amp;#039;Possibly empty category&amp;#039; }&lt;br /&gt;
				local txWPCat      = frame:expandTemplate{ title = &amp;#039;Wikipedia category&amp;#039;, args = { hidden = &amp;#039;yes&amp;#039;, tracking = &amp;#039;yes&amp;#039; } }&lt;br /&gt;
				local txTOC = whichTOC( frame )&lt;br /&gt;
				local wpCat = &amp;#039;Articles with authority control information&amp;#039;&lt;br /&gt;
				local outString = txCatExplain..txCatMore..txEmptyCat..txWPCat..txTOC..&amp;#039;\n&amp;#039;..&amp;#039;Pages in this category should only be added by [[Module:Authority control]].&amp;#039;..addCat2(wpCat, id)&lt;br /&gt;
				return outString&lt;br /&gt;
			end&lt;br /&gt;
		end&lt;br /&gt;
		return &amp;#039;&amp;#039;&lt;br /&gt;
	end&lt;br /&gt;
	if currentTitle.namespace == 14 then --cat space&lt;br /&gt;
		local wpfaultyID = mw.ustring.match(title, &amp;#039;Articles with faulty ([%w%.%- ]+) identifiers&amp;#039;)&lt;br /&gt;
		local wpID       = mw.ustring.match(title, &amp;#039;Articles with ([%w%.%- ]+) identifiers&amp;#039;)&lt;br /&gt;
		if wpfaultyID then return wpfaulty( frame, wpfaultyID )     --must be before wpID check, in case they both match&lt;br /&gt;
		elseif wpID       then return wp( frame, wpID )             --to keep the regex simple&lt;br /&gt;
		else   return &amp;#039;[[Category:Pages with authority control identifiers unknown category]]&amp;#039;&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
	return &amp;#039;&amp;#039;&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
return p&lt;/div&gt;</summary>
		<author><name>imported&gt;Fire</name></author>
	</entry>
</feed>