انتقل إلى المحتوى

الفرق بين المراجعتين لصفحة: «وحدة:Message box»

أُضيف ٣١٤ بايت ،  ١١ نوفمبر ٢٠٢٢
لا يوجد ملخص تحرير
(Replace Module:No globals with require( "strict" ))
لا ملخص تعديل
سطر ١: سطر ١:
require('strict')
require('Module:No globals')
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, 'talk' ) then
elseif string.find( demospace, 'نقاش' ) 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('[[Category:%s|%s]]', cat, sort)
cat = string.format('[[تصنيف:%s|%s]]', cat, sort)
else
else
cat = string.format('[[Category:%s]]', cat)
cat = string.format('[[تصنيف:%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_]*(.*)$'
'^([tT][eE][mM][pP][lL][aA][tT][eE]|قالب)[%s_]*:[%s_]*(.*)$'
) or self.name
) or self.name
templateName = 'Template:' .. templateName
templateName = 'قالب:' .. templateName
self.templateTitle = getTitleObject(templateName)
self.templateTitle = getTitleObject(templateName)
end
end
سطر ٢١٧: سطر ٢١٧:
local sect
local sect
if args.sect == '' then
if args.sect == '' then
sect = 'This ' .. (cfg.sectionDefault or 'page')
sect = 'هذه ' .. (cfg.sectionDefault or 'page')
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
سطر ٢٦٤: سطر ٢٦٤:
                 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|talk]])', talkLink)
                     talkText = string.format('([[%s|نقاش]])', talkLink)
                 else
                 else
                     talkText = 'Relevant discussion may be found on'
                     talkText = 'قد يكون هنالك نقاشٌ ذو علاقةٍ في'
                     if talkArgIsTalkPage then
                     if talkArgIsTalkPage then
                         talkText = string.format(
                         talkText = string.format(
                             '%s [[%s|%s]].',
                             '%s [[%s|%s]] %s.',
                             talkText,
                             talkText,
                             talk,
                             talk,
                             talkTitle.prefixedText
                             talkTitle.prefixedText,
                            'المتعلّقة'
                         )
                         )
                     else
                     else
                         talkText = string.format(
                         talkText = string.format(
                             '%s the [[%s#%s|talk page]].',
                             '%s [[%s#%s|صفحة النقاش]] %s.',
                             talkText,
                             talkText,
                             talkTitle.prefixedText,
                             talkTitle.prefixedText,
                             talk
                             talk,
                            'المتعلّقة'
                         )
                         )
                     end
                     end
سطر ٣١٩: سطر ٣٢١:
self.imageEmptyCell = cfg.imageEmptyCell
self.imageEmptyCell = cfg.imageEmptyCell


-- Left image settings.
-- Right image settings.
local imageLeft = self.isSmall and args.smallimage or args.image
local imageRight = self.isSmall and args.smallimage or args.image
if cfg.imageCheckBlank and imageLeft ~= 'blank' and imageLeft ~= 'none'
if cfg.imageCheckBlank and imageRight ~= 'blank' and imageRight ~= 'none' and imageRight ~= 'بدون'
or not cfg.imageCheckBlank and imageLeft ~= 'none'
or not cfg.imageCheckBlank and imageRight ~= 'none' and imageRight ~= 'بدون'
then
then
self.imageLeft = imageLeft
self.imageRight = imageRight
if not imageLeft then
if not imageRight then
local imageSize = self.isSmall
local imageSize = self.isSmall
and (cfg.imageSmallSize or '30x30px')
and (cfg.imageSmallSize or '30x30px')
or '40x40px'
or '40x40px'
self.imageLeft = string.format('[[File:%s|%s|link=|alt=]]', self.typeImage
self.imageRight = 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.
-- Left image settings.
local imageRight = self.isSmall and args.smallimageright or args.imageright
local imageLeft = self.isSmall and args.smallimageleft or args.imageleft
if not (cfg.imageRightNone and imageRight == 'none') then
if not (cfg.imageLeftNone and imageLeft == 'none' and imageLeft == 'بدون') then
self.imageRight = imageRight
self.imageLeft = imageLeft
end
end
سطر ٣٦٢: سطر ٣٦٤:
local date = args.date
local date = args.date
date = type(date) == 'string' and date
date = type(date) == 'string' and date
local preposition = 'from'
local preposition = 'منذ'
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, 'Articles with invalid date parameter in template')
self:addCat(0, 'مقالات تستعمل قوالب صيانة غير مؤرخة')
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.',
'قالب <code>%s[[قالب:%s|%s]]%s</code> تم نسخه بشكلٍ خاطئٍ.',
mw.text.nowiki('{{'), self.name, self.name, mw.text.nowiki('}}')
mw.text.nowiki('{{'), self.name, self.name, mw.text.nowiki('}}')
))
))
سطر ٥٠٧: سطر ٥٠٩:
end
end


-- Add the left-hand image.
-- Add the right-hand image.
local row = boxTable:tag('tr')
local row = boxTable:tag('tr')
if self.imageLeft then
if self.imageRight then
local imageLeftCell = row:tag('td'):addClass('mbox-image')
local imageRightCell = 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
-- If we are using a div, redefine imageRightCell so that the image
-- is inside it. Divs use style="width: 52px;", which limits the
-- is inside it. Divs use style="width: 42px;", 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')
imageRightCell = imageRightCell:tag('div'):addClass('mbox-image-div')
end
end
imageLeftCell:wikitext(self.imageLeft or nil)
imageRightCell:wikitext(self.imageRight 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 right-hand image.
-- Add the left-hand image.
if self.imageRight then
if self.imageLeft then
local imageRightCell = row:tag('td'):addClass('mbox-imageright')
local imageLeftCell = row:tag('td'):addClass('mbox-imageleft')
if self.imageCellDiv then
if self.imageCellDiv then
-- If we are using a div, redefine imageRightCell so that the image
-- If we are using a div, redefine imageLeftCell so that the image
-- is inside it.
-- is inside it.
imageRightCell = imageRightCell:tag('div'):addClass('mbox-image-div')
imageLeftCell = imageLeftCell:tag('div'):addClass('mbox-image-div')
end
end
imageRightCell
imageLeftCell
:wikitext(self.imageRight or nil)
:wikitext(self.imageLeft or nil)
end
end


سطر ٥٨٠: سطر ٥٨٢:
boxTable:tag('tr')
boxTable:tag('tr')
:tag('td')
:tag('td')
:attr('colspan', self.imageRight and '3' or '2')
:attr('colspan', self.imageLeft 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.',
'صندوق الرسالة هذا يستخدم وسيط "type=%s" غير صالح، وينبغي إصلاحه.',
self.type or ''
self.type or ''
))
))
مستخدم مجهول