require('strict')local p = local configfile = 'Module:Authority control/config' -- default configuation modulelocal arg = mw.getCurrentFrame.args.configif arg and arg~= then configfile = 'Module:Authority control/config/' .. argendlocal configif mw.title.new(configfile).exists then config = mw.loadData(configfile)else return error('Invalid configuration file',0)endlocal title = mw.title.getCurrentTitlelocal namespace = title.namespacelocal testcases = title.subpageText
local function needsAttention(sortkey) return '' .. sortkey .. title.text .. ''end
local function addCat(cat,sortkey) if cat and cat ~= and (namespace
14 or testcases) then local redlinkcat = if testcases
false then redlinkcat = needsAttention('N') end if sortkey then cat = '' .. sortkey .. title.text .. '' else cat = '' end cat = cat .. redlinkcat return cat else return endend
-- Creates a human-readable standalone wikitable version of conf, and tracking categories with page counts, for use in the documentationfunction p.docConfTable(frame) local function checkcat(category,label) local ret=''..label..'' --if mw.title.new(category,14).exists
' .. lang:ucfirst(config.i18n.identifier) .. ' | ' .. config.i18n.Section .. ' | ' .. config.i18n.WDproperty .. ' | ' .. config.i18n.Appears_as .. ' | ' .. config.i18n.Articles .. ' ' .. '(' .. config.i18n.Faults .. ') |
---|---|---|---|---|
' .. config.i18n.Totals .. ' | ' .. P .. ' | ' .. lang:formatNum(a) .. ' (' .. f .. ') |
function p.errorTable(frame) local Table = '
' .. config.i18n.WDproperty .. ' | ' .. lang:ucfirst(config.i18n.faulty) .. ' ' .. config.i18n.identifiers .. ' | ' .. config.i18n.Tracking_category .. ' |
---|---|---|
'..frame:expandTemplate .. ' | '..tostring(count)..' | |
' .. config.i18n.Totals .. ' | ' .. '' .. tostring(f) .. ' | '..tostring(P)..' |
function p.whitelisttable(frame) local Table = '
' .. config.i18n.Code .. ' | ' .. config.i18n.Topic .. ' | ' .. lang:ucfirst(config.i18n.identifiers) .. ' |
---|---|---|
' .. code .. ' | ' .. mw.wikibase.getSitelink('Q' .. wlist.topic) .. ' | ' .. table.concat(plist,', ') .. ' |
function p.sectiontable(frame) local Table = '
' .. config.i18n.Section .. ' | ' .. config.i18n.Description .. ' | ' .. lang:ucfirst(config.i18n.identifiers) .. ' |
---|---|---|
' .. number .. ' | ' .. section.name .. ' | ' .. table.concat(plist,', ') .. ' |
-- Main/External Call for Pages with authority control identifiersfunction p.autoDetect(frame) local function whichTOC(frame) -- standardize TOC behavior via return frame:expandTemplate end local function wpa(frame,id,faulty) for _,conf in pairs(config.config) do if conf.category
id then local getname = function(nameprop) local name = mw.wikibase.getBestStatements('P'..conf.property,nameprop) if name and name[1] and name[1].mainsnak.datavalue.value.id then return frame:expandTemplate end end local name = getname('P1629') or getname('P10726') or local outString = frame:expandTemplate .. frame:expandTemplate .. frame:expandTemplate .. frame:expandTemplate .. frame:expandTemplate .. whichTOC(frame) if faulty then outString = outString .. addCat(config.i18n.faultcat,id) .. addCat(string.format(config.i18n.cat, id)) else outString = outString .. addCat(config.i18n.maincat,id) end return outString end end end if namespace
function p.idproposal(frame) local property = frame.args.property or local out = '
if section~= then out = out .. config.sections[section].name .. ' (' .. section .. ')' else out = out .. 'Not specified' end out = out .. '
' .. link .. '
' else out = out .. 'Not specified' end out = out .. 'return p