今天是2024年10月3日 第40周 星期四
代人,时大变了。
我们生活在大地上,但我们的梦想超越天空。
變更
跳至導覽
跳至搜尋
行 1:
行 1:
− +
− -- {{imbox}}, {{tmbox}}, {{ombox}}, {{cmbox}} and {{fmbox}}.
− local htmlBuilder = require('Module:HtmlBuilder')
行 122:
行 120:
− +
行 158:
行 156:
− +
行 244:
行 242:
− +
− +
行 256:
行 254:
− +
行 279:
行 277:
− +
− +
− +
行 290:
行 288:
− self.fix = args.fix ~= '' and args.fix or nil
− +
+
+
− +
+
+
+
+
+
行 356:
行 360:
− +
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
− +
行 365:
行 411:
− +
− +
+
+
+
+
− +
行 420:
行 470:
− +
− +
行 438:
行 488:
− +
− .tag('b') +
− .addClass('error') +
− .wikitext(format( +
− +
行 452:
行 502:
− +
− .attr('id', self.id) +
− .addClass(class) +
− .cssText(self.style) +
− .attr('role', 'presentation') +
− +
− +
行 472:
行 522:
− +
− .wikitext(self.imageLeft) +
− +
− .addClass('mbox-empty-cell') +
− .cssText(self.imageEmptyCellStyle) +
− +
− .cssText(self.textstyle) +
− +
− .addClass('mbox-text-span') +
− .wikitext(self.issue) +
− .tag('span') +
− .addClass('hide-when-compact') +
− .wikitext(self.talk and ' ' .. self.talk) +
− .wikitext(self.fix and ' ' .. self.fix)
− .wikitext(self.date and ' ' .. self.date) +
+
+
+
+
+
+
− .tag('span') +
− .addClass('hide-when-compact') +
− .wikitext(self.info and ' ' .. self.info) +
− .cssText(self.textstyle) +
− .wikitext(self.text) +
− +
− +
− .wikitext(self.imageRight) +
− +
− .tag('td') +
− .attr('colspan', self.imageRight and '3' or '2') +
− .addClass('mbox-text') +
− .cssText(self.textstyle) +
− .wikitext(self.below) +
行 541:
行 596:
− .tag('div') +
− .css('text-align', 'center') +
− .wikitext(format('This message box is using an invalid "type=%s" parameter and needs fixing.', self.type or '')) +
− .wikitext(self.categories) +
自Draft:模块:Message box/30874853合并Dabao qian的版本42272821
-- This is a meta-module for producing message box templates, including {{mbox}}, {{ambox}},
-- This is a meta-module for producing message box templates, including {{mbox}}, {{ambox}}, {{imbox}}, {{tmbox}}, {{ombox}}, {{cmbox}} and {{fmbox}}.
-- Require necessary modules.
-- Require necessary modules.
local getArgs = require('Module:Arguments').getArgs
local getArgs = require('Module:Arguments').getArgs
local categoryHandler = require('Module:Category handler').main
local categoryHandler = require('Module:Category handler').main
local yesno = require('Module:Yesno')
local yesno = require('Module:Yesno')
nsVals[i] = format('"%s"', val)
nsVals[i] = format('"%s"', val)
end
end
error('invalid ns parameter passed to box:addCat; valid values are ' .. mw.text.listToText(nsVals, nil, ' or '))
error(' 無效的ns參數傳送到box:addCat ;有效的數值為' .. mw.text.listToText(nsVals, '、', ' 或'))
end
end
self[tname] = self[tname] or {}
self[tname] = self[tname] or {}
end
end
tinsert(boxTypes, '"mbox"')
tinsert(boxTypes, '"mbox"')
error(format('invalid message box type "%s"; valid types are %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
local sect
local sect
if args.sect == '' then
if args.sect == '' then
sect = 'This ' .. (cfg.sectionDefault or 'page')
sect = ' 本' .. (cfg.sectionDefault or ' 頁面')
elseif type(args.sect) == 'string' then
elseif type(args.sect) == 'string' then
sect = 'This ' .. args.sect
sect = ' 本' .. args.sect
end
end
local issue = args.issue
local issue = args.issue
tinsert(issues, issue)
tinsert(issues, issue)
tinsert(issues, text)
tinsert(issues, text)
self.issue = tconcat(issues, ' ')
self.issue = tconcat(issues)
end
end
end
end
if talkTitle and talkTitle.exists then
if talkTitle and talkTitle.exists then
local talkText = 'Relevant discussion may be found on'
local talkText = ' 相關討論可見於'
if talkArgIsTalkPage then
if talkArgIsTalkPage then
talkText = format('%s [[%s|%s]].', talkText, talk, talkTitle.prefixedText)
talkText = format('%s[[%s|%s]].', talkText, talk, talkTitle.prefixedText)
else
else
talkText = format('%s the [[%s#%s|talk page]].', talkText, talkTitle.prefixedText, talk)
talkText = format('%s[[%s#%s| 討論頁]].', talkText, talkTitle.prefixedText, talk)
end
end
self.talk = talkText
self.talk = talkText
-- Get other values.
-- Get other values.
local date
local date
if args.date and args.date ~= '' then
if args.date and args.date ~= '' then
date = args.date
date = args.date
elseif args.date == '' and self.isTemplatePage then
elseif args.date == '' and self.isTemplatePage then
date = lang:formatDate('F Y')
date = lang:formatDate('Y 年n月j日')
elseif args.time and args.time ~= '' then
date = lang:formatDate('Y年n月j日', time)
end
end
if date then
if date then
self.date = format(" <small>''(%s)''</small>", date)
self.date = format("<small> (%s)</small>", date)
end
if args.fix and args.fix ~= '' then
self.fix = format("<br /><small>%s</small>", args.fix)
else
self.fix = ''
end
end
self.info = args.info
self.info = args.info
self.categoryParamNums = union(self.categoryParamNums, self.allNums)
self.categoryParamNums = union(self.categoryParamNums, self.allNums)
-- The following is roughly equivalent to the old {{Ambox/category}}.
-- The following is roughly equivalent to the old {{Ambox/category}}.
local date = args.date
local date
local sortDay
local dayName = {
[1] = '㏠',
[2] = '㏡',
[3] = '㏢',
[4] = '㏣',
[5] = '㏤',
[6] = '㏥',
[7] = '㏦',
[8] = '㏧',
[9] = '㏨',
[10] = '㏩',
[11] = '㏪',
[12] = '㏫',
[13] = '㏬',
[14] = '㏭',
[15] = '㏮',
[16] = '㏯',
[17] = '㏰',
[18] = '㏱',
[19] = '㏲',
[20] = '㏳',
[21] = '㏴',
[22] = '㏵',
[23] = '㏶',
[24] = '㏷',
[25] = '㏸',
[26] = '㏹',
[27] = '㏺',
[28] = '㏻',
[29] = '㏼',
[30] = '㏽',
[31] = '㏾'
}
if args.date and args.date ~= '' then
date = args.date
elseif args.time and args.time ~= '' then
date = lang:formatDate('Y年n月', time)
sortDay = lang:formatDate('j', time)
sortDay = tonumber(sortDay)
sortDay = dayName[sortDay]
end
date = type(date) == 'string' and date
date = type(date) == 'string' and date
local preposition = 'from'
local preposition = ' 自'
for _, num in ipairs(self.categoryParamNums) do
for _, num in ipairs(self.categoryParamNums) do
local mainCat = args['cat' .. tostring(num)] or args['category' .. tostring(num)]
local mainCat = args['cat' .. tostring(num)] or args['category' .. tostring(num)]
allCat = type(allCat) == 'string' and allCat
allCat = type(allCat) == 'string' and allCat
if mainCat and date and date ~= '' then
if mainCat and date and date ~= '' then
local catTitle = format('%s %s %s', mainCat, preposition, date)
local catTitle = format('%s%s%s', preposition, date, mainCat)
self:addCat('main', catTitle)
if sortDay then
self:addCat('main', catTitle, sortDay)
else
self:addCat('main', catTitle)
end
catTitle = getTitleObject('Category:' .. catTitle)
catTitle = getTitleObject('Category:' .. catTitle)
if not catTitle or not catTitle.exists then
if not catTitle or not catTitle.exists then
self:addCat('main', 'Articles with invalid date parameter in template')
self:addCat('main', ' 模板中使用无效日期参数的条目')
end
end
elseif mainCat and (not date or date == '') then
elseif mainCat and (not date or date == '') then
if self.invalidTypeError then
if self.invalidTypeError then
local allSort = (self.nsid == 0 and 'Main:' or '') .. self.title.prefixedText
local allSort = (self.nsid == 0 and 'Main:' or '') .. self.title.prefixedText
self:addCat('all', 'Wikisource message box parameter needs fixing', allSort)
self:addCat('all', ' 需要修复的信息框', allSort)
end
end
if self.isSubstituted then
if self.isSubstituted then
self:addCat('all', 'Pages with incorrectly substituted templates')
self:addCat('all', ' 錯誤使用替換引用的頁面')
end
end
function box:export()
function box:export()
local root = htmlBuilder.create()
local root = mw.html.create()
-- Add the subst check error.
-- Add the subst check error.
if self.isSubstituted and self.name then
if self.isSubstituted and self.name then
root
root
:tag('b')
:addClass('error')
:wikitext(format(
'Template <code>%s[[Template:%s|%s]]%s</code> has been incorrectly substituted.',
' 模板<code>%s[[Template:%s|%s]]%s</code> 被錯誤地替代。',
mw.text.nowiki('{{'), self.name, self.name, mw.text.nowiki('}}')
mw.text.nowiki('{{'), self.name, self.name, mw.text.nowiki('}}')
))
))
-- Create the box table.
-- Create the box table.
local boxTable = root.tag('table')
local boxTable = root:tag('table')
boxTable
boxTable
:attr('id', self.id)
for i, class in ipairs(self.classes or {}) do
for i, class in ipairs(self.classes or {}) do
boxTable
boxTable
:addClass(class)
end
end
boxTable
boxTable
:cssText(self.style)
:attr('role', 'presentation')
-- Add the left-hand image.
-- Add the left-hand image.
local row = boxTable.tag('tr')
local row = boxTable:tag('tr')
if self.imageLeft then
if self.imageLeft then
local imageLeftCell = row.tag('td').addClass('mbox-image')
local imageLeftCell = row:tag('td'):addClass('mbox-image')
if self.imageCellDiv then
if self.imageCellDiv then
-- If we are using a div, redefine imageLeftCell so that the image is inside it.
-- If we are using a div, redefine imageLeftCell so that the image is inside it.
-- images in a div are wider than that, they may overlap with the text or cause
-- images in a div are wider than that, they may overlap with the text or cause
-- other display problems.
-- other display problems.
imageLeftCell = imageLeftCell.tag('div').css('width', '52px')
imageLeftCell = imageLeftCell:tag('div'):css('width', '52px')
end
end
imageLeftCell
imageLeftCell
:wikitext(self.imageLeft)
elseif self.imageEmptyCell then
elseif self.imageEmptyCell then
-- Some message boxes define an empty cell if no image is specified, and some don't.
-- Some message boxes define an empty cell if no image is specified, and some don't.
-- The old template code in templates where empty cells are specified gives the following hint:
-- The old template code in templates where empty cells are specified gives the following hint:
-- "No image. Cell with some width or padding necessary for text cell to have 100% width."
-- "No image. Cell with some width or padding necessary for text cell to have 100% width."
row.tag('td')
row:tag('td')
:addClass('mbox-empty-cell')
:cssText(self.imageEmptyCellStyle)
end
end
-- Add the text.
-- Add the text.
local textCell = row.tag('td').addClass('mbox-text')
local textCell = row:tag('td'):addClass('mbox-text')
if self.useCollapsibleTextFields then
if self.useCollapsibleTextFields then
-- The message box uses advanced text parameters that allow things to be collapsible. At the
-- The message box uses advanced text parameters that allow things to be collapsible. At the
-- moment, only ambox uses this.
-- moment, only ambox uses this.
textCell
textCell
:cssText(self.textstyle)
local textCellSpan = textCell.tag('span')
local textCellSpan = textCell:tag('span')
textCellSpan
textCellSpan
:addClass('mbox-text-span')
:wikitext(self.issue)
if not self.isSmall then
if not self.isSmall then
textCellSpan
textCellSpan
:tag('span')
:addClass('hide-when-compact')
:wikitext(self.talk and self.talk)
end
end
textCellSpan
textCellSpan
:wikitext(self.date and self.date)
if not self.isSmall and self.fix ~= '' then
textCellSpan
:tag('span')
:addClass('hide-when-compact')
:wikitext(self.fix and self.fix)
end
if not self.isSmall then
if not self.isSmall then
textCellSpan
textCellSpan
:tag('span')
:addClass('hide-when-compact')
:wikitext(self.info and self.info)
end
end
else
else
-- Default text formatting - anything goes.
-- Default text formatting - anything goes.
textCell
textCell
:cssText(self.textstyle)
:wikitext(self.text)
end
end
-- Add the right-hand image.
-- Add the right-hand image.
if self.imageRight then
if self.imageRight then
local imageRightCell = row.tag('td').addClass('mbox-imageright')
local imageRightCell = row:tag('td'):addClass('mbox-imageright')
if self.imageCellDiv then
if self.imageCellDiv then
imageRightCell = imageRightCell.tag('div').css('width', '52px') -- If we are using a div, redefine imageRightCell so that the image is inside it.
imageRightCell = imageRightCell:tag('div'):css('width', '52px') -- If we are using a div, redefine imageRightCell so that the image is inside it.
end
end
imageRightCell
imageRightCell
:wikitext(self.imageRight)
end
end
-- Add the below row.
-- Add the below row.
if self.below then
if self.below then
boxTable.tag('tr')
boxTable:tag('tr')
:tag('td')
:attr('colspan', self.imageRight and '3' or '2')
:addClass('mbox-text')
:cssText(self.textstyle)
:wikitext(self.below)
end
end
if self.invalidTypeError then
if self.invalidTypeError then
root
root
:tag('div')
:css('text-align', 'center')
:wikitext(format(' 本訊息框使用無效的「type=%s 」參數,需要修復。', self.type or ''))
end
end
-- Add categories.
-- Add categories.
root
root
:wikitext(self.categories)
return tostring(root)
return tostring(root)