11.314
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(' | local yesno = require('Modul:Yesno') | ||
local lang = mw.language.getContentLanguage() | local lang = mw.language.getContentLanguage() | ||
local CONFIG_MODULE = ' | 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'} | ||
-------------------------------------------------------------------------------- | -------------------------------------------------------------------------------- | ||
-- | -- Fungsi pembantu | ||
-------------------------------------------------------------------------------- | -------------------------------------------------------------------------------- | ||
local function getTitleObject(...) | local function getTitleObject(...) | ||
-- | -- Mendapatkan nilai objek judul dan kemudian menyalurkan fungsi ke kode pcall | ||
local success, title = pcall(mw.title.new, ...) | local success, title = pcall(mw.title.new, ...) | ||
if success then | if success then | ||
Baris 50: | Baris 49: | ||
-------------------------------------------------------------------------------- | -------------------------------------------------------------------------------- | ||
-- | -- Definisi kelas kotak | ||
-------------------------------------------------------------------------------- | -------------------------------------------------------------------------------- | ||
Baris 60: | Baris 59: | ||
local obj = {} | local obj = {} | ||
-- | -- 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() | ||
-- | -- 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 | -- boxType diatur sebagai "mbox" atau pemasukan akan bernilai tidak terduga | ||
if args.demospace and args.demospace ~= '' then | if args.demospace and args.demospace ~= '' then | ||
-- | -- demospasi mbox | ||
local demospace = string.lower(args.demospace) | local demospace = string.lower(args.demospace) | ||
if DEMOSPACES[demospace] then | if DEMOSPACES[demospace] then | ||
-- | -- 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 | ||
-- | -- pengaturan argumen | ||
-- listed in cfg.allowBlankParams. | -- listed in cfg.allowBlankParams. | ||
do | do | ||
Baris 112: | Baris 111: | ||
end | end | ||
-- | -- Penentuan struktur data. | ||
obj.categories = {} | obj.categories = {} | ||
obj.classes = {} | obj.classes = {} | ||
-- | -- 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('[[ | cat = string.format('[[Kategori:%s|%s]]', cat, sort) | ||
else | else | ||
cat = string.format('[[ | 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 | ||
-- | -- 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' | ||
-- | -- 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 = ' | templateName = 'Templat:' .. templateName | ||
self.templateTitle = getTitleObject(templateName) | self.templateTitle = getTitleObject(templateName) | ||
end | end | ||
Baris 209: | Baris 207: | ||
end | end | ||
-- | -- Pemrosesan data pada | ||
-- | -- {{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 = ' | 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 | ||
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| | talkText = string.format('([[%s|pembicaraan]])', talkLink) | ||
else | else | ||
talkText = ' | 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| | '%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('[[ | self.imageLeft = string.format('[[Berkas:%s|%s|link=|alt=]]', self.typeImage | ||
or ' | or 'Imbox notice.png', imageSize) | ||
end | end | ||
end | end | ||
Baris 355: | Baris 353: | ||
local nums = {} | local nums = {} | ||
for _, prefix in ipairs{'cat', ' | 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[' | 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 | self:addCat('all', 'Parameter kotak pesan Wikipedia yang membutuhkan perbaikan', allSort) | ||
end | end | ||
if self.isSubstituted then | if self.isSubstituted then | ||
self:addCat('all', ' | 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(' | 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( | ||
' | '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('}}') | ||
)) | )) |