Minecraft Wiki

除另有声明,转载时均必须注明出处若簡繁轉換出錯,請以遊戲內為準请勇于扩充与修正内容有兴趣逛逛我们的微博沟通交流,欢迎到社区专页需要协助,请在告示板留言

了解更多

Minecraft Wiki
Advertisement
[创建 | 历史 | 清除缓存]文档页面
此模块没有文档页面。如果你知道如何使用模块,请创建它。
local p = {}
function base( args )
	local type = args.type or 'Unsigned'
    local typetable = {unsigned = '未签名', undated = '没有日期的'}
	local user = args.user
	local date = args.date
	if date and not date:find( '%(UTC%)$' ) then
		date = date .. ' (UTC)'
	end
	local nowiki = ''
	if mw.isSubsting() then
		nowiki = '<nowiki/>'
	end
	
	local text = {
		'<small>–该' .. (typetable[mw.ustring.lower( type )] or '未签名') .. '留言',
		' 添加。请在您的回复后面加上 ~~' .. nowiki .. '~~</small>'
	}
	if date then
		table.insert( text, 2, '在' .. date )
	end
	if user then
		local userLinks
		if not user:find( '[^:%x%.%d]' ) and require( 'Module:IPAddress' ).isIP( user ) then
			userLinks = '[[Special:Contribs/' .. user .. '|' .. user .. ']]([[User talk:' .. user .. '|讨论]])'
		else
			userLinks = '[[User:' .. user .. '|' .. user .. ']]([[User talk:' .. user .. '|讨论]] • [[Special:Contribs/' .. user .. '|贡献]])'
		end
		table.insert( text, 2, '由' .. userLinks)
	end

	return table.concat( text )
end

p.unsigned = function( f )
	local args = require( 'Module:ProcessArgs' ).norm( f.args or f )
	local type = args.type or 'Unsigned'
	local user = args.user
	local date = args.date
	
	local category = { '<!-- Template:' .. type .. ' -->' }
	if mw.isSubsting() then
		-- Don't allow substitution with missing required arg
		if type == 'Unsigned' and not user then
			local dateArg = ''
			if date then
				dateArg = '||' .. date
			end
			return '{{Unsigned' .. dateArg .. '}}'
		elseif type == 'Undated' and not date then
			return '{{Undated}}'
		end
	elseif mw.title:getCurrentTitle().namespace ~= 10 then
		if type == 'Unsigned' and not user then
			table.insert( category, '[[Category:使用了未正确标明签名的模板]]' )
		elseif type == 'Undated' and not date then
			table.insert( category, '[[Category:使用了未正确标明日期的模板]]' )
		end
		table.insert( category, '[[Category:需要替换模板的页面]]' )
	end
	
	return base( args ) .. table.concat( category )
end

return p
Advertisement