Modul:Message box: Perbedaan antara revisi

Loncat ke navigasi Loncat ke pencarian
tidak ada ringkasan suntingan
Tidak ada ringkasan suntingan
Tag: Dikembalikan
Tidak ada ringkasan suntingan
Tag: Pengembalian manual
Baris 1: Baris 1:
require('strict')
require('strict')
local getArgs
local getArgs
local yesno = require('Module:Yesno')
local yesno = require('Modul:Yesno')
local lang = mw.language.getContentLanguage()
local lang = mw.language.getContentLanguage()


local CONFIG_MODULE = 'Module:Message box/configuration'
local CONFIG_MODULE = 'Modul: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'}


--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
-- Helper functions
-- Fungsi pembantu
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------


local function getTitleObject(...)
local function getTitleObject(...)
-- Get the title object, passing the function through pcall
-- Mendapatkan nilai objek judul dan kemudian menyalurkan fungsi ke kode pcall
-- in case we are over the expensive function count limit.
local success, title = pcall(mw.title.new, ...)
local success, title = pcall(mw.title.new, ...)
if success then
if success then
Baris 50: Baris 49:


--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
-- Box class definition
-- Definisi kelas kotak
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------


Baris 60: Baris 59:
local obj = {}
local obj = {}


-- Set the title object and the namespace.
-- Pengaturan nilai objek judul dengan ruang nama.
obj.title = getTitleObject(args.page) or mw.title.getCurrentTitle()
obj.title = getTitleObject(args.page) or mw.title.getCurrentTitle()


-- Set the config for our box type.
-- konfigurasi kotak pesan.
obj.cfg = cfg[boxType]
obj.cfg = cfg[boxType]
if not obj.cfg then
if not obj.cfg then
local ns = obj.title.namespace
local ns = obj.title.namespace
-- boxType is "mbox" or invalid input
-- boxType diatur sebagai "mbox" atau pemasukan akan bernilai tidak terduga
if args.demospace and args.demospace ~= '' then
if args.demospace and args.demospace ~= '' then
-- implement demospace parameter of mbox
-- demospasi mbox
local demospace = string.lower(args.demospace)
local demospace = string.lower(args.demospace)
if DEMOSPACES[demospace] then
if DEMOSPACES[demospace] then
-- use template from DEMOSPACES
-- penggunaan templat dari DEMOSPACES
obj.cfg = cfg[DEMOSPACES[demospace]]
obj.cfg = cfg[DEMOSPACES[demospace]]
elseif string.find( demospace, 'talk' ) then
elseif string.find( demospace, 'talk' ) then
Baris 97: Baris 96:
end
end


-- Set the arguments, and remove all blank arguments except for the ones
-- pengaturan argumen
-- listed in cfg.allowBlankParams.
-- listed in cfg.allowBlankParams.
do
do
Baris 112: Baris 111:
end
end


-- Define internal data structure.
-- Penentuan struktur data.
obj.categories = {}
obj.categories = {}
obj.classes = {}
obj.classes = {}
-- For lazy loading of [[Module:Category handler]].
-- Pemuatan [[Modul:Category handler]].
obj.hasCategories = false
obj.hasCategories = false


Baris 126: Baris 125:
end
end
if sort then
if sort then
cat = string.format('[[Category:%s|%s]]', cat, sort)
cat = string.format('[[Kategori:%s|%s]]', cat, sort)
else
else
cat = string.format('[[Category:%s]]', cat)
cat = string.format('[[Kategori:%s]]', cat)
end
end
self.hasCategories = true
self.hasCategories = true
Baris 155: Baris 154:
self.typeClass = typeData.class
self.typeClass = typeData.class
self.typeImage = typeData.image
self.typeImage = typeData.image
self.typeImageNeedsLink = typeData.imageNeedsLink


-- Find if the box has been wrongly substituted.
-- Menentukan apakah kotak yang ada mengalami kesalahan atau tidak.
self.isSubstituted = cfg.substCheck and args.subst == 'SUBST'
self.isSubstituted = cfg.substCheck and args.subst == 'SUBST'


-- Find whether we are using a small message box.
-- Menentukan penggunaan kotak pesan yang digunakan.
self.isSmall = cfg.allowSmall and (
self.isSmall = cfg.allowSmall and (
cfg.smallParam and args.small == cfg.smallParam
cfg.smallParam and args.small == cfg.smallParam
Baris 202: Baris 200:
'^[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 = 'Template:' .. templateName
templateName = 'Templat:' .. templateName
self.templateTitle = getTitleObject(templateName)
self.templateTitle = getTitleObject(templateName)
end
end
Baris 209: Baris 207:
end
end
-- Process data for collapsible text fields. At the moment these are only
-- Pemrosesan data pada
-- used in {{ambox}}.
-- {{ambox}}.
if self.useCollapsibleTextFields then
if self.useCollapsibleTextFields then
-- Get the self.issue value.
-- Get the self.issue value.
Baris 218: Baris 216:
local sect
local sect
if args.sect == '' then
if args.sect == '' then
sect = 'This ' .. (cfg.sectionDefault or 'page')
sect = '' .. (cfg.sectionDefault or 'page')
elseif type(args.sect) == 'string' then
elseif type(args.sect) == 'string' then
sect = 'This ' .. args.sect
sect = '' .. args.sect
end
end
local issue = args.issue
local issue = args.issue
Baris 265: Baris 263:
                 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 = string.format('([[%s|pembicaraan]])', talkLink)
                 else
                 else
                     talkText = 'Relevant discussion may be found on'
                     talkText = 'Diskusi terkait dapat dibaca pada'
                     if talkArgIsTalkPage then
                     if talkArgIsTalkPage then
                         talkText = string.format(
                         talkText = string.format(
Baris 277: Baris 275:
                     else
                     else
                         talkText = string.format(
                         talkText = string.format(
                             '%s the [[%s#%s|talk page]].',
                             '%s the [[%s#%s|halaman pembicaraan]].',
                             talkText,
                             talkText,
                             talkTitle.prefixedText,
                             talkTitle.prefixedText,
Baris 330: Baris 328:
and (cfg.imageSmallSize or '30x30px')
and (cfg.imageSmallSize or '30x30px')
or '40x40px'
or '40x40px'
self.imageLeft = string.format('[[File:%s|%s%s|alt=]]', self.typeImage
self.imageLeft = string.format('[[Berkas:%s|%s|link=|alt=]]', self.typeImage
or 'Information icon4.svg', imageSize, self.typeImageNeedsLink and "" or "|link=" )
or 'Imbox notice.png', imageSize)
end
end
end
end
Baris 355: Baris 353:


local nums = {}
local nums = {}
for _, prefix in ipairs{'cat', 'category', 'all'} do
for _, prefix in ipairs{'cat', 'kategori', 'all'} do
args[prefix .. '1'] = args[prefix]
args[prefix .. '1'] = args[prefix]
nums = union(nums, getArgNums(args, prefix))
nums = union(nums, getArgNums(args, prefix))
Baris 366: Baris 364:
for _, num in ipairs(nums) do
for _, num in ipairs(nums) do
local mainCat = args['cat' .. tostring(num)]
local mainCat = args['cat' .. tostring(num)]
or args['category' .. tostring(num)]
or args['kategori' .. tostring(num)]
local allCat = args['all' .. tostring(num)]
local allCat = args['all' .. tostring(num)]
mainCat = type(mainCat) == 'string' and mainCat
mainCat = type(mainCat) == 'string' and mainCat
Baris 432: Baris 430:
if self.invalidTypeError then
if self.invalidTypeError then
local allSort = (self.title.namespace == 0 and 'Main:' or '') .. self.title.prefixedText
local allSort = (self.title.namespace == 0 and 'Main:' or '') .. self.title.prefixedText
self:addCat('all', 'Wikipedia message box parameter needs fixing', allSort)
self:addCat('all', 'Parameter kotak pesan Wikipedia yang membutuhkan perbaikan', allSort)
end
end
if self.isSubstituted then
if self.isSubstituted then
self:addCat('all', 'Pages with incorrectly substituted templates')
self:addCat('all', 'Halaman dengan kesalahan subtitusi templat')
end
end
end
end
Baris 457: Baris 455:
-- Convert category tables to strings and pass them through
-- Convert category tables to strings and pass them through
-- [[Module:Category handler]].
-- [[Module:Category handler]].
return require('Module:Category handler')._main{
return require('Modul:Category handler')._main{
main = table.concat(self.categories[0] or {}),
main = table.concat(self.categories[0] or {}),
template = table.concat(self.categories[10] or {}),
template = table.concat(self.categories[10] or {}),
Baris 474: Baris 472:
:addClass('error')
:addClass('error')
:wikitext(string.format(
:wikitext(string.format(
'Template <code>%s[[Template:%s|%s]]%s</code> has been incorrectly substituted.',
'Templat <code>%s[[Template:%s|%s]]%s</code> tidak disubtitusikan dengan benar.',
mw.text.nowiki('{{'), self.name, self.name, mw.text.nowiki('}}')
mw.text.nowiki('{{'), self.name, self.name, mw.text.nowiki('}}')
))
))

Menu navigasi