跳去內容

模組:Pp-move-indef

出自維基百科,自由嘅百科全書
模組解[]
-- 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 = '維基百科搬保護用戶同用戶傾偈版'
		elseif namespace == 4 or namepace == 12 then
			category = '維基百科搬保護計劃版'
		elseif namespace == 100 then
			category = '維基百科搬保護指南版'
		elseif title.isTalkPage then
			category = '維基百科搬保護討論版'
		else
			category = '維基百科無限搬保護版'
		end
	else
		category = '有唔正確保護模嘅維基百科版'
	end

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

return p