پودمان:Message box: تفاوت میان نسخه‌ها

fa>Jeeputer
جزبدون خلاصۀ ویرایش
جز ۱ نسخه واردشده
 
(۴ نسخهٔ میانی ویرایش شده توسط ۳ کاربر نشان داده نشد)
خط ۳: خط ۳:


-- Load necessary modules.
-- Load necessary modules.
require('Module:No globals')
require('strict')
local getArgs
local getArgs
local yesno = require('Module:Yesno')
local yesno = require('Module:Yesno')
local lang = mw.language.getContentLanguage()


-- 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 = string.lower(args.demospace)
local demospace = mw.ustring.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 string.find( demospace, 'بحث' ) then
elseif mw.ustring.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('[[رده:%s|%s]]', cat, sort)
cat = mw.ustring.format('[[رده:%s|%s]]', cat, sort)
else
else
cat = string.format('[[رده:%s]]', cat)
cat = mw.ustring.format('[[رده:%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-' .. string.gsub(self.name,' ','_'))
self:addClass('box-' .. mw.ustring.gsub(self.name,' ','_'))
end
end
if yesno(args.plainlinks) ~= false then
if yesno(args.plainlinks) ~= false then
خط ۲۷۱: خط ۲۷۲:
                 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 = mw.ustring.format('([[%s|بحث]])', talkLink)
                 else
                 else
                     talkText = 'گفتگوی مربوطه ممکن است در'
                     talkText = 'گفتگوی مربوطه ممکن است در'
                     if talkArgIsTalkPage then
                     if talkArgIsTalkPage then
                         talkText = string.format(
                         talkText = mw.ustring.format(
                             '%s [[%s|%s]] %s.',
                             '%s [[%s|%s]] %s',
                             talkText,
                             talkText,
                             talk,
                             talk,
خط ۲۸۳: خط ۲۸۴:
                         )
                         )
                     else
                     else
                         talkText = string.format(
                         talkText = mw.ustring.format(
                             '%s [[%s#%s|صفحهٔ بحث]] %s.',
                             '%s [[%s#%s|صفحهٔ بحث]] %s.',
                             talkText,
                             talkText,
خط ۳۰۲: خط ۳۰۳:
date = args.date
date = args.date
elseif args.date == '' and self.isTemplatePage then
elseif args.date == '' and self.isTemplatePage then
date = lang:formatDate('xiF xiY')
date = lang:formatDate('F Y') -- استفاده از تاریخ میلادی مرسوم است و نه تاریخ شمسی
end
end
if date then
if date then
self.date = string.format(" <small class='date-container'>''(<span class='date'>%s</span>)''</small>", date)
self.date = mw.ustring.format(" <span class='date-container'><i>(<span class='date'>%s</span>)</i></span>", date)
end
end
self.info = args.info
self.info = args.info
خط ۳۴۱: خط ۳۴۲:
and (cfg.imageSmallSize or '30x30px')
and (cfg.imageSmallSize or '30x30px')
or '40x40px'
or '40x40px'
self.imageLeft = string.format('[[پرونده:%s|%s|link=|alt=]]', self.typeImage
self.imageLeft = mw.ustring.format('[[پرونده:%s|%s|link=|alt=]]', self.typeImage
or 'Imbox notice.png', imageSize)
or 'Imbox notice.png', imageSize)
end
end
خط ۳۵۱: خط ۳۵۲:
self.imageRight = imageRight
self.imageRight = imageRight
end
end
-- set templatestyles
self.base_templatestyles = cfg.templatestyles
self.templatestyles = args.templatestyles
end
end


خط ۳۷۸: خط ۳۸۳:
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 = string.format('%s %s %s', mainCat, preposition, date)
local catTitle = mw.ustring.format('%s %s %s', mainCat, preposition, date)
self:addCat(0, catTitle)
self:addCat(0, catTitle)
catTitle = getTitleObject('رده:' .. catTitle)
catTitle = getTitleObject('رده:' .. catTitle)
خط ۴۸۰: خط ۴۸۵:
root:tag('b')
root:tag('b')
:addClass('error')
:addClass('error')
:wikitext(string.format(
:wikitext(mw.ustring.format(
'الگوی <code>%s[[الگو:%s|%s]]%s</code> اشتباه جانشین شده‌است.',
'الگوی <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
local frame = mw.getCurrentFrame()
root:wikitext(frame:extensionTag{
name = 'templatestyles',
args = { src = self.base_templatestyles },
})
-- Add support for a single custom templatestyles sheet. Undocumented as
-- need should be limited and many templates using mbox are substed; we
-- don't want to spread templatestyles sheets around to arbitrary places
if self.templatestyles then
root:wikitext(frame:extensionTag{
name = 'templatestyles',
args = { src = self.templatestyles },
})
end
end


خط ۵۰۹: خط ۵۲۸:
-- 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'):css('width', '52px')
imageLeftCell = imageLeftCell:tag('div'):addClass('mbox-image-div')
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


خط ۵۴۶: خط ۵۶۴:
end
end
if self.removalNotice then
if self.removalNotice then
textCellDiv:tag('small')
textCellDiv:tag('span')
:addClass('hide-when-compact')
:addClass('hide-when-compact')
:tag('i')
:tag('i')
:wikitext(string.format(" (%s)", self.removalNotice))
:wikitext(mw.ustring.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'):css('width', '52px')
imageRightCell = imageRightCell:tag('div'):addClass('mbox-image-div')
end
end
imageRightCell
imageRightCell
خط ۵۸۳: خط ۶۰۱:
if self.invalidTypeError then
if self.invalidTypeError then
root:tag('div')
root:tag('div')
:css('text-align', 'center')
:addClass('mbox-invalid-type')
:wikitext(string.format(
:wikitext(mw.ustring.format(
'این جعبه پیام از پارامتر نامعتبر «type=%s» استفاده می‌کند و نیازمند اصلاح است.',
'این جعبه پیام از پارامتر نامعتبر «type=%s» استفاده می‌کند و نیازمند اصلاح است.',
self.type or ''
self.type or ''