Module:Sandbox/BrandonXLF/2

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 .. ' ' .. section .. ' ';		out = out .. ' ';	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 conf[1] 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 conf[1])..' 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 = example[1].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 name[1] and name[1].mainsnak.datavalue.value.id then name = getlink(name[1].mainsnak.datavalue.value.id) else name = '' end if conf.remark then wikiTable = wikiTable..' ' else wikiTable = wikiTable..' ' end wikiTable = wikiTable .. '' .. conf[1] .. ' ' wikiTable = wikiTable..' '.. name .. ' ' ..			'' .. frame:expandTemplate{title='Wikidata property link',args={id='f',conf.property}} .. ' ' ..			' ' .. config.sectionNames[conf.section]..' ' .. ' ' .. example .. ' '		if count then wikiTable = wikiTable .. ''..checkcat(articleCat,lang:formatNum(articleCount))..' ('..checkcat(errorCat,errorCount)..') ' end wikiTable = wikiTable .. ' '		if conf.remark then wikiTable = wikiTable .. " Remarks: "..conf.remark .. " "		end end if count then wikiTable = wikiTable .. ' Totals ' .. '' .. P .. ' ' ..			'' .. lang:formatNum(a) .. ' (' .. f .. ') ' end wikiTable = wikiTable .. ' '	return require('Module:Suppress categories').main(wikiTable) end

function p.errorTable(frame) local Table = ' ' return Table end

function p.whitelisttable(frame) local Table = ' ' return Table end

function p.sectiontable(frame) local 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 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, i.e. on 	local function wpfaulty( frame, id ) for _, conf in pairs(ac_conf) do			if conf.category == id or conf[1] == id then local outString = frame:expandTemplate{ title = 'Cat more', args = {'Wikipedia:Authority control', conf.idlink or conf[1]..' (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, i.e. on 	local function wp(frame,id ) for _, conf in pairs( ac_conf ) do			if conf.category == id or conf[1] == id then local link =  .. conf[1] ..  local outString = frame:expandTemplate{ title = 'Category explanation', args = {'articles with '..link..' identifiers.'..' Please do not add 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