Modul:Message box: Perbedaan antara revisi

Konten dihapus Konten ditambahkan
RXerself (bicara | kontrib)
relevant discussion
Nyilvoskt (bicara | kontrib)
Tidak ada ringkasan suntingan
Tag: Suntingan perangkat seluler Suntingan peramban seluler Suntingan seluler lanjutan
 
(7 revisi perantara oleh 2 pengguna tidak ditampilkan)
Baris 1:
require('Modul:No globalsstrict')
-- This is a meta-module for producing message box templates, including
-- {{mbox}}, {{ambox}}, {{imbox}}, {{tmbox}}, {{ombox}}, {{cmbox}} and {{fmbox}}.
 
-- Load necessary modules.
require('Modul:No globals')
local getArgs
local yesno = require('Modul:Yesno')
 
-- Get a language object for formatDate and ucfirst.
local lang = mw.language.getContentLanguage()
 
-- Define constants
local CONFIG_MODULE = 'Modul:Message box/configuration'
local DEMOSPACES = {talk = 'tmbox', image = 'imbox', file = 'imbox', category = 'cmbox', article = 'ambox', main = 'ambox'}
 
--------------------------------------------------------------------------------
-- HelperFungsi functionspembantu
--------------------------------------------------------------------------------
 
local function getTitleObject(...)
-- Mendapatkan nilai objek judul dan kemudian menyalurkan fungsi ke kode pcall
-- Get the title object, passing the function through pcall
-- in case we are over the expensive function count limit.
local success, title = pcall(mw.title.new, ...)
if success then
Baris 57 ⟶ 49:
 
--------------------------------------------------------------------------------
-- Definisi kelas kotak
-- Box class definition
--------------------------------------------------------------------------------
 
Baris 67 ⟶ 59:
local obj = {}
 
-- Pengaturan nilai objek judul dengan ruang nama.
-- Set the title object and the namespace.
obj.title = getTitleObject(args.page) or mw.title.getCurrentTitle()
 
-- konfigurasi kotak pesan.
-- Set the config for our box type.
obj.cfg = cfg[boxType]
if not obj.cfg then
local ns = obj.title.namespace
-- boxType isdiatur sebagai "mbox" oratau pemasukan akan bernilai invalidtidak inputterduga
if args.demospace and args.demospace ~= '' then
-- implement demospace parameter ofdemospasi mbox
local demospace = string.lower(args.demospace)
if DEMOSPACES[demospace] then
-- usepenggunaan templatetemplat fromdari DEMOSPACES
obj.cfg = cfg[DEMOSPACES[demospace]]
elseif string.find( demospace, 'talk' ) then
Baris 104 ⟶ 96:
end
 
-- pengaturan argumen
-- Set the arguments, and remove all blank arguments except for the ones
-- listed in cfg.allowBlankParams.
do
Baris 119 ⟶ 111:
end
 
-- DefinePenentuan internalstruktur data structure.
obj.categories = {}
obj.classes = {}
-- For lazy loading ofPemuatan [[Modul:Category handler]].
obj.hasCategories = false
 
Baris 163 ⟶ 155:
self.typeImage = typeData.image
 
-- Menentukan apakah kotak yang ada mengalami kesalahan atau tidak.
-- Find if the box has been wrongly substituted.
self.isSubstituted = cfg.substCheck and args.subst == 'SUBST'
 
-- Menentukan penggunaan kotak pesan yang digunakan.
-- Find whether we are using a small message box.
self.isSmall = cfg.allowSmall and (
cfg.smallParam and args.small == cfg.smallParam
Baris 208 ⟶ 200:
'^[tT][eE][mM][pP][lL][aA][tT][eE][%s_]*:[%s_]*(.*)$'
) or self.name
templateName = 'TemplateTemplat:' .. templateName
self.templateTitle = getTitleObject(templateName)
end
Baris 215 ⟶ 207:
end
-- Pemrosesan data pada
-- Process data for collapsible text fields. At the moment these are only
-- used in {{ambox}}.
if self.useCollapsibleTextFields then
-- Get the self.issue value.
Baris 224 ⟶ 216:
local sect
if args.sect == '' then
sect = 'Halaman ' .. (cfg.sectionDefault or 'page')
elseif type(args.sect) == 'string' then
sect = 'Bagian ' .. args.sect
end
local issue = args.issue
Baris 271 ⟶ 263:
if self.isSmall then
local talkLink = talkArgIsTalkPage and talk or (talkTitle.prefixedText .. '#' .. talk)
talkText = string.format('([[%s|talkpembicaraan]])', talkLink)
else
talkText = 'SilakanDiskusi berdiskusiterkait didapat dibaca pada'
if talkArgIsTalkPage then
talkText = string.format(
Baris 283 ⟶ 275:
else
talkText = string.format(
'%s the [[%s#%s|halaman pembicaraan]].',
talkText,
talkTitle.prefixedText,
Baris 303 ⟶ 295:
end
if date then
self.date = string.format(" <span class='date-container'>''<i>(<span class='date'>%s</span>)''</i></span>", date)
end
self.info = args.info
Baris 325 ⟶ 317:
self.imageCellDiv = not self.isSmall and cfg.imageCellDiv
self.imageEmptyCell = cfg.imageEmptyCell
if cfg.imageEmptyCellStyle then
self.imageEmptyCellStyle = 'border:none;padding:0;width:1px'
end
 
-- Left image settings.
Baris 349 ⟶ 338:
self.imageRight = imageRight
end
-- set templatestyles
self.base_templatestyles = cfg.templatestyles
self.templatestyles = args.templatestyles
end
 
Baris 360 ⟶ 353:
 
local nums = {}
for _, prefix in ipairs{'cat', 'categorykategori', 'all'} do
args[prefix .. '1'] = args[prefix]
nums = union(nums, getArgNums(args, prefix))
Baris 368 ⟶ 361:
local date = args.date
date = type(date) == 'string' and date
local preposition = 'sejakfrom'
for _, num in ipairs(nums) do
local mainCat = args['cat' .. tostring(num)]
or args['categorykategori' .. tostring(num)]
local allCat = args['all' .. tostring(num)]
mainCat = type(mainCat) == 'string' and mainCat
Baris 378 ⟶ 371:
local catTitle = string.format('%s %s %s', mainCat, preposition, date)
self:addCat(0, catTitle)
catTitle = getTitleObject('KategoriCategory:' .. catTitle)
if not catTitle or not catTitle.exists then
self:addCat(0, 'ArtikelArticles denganwith parameterinvalid tanggaldate yang tidak validparameter padain templattemplate')
end
elseif mainCat and (not date or date == '') then
Baris 440 ⟶ 433:
end
if self.isSubstituted then
self:addCat('all', 'Halaman dengan templatkesalahan yangsubtitusi salah disubstitusitemplat')
end
end
Baris 461 ⟶ 454:
end
-- Convert category tables to strings and pass them through
-- [[ModulModule:Category handler]].
return require('Modul:Category handler')._main{
main = table.concat(self.categories[0] or {}),
Baris 479 ⟶ 472:
:addClass('error')
:wikitext(string.format(
'Templat <code>%s[[Template:%s|%s]]%s</code> disubstitusitidak disubtitusikan dengan kelirubenar.',
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
 
Baris 507 ⟶ 515:
-- 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.
imageLeftCell = imageLeftCell:tag('div'):cssaddClass('width', '52pxmbox-image-div')
end
imageLeftCell:wikitext(self.imageLeft or nil)
Baris 517 ⟶ 525:
row:tag('td')
:addClass('mbox-empty-cell')
:cssText(self.imageEmptyCellStyle or nil)
end
 
Baris 562 ⟶ 569:
-- If we are using a div, redefine imageRightCell so that the image
-- is inside it.
imageRightCell = imageRightCell:tag('div'):cssaddClass('width', '52pxmbox-image-div')
end
imageRightCell
Baris 581 ⟶ 588:
if self.invalidTypeError then
root:tag('div')
:cssaddClass('textmbox-align', 'centerinvalid-type')
:wikitext(string.format(
'KotakThis pesanmessage inibox menggunakanis parameterusing an invalid "type=%s" yangparameter and butuhneeds perbaikanfixing.',
self.type or ''
))
Baris 617 ⟶ 624:
return function (frame)
if not getArgs then
getArgs = require('ModulModule:Arguments').getArgs
end
return t.main(k, getArgs(frame, {trim = false, removeBlanks = false}))