| Modul Lua ini digunakan pada sekitar 264.000 halaman, atau sekira 6% dari keseluruhan halaman. Untuk mencegah suntingan mengganggu skala besar dan beban peladen, setiap perubahan harus diuji di subhalaman /bak pasir atau /kasus uji Modul:Message box, atau bak pasir modul Anda. Perubahan yang telah diuji kemudian dapat ditambahkan ke halaman ini dalam satu suntingan. Pertimbangkan untuk mendiskusikan perubahan di halaman pembicaraan sebelum mengimplementasikannya. |
| Modul ini dilindungi. Modul ini sangat mencolok yang digunakan oleh banyak halaman, atau sangat sering disubstitusikan. Karena vandalisme atau kesalahan akan mempengaruhi banyak halaman, dan suntingan kecil dapat memberi beban besar pada server, modul ini dilindungi dari penyuntingan. |
| Modul ini menggunakan Lua: |
| Modul ini menggunakan TemplateStyles: |
Modul-meta ini digunakan oleh templat message box seperti, {{mbox}}, {{ambox}}, {{cmbox}}, {{fmbox}}, {{imbox}}, {{ombox}}, dan {{tmbox}}. Harus dijalankan melalui modul Lua, tidak boleh digunakan langsung pada halaman wiki. Jika Anda ingin menggunakan fungsi modul ini dari halaman wiki, gunakan templat message box sebagai gantinya.
PenggunaanPenggunaan
Untuk bisa menggunakan modul ini dari Lua yang lain, anda perlu memuat seperti ini:
localmessageBox=require('Modul:Message box')
Untuk membuat message box, gunakan fungsi main. Diperlukan dua parameter: string dan tabel yang berisi parameter message box.
localbox=messageBox.main(boxType,{ param1=param1, param2=param2, -- Parameter lainnya... })
Ada 7 jenis box yang tersedia:
| Jenis box | Templat | Kegunaan |
|---|---|---|
mbox |
{{mbox}} | Untuk pembuatan message box yang akan digunakan dalam beberapa ruang nama |
ambox |
{{ambox}} | Untuk pembuatan message box pada artikel |
cmbox |
{{cmbox}} | Untuk pembuatan message box pada kategori |
fmbox |
{{fmbox}} | Untuk pembuatan message box antarmuka |
imbox |
{{imbox}} | Untuk pembuatan message box pada ruang nama berkas |
tmbox |
{{tmbox}} | Untuk pembuatan message box pada halaman pembicaraan |
ombox |
{{ombox}} | Untuk pembuatan message box pada ruang nama lainnya |
Lihat halaman templat masing-masing jenis message box untuk parameter yang tersedia.
Gunakan #invokeGunakan #invoke
Disertai fungsi main, modul ini memiliki fungsi terpisah untuk message box masing-masing. Dijalankan menggunakan kode {{#invoke:Message box|mbox|...}}, {{#invoke:Message box|ambox|...}}, dsb. Fungsi ini akan bekerja ketika dipanggil melalui modul lain, tetapi masing-masing menjalankan kode yang digunakan untuk memproses argumen menggunakan #invoke, dan tentu saja memanggil mereka akan kurang efisien daripada memanggil fungsi main.
Detail teknisDetail teknis
Modul ini menggunakan kode dasar yang sama untuk setiap templat yang tercantum di atas; perbedaan antara masing-masing templat dikonfigurasi menggunakan data di Module:Message box/configuration. Berikut adalah berbagai opsi konfigurasi yang tersedia dan penjelasannya:
types– tabel yang berisi data yang digunakan oleh parametertypepada kotak pesan. Kunci tabel adalah nilai-nilai yang dapat diteruskan ke parametertype, dan nilai tabelnya adalah tabel lain yang berisi kelas dan gambar yang digunakan oleh tipe tersebut.default– tipe yang akan digunakan jika tidak ada nilai yang diberikan pada parametertype, atau jika nilai yang diberikan tidak valid.showInvalidTypeError– menentukan apakah kesalahan akan ditampilkan jika nilai yang diteruskan ke parametertypetidak valid.allowBlankParams– secara umum, nilai kosong dihapus dari parameter yang diteruskan ke modul. Namun, spasi tetap dipertahankan untuk parameter yang disertakan dalam tabelallowBlankParams.allowSmall– menentukan apakah versi kecil dari kotak pesan dapat dibuat dengan menggunakansmall=yes.smallParam– nama khusus untuk parametersmall. Misalnya, jika diatur menjadi "left", kamu dapat membuat kotak pesan kecil menggunakansmall=left.smallClass– kelas CSS yang digunakan untuk kotak pesan kecil.substCheck– menentukan apakah pemeriksaansubstakan dilakukan atau tidak.classes– array kelas CSS yang akan digunakan pada kotak pesan.imageEmptyCell– menentukan apakah akan menggunakan sel<td>...</td>kosong jika tidak ada gambar yang ditetapkan. Hal ini digunakan untuk menjaga jarak (spasi) pada kotak pesan yang lebarnya kurang dari 100% dari layar.imageEmptyCellStyle– menentukan apakah sel gambar kosong akan diberi gaya (styled) atau tidak.imageCheckBlank– menentukan apakahimage=blankberarti tidak ada gambar yang ditampilkan.imageSmallSize– biasanya gambar pada kotak pesan kecil diatur berukuran 30x30px. Opsi ini memungkinkan untuk menetapkan ukuran khusus.imageCellDiv– menentukan apakah gambar harus dibungkus dalam elemendivyang membatasi ukuran maksimum gambar.useCollapsibleTextFields– menentukan apakah akan menggunakan kolom teks yang dapat diciutkan (collapsible), seperti "issue", "fix", "talk", dan sebagainya. Saat ini hanya digunakan pada modulambox.imageRightNone– menentukan apakahimageright=noneberarti tidak ada gambar yang ditampilkan di sisi kanan kotak pesan.sectionDefault– nama default untuk parametersection. Nilainya bergantung pada pengaturanuseCollapsibleTextFields.allowMainspaceCategories– mengizinkan pengkategorian di ruang nama utama (main namespace).templateCategory– nama kategori yang akan ditempatkan pada halaman templat.templateCategoryRequireName– menentukan apakah parameternamediperlukan agar kategori templat dapat ditampilkan.templateErrorCategory– nama kategori kesalahan (error category) yang akan digunakan di halaman templat.templateErrorParamsToCheck– array nama parameter yang harus diperiksa. Jika salah satunya tidak ada, makatemplateErrorCategoryakan diterapkan pada halaman templat.
Penyunting dapat melakukan uji coba pada halaman bak pasir (sunting | beda) dan kasus uji (buat) modul ini.
Subhalaman modul ini.
require('strict') localgetArgs localyesno=require('Modul:Yesno') locallang=mw.language.getContentLanguage() localCONFIG_MODULE='Modul:Message box/configuration' localDEMOSPACES={talk='tmbox',image='imbox',file='imbox',category='cmbox',article='ambox',main='ambox'} -------------------------------------------------------------------------------- -- Fungsi pembantu -------------------------------------------------------------------------------- localfunctiongetTitleObject(...) -- Mendapatkan nilai objek judul dan kemudian menyalurkan fungsi ke kode pcall localsuccess,title=pcall(mw.title.new,...) ifsuccessthen returntitle end end localfunctionunion(t1,t2) -- Returns the union of two arrays. localvals={} fori,vinipairs(t1)do vals[v]=true end fori,vinipairs(t2)do vals[v]=true end localret={} forkinpairs(vals)do table.insert(ret,k) end table.sort(ret) returnret end localfunctiongetArgNums(args,prefix) localnums={} fork,vinpairs(args)do localnum=mw.ustring.match(tostring(k),'^'..prefix..'([1-9]%d*)$') ifnumthen table.insert(nums,tonumber(num)) end end table.sort(nums) returnnums end -------------------------------------------------------------------------------- -- Definisi kelas kotak -------------------------------------------------------------------------------- localMessageBox={} MessageBox.__index=MessageBox functionMessageBox.new(boxType,args,cfg) args=argsor{} localobj={} -- Pengaturan nilai objek judul dengan ruang nama. obj.title=getTitleObject(args.page)ormw.title.getCurrentTitle() -- konfigurasi kotak pesan. obj.cfg=cfg[boxType] ifnotobj.cfgthen localns=obj.title.namespace -- boxType diatur sebagai "mbox" atau pemasukan akan bernilai tidak terduga ifargs.demospaceandargs.demospace~=''then -- demospasi mbox localdemospace=string.lower(args.demospace) ifDEMOSPACES[demospace]then -- penggunaan templat dari DEMOSPACES obj.cfg=cfg[DEMOSPACES[demospace]] elseifstring.find(demospace,'talk')then -- demo as a talk page obj.cfg=cfg.tmbox else -- default to ombox obj.cfg=cfg.ombox end elseifns==0then obj.cfg=cfg.ambox-- main namespace elseifns==6then obj.cfg=cfg.imbox-- file namespace elseifns==14then obj.cfg=cfg.cmbox-- category namespace else localnsTable=mw.site.namespaces[ns] ifnsTableandnsTable.isTalkthen obj.cfg=cfg.tmbox-- any talk namespace else obj.cfg=cfg.ombox-- other namespaces or invalid input end end end -- pengaturan argumen -- listed in cfg.allowBlankParams. do localnewArgs={} fork,vinpairs(args)do ifv~=''then newArgs[k]=v end end fori,paraminipairs(obj.cfg.allowBlankParamsor{})do newArgs[param]=args[param] end obj.args=newArgs end -- Penentuan struktur data. obj.categories={} obj.classes={} -- Pemuatan [[Modul:Category handler]]. obj.hasCategories=false returnsetmetatable(obj,MessageBox) end functionMessageBox:addCat(ns,cat,sort) ifnotcatthen returnnil end ifsortthen cat=string.format('[[Kategori:%s|%s]]',cat,sort) else cat=string.format('[[Kategori:%s]]',cat) end self.hasCategories=true self.categories[ns]=self.categories[ns]or{} table.insert(self.categories[ns],cat) end functionMessageBox:addClass(class) ifnotclassthen returnnil end table.insert(self.classes,class) end functionMessageBox:setParameters() localargs=self.args localcfg=self.cfg -- Get type data. self.type=args.type localtypeData=cfg.types[self.type] self.invalidTypeError=cfg.showInvalidTypeError andself.type andnottypeData typeData=typeDataorcfg.types[cfg.default] self.typeClass=typeData.class self.typeImage=typeData.image -- Menentukan apakah kotak yang ada mengalami kesalahan atau tidak. self.isSubstituted=cfg.substCheckandargs.subst=='SUBST' -- Menentukan penggunaan kotak pesan yang digunakan. self.isSmall=cfg.allowSmalland( cfg.smallParamandargs.small==cfg.smallParam ornotcfg.smallParamandyesno(args.small) ) -- Set the below row. self.below=cfg.belowandargs.below -- Add attributes, classes and styles. self.id=args.id self.name=args.name ifself.namethen self:addClass('box-'..string.gsub(self.name,' ','_')) end ifyesno(args.plainlinks)~=falsethen self:addClass('plainlinks') end ifself.belowthen self:addClass('mbox-with-below') end for_,classinipairs(cfg.classesor{})do self:addClass(class) end ifself.isSmallthen self:addClass(cfg.smallClassor'mbox-small') end self:addClass(self.typeClass) self:addClass(args.class) self.style=args.style self.attrs=args.attrs -- Set text style. self.textstyle=args.textstyle -- Find if we are on the template page or not. This functionality is only -- used if useCollapsibleTextFields is set, or if both cfg.templateCategory -- and cfg.templateCategoryRequireName are set. self.useCollapsibleTextFields=cfg.useCollapsibleTextFields ifself.useCollapsibleTextFields orcfg.templateCategory andcfg.templateCategoryRequireName then ifself.namethen localtemplateName=mw.ustring.match( self.name, '^[tT][eE][mM][pP][lL][aA][tT][eE][%s_]*:[%s_]*(.*)$' )orself.name templateName='Templat:'..templateName self.templateTitle=getTitleObject(templateName) end self.isTemplatePage=self.templateTitle andmw.title.equals(self.title,self.templateTitle) end -- Pemrosesan data pada -- {{ambox}}. ifself.useCollapsibleTextFieldsthen -- Get the self.issue value. ifself.isSmallandargs.smalltextthen self.issue=args.smalltext else localsect ifargs.sect==''then sect=''..(cfg.sectionDefaultor'page') elseiftype(args.sect)=='string'then sect=''..args.sect end localissue=args.issue issue=type(issue)=='string'andissue~=''andissueornil localtext=args.text text=type(text)=='string'andtextornil localissues={} table.insert(issues,sect) table.insert(issues,issue) table.insert(issues,text) self.issue=table.concat(issues,' ') end -- Get the self.talk value. localtalk=args.talk -- Show talk links on the template page or template subpages if the talk -- parameter is blank. iftalk=='' andself.templateTitle and( mw.title.equals(self.templateTitle,self.title) orself.title:isSubpageOf(self.templateTitle) ) then talk='#' elseiftalk==''then talk=nil end iftalkthen -- If the talk value is a talk page, make a link to that page. Else -- assume that it's a section heading, and make a link to the talk -- page of the current page with that section heading. localtalkTitle=getTitleObject(talk) localtalkArgIsTalkPage=true ifnottalkTitleornottalkTitle.isTalkPagethen talkArgIsTalkPage=false talkTitle=getTitleObject( self.title.text, mw.site.namespaces[self.title.namespace].talk.id ) end iftalkTitleandtalkTitle.existsthen localtalkText ifself.isSmallthen localtalkLink=talkArgIsTalkPageandtalkor(talkTitle.prefixedText..'#'..talk) talkText=string.format('([[%s|pembicaraan]])',talkLink) else talkText='Diskusi terkait dapat dibaca pada' iftalkArgIsTalkPagethen talkText=string.format( '%s [[%s|%s]].', talkText, talk, talkTitle.prefixedText ) else talkText=string.format( '%s [[%s#%s|halaman pembicaraan]].', talkText, talkTitle.prefixedText, talk ) end end self.talk=talkText end end -- Get other values. self.fix=args.fix~=''andargs.fixornil localdate ifargs.dateandargs.date~=''then date=args.date elseifargs.date==''andself.isTemplatePagethen date=lang:formatDate('F Y') end ifdatethen self.date=string.format(" <span class='date-container'><i>(<span class='date'>%s</span>)</i></span>",date) end self.info=args.info ifyesno(args.removalnotice)then self.removalNotice=cfg.removalNotice end end -- Set the non-collapsible text field. At the moment this is used by all box -- types other than ambox, and also by ambox when small=yes. ifself.isSmallthen self.text=args.smalltextorargs.text else self.text=args.text end -- General image settings. self.imageCellDiv=notself.isSmallandcfg.imageCellDiv self.imageEmptyCell=cfg.imageEmptyCell -- Left image settings. localimageLeft=self.isSmallandargs.smallimageorargs.image ifcfg.imageCheckBlankandimageLeft~='blank'andimageLeft~='none' ornotcfg.imageCheckBlankandimageLeft~='none' then self.imageLeft=imageLeft ifnotimageLeftthen localimageSize=self.isSmall and(cfg.imageSmallSizeor'30x30px') or'40x40px' self.imageLeft=string.format('[[Berkas:%s|%s|link=|alt=]]',self.typeImage or'Imbox notice.png',imageSize) end end -- Right image settings. localimageRight=self.isSmallandargs.smallimagerightorargs.imageright ifnot(cfg.imageRightNoneandimageRight=='none')then self.imageRight=imageRight end -- set templatestyles self.base_templatestyles=cfg.templatestyles self.templatestyles=args.templatestyles end functionMessageBox:setMainspaceCategories() localargs=self.args localcfg=self.cfg ifnotcfg.allowMainspaceCategoriesthen returnnil end localnums={} for_,prefixinipairs{'cat','kategori','all'}do args[prefix..'1']=args[prefix] nums=union(nums,getArgNums(args,prefix)) end -- The following is roughly equivalent to the old {{Ambox/category}}. localdate=args.date date=type(date)=='string'anddate for_,numinipairs(nums)do localmainCat=args['cat'..tostring(num)] orargs['kategori'..tostring(num)] localallCat=args['all'..tostring(num)] mainCat=type(mainCat)=='string'andmainCat allCat=type(allCat)=='string'andallCat ifmainCatanddateanddate~=''then localcatTitle=string.format('%s %s',mainCat,date) self:addCat(0,catTitle) catTitle=getTitleObject('Category:'..catTitle) ifnotcatTitleornotcatTitle.existsthen self:addCat(0,'Articles with invalid date parameter in template') end elseifmainCatand(notdateordate=='')then self:addCat(0,mainCat) end ifallCatthen self:addCat(0,allCat) end end end functionMessageBox:setTemplateCategories() localargs=self.args localcfg=self.cfg -- Add template categories. ifcfg.templateCategorythen ifcfg.templateCategoryRequireNamethen ifself.isTemplatePagethen self:addCat(10,cfg.templateCategory) end elseifnotself.title.isSubpagethen self:addCat(10,cfg.templateCategory) end end -- Add template error categories. ifcfg.templateErrorCategorythen localtemplateErrorCategory=cfg.templateErrorCategory localtemplateCat,templateSort ifnotself.nameandnotself.title.isSubpagethen templateCat=templateErrorCategory elseifself.isTemplatePagethen localparamsToCheck=cfg.templateErrorParamsToCheckor{} localcount=0 fori,paraminipairs(paramsToCheck)do ifnotargs[param]then count=count+1 end end ifcount>0then templateCat=templateErrorCategory templateSort=tostring(count) end ifself.categoryNumsand#self.categoryNums>0then templateCat=templateErrorCategory templateSort='C' end end self:addCat(10,templateCat,templateSort) end end functionMessageBox:setAllNamespaceCategories() -- Set categories for all namespaces. ifself.invalidTypeErrorthen localallSort=(self.title.namespace==0and'Main:'or'')..self.title.prefixedText self:addCat('all','Parameter kotak pesan Wikipedia yang membutuhkan perbaikan',allSort) end ifself.isSubstitutedthen self:addCat('all','Halaman dengan kesalahan subtitusi templat') end end functionMessageBox:setCategories() ifself.title.namespace==0then self:setMainspaceCategories() elseifself.title.namespace==10then self:setTemplateCategories() end self:setAllNamespaceCategories() end functionMessageBox:renderCategories() ifnotself.hasCategoriesthen -- 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]]. returnrequire('Modul:Category handler')._main{ main=table.concat(self.categories[0]or{}), template=table.concat(self.categories[10]or{}), all=table.concat(self.categories.allor{}), nocat=self.args.nocat, page=self.args.page } end functionMessageBox:exportDiv() localroot=mw.html.create() -- Add the subst check error. ifself.isSubstitutedandself.namethen root:tag('b') :addClass('error') :wikitext(string.format( 'Templat <code>%s[[Templat:%s|%s]]%s</code> telah diganti secara tidak tepat.', mw.text.nowiki('{{'),self.name,self.name,mw.text.nowiki('}}') )) end localframe=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 ifself.templatestylesthen root:wikitext(frame:extensionTag{ name='templatestyles', args={src=self.templatestyles}, }) end -- Create the box. localmbox=root:tag('div') mbox:attr('id',self.idornil) fori,classinipairs(self.classesor{})do mbox:addClass(classornil) end mbox :cssText(self.styleornil) ifself.attrsthen mbox:attr(self.attrs) end localflex_container ifself.belowthen -- we need to wrap the flex components (`image(right)` and `text`) in their -- own container div to support the `below` parameter flex_container=mw.html.create('div') flex_container:addClass('mbox-flex') else -- the mbox itself is the parent, so we need no HTML flex_container flex_container=mw.html.create() end -- Add the left-hand image. ifself.imageLeftthen localimageLeftCell=flex_container:tag('div'):addClass('mbox-image') imageLeftCell :addClass(self.imageLeftClass) :wikitext(self.imageLeftornil) end -- Add the text. localtextCell=flex_container:tag('div'):addClass('mbox-text') ifself.useCollapsibleTextFieldsthen -- The message box uses advanced text parameters that allow things to be -- collapsible. At the moment, only ambox uses this. textCell:cssText(self.textstyleornil) localtextCellDiv=textCell:tag('div') textCellDiv :addClass('mbox-text-span') :wikitext(self.issueornil) if(self.talkorself.fix)then textCellDiv:tag('span') :addClass('hide-when-compact') :wikitext(self.talkand(' '..self.talk)ornil) :wikitext(self.fixand(' '..self.fix)ornil) end textCellDiv:wikitext(self.dateand(' '..self.date)ornil) ifself.infoandnotself.isSmallthen textCellDiv :tag('span') :addClass('hide-when-compact') :wikitext(self.infoand(' '..self.info)ornil) end ifself.removalNoticethen textCellDiv:tag('span') :addClass('hide-when-compact') :tag('i') :wikitext(string.format(" (%s)",self.removalNotice)) end else -- Default text formatting - anything goes. textCell :cssText(self.textstyleornil) :wikitext(self.textornil) end -- Add the right-hand image. ifself.imageRightthen localimageRightCell=flex_container:tag('div'):addClass('mbox-imageright') imageRightCell :addClass(self.imageRightClass) :wikitext(self.imageRightornil) end mbox:node(flex_container) -- Add the below row. ifself.belowthen mbox:tag('div') :addClass('mbox-text mbox-below') :cssText(self.textstyleornil) :wikitext(self.belowornil) end -- Add error message for invalid type parameters. ifself.invalidTypeErrorthen root:tag('div') :addClass('mbox-invalid-type') :wikitext(string.format( 'Kotak pesan ini menggunakan parameter "type=%s" tidak valid dan memerlukan perbaikan.', self.typeor'' )) end -- Add categories. root:wikitext(self:renderCategories()ornil) returntostring(root) end functionMessageBox:export() localroot=mw.html.create() -- Add the subst check error. ifself.isSubstitutedandself.namethen root:tag('b') :addClass('error') :wikitext(string.format( 'Templat <code>%s[[Templat:%s|%s]]%s</code> tidak disubtitusikan dengan benar.', mw.text.nowiki('{{'),self.name,self.name,mw.text.nowiki('}}') )) end localframe=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 ifself.templatestylesthen root:wikitext(frame:extensionTag{ name='templatestyles', args={src=self.templatestyles}, }) end -- Create the box table. localboxTable=root:tag('table') boxTable:attr('id',self.idornil) fori,classinipairs(self.classesor{})do boxTable:addClass(classornil) end boxTable :cssText(self.styleornil) :attr('role','presentation') ifself.attrsthen boxTable:attr(self.attrs) end -- Add the left-hand image. localrow=boxTable:tag('tr') ifself.imageLeftthen localimageLeftCell=row:tag('td'):addClass('mbox-image') ifself.imageCellDivthen -- If we are using a div, redefine imageLeftCell so that the image -- is inside it. Divs use style="width: 52px;", which limits the -- 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'):addClass('mbox-image-div') end imageLeftCell:wikitext(self.imageLeftornil) elseifself.imageEmptyCellthen -- Some message boxes define an empty cell if no image is specified, and -- some don't. The old template code in templates where empty cells are -- specified gives the following hint: "No image. Cell with some width -- or padding necessary for text cell to have 100% width." row:tag('td') :addClass('mbox-empty-cell') end -- Add the text. localtextCell=row:tag('td'):addClass('mbox-text') ifself.useCollapsibleTextFieldsthen -- The message box uses advanced text parameters that allow things to be -- collapsible. At the moment, only ambox uses this. textCell:cssText(self.textstyleornil) localtextCellDiv=textCell:tag('div') textCellDiv :addClass('mbox-text-span') :wikitext(self.issueornil) if(self.talkorself.fix)then textCellDiv:tag('span') :addClass('hide-when-compact') :wikitext(self.talkand(' '..self.talk)ornil) :wikitext(self.fixand(' '..self.fix)ornil) end textCellDiv:wikitext(self.dateand(' '..self.date)ornil) ifself.infoandnotself.isSmallthen textCellDiv :tag('span') :addClass('hide-when-compact') :wikitext(self.infoand(' '..self.info)ornil) end ifself.removalNoticethen textCellDiv:tag('span') :addClass('hide-when-compact') :tag('i') :wikitext(string.format(" (%s)",self.removalNotice)) end else -- Default text formatting - anything goes. textCell :cssText(self.textstyleornil) :wikitext(self.textornil) end -- Add the right-hand image. ifself.imageRightthen localimageRightCell=row:tag('td'):addClass('mbox-imageright') ifself.imageCellDivthen -- If we are using a div, redefine imageRightCell so that the image -- is inside it. imageRightCell=imageRightCell:tag('div'):addClass('mbox-image-div') end imageRightCell :wikitext(self.imageRightornil) end -- Add the below row. ifself.belowthen boxTable:tag('tr') :tag('td') :attr('colspan',self.imageRightand'3'or'2') :addClass('mbox-text') :cssText(self.textstyleornil) :wikitext(self.belowornil) end -- Add error message for invalid type parameters. ifself.invalidTypeErrorthen root:tag('div') :addClass('mbox-invalid-type') :wikitext(string.format( 'Kotak pesan ini menggunakan parameter "type=%s" tidak valid dan membutuhkan perbaikan.', self.typeor'' )) end -- Add categories. root:wikitext(self:renderCategories()ornil) returntostring(root) end -------------------------------------------------------------------------------- -- Exports -------------------------------------------------------------------------------- localp,mt={},{} functionp._exportClasses() -- For testing. return{ MessageBox=MessageBox } end functionp.main(boxType,args,cfgTables) localbox=MessageBox.new(boxType,args,cfgTablesormw.loadData(CONFIG_MODULE)) box:setParameters() box:setCategories() -- DIV MIGRATION CONDITIONAL ifbox.cfg.div_structurethen returnbox:exportDiv() end -- END DIV MIGRATION CONDITIONAL returnbox:export() end functionmt.__index(t,k) returnfunction(frame) ifnotgetArgsthen getArgs=require('Modul:Arguments').getArgs end returnt.main(k,getArgs(frame,{trim=false,removeBlanks=false})) end end returnsetmetatable(p,mt)