در حال ویرایش پودمان:Message box
این ویرایش را میتوان خنثی کرد. لطفاً تفاوت زیر را بررسی کنید تا تأیید کنید که این چیزی است که میخواهید انجام دهید، سپس تغییرات زیر را ذخیره کنید تا خنثیسازی ویرایش را به پایان ببرید.
نسخهٔ فعلی | متن شما | ||
خط ۳: | خط ۳: | ||
-- Load necessary modules. | -- Load necessary modules. | ||
require(' | require('Module:No globals') | ||
local getArgs | local getArgs | ||
local yesno = require('Module:Yesno') | local yesno = require('Module:Yesno') | ||
-- Get a language object for formatDate and ucfirst. | -- Get a language object for formatDate and ucfirst. | ||
خط ۷۸: | خط ۷۷: | ||
if args.demospace and args.demospace ~= '' then | if args.demospace and args.demospace ~= '' then | ||
-- implement demospace parameter of mbox | -- implement demospace parameter of mbox | ||
local demospace = | local demospace = string.lower(args.demospace) | ||
if DEMOSPACES[demospace] then | if DEMOSPACES[demospace] then | ||
-- use template from DEMOSPACES | -- use template from DEMOSPACES | ||
obj.cfg = cfg[DEMOSPACES[demospace]] | obj.cfg = cfg[DEMOSPACES[demospace]] | ||
elseif | elseif string.find( demospace, 'talk' ) then | ||
-- demo as a talk page | -- demo as a talk page | ||
obj.cfg = cfg.tmbox | obj.cfg = cfg.tmbox | ||
خط ۱۳۴: | خط ۱۳۳: | ||
end | end | ||
if sort then | if sort then | ||
cat = | cat = string.format('[[Category:%s|%s]]', cat, sort) | ||
else | else | ||
cat = | cat = string.format('[[Category:%s]]', cat) | ||
end | end | ||
self.hasCategories = true | self.hasCategories = true | ||
خط ۱۷۷: | خط ۱۷۶: | ||
self.name = args.name | self.name = args.name | ||
if self.name then | if self.name then | ||
self:addClass('box-' .. | self:addClass('box-' .. string.gsub(self.name,' ','_')) | ||
end | end | ||
if yesno(args.plainlinks) ~= false then | if yesno(args.plainlinks) ~= false then | ||
خط ۲۰۷: | خط ۲۰۶: | ||
local templateName = mw.ustring.match( | local templateName = mw.ustring.match( | ||
self.name, | self.name, | ||
'^ | '^[tT][eE][mM][pP][lL][aA][tT][eE][%s_]*:[%s_]*(.*)$' | ||
) or self.name | ) or self.name | ||
templateName = ' | templateName = 'Template:' .. templateName | ||
self.templateTitle = getTitleObject(templateName) | self.templateTitle = getTitleObject(templateName) | ||
end | end | ||
خط ۲۲۵: | خط ۲۲۴: | ||
local sect | local sect | ||
if args.sect == '' then | if args.sect == '' then | ||
sect = ' | sect = 'This ' .. (cfg.sectionDefault or 'page') | ||
elseif type(args.sect) == 'string' then | elseif type(args.sect) == 'string' then | ||
sect = ' | sect = 'This ' .. args.sect | ||
end | end | ||
local issue = args.issue | local issue = args.issue | ||
خط ۲۷۲: | خط ۲۷۱: | ||
if self.isSmall then | if self.isSmall then | ||
local talkLink = talkArgIsTalkPage and talk or (talkTitle.prefixedText .. '#' .. talk) | local talkLink = talkArgIsTalkPage and talk or (talkTitle.prefixedText .. '#' .. talk) | ||
talkText = | talkText = string.format('([[%s|talk]])', talkLink) | ||
else | else | ||
talkText = ' | talkText = 'Relevant discussion may be found on' | ||
if talkArgIsTalkPage then | if talkArgIsTalkPage then | ||
talkText = | talkText = string.format( | ||
'%s [[%s|%s]] | '%s [[%s|%s]].', | ||
talkText, | talkText, | ||
talk, | talk, | ||
talkTitle.prefixedText | talkTitle.prefixedText | ||
) | ) | ||
else | else | ||
talkText = | talkText = string.format( | ||
'%s [[%s#%s| | '%s the [[%s#%s|talk page]].', | ||
talkText, | talkText, | ||
talkTitle.prefixedText, | talkTitle.prefixedText, | ||
talk | talk | ||
) | ) | ||
end | end | ||
خط ۳۰۳: | خط ۳۰۰: | ||
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('F Y') | ||
end | end | ||
if date then | if date then | ||
self.date = | self.date = string.format(" <span class='date-container'>''(<span class='date'>%s</span>)''</span>", date) | ||
end | end | ||
self.info = args.info | self.info = args.info | ||
خط ۳۲۹: | خط ۳۲۶: | ||
self.imageEmptyCell = cfg.imageEmptyCell | self.imageEmptyCell = cfg.imageEmptyCell | ||
if cfg.imageEmptyCellStyle then | if cfg.imageEmptyCellStyle then | ||
self.imageEmptyCellStyle = 'border:none;padding: | self.imageEmptyCellStyle = 'border:none;padding:0;width:1px' | ||
end | end | ||
خط ۳۴۲: | خط ۳۳۹: | ||
and (cfg.imageSmallSize or '30x30px') | and (cfg.imageSmallSize or '30x30px') | ||
or '40x40px' | or '40x40px' | ||
self.imageLeft = | self.imageLeft = string.format('[[File:%s|%s|link=|alt=]]', self.typeImage | ||
or 'Imbox notice.png', imageSize) | or 'Imbox notice.png', imageSize) | ||
end | end | ||
خط ۳۵۴: | خط ۳۵۱: | ||
-- set templatestyles | -- set templatestyles | ||
self.templatestyles = args.templatestyles | self.templatestyles = args.templatestyles | ||
end | end | ||
خط ۳۷۵: | خط ۳۷۱: | ||
local date = args.date | local date = args.date | ||
date = type(date) == 'string' and date | date = type(date) == 'string' and date | ||
local preposition = ' | local preposition = 'from' | ||
for _, num in ipairs(nums) do | for _, num in ipairs(nums) do | ||
local mainCat = args['cat' .. tostring(num)] | local mainCat = args['cat' .. 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 = | local catTitle = string.format('%s %s %s', mainCat, preposition, date) | ||
self:addCat(0, catTitle) | self:addCat(0, catTitle) | ||
catTitle = getTitleObject(' | catTitle = getTitleObject('Category:' .. catTitle) | ||
if not catTitle or not catTitle.exists then | if not catTitle or not catTitle.exists then | ||
self:addCat(0, ' | self:addCat(0, 'Articles with invalid date parameter in template') | ||
end | end | ||
elseif mainCat and (not date or date == '') then | elseif mainCat and (not date or date == '') then | ||
خط ۴۳۳: | خط ۴۲۹: | ||
if self.categoryNums and #self.categoryNums > 0 then | if self.categoryNums and #self.categoryNums > 0 then | ||
templateCat = templateErrorCategory | templateCat = templateErrorCategory | ||
templateSort = ' | templateSort = 'C' | ||
end | end | ||
end | end | ||
خط ۴۴۴: | خط ۴۴۰: | ||
if self.invalidTypeError then | if self.invalidTypeError then | ||
local allSort = (self.title.namespace == 0 and 'Main:' or '') .. self.title.prefixedText | local allSort = (self.title.namespace == 0 and 'Main:' or '') .. self.title.prefixedText | ||
self:addCat('all', ' | self:addCat('all', 'Wikipedia message box parameter needs fixing', allSort) | ||
end | end | ||
if self.isSubstituted then | if self.isSubstituted then | ||
self:addCat('all', ' | self:addCat('all', 'Pages with incorrectly substituted templates') | ||
end | end | ||
end | end | ||
خط ۴۸۵: | خط ۴۸۱: | ||
root:tag('b') | root:tag('b') | ||
:addClass('error') | :addClass('error') | ||
:wikitext( | :wikitext(string.format( | ||
' | 'Template <code>%s[[Template:%s|%s]]%s</code> has been incorrectly substituted.', | ||
mw.text.nowiki('{{'), self.name, self.name, mw.text.nowiki('}}') | mw.text.nowiki('{{'), self.name, self.name, mw.text.nowiki('}}') | ||
)) | )) | ||
end | end | ||
-- Add support for a single custom templatestyles sheet. Undocumented as | -- Add support for a single custom templatestyles sheet. Undocumented as | ||
-- need should be limited and many templates using mbox are substed; we | -- need should be limited and many templates using mbox are substed; we | ||
-- don't want to spread templatestyles sheets around to arbitrary places | -- don't want to spread templatestyles sheets around to arbitrary places | ||
-- TODO: Add each template's stylesheet, waiting on [[MediaWiki talk:Common.css/to do]] | |||
local frame = mw.getCurrentFrame() -- we'll need this unconditionally for the TODO | |||
if self.templatestyles then | if self.templatestyles then | ||
root:wikitext(frame:extensionTag{ | root:wikitext(frame:extensionTag{ | ||
خط ۵۲۸: | خط ۵۲۲: | ||
-- image width to 52px. If any images in a div are wider than that, | -- image width to 52px. If any images in a div are wider than that, | ||
-- they may overlap with the text or cause other display problems. | -- they may overlap with the text or cause other display problems. | ||
imageLeftCell = imageLeftCell:tag('div'): | imageLeftCell = imageLeftCell:tag('div'):css('width', '52px') | ||
end | end | ||
imageLeftCell:wikitext(self.imageLeft or nil) | imageLeftCell:wikitext(self.imageLeft or nil) | ||
خط ۵۳۸: | خط ۵۳۲: | ||
row:tag('td') | row:tag('td') | ||
:addClass('mbox-empty-cell') | :addClass('mbox-empty-cell') | ||
:cssText(self.imageEmptyCellStyle or nil) | |||
end | end | ||
خط ۵۶۷: | خط ۵۶۲: | ||
:addClass('hide-when-compact') | :addClass('hide-when-compact') | ||
:tag('i') | :tag('i') | ||
:wikitext( | :wikitext(string.format(" (%s)", self.removalNotice)) | ||
end | end | ||
else | else | ||
خط ۵۸۲: | خط ۵۷۷: | ||
-- If we are using a div, redefine imageRightCell so that the image | -- If we are using a div, redefine imageRightCell so that the image | ||
-- is inside it. | -- is inside it. | ||
imageRightCell = imageRightCell:tag('div'): | imageRightCell = imageRightCell:tag('div'):css('width', '52px') | ||
end | end | ||
imageRightCell | imageRightCell | ||
خط ۶۰۱: | خط ۵۹۶: | ||
if self.invalidTypeError then | if self.invalidTypeError then | ||
root:tag('div') | root:tag('div') | ||
: | :css('text-align', 'center') | ||
:wikitext( | :wikitext(string.format( | ||
' | 'This message box is using an invalid "type=%s" parameter and needs fixing.', | ||
self.type or '' | self.type or '' | ||
)) | )) |