Module:Pp-move-indef

From Porn Base Central
Revision as of 15:41, 23 August 2020 by PeaceDeadC (talk | contribs) (Created page with "-- This module implements Template:Pp-move-indef. local p = {} function p.main(title) if type(title) == 'string' then title = mw.title.new(title) elseif type(title)...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Documentation for this module may be created at Module:Pp-move-indef/doc

-- This module implements [[Template:Pp-move-indef]].

local p = {}

function p.main(title)
	if type(title) == 'string' then
		title = mw.title.new(title)
	elseif type(title) ~= 'table' or not title.text or not title.getContent then
		-- The title parameter is absent or not a title object. It could be a
		-- frame object if we are being called from #invoke.
		title = mw.title.getCurrentTitle()
	end
	
	local level = title
		and title.protectionLevels
		and title.protectionLevels.move
		and title.protectionLevels.move[1]
	local namespace = title and title.namespace

	local category
	if level == 'sysop' or level == 'templateeditor' then
		if namespace == 2 or namespace == 3 then
			category = 'PBC move-protected user and user talk pages'
		elseif namespace == 4 or namepace == 12 then
			category = 'PBC move-protected project pages'
		elseif namespace == 100 then
			category = 'PBC move-protected portals'
		elseif title.isTalkPage then
			category = 'PBC move-protected talk pages'
		else
			category = 'PBC indefinitely move-protected pages'
		end
	else
		category = 'PBC pages with incorrect protection templates'
	end

	return string.format(
		'[[%s:%s|%s]]',
		mw.site.namespaces[14].name, -- "Category"
		category,
		title.text -- equivalent of {{PAGENAME}}
	)
end

return p