跳转到内容

模組:TrackingCategory

本页使用了标题或全文手工转换
被永久保护的模块
维基百科,自由的百科全书

local p={}
function p.append(frame, category, display_category) --fork from [[Module:If_empty]]
	if mw.isSubsting() then return '' end
	local cat,display_cat = '',''
	if type(frame) == type('string') then --type('string') avoid version change
		cat = mw.text.trim(frame)
		display_cat = mw.text.trim(category or display_cat)
	else
		if type((frame or {}).args) ~= type({}) then frame.args = {} end
		cat = mw.text.trim(category or frame.args['1'] or frame.args[1] or frame.args.cat or
			frame['1'] or frame[1] or frame.cat or '')
		display_cat = mw.text.trim(display_category or frame.args['2'] or frame.args[2] or frame.args.display or 
			frame['2'] or frame[2] or frame.display or '')
	end
	if cat ~= '' then
		--if call from a fake frame object, use Current Frame.
		if not xpcall(function()frame:getTitle()end,function()end) then frame = mw.getCurrentFrame() end
		--fork from [[Module:If_empty]]
		frame:extensionTag('ref', string.format('[[Category:%s]]', cat .. (display_cat ~= '' and ('|' .. display_cat) or '')), {group = 'TrackingCategory'})
		frame:extensionTag('references', '', {group = 'TrackingCategory'})
	end
	return ''
end
function p.hideText(frame)
	if mw.isSubsting() then return '' end
	local text = ''
	if type(frame) == type('string') then --type('string') avoid version change
		text = mw.text.trim(frame)
	else
		if type((frame or {}).args) ~= type({}) then frame.args = {} end
		text = mw.text.trim(frame.args['1'] or frame.args[1] or frame.args.text or
			frame['1'] or frame[1] or frame.text or '')
	end
	text = mw.text.trim(text)
	if text ~= '' then
		--if call from a fake frame object, use Current Frame.
		if not xpcall(function()frame:getTitle()end,function()end) then frame = mw.getCurrentFrame() end
		--fork from [[Module:If_empty]]
		frame:extensionTag('ref', text, {group = 'TrackingCategory'})
		frame:extensionTag('references', '', {group = 'TrackingCategory'})
	end
	return ''
end
return p