Modul:Message box: Perbedaan antara revisi
Konten dihapus Konten ditambahkan
relevant discussion |
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 globals')
local getArgs
local yesno = require('Modul:Yesno')
local lang = mw.language.getContentLanguage()
local CONFIG_MODULE = 'Modul:Message box/configuration'
local DEMOSPACES = {talk = 'tmbox', image = 'imbox', file = 'imbox', category = 'cmbox', article = 'ambox', main = 'ambox'}
--------------------------------------------------------------------------------
--
--------------------------------------------------------------------------------
local function getTitleObject(...)
-- Mendapatkan nilai objek judul dan kemudian menyalurkan fungsi ke kode pcall
local success, title = pcall(mw.title.new, ...)
if success then
Baris 57 ⟶ 49:
--------------------------------------------------------------------------------
-- Definisi kelas kotak
--------------------------------------------------------------------------------
Baris 67 ⟶ 59:
local obj = {}
-- Pengaturan nilai objek judul dengan ruang nama.
obj.title = getTitleObject(args.page) or mw.title.getCurrentTitle()
-- konfigurasi kotak pesan.
obj.cfg = cfg[boxType]
if not obj.cfg then
local ns = obj.title.namespace
-- boxType
if args.demospace and args.demospace ~= '' then
--
local demospace = string.lower(args.demospace)
if DEMOSPACES[demospace] then
--
obj.cfg = cfg[DEMOSPACES[demospace]]
elseif string.find( demospace, 'talk' ) then
Baris 104 ⟶ 96:
end
-- pengaturan argumen
-- listed in cfg.allowBlankParams.
do
Baris 119 ⟶ 111:
end
--
obj.categories = {}
obj.classes = {}
--
obj.hasCategories = false
Baris 163 ⟶ 155:
self.typeImage = typeData.image
-- Menentukan apakah kotak yang ada mengalami kesalahan atau tidak.
self.isSubstituted = cfg.substCheck and args.subst == 'SUBST'
-- Menentukan penggunaan kotak pesan yang digunakan.
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 = '
self.templateTitle = getTitleObject(templateName)
end
Baris 215 ⟶ 207:
end
-- Pemrosesan data pada
--
if self.useCollapsibleTextFields then
-- Get the self.issue value.
Baris 224 ⟶ 216:
local sect
if args.sect == '' then
sect = '
elseif type(args.sect) == 'string' then
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|
else
talkText = '
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'>
end
self.info = args.info
Baris 325 ⟶ 317:
self.imageCellDiv = not self.isSmall and cfg.imageCellDiv
self.imageEmptyCell = cfg.imageEmptyCell
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', '
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 = '
for _, num in ipairs(nums) do
local mainCat = args['cat' .. tostring(num)]
or args['
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('
if not catTitle or not catTitle.exists then
self:addCat(0, '
end
elseif mainCat and (not date or date == '') then
Baris 440 ⟶ 433:
end
if self.isSubstituted then
self:addCat('all', 'Halaman dengan
end
end
Baris 461 ⟶ 454:
end
-- Convert category tables to strings and pass them through
-- [[
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>
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'):
end
imageLeftCell:wikitext(self.imageLeft or nil)
Baris 517 ⟶ 525:
row:tag('td')
:addClass('mbox-empty-cell')
end
Baris 562 ⟶ 569:
-- If we are using a div, redefine imageRightCell so that the image
-- is inside it.
imageRightCell = imageRightCell:tag('div'):
end
imageRightCell
Baris 581 ⟶ 588:
if self.invalidTypeError then
root:tag('div')
:
:wikitext(string.format(
'
self.type or ''
))
Baris 617 ⟶ 624:
return function (frame)
if not getArgs then
getArgs = require('
end
return t.main(k, getArgs(frame, {trim = false, removeBlanks = false}))
|