Modul:Message box: Perbedaan antara revisi
Tampilan
Mediawiki>Izno per tper |
k 1 revisi diimpor |
||
| Baris 3: | Baris 3: | ||
-- Load necessary modules. | -- Load necessary modules. | ||
require(' | require('Modul:No globals') | ||
local getArgs | local getArgs | ||
local yesno = require(' | local categoryHandler = require('Modul:Category handler')._main | ||
local yesno = require('Modul:Yesno') | |||
-- Get a language object for formatDate and ucfirst. | -- Get a language object for formatDate and ucfirst. | ||
| Baris 11: | Baris 12: | ||
-- Define constants | -- Define constants | ||
local CONFIG_MODULE = ' | local CONFIG_MODULE = 'Modul:Message box/configuration' | ||
-------------------------------------------------------------------------------- | -------------------------------------------------------------------------------- | ||
| Baris 75: | Baris 75: | ||
local ns = obj.title.namespace | local ns = obj.title.namespace | ||
-- boxType is "mbox" or invalid input | -- boxType is "mbox" or invalid input | ||
if | if ns == 0 then | ||
obj.cfg = cfg.ambox -- main namespace | obj.cfg = cfg.ambox -- main namespace | ||
elseif ns == 6 then | elseif ns == 6 then | ||
| Baris 122: | Baris 109: | ||
obj.categories = {} | obj.categories = {} | ||
obj.classes = {} | obj.classes = {} | ||
return setmetatable(obj, MessageBox) | return setmetatable(obj, MessageBox) | ||
| Baris 133: | Baris 118: | ||
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.categories[ns] = self.categories[ns] or {} | self.categories[ns] = self.categories[ns] or {} | ||
table.insert(self.categories[ns], cat) | table.insert(self.categories[ns], cat) | ||
| Baris 174: | Baris 158: | ||
-- Add attributes, classes and styles. | -- Add attributes, classes and styles. | ||
self.id = args.id | self.id = args.id | ||
if yesno(args.plainlinks) ~= false then | if yesno(args.plainlinks) ~= false then | ||
self:addClass('plainlinks') | self:addClass('plainlinks') | ||
| Baris 203: | Baris 183: | ||
and cfg.templateCategoryRequireName | and cfg.templateCategoryRequireName | ||
then | then | ||
self.name = args.name | |||
if self.name then | if self.name then | ||
local templateName = mw.ustring.match( | local templateName = mw.ustring.match( | ||
| Baris 214: | Baris 195: | ||
and mw.title.equals(self.title, self.templateTitle) | and mw.title.equals(self.title, self.templateTitle) | ||
end | end | ||
-- Process data for collapsible text fields. At the moment these are only | -- Process data for collapsible text fields. At the moment these are only | ||
-- used in {{ambox}}. | -- used in {{ambox}}. | ||
| Baris 224: | Baris 205: | ||
local sect | local sect | ||
if args.sect == '' then | if args.sect == '' then | ||
sect = ' | sect = 'Halaman ' .. (cfg.sectionDefault or 'page') | ||
elseif args.sect == 'section' then | |||
sect = 'Bagian ini' | |||
elseif type(args.sect) == 'string' then | elseif type(args.sect) == 'string' then | ||
sect = | sect = args.sect .. 'ini' | ||
end | end | ||
local issue = args.issue | local issue = args.issue | ||
| Baris 250: | Baris 233: | ||
) | ) | ||
then | then | ||
talk = ' | talk = '' | ||
elseif talk == '' then | elseif talk == '' then | ||
talk = nil | talk = nil | ||
| Baris 268: | Baris 251: | ||
end | end | ||
if talkTitle and talkTitle.exists then | if talkTitle and talkTitle.exists then | ||
local talkText = 'Diskusi yang sesuai mungkin dapat ditemukan di' | |||
if talkArgIsTalkPage then | |||
talkText = string.format( | |||
'%s [[%s|%s]].', | |||
talkText, | |||
talk, | |||
talkTitle.prefixedText | |||
) | |||
else | |||
talkText = string.format( | |||
'%s [[%s#%s|halaman pembicaraannya]].', | |||
talkText, | |||
talkTitle.prefixedText, | |||
talk | |||
) | |||
end | |||
self.talk = talkText | self.talk = talkText | ||
end | end | ||
| Baris 303: | Baris 280: | ||
end | end | ||
if date then | if date then | ||
self.date = string.format(" < | self.date = string.format(" <small>''(%s)''</small>", date) | ||
end | end | ||
self.info = args.info | self.info = args.info | ||
| Baris 326: | Baris 303: | ||
self.imageEmptyCell = cfg.imageEmptyCell | self.imageEmptyCell = cfg.imageEmptyCell | ||
if cfg.imageEmptyCellStyle then | if cfg.imageEmptyCellStyle then | ||
self.imageEmptyCellStyle = 'border:none;padding: | self.imageEmptyCellStyle = 'border:none;padding:2px;width:1px' | ||
end | end | ||
| Baris 339: | Baris 316: | ||
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 'Imbox notice.png', imageSize) | or 'Imbox notice.png', imageSize) | ||
end | end | ||
| Baris 368: | Baris 345: | ||
local date = args.date | local date = args.date | ||
date = type(date) == 'string' and date | date = type(date) == 'string' and date | ||
local preposition = ' | local preposition = 'sejak' | ||
for _, num in ipairs(nums) do | for _, num in ipairs(nums) do | ||
local mainCat = args['cat' .. tostring(num)] | local mainCat = args['cat' .. tostring(num)] | ||
| Baris 380: | Baris 357: | ||
catTitle = getTitleObject('Category:' .. catTitle) | catTitle = getTitleObject('Category:' .. catTitle) | ||
if not catTitle or not catTitle.exists then | if not catTitle or not catTitle.exists then | ||
self:addCat(0, ' | self:addCat(0, 'Artikel dengan parameter tanggal yang tidak valid pada templat') | ||
end | end | ||
elseif mainCat and (not date or date == '') then | elseif mainCat and (not date or date == '') then | ||
| Baris 437: | Baris 414: | ||
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 templat yang salah disubstitusi') | ||
end | end | ||
end | end | ||
| Baris 454: | Baris 431: | ||
function MessageBox:renderCategories() | function MessageBox:renderCategories() | ||
-- 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 | return categoryHandler{ | ||
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 479: | Baris 450: | ||
:addClass('error') | :addClass('error') | ||
:wikitext(string.format( | :wikitext(string.format( | ||
' | 'Templat <code>%s[[Template:%s|%s]]%s</code> yang keliru disubstitusi.', | ||
mw.text.nowiki('{{'), self.name, self.name, mw.text.nowiki('}}') | mw.text.nowiki('{{'), self.name, self.name, mw.text.nowiki('}}') | ||
)) | )) | ||
| Baris 530: | Baris 501: | ||
:addClass('mbox-text-span') | :addClass('mbox-text-span') | ||
:wikitext(self.issue or nil) | :wikitext(self.issue or nil) | ||
if (self.talk or self.fix) then | if (self.talk or self.fix) and not self.isSmall then | ||
textCellDiv:tag('span') | textCellDiv:tag('span') | ||
:addClass('hide-when-compact') | :addClass('hide-when-compact') | ||
| Baris 544: | Baris 515: | ||
end | end | ||
if self.removalNotice then | if self.removalNotice then | ||
textCellDiv:tag(' | textCellDiv:tag('small') | ||
:addClass('hide-when-compact') | :addClass('hide-when-compact') | ||
:tag('i') | :tag('i') | ||
| Baris 583: | Baris 554: | ||
:css('text-align', 'center') | :css('text-align', 'center') | ||
:wikitext(string.format( | :wikitext(string.format( | ||
' | 'Kota pesan ini menggunakan parameter "type=%s" yang tidak valid dan membutuhkan perbaikan.', | ||
self.type or '' | self.type or '' | ||
)) | )) | ||
| Baris 617: | Baris 588: | ||
return function (frame) | return function (frame) | ||
if not getArgs then | if not getArgs then | ||
getArgs = require(' | getArgs = require('Modul:Arguments').getArgs | ||
end | end | ||
return t.main(k, getArgs(frame, {trim = false, removeBlanks = false})) | return t.main(k, getArgs(frame, {trim = false, removeBlanks = false})) | ||