From Wikipedia, the free encyclopedia


require('strict')

local config = require("Module:Authority control/config/sandbox")

local getlink = require("Module:Wikidata table")._getLink

local p = {}



function p.helpSections(frame)

	local out = '';



	for number, section in ipairs(config.sectionNames) do

		out = out .. '<h2>' .. section .. '</h2>';

		out = out .. '<table>';

	

		for _, conf in pairs(config.config) do

			if conf.section == number then

				local row = '<td>' .. (conf.label or conf1]) .. '</td>'

				local name = mw.wikibase.getBestStatements('P' .. conf.property, 'P1629')

		

				if name and name1 and name1].mainsnak.datavalue.value.id then

					name = getlink(name1].mainsnak.datavalue.value.id)

				else

					name = ''

				end

				

				row = row .. '<td>' .. name .. '</td>'

				

				--[[

				if conf.remark then

					desc = desc .. '<div>' .. conf.remark .. '</div>'

				end

				]]

				

				out = out .. '<tr>' .. row .. '</tr>'

			end

		end

		

		out = out .. '</table>';

	end



	return out

end



-- Creates a human-readable standalone wikitable version of conf, and tracking categories with page counts, for use in the documentation

function p.docConfTable(frame)

	local count = frame.args.count or false

	local out = '';



	for _, conf in pairs(config.config) do

		local category = conf.category or conf1

		local articleCat = 'Articles with '..category..' identifiers'

		local articleCount = mw.site.stats.pagesInCategory(articleCat,'pages')

		local errorCat = conf.errorcat or 'Articles with faulty '..(conf.category or conf1])..' identifiers'

		local errorCount =  mw.site.stats.pagesInCategory(errorCat,'pages')

		P = P + 1 --property count

		a = a + articleCount

		f = f + errorCount

		local example = mw.wikibase.getBestStatements('P'..conf.property,'P1855') or ''

		if example then

			example = example1].qualifiers'P'..conf.property][1].datavalue.value

			example = mw.getCurrentFrame():expandTemplate{title = "Hlist", args = {'\n' .. makelink(conf,{id=example},1)}} .. '\n'

		end

	

		local name = mw.wikibase.getBestStatements('P' .. conf.property, 'P1629')

		

		if name and name1 and name1].mainsnak.datavalue.value.id then

			name = getlink(name1].mainsnak.datavalue.value.id)

		else

			name = ''

		end

	

		if conf.remark then

			wikiTable = wikiTable..'<tr><td rowspan=2>'

		else

			wikiTable = wikiTable..'<tr><td>'

		end

		wikiTable = wikiTable .. '[[' .. conf1 .. ' (identifier)' .. '|' .. conf1 .. ']]</td>'

		wikiTable = wikiTable..'<td>'.. name .. '</td>' ..

			'<td data-sort-value=' .. conf.property .. '>' .. frame:expandTemplate{title='Wikidata property link',args={id='f',conf.property}} .. '</td>' ..

			'<td>' .. config.sectionNamesconf.section..'</td>' ..

			'<td>' .. example .. '</td>'

		if count then

			wikiTable = wikiTable .. '<td style="text-align: right;">'..checkcat(articleCat,lang:formatNum(articleCount))..' ('..checkcat(errorCat,errorCount)..')</td>'

		end

		wikiTable = wikiTable .. '</tr>'

		if conf.remark then

			wikiTable = wikiTable .. "<tr><td colspan=" .. columns .. ">'''Remarks:''' "..conf.remark .. "</td></tr>"

		end

	end

	if count then

		wikiTable = wikiTable .. '<tr><th style="text-align: right;" colspan=' .. columns-1 .. '>Totals</th>' ..

			'<th style="text-align: right;">' .. P .. '</th>' ..

			'<th style="text-align: right;">' .. lang:formatNum(a) .. ' ([[:Category:All articles with faulty authority control information|' .. f .. ']])</th></tr>'

	end

	wikiTable = wikiTable .. '</table>'

	return require('Module:Suppress categories').main(wikiTable)

end



function p.errorTable(frame)

	local Table = '<table class="wikitable sortable">'..

	  '<tr><th>Code</th>'..

	  '<th>Wikidata property</th>'..

	  '<th>Faulty IDs</th>'..

	  '<th>[[:Category:Articles with faulty authority control information|Tracking category]]</th></tr>'

	local f, P = 0, 0, 0 --cumulative sums

	for _, conf in pairs(config.config) do

		local category = conf.errorcat or 'Articles with faulty '..(conf.category or conf1])..' identifiers'

		local count =  mw.site.stats.pagesInCategory(category,'pages')

		if count > 0 then

			P = P + 1

			f = f + count

			Table = Table..'<tr><th>[['..(conf.idlink or conf1..' (identifier)')..'|'..conf1..']]</th>'..

				'<td>'..frame:expandTemplate{ title = 'Wikidata property link', args = { id = 'f', conf.property } } .. '</td>'..

				'<td style="text-align:center;">'..tostring(count)..'</td>'..

				'<td>[[:Category:'..category..']]</td></tr>'

		end

	end

	Table = Table..'<tr><th colspan=2 style="text-align: right;">Totals</th>'..

		'<th style="text-align:center;">' .. '[[:Category:All articles with faulty authority control information|' .. tostring(f) .. ']]</th>'..

		'<th style="text-align:center;">'..tostring(P)..'</th></tr></table>'

	return Table

end



function p.whitelisttable(frame)

	local Table = '<table class="wikitable sortable">'..

	  '<tr><th>Code</th>'..

	  '<th>Topic</th>'..

	  '<th>Identifiers</th></tr>'

	for code, wlist in pairs(config.whitelists) do

		Table = Table .. '<tr><th>' .. code .. '</th>'..

			'<td>[[' .. mw.wikibase.getSitelink('Q' .. wlist.topic) .. ']]</td>'

		local plist = {}

		for _, property in pairs(wlist.properties) do

			table.insert(plist,frame:expandTemplate{title='Wikidata property link', args={'P' .. property}})

		end

		Table = Table .. '<td>' .. table.concat(plist,', ') .. '</td></tr>'

	end

	Table = Table .. '</table>'

	return Table

end



function p.sectiontable(frame)

	local Table = '<table class="wikitable sortable">'..

	  '<tr><th>Section</th>'..

	  '<th>Description</th>'..

	  '<th>Identifiers</th></tr>'

	for number,section in ipairs(config.sectionNames) do

		Table = Table .. '<tr><th>' .. number .. '</th>' ..	'<td>' .. section .. '</td>'

		local plist = {}

		for _,id in pairs(config.config) do

			if id.section == number then

				table.insert(plist,frame:expandTemplate{title='Wikidata property link', args={'P' .. id.property}})

			end

		end

		Table = Table .. '<td>' .. table.concat(plist,', ') .. '</td></tr>'

	end

	Table = Table .. '</table>'

	return Table

end



-- Main/External Call for Pages with authority control identifiers

function p.autoDetect( frame )

	local function whichTOC( frame ) -- standardize TOC behavior via {{CatAutoTOC}}

		return frame:expandTemplate{ title = 'CatAutoTOC', args = { align = 'center' } }

	end

	local ac_conf = require('Module:Authority control/config').config

	local rmCats = require('Module:Suppress categories').main

	--For use in [[Category:Articles with faulty authority control information]], i.e. on [[Category:Articles with faulty VIAF identifiers]]

	local function wpfaulty( frame, id )

		for _, conf in pairs(ac_conf) do

			if conf.category == id or conf1 == id then

				local outString = frame:expandTemplate{ title = 'Cat more', args = {'Wikipedia:Authority control', conf.idlink or conf1..' (identifier)', ':d:Property:P'..conf.property} }

					.. frame:expandTemplate{ title = 'Possibly empty category' }

					.. frame:expandTemplate{ title = 'Wikipedia category', args = { hidden = 'yes', tracking = 'yes' } }

					.. frame:expandTemplate{ title = 'Polluted category' }

					.. whichTOC( frame )

					.. '\nPages in this category should only be added by [[Module:Authority control]].'

					.. addCat('Articles with '..id..' identifiers')

					.. addCat('Articles with faulty authority control information',id)

				return outString

			end

		end

		return ''

	end

	--For use in [[Category:Articles with authority control information]], i.e. on [[Category:Articles with VIAF identifiers]]

	local function wp(frame,id )

		for _, conf in pairs( ac_conf ) do

			if conf.category == id or conf1 == id then

				local link = '[[' .. (conf.idlink or conf1 .. ' (identifier)') .. '|' .. conf1 .. ']]'

				local outString = frame:expandTemplate{ title = 'Category explanation', args = {'articles with '..link..' identifiers.'..' Please do not add [[Wikipedia:Categorization#Subcategorization|subcategories]].'} }

					.. frame:expandTemplate{ title = 'Cat more', args = {'Wikipedia:Authority control', ':d:Property:P'..conf.property} }

					.. frame:expandTemplate{ title = 'Possibly empty category' }

					.. frame:expandTemplate{ title = 'Wikipedia category', args = { hidden = 'yes', tracking = 'yes' } }

					.. whichTOC( frame )

					.. '\nPages in this category should only be added by [[Module:Authority control]].'

					.. addCat('Articles with authority control information',id)

				return outString

			end

		end

		return ''

	end

	if namespace == 14 then --cat space

		local wpfaultyID = mw.ustring.match(title.text, 'Articles with faulty ([%w%.%- ]+) identifiers')

		local wpID       = mw.ustring.match(title.text, 'Articles with ([%w%.%- ]+) identifiers')

		if wpfaultyID then

			return wpfaulty(frame,wpfaultyID)-- must be before wpID check, in case they both match

		elseif wpID then

			return wp(frame, wpID)-- to keep the regex simple

		else

			return needsAttention('U')

		end

	end

	return ''

end



return p
From Wikipedia, the free encyclopedia


require('strict')

local config = require("Module:Authority control/config/sandbox")

local getlink = require("Module:Wikidata table")._getLink

local p = {}



function p.helpSections(frame)

	local out = '';



	for number, section in ipairs(config.sectionNames) do

		out = out .. '<h2>' .. section .. '</h2>';

		out = out .. '<table>';

	

		for _, conf in pairs(config.config) do

			if conf.section == number then

				local row = '<td>' .. (conf.label or conf1]) .. '</td>'

				local name = mw.wikibase.getBestStatements('P' .. conf.property, 'P1629')

		

				if name and name1 and name1].mainsnak.datavalue.value.id then

					name = getlink(name1].mainsnak.datavalue.value.id)

				else

					name = ''

				end

				

				row = row .. '<td>' .. name .. '</td>'

				

				--[[

				if conf.remark then

					desc = desc .. '<div>' .. conf.remark .. '</div>'

				end

				]]

				

				out = out .. '<tr>' .. row .. '</tr>'

			end

		end

		

		out = out .. '</table>';

	end



	return out

end



-- Creates a human-readable standalone wikitable version of conf, and tracking categories with page counts, for use in the documentation

function p.docConfTable(frame)

	local count = frame.args.count or false

	local out = '';



	for _, conf in pairs(config.config) do

		local category = conf.category or conf1

		local articleCat = 'Articles with '..category..' identifiers'

		local articleCount = mw.site.stats.pagesInCategory(articleCat,'pages')

		local errorCat = conf.errorcat or 'Articles with faulty '..(conf.category or conf1])..' identifiers'

		local errorCount =  mw.site.stats.pagesInCategory(errorCat,'pages')

		P = P + 1 --property count

		a = a + articleCount

		f = f + errorCount

		local example = mw.wikibase.getBestStatements('P'..conf.property,'P1855') or ''

		if example then

			example = example1].qualifiers'P'..conf.property][1].datavalue.value

			example = mw.getCurrentFrame():expandTemplate{title = "Hlist", args = {'\n' .. makelink(conf,{id=example},1)}} .. '\n'

		end

	

		local name = mw.wikibase.getBestStatements('P' .. conf.property, 'P1629')

		

		if name and name1 and name1].mainsnak.datavalue.value.id then

			name = getlink(name1].mainsnak.datavalue.value.id)

		else

			name = ''

		end

	

		if conf.remark then

			wikiTable = wikiTable..'<tr><td rowspan=2>'

		else

			wikiTable = wikiTable..'<tr><td>'

		end

		wikiTable = wikiTable .. '[[' .. conf1 .. ' (identifier)' .. '|' .. conf1 .. ']]</td>'

		wikiTable = wikiTable..'<td>'.. name .. '</td>' ..

			'<td data-sort-value=' .. conf.property .. '>' .. frame:expandTemplate{title='Wikidata property link',args={id='f',conf.property}} .. '</td>' ..

			'<td>' .. config.sectionNamesconf.section..'</td>' ..

			'<td>' .. example .. '</td>'

		if count then

			wikiTable = wikiTable .. '<td style="text-align: right;">'..checkcat(articleCat,lang:formatNum(articleCount))..' ('..checkcat(errorCat,errorCount)..')</td>'

		end

		wikiTable = wikiTable .. '</tr>'

		if conf.remark then

			wikiTable = wikiTable .. "<tr><td colspan=" .. columns .. ">'''Remarks:''' "..conf.remark .. "</td></tr>"

		end

	end

	if count then

		wikiTable = wikiTable .. '<tr><th style="text-align: right;" colspan=' .. columns-1 .. '>Totals</th>' ..

			'<th style="text-align: right;">' .. P .. '</th>' ..

			'<th style="text-align: right;">' .. lang:formatNum(a) .. ' ([[:Category:All articles with faulty authority control information|' .. f .. ']])</th></tr>'

	end

	wikiTable = wikiTable .. '</table>'

	return require('Module:Suppress categories').main(wikiTable)

end



function p.errorTable(frame)

	local Table = '<table class="wikitable sortable">'..

	  '<tr><th>Code</th>'..

	  '<th>Wikidata property</th>'..

	  '<th>Faulty IDs</th>'..

	  '<th>[[:Category:Articles with faulty authority control information|Tracking category]]</th></tr>'

	local f, P = 0, 0, 0 --cumulative sums

	for _, conf in pairs(config.config) do

		local category = conf.errorcat or 'Articles with faulty '..(conf.category or conf1])..' identifiers'

		local count =  mw.site.stats.pagesInCategory(category,'pages')

		if count > 0 then

			P = P + 1

			f = f + count

			Table = Table..'<tr><th>[['..(conf.idlink or conf1..' (identifier)')..'|'..conf1..']]</th>'..

				'<td>'..frame:expandTemplate{ title = 'Wikidata property link', args = { id = 'f', conf.property } } .. '</td>'..

				'<td style="text-align:center;">'..tostring(count)..'</td>'..

				'<td>[[:Category:'..category..']]</td></tr>'

		end

	end

	Table = Table..'<tr><th colspan=2 style="text-align: right;">Totals</th>'..

		'<th style="text-align:center;">' .. '[[:Category:All articles with faulty authority control information|' .. tostring(f) .. ']]</th>'..

		'<th style="text-align:center;">'..tostring(P)..'</th></tr></table>'

	return Table

end



function p.whitelisttable(frame)

	local Table = '<table class="wikitable sortable">'..

	  '<tr><th>Code</th>'..

	  '<th>Topic</th>'..

	  '<th>Identifiers</th></tr>'

	for code, wlist in pairs(config.whitelists) do

		Table = Table .. '<tr><th>' .. code .. '</th>'..

			'<td>[[' .. mw.wikibase.getSitelink('Q' .. wlist.topic) .. ']]</td>'

		local plist = {}

		for _, property in pairs(wlist.properties) do

			table.insert(plist,frame:expandTemplate{title='Wikidata property link', args={'P' .. property}})

		end

		Table = Table .. '<td>' .. table.concat(plist,', ') .. '</td></tr>'

	end

	Table = Table .. '</table>'

	return Table

end



function p.sectiontable(frame)

	local Table = '<table class="wikitable sortable">'..

	  '<tr><th>Section</th>'..

	  '<th>Description</th>'..

	  '<th>Identifiers</th></tr>'

	for number,section in ipairs(config.sectionNames) do

		Table = Table .. '<tr><th>' .. number .. '</th>' ..	'<td>' .. section .. '</td>'

		local plist = {}

		for _,id in pairs(config.config) do

			if id.section == number then

				table.insert(plist,frame:expandTemplate{title='Wikidata property link', args={'P' .. id.property}})

			end

		end

		Table = Table .. '<td>' .. table.concat(plist,', ') .. '</td></tr>'

	end

	Table = Table .. '</table>'

	return Table

end



-- Main/External Call for Pages with authority control identifiers

function p.autoDetect( frame )

	local function whichTOC( frame ) -- standardize TOC behavior via {{CatAutoTOC}}

		return frame:expandTemplate{ title = 'CatAutoTOC', args = { align = 'center' } }

	end

	local ac_conf = require('Module:Authority control/config').config

	local rmCats = require('Module:Suppress categories').main

	--For use in [[Category:Articles with faulty authority control information]], i.e. on [[Category:Articles with faulty VIAF identifiers]]

	local function wpfaulty( frame, id )

		for _, conf in pairs(ac_conf) do

			if conf.category == id or conf1 == id then

				local outString = frame:expandTemplate{ title = 'Cat more', args = {'Wikipedia:Authority control', conf.idlink or conf1..' (identifier)', ':d:Property:P'..conf.property} }

					.. frame:expandTemplate{ title = 'Possibly empty category' }

					.. frame:expandTemplate{ title = 'Wikipedia category', args = { hidden = 'yes', tracking = 'yes' } }

					.. frame:expandTemplate{ title = 'Polluted category' }

					.. whichTOC( frame )

					.. '\nPages in this category should only be added by [[Module:Authority control]].'

					.. addCat('Articles with '..id..' identifiers')

					.. addCat('Articles with faulty authority control information',id)

				return outString

			end

		end

		return ''

	end

	--For use in [[Category:Articles with authority control information]], i.e. on [[Category:Articles with VIAF identifiers]]

	local function wp(frame,id )

		for _, conf in pairs( ac_conf ) do

			if conf.category == id or conf1 == id then

				local link = '[[' .. (conf.idlink or conf1 .. ' (identifier)') .. '|' .. conf1 .. ']]'

				local outString = frame:expandTemplate{ title = 'Category explanation', args = {'articles with '..link..' identifiers.'..' Please do not add [[Wikipedia:Categorization#Subcategorization|subcategories]].'} }

					.. frame:expandTemplate{ title = 'Cat more', args = {'Wikipedia:Authority control', ':d:Property:P'..conf.property} }

					.. frame:expandTemplate{ title = 'Possibly empty category' }

					.. frame:expandTemplate{ title = 'Wikipedia category', args = { hidden = 'yes', tracking = 'yes' } }

					.. whichTOC( frame )

					.. '\nPages in this category should only be added by [[Module:Authority control]].'

					.. addCat('Articles with authority control information',id)

				return outString

			end

		end

		return ''

	end

	if namespace == 14 then --cat space

		local wpfaultyID = mw.ustring.match(title.text, 'Articles with faulty ([%w%.%- ]+) identifiers')

		local wpID       = mw.ustring.match(title.text, 'Articles with ([%w%.%- ]+) identifiers')

		if wpfaultyID then

			return wpfaulty(frame,wpfaultyID)-- must be before wpID check, in case they both match

		elseif wpID then

			return wp(frame, wpID)-- to keep the regex simple

		else

			return needsAttention('U')

		end

	end

	return ''

end



return p

Videos

Youtube | Vimeo | Bing

Websites

Google | Yahoo | Bing

Encyclopedia

Google | Yahoo | Bing

Facebook