Modul:Message box: Perbedaan antara revisi
Konten dihapus Konten ditambahkan
k Melindungi "Modul:Message box": 7. Templat atau modul yang banyak digunakan ([Sunting=Hanya untuk pengurus] (selamanya) [Pindahkan=Hanya untuk pengurus] (selamanya)) |
Tidak ada ringkasan suntingan Tag: Suntingan perangkat seluler Suntingan peramban seluler Suntingan seluler lanjutan |
||
(15 revisi perantara oleh 6 pengguna tidak ditampilkan) | |||
Baris 1:
require('strict')
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
-- demospasi mbox
local demospace = string.lower(args.demospace)
if DEMOSPACES[demospace] then
-- penggunaan templat dari DEMOSPACES
obj.cfg = cfg[DEMOSPACES[demospace]]
elseif string.find( demospace, 'talk' ) then
-- demo as a talk page
obj.cfg = cfg.tmbox
else
-- default to ombox
obj.cfg = cfg.ombox
end
elseif ns == 0 then
obj.cfg = cfg.ambox -- main namespace
elseif ns == 6 then
Baris 91 ⟶ 96:
end
-- pengaturan argumen
-- listed in cfg.allowBlankParams.
do
Baris 106 ⟶ 111:
end
--
obj.categories = {}
obj.classes = {}
-- Pemuatan [[Modul:Category handler]].
obj.hasCategories = false
return setmetatable(obj, MessageBox)
Baris 122 ⟶ 129:
cat = string.format('[[Kategori:%s]]', cat)
end
self.hasCategories = true
self.categories[ns] = self.categories[ns] or {}
table.insert(self.categories[ns], cat)
Baris 147 ⟶ 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 158 ⟶ 166:
-- Add attributes, classes and styles.
self.id = args.id
self.name = args.name
if self.name then
self:addClass('box-' .. string.gsub(self.name,' ','_'))
end
if yesno(args.plainlinks) ~= false then
self:addClass('plainlinks')
Baris 183 ⟶ 195:
and cfg.templateCategoryRequireName
then
if self.name then
local templateName = mw.ustring.match(
Baris 189 ⟶ 200:
'^[tT][eE][mM][pP][lL][aA][tT][eE][%s_]*:[%s_]*(.*)$'
) or self.name
templateName = '
self.templateTitle = getTitleObject(templateName)
end
Baris 195 ⟶ 206:
and mw.title.equals(self.title, self.templateTitle)
end
-- Pemrosesan data pada
--
if self.useCollapsibleTextFields then
-- Get the self.issue value.
Baris 205 ⟶ 216:
local sect
if args.sect == '' then
sect = '
elseif type(args.sect) == 'string' then
sect = '
end
local issue = args.issue
Baris 249 ⟶ 260:
end
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|pembicaraan]])', talkLink)
else
talkText = 'Diskusi terkait dapat dibaca pada'
if talkArgIsTalkPage then
talkText = string.format(
'%s [[%s|%s]].',
talkText,
talk,
talkTitle.prefixedText
)
else
talkText = string.format(
'%s the [[%s#%s|halaman pembicaraan]].',
talkText,
talkTitle.prefixedText,
talk
)
end
end
self.talk = talkText
end
Baris 278 ⟶ 295:
end
if date then
self.date = string.format(" <
end
self.info = args.info
Baris 300 ⟶ 317:
self.imageCellDiv = not self.isSmall and cfg.imageCellDiv
self.imageEmptyCell = cfg.imageEmptyCell
-- Left image settings.
Baris 324 ⟶ 338:
self.imageRight = imageRight
end
-- set templatestyles
self.base_templatestyles = cfg.templatestyles
self.templatestyles = args.templatestyles
end
Baris 335 ⟶ 353:
local nums = {}
for _, prefix in ipairs{'cat', '
args[prefix .. '1'] = args[prefix]
nums = union(nums, getArgNums(args, prefix))
Baris 346 ⟶ 364:
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 355 ⟶ 373:
catTitle = getTitleObject('Category:' .. catTitle)
if not catTitle or not catTitle.exists then
self:addCat(0, '
end
elseif mainCat and (not date or date == '') then
Baris 415 ⟶ 433:
end
if self.isSubstituted then
self:addCat('all', 'Halaman dengan
end
end
Baris 429 ⟶ 447:
function MessageBox:renderCategories()
if not self.hasCategories then
-- No categories added, no need to pass them to Category handler so,
-- if it was invoked, it would return the empty string.
-- So we shortcut and return the empty string.
return ""
end
-- Convert category tables to strings and pass them through
-- [[Module:Category handler]].
return require('Modul:Category handler')._main{
main = table.concat(self.categories[0] or {}),
template = table.concat(self.categories[10] or {}),
Baris 448 ⟶ 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 476 ⟶ 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 486 ⟶ 525:
row:tag('td')
:addClass('mbox-empty-cell')
end
Baris 499 ⟶ 537:
:addClass('mbox-text-span')
:wikitext(self.issue or nil)
if (self.talk or self.fix)
textCellDiv:tag('span')
:addClass('hide-when-compact')
Baris 513 ⟶ 551:
end
if self.removalNotice then
textCellDiv:tag('
:addClass('hide-when-compact')
:tag('i')
Baris 531 ⟶ 569:
-- If we are using a div, redefine imageRightCell so that the image
-- is inside it.
imageRightCell = imageRightCell:tag('div'):
end
imageRightCell
Baris 550 ⟶ 588:
if self.invalidTypeError then
root:tag('div')
:
:wikitext(string.format(
'
self.type or ''
))
Baris 586 ⟶ 624:
return function (frame)
if not getArgs then
getArgs = require('
end
return t.main(k, getArgs(frame, {trim = false, removeBlanks = false}))
|