١٥٠
تعديل
لا ملخص تعديل |
ط (مراجعة واحدة) |
||
| سطر ١: | سطر ١: | ||
require(' | require('strict') | ||
local getArgs | local getArgs | ||
local yesno = require('Module:Yesno') | local yesno = require('Module:Yesno') | ||
| سطر ٧٤: | سطر ٧٤: | ||
-- use template from DEMOSPACES | -- use template from DEMOSPACES | ||
obj.cfg = cfg[DEMOSPACES[demospace]] | obj.cfg = cfg[DEMOSPACES[demospace]] | ||
elseif string.find( demospace, ' | 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 = string.format('[[ | cat = string.format('[[Category:%s|%s]]', cat, sort) | ||
else | else | ||
cat = string.format('[[ | cat = string.format('[[Category:%s]]', cat) | ||
end | end | ||
self.hasCategories = true | self.hasCategories = true | ||
| سطر ١٩٩: | سطر ١٩٩: | ||
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 = string.format('([[%s| | talkText = string.format('([[%s|talk]])', talkLink) | ||
else | else | ||
talkText = ' | talkText = 'Relevant discussion may be found on' | ||
if talkArgIsTalkPage then | if talkArgIsTalkPage then | ||
talkText = string.format( | talkText = string.format( | ||
'%s [[%s|%s]] | '%s [[%s|%s]].', | ||
talkText, | talkText, | ||
talk, | talk, | ||
talkTitle.prefixedText | talkTitle.prefixedText | ||
) | ) | ||
else | else | ||
talkText = string.format( | talkText = string.format( | ||
'%s [[%s#%s| | '%s the [[%s#%s|talk page]].', | ||
talkText, | talkText, | ||
talkTitle.prefixedText, | talkTitle.prefixedText, | ||
talk | talk | ||
) | ) | ||
end | end | ||
| سطر ٣٢١: | سطر ٣١٩: | ||
self.imageEmptyCell = cfg.imageEmptyCell | self.imageEmptyCell = cfg.imageEmptyCell | ||
-- | -- Left image settings. | ||
local | local imageLeft = self.isSmall and args.smallimage or args.image | ||
if cfg.imageCheckBlank and | if cfg.imageCheckBlank and imageLeft ~= 'blank' and imageLeft ~= 'none' | ||
or not cfg.imageCheckBlank and | or not cfg.imageCheckBlank and imageLeft ~= 'none' | ||
then | then | ||
self. | self.imageLeft = imageLeft | ||
if not | if not imageLeft then | ||
local imageSize = self.isSmall | local imageSize = self.isSmall | ||
and (cfg.imageSmallSize or '30x30px') | and (cfg.imageSmallSize or '30x30px') | ||
or '40x40px' | or '40x40px' | ||
self. | self.imageLeft = string.format('[[File:%s|%s|link=|alt=]]', self.typeImage | ||
or 'Imbox notice.png', imageSize) | or 'Imbox notice.png', imageSize) | ||
end | end | ||
end | end | ||
-- | -- Right image settings. | ||
local | local imageRight = self.isSmall and args.smallimageright or args.imageright | ||
if not (cfg. | if not (cfg.imageRightNone and imageRight == 'none') then | ||
self. | self.imageRight = imageRight | ||
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)] | ||
| سطر ٣٧٦: | سطر ٣٧٤: | ||
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(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 | ||
| سطر ٤٧٥: | سطر ٤٧٣: | ||
:addClass('error') | :addClass('error') | ||
:wikitext(string.format( | :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 the | -- Add the left-hand image. | ||
local row = boxTable:tag('tr') | local row = boxTable:tag('tr') | ||
if self. | if self.imageLeft then | ||
local | local imageLeftCell = row:tag('td'):addClass('mbox-image') | ||
if self.imageCellDiv then | if self.imageCellDiv then | ||
-- If we are using a div, redefine | -- If we are using a div, redefine imageLeftCell so that the image | ||
-- is inside it. Divs use style="width: | -- is inside it. Divs use style="width: 52px;", which limits the | ||
-- 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'):addClass('mbox-image-div') | |||
end | end | ||
imageLeftCell:wikitext(self.imageLeft or nil) | |||
elseif self.imageEmptyCell then | elseif self.imageEmptyCell then | ||
-- Some message boxes define an empty cell if no image is specified, and | -- Some message boxes define an empty cell if no image is specified, and | ||
| سطر ٥٥٧: | سطر ٥٥٥: | ||
:addClass('hide-when-compact') | :addClass('hide-when-compact') | ||
:tag('i') | :tag('i') | ||
:wikitext(string.format("%s", self.removalNotice)) | :wikitext(string.format(" (%s)", self.removalNotice)) | ||
end | end | ||
else | else | ||
| سطر ٥٦٦: | سطر ٥٦٤: | ||
end | end | ||
-- Add the | -- Add the right-hand image. | ||
if self. | if self.imageRight then | ||
local | local imageRightCell = row:tag('td'):addClass('mbox-imageright') | ||
if self.imageCellDiv then | if self.imageCellDiv then | ||
-- If we are using a div, redefine | -- If we are using a div, redefine imageRightCell so that the image | ||
-- is inside it. | -- is inside it. | ||
imageRightCell = imageRightCell:tag('div'):addClass('mbox-image-div') | |||
end | end | ||
imageRightCell | |||
:wikitext(self. | :wikitext(self.imageRight or nil) | ||
end | end | ||
| سطر ٥٨٢: | سطر ٥٨٠: | ||
boxTable:tag('tr') | boxTable:tag('tr') | ||
:tag('td') | :tag('td') | ||
:attr('colspan', self. | :attr('colspan', self.imageRight and '3' or '2') | ||
:addClass('mbox-text') | :addClass('mbox-text') | ||
:cssText(self.textstyle or nil) | :cssText(self.textstyle or nil) | ||
| سطر ٥٩٣: | سطر ٥٩١: | ||
:addClass('mbox-invalid-type') | :addClass('mbox-invalid-type') | ||
:wikitext(string.format( | :wikitext(string.format( | ||
' | 'This message box is using an invalid "type=%s" parameter and needs fixing.', | ||
self.type or '' | self.type or '' | ||
)) | )) | ||