Jump to content

Module:Check blp parameter

Permanently protected module
From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by MSGJ (talk | contribs) at 21:15, 7 September 2024 (improve). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.

require('strict')
local p = {}

p.main = function(frame)
	local yesno = require('Module:Yesno')
	local page = mw.title.getCurrentTitle().fullText
	local templates = mw.loadData('Module:WikiProject banner/config').banner_shell.redirects
	local getparam = function(p)
		local TPVmodule = require('Module:Template parameter value').getParameter
		local success, param = TPVmodule(page, templates, p, {ignore_subtemplates=true, ignore_blank=true})
		return success and param
	end
	local check = function(p1, p2)
		local b1, b2 = yesno(p1), yesno(p2)
		local conflict = false
		local resolved
		if b1==nil then
			resolved = b2
		elseif b2==nil then
			resolved = b1
		elseif b1==b2 then
			resolved = b1
		else
			conflict = true
		end
		return resolved, conflict
	end
	local conflict, conflict2, conflict3, shell_resolved, bio_resolved, resolved
	shell_resolved, conflict = check(getparam('blp'), getparam('living'))
	if not conflict then
		bio_resolved, conflict2 = check(frame.args.blp, frame.args.living)
		if not conflict2 then
			resolved, conflict3 = check(shell_resolved, bio_resolved)
		end
	end
	local out
	if conflict or conflict2 or conflict3 then
		out = 'Pages using WikiProject Biography with conflicting living parameter'
	elseif shell_resolved==bio_resolved then
		out = 'Pages using WikiProject Biography with redundant living parameter'
	elseif shell_resolved==nil and bio_resolved~=nil then
		out = 'Pages using WikiProject Biography which need living parameter transferring'
	elseif shell_resolved==nil and bio_resolved==nil then
		out = 'Biography articles without living parameter'
	end
	return out and '[[:Category:' .. out .. ']]'
end

return p