Module:Check blp parameter/sandbox

require('strict')
local p = {}

p.main = function(frame)
	local args = frame:getParent().args
	local yesno = require('Module:Yesno')
	local current_title = mw.title.getCurrentTitle()
	local pagetype = require('Module:Pagetype')._main{page = current_title.prefixedText, defaultns = "extended"}

	if pagetype=='user page' or args.category=='no' then -- bot does not run on user talk namespace
		return ''
	end

	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(current_title.fullText, templates, p, {ignore_subtemplates=true, ignore_blank=true})
		return success and param or nil
	end
	local check = function(p_table)
		local conflict = false
		local resolved
		for _, p in pairs(p_table) do
			local yn = yesno(p)
			-- check if "other" or "activepol" are set
			if p=='activepol' then
				yn = true -- activepol are living
			elseif p=='other' then
				yn = false -- other is treated as non-living
			end
			if yn==true or yn==false then -- parameter is set
				if resolved==nil then -- no resolved status yet
					resolved = yn -- resolve to parameter
				elseif yn~=resolved then -- resolved differs from parameter
					conflict = true
				end
			end
		end
		return resolved, conflict
	end
	local conflict, shell_resolved, bio_resolved, resolved
	shell_resolved, conflict = check({getparam('blp'), getparam('living')})
	if not conflict then
		bio_resolved, conflict = check({args.blp, args.living, args.BLP})
		if not conflict then
			resolved, conflict = check({shell_resolved, bio_resolved})
		end
	end
	local out
	if conflict then
	elseif shell_resolved==nil then
		if bio_resolved==nil then
			if pagetype=='article' then
				out = 'Biography articles without blp parameter'
			end
		else
			out = 'Pages using WikiProject Biography which need living parameter transferring'
		end
	end
	return out and '[[Category:' .. out .. ']]' or ''
end

return p

Content Disclaimer

Informasi ini disarikan dari Wikipedia dan disajikan kembali untuk tujuan edukasi. Konten tersedia di bawah lisensi CC BY-SA 3.0. Kami tidak bertanggung jawab atas ketidakakuratan data yang bersumber dari kontribusi publik tersebut.

  1. The information displayed on this website is sourced in part or in whole from Wikipedia and has been adapted for the purpose of restating it. We strive to provide accurate and relevant information, however:
  2. There is no guarantee of absolute accuracy. Wikipedia is an open, collaborative project that can be edited by anyone, so information is subject to change.
  3. It is not intended to constitute professional advice. The content displayed is for informational and educational purposes only. For important decisions (e.g., medical, legal, or financial), please consult a professional.
  4. Content copyright. Wikipedia is licensed under the Creative Commons Attribution-ShareAlike License (CC BY-SA). This means that content may be reused with appropriate attribution and shared under a similar license.
  5. Responsible use. Any risk arising from the use of information from this website is entirely the responsibility of the user.