الفرق بين المراجعتين لصفحة: «وحدة:Message box»
ط مراجعة واحدة |
ط مراجعة واحدة |
||
| (٤ مراجعات متوسطة بواسطة مستخدمين اثنين آخرين غير معروضة) | |||
| سطر ١: | سطر ١: | ||
require('strict') | |||
require(' | |||
local getArgs | local getArgs | ||
local yesno = require('Module:Yesno') | local yesno = require('Module:Yesno') | ||
local lang = mw.language.getContentLanguage() | local lang = mw.language.getContentLanguage() | ||
local CONFIG_MODULE = 'Module:Message box/configuration' | local CONFIG_MODULE = 'Module:Message box/configuration' | ||
local DEMOSPACES = {talk = 'tmbox', image = 'imbox', file = 'imbox', category = 'cmbox', article = 'ambox', main = 'ambox'} | local DEMOSPACES = {talk = 'tmbox', image = 'imbox', file = 'imbox', category = 'cmbox', article = 'ambox', main = 'ambox'} | ||
| سطر ٨١: | سطر ٧٤: | ||
-- 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, 'نقاش' ) 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('[[تصنيف:%s|%s]]', cat, sort) | ||
else | else | ||
cat = string.format('[[ | 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 = ' | 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 = ' | sect = 'هذه ' .. (cfg.sectionDefault or 'page') | ||
elseif type(args.sect) == 'string' then | elseif type(args.sect) == 'string' then | ||
sect = ' | sect = 'هذه ' .. args.sect | ||
end | end | ||
local issue = args.issue | local issue = args.issue | ||
| سطر ٢٦٨: | سطر ٢٦١: | ||
end | end | ||
if talkTitle and talkTitle.exists then | if talkTitle and talkTitle.exists then | ||
local talkText | |||
if self.isSmall then | |||
local talkLink = talkArgIsTalkPage and talk or (talkTitle.prefixedText .. '#' .. talk) | |||
talkText = string.format('([[%s|نقاش]])', talkLink) | |||
else | |||
talkText = 'قد يكون هنالك نقاشٌ ذو علاقةٍ في' | |||
if talkArgIsTalkPage then | |||
talkText = string.format( | |||
'%s [[%s|%s]] %s.', | |||
talkText, | |||
talk, | |||
talkTitle.prefixedText, | |||
'المتعلّقة' | |||
) | |||
else | |||
talkText = string.format( | |||
'%s [[%s#%s|صفحة النقاش]] %s.', | |||
talkText, | |||
talkTitle.prefixedText, | |||
talk, | |||
'المتعلّقة' | |||
) | |||
end | |||
end | |||
self.talk = talkText | self.talk = talkText | ||
end | end | ||
| سطر ٢٩٧: | سطر ٢٩٨: | ||
end | end | ||
if date then | if date then | ||
self.date = string.format(" < | self.date = string.format(" <span class='date-container'><i>(<span class='date'>%s</span>)</i></span>", date) | ||
end | end | ||
self.info = args.info | self.info = args.info | ||
| سطر ٣١٩: | سطر ٣٢٠: | ||
self.imageCellDiv = not self.isSmall and cfg.imageCellDiv | self.imageCellDiv = not self.isSmall and cfg.imageCellDiv | ||
self.imageEmptyCell = cfg.imageEmptyCell | self.imageEmptyCell = cfg.imageEmptyCell | ||
-- | -- Right image settings. | ||
local | local imageRight = self.isSmall and args.smallimage or args.image | ||
if cfg.imageCheckBlank and | if cfg.imageCheckBlank and imageRight ~= 'blank' and imageRight ~= 'none' and imageRight ~= 'بدون' | ||
or not cfg.imageCheckBlank and | or not cfg.imageCheckBlank and imageRight ~= 'none' and imageRight ~= 'بدون' | ||
then | then | ||
self. | self.imageRight = imageRight | ||
if not | 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. | 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 | ||
-- | -- Left image settings. | ||
local | local imageLeft = self.isSmall and args.smallimageleft or args.imageleft | ||
if not (cfg. | if not (cfg.imageLeftNone and imageLeft == 'none' and imageLeft == 'بدون') then | ||
self. | self.imageLeft = imageLeft | ||
end | end | ||
-- set templatestyles | |||
self.base_templatestyles = cfg.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 = 'منذ' | ||
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, 'مقالات تستعمل قوالب صيانة غير مؤرخة') | ||
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( | ||
' | 'قالب <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 | ||
| سطر ٤٩٢: | سطر ٥٠٩: | ||
end | end | ||
-- Add the | -- Add the right-hand image. | ||
local row = boxTable:tag('tr') | local row = boxTable:tag('tr') | ||
if self. | if self.imageRight then | ||
local | local imageRightCell = 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 imageRightCell so that the image | ||
-- is inside it. Divs use style="width: | -- 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. | ||
imageRightCell = imageRightCell:tag('div'):addClass('mbox-image-div') | |||
end | end | ||
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 | ||
| سطر ٥١١: | سطر ٥٢٨: | ||
row:tag('td') | row:tag('td') | ||
:addClass('mbox-empty-cell') | :addClass('mbox-empty-cell') | ||
end | end | ||
| سطر ٥٢٤: | سطر ٥٤٠: | ||
:addClass('mbox-text-span') | :addClass('mbox-text-span') | ||
:wikitext(self.issue or nil) | :wikitext(self.issue or nil) | ||
if (self.talk or self.fix) | if (self.talk or self.fix) then | ||
textCellDiv:tag('span') | textCellDiv:tag('span') | ||
:addClass('hide-when-compact') | :addClass('hide-when-compact') | ||
| سطر ٥٣٨: | سطر ٥٥٤: | ||
end | end | ||
if self.removalNotice then | if self.removalNotice then | ||
textCellDiv:tag(' | textCellDiv:tag('span') | ||
:addClass('hide-when-compact') | :addClass('hide-when-compact') | ||
:tag('i') | :tag('i') | ||
:wikitext(string.format(" | :wikitext(string.format("%s", self.removalNotice)) | ||
end | end | ||
else | else | ||
| سطر ٥٥٠: | سطر ٥٦٦: | ||
end | end | ||
-- Add the | -- Add the left-hand image. | ||
if self. | if self.imageLeft then | ||
local | local imageLeftCell = row:tag('td'):addClass('mbox-imageleft') | ||
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. | -- is inside it. | ||
imageLeftCell = imageLeftCell:tag('div'):addClass('mbox-image-div') | |||
end | end | ||
imageLeftCell | |||
:wikitext(self. | :wikitext(self.imageLeft or nil) | ||
end | end | ||
| سطر ٥٦٦: | سطر ٥٨٢: | ||
boxTable:tag('tr') | boxTable:tag('tr') | ||
:tag('td') | :tag('td') | ||
:attr('colspan', self. | :attr('colspan', self.imageLeft and '3' or '2') | ||
:addClass('mbox-text') | :addClass('mbox-text') | ||
:cssText(self.textstyle or nil) | :cssText(self.textstyle or nil) | ||
| سطر ٥٧٥: | سطر ٥٩١: | ||
if self.invalidTypeError then | if self.invalidTypeError then | ||
root:tag('div') | root:tag('div') | ||
: | :addClass('mbox-invalid-type') | ||
:wikitext(string.format( | :wikitext(string.format( | ||
' | 'صندوق الرسالة هذا يستخدم وسيط "type=%s" غير صالح، وينبغي إصلاحه.', | ||
self.type or '' | self.type or '' | ||
)) | )) | ||