134
个编辑
(创建页面,内容为“-- 摘自中文维基百科:https://zh.wikipedia.org/w/index.php?title=Module:Message_box -- This is a meta-module for producing message box templates, including {{mbox}}, {{ambox}}, {{imbox}}, {{tmbox}}, {{ombox}}, {{cmbox}} and {{fmbox}}. -- Require necessary modules. local getArgs = require('Module:Arguments').getArgs local categoryHandler = require('Module:Category handler').main local yesno = require('Module:Yesno') -- Load the configuration page. loc…”) |
无编辑摘要 |
||
第62行: | 第62行: | ||
table.sort(nums) | table.sort(nums) | ||
return nums | return nums | ||
end | end | ||
第174行: | 第160行: | ||
error(format('無效的訊息框類型「%s」;有效的類型為%s', tostring(boxType), mw.text.listToText(boxTypes)), 2) | error(format('無效的訊息框類型「%s」;有效的類型為%s', tostring(boxType), mw.text.listToText(boxTypes)), 2) | ||
end | end | ||
return cfg | return cfg | ||
end | end | ||
function box:removeBlankArgs(args) | function box:removeBlankArgs(cfg, args) | ||
-- Only allow blank arguments for the parameter names listed in cfg.allowBlankParams. | -- Only allow blank arguments for the parameter names listed in cfg.allowBlankParams. | ||
local newArgs = {} | local newArgs = {} | ||
第186行: | 第171行: | ||
end | end | ||
end | end | ||
for i, param in ipairs( | for i, param in ipairs(cfg.allowBlankParams or {}) do | ||
newArgs[param] = args[param] | newArgs[param] = args[param] | ||
end | end | ||
第192行: | 第177行: | ||
end | end | ||
function box:setBoxParameters(args) | function box:setBoxParameters(cfg, args) | ||
-- Get type data. | -- Get type data. | ||
self.type = args.type | self.type = args.type | ||
第302行: | 第285行: | ||
local talkText = '相關討論可見於' | local talkText = '相關討論可見於' | ||
if talkArgIsTalkPage then | if talkArgIsTalkPage then | ||
talkText = format('%s[[%s|%s]] | talkText = format('%s[[%s|%s]]。', talkText, talk, talkTitle.prefixedText) | ||
else | else | ||
talkText = format('%s[[%s#%s|討論頁]] | talkText = format('%s[[%s#%s|討論頁]]。', talkText, talkTitle.prefixedText, talk) | ||
end | end | ||
self.talk = talkText | self.talk = talkText | ||
第533行: | 第516行: | ||
)) | )) | ||
end | end | ||
-- Create the box table. | -- Create the box table. | ||
第577行: | 第558行: | ||
textCell | textCell | ||
:cssText(self.textstyle) | :cssText(self.textstyle) | ||
local textCellSpan = textCell:tag(' | local textCellSpan = textCell:tag('span') | ||
textCellSpan | textCellSpan | ||
:addClass('mbox-text-span') | :addClass('mbox-text-span') | ||
第646行: | 第627行: | ||
local outputBox = box.new() | local outputBox = box.new() | ||
outputBox:setTitle(args) | outputBox:setTitle(args) | ||
outputBox:getConfig(boxType) | local cfg = outputBox:getConfig(boxType) | ||
args = outputBox:removeBlankArgs(args) | args = outputBox:removeBlankArgs(cfg, args) | ||
outputBox:setBoxParameters(args) | outputBox:setBoxParameters(cfg, args) | ||
return outputBox:export() | return outputBox:export() | ||
end | end | ||
第657行: | 第638行: | ||
return main(boxType, args) | return main(boxType, args) | ||
end | end | ||
end | end | ||
local p = { | local p = { | ||
main = main, | main = main, | ||
mbox = makeWrapper('mbox') | mbox = makeWrapper('mbox') | ||
} | } | ||
for boxType in pairs(cfgTables) do | for boxType in pairs(cfgTables) do | ||
p[boxType] = makeWrapper(boxType) | |||
end | end | ||
return p | return p |
个编辑