Jumat, 09 Oktober 2026
19:24 WIB
TERKINI
Teknologi Sega Siapkan DLC Penutup dan Final Kejuaraan Dunia Sonic Racing: CrossWorlds Otomotif Bengkel Mini di Rumah: 6 Alat Penting untuk Perbaikan Ringan Kendaraan Teknologi School Party Craft: Rasakan Sensasi Unik Simulasi Kehidupan di Dunia Terbuka Hukum Polemik Dokumen Pencalonan Gibran: KPU Didesak Transparan Pasca Putusan MK Hiburan Syahrini Kembali Guncang Panggung Musik: Rilis Lagu Baru dan Gebrak Pestapora 2026 Regional LPS Periksa Aset Debitur BPR Tripanca Setiadana di Lampung untuk Pemulihan Regional Bandar Lampung Meriahkan Acara Bersholawat, Eratkan Persaudaraan Umat Lampung Pesisir Lampung Waspada Banjir Rob, BMKG Ingatkan Pasang Maksimum 12-15 Oktober Hukum Pujianto Divonis 8 Bulan Penjara: Perdagangan Ajinomoto Palsu Merugikan Konsumen Lampung Lampung Diprediksi Cerah Berawan, Hujan Lokal Sambangi Beberapa Wilayah Teknologi Sega Siapkan DLC Penutup dan Final Kejuaraan Dunia Sonic Racing: CrossWorlds Otomotif Bengkel Mini di Rumah: 6 Alat Penting untuk Perbaikan Ringan Kendaraan Teknologi School Party Craft: Rasakan Sensasi Unik Simulasi Kehidupan di Dunia Terbuka Hukum Polemik Dokumen Pencalonan Gibran: KPU Didesak Transparan Pasca Putusan MK Hiburan Syahrini Kembali Guncang Panggung Musik: Rilis Lagu Baru dan Gebrak Pestapora 2026 Regional LPS Periksa Aset Debitur BPR Tripanca Setiadana di Lampung untuk Pemulihan Regional Bandar Lampung Meriahkan Acara Bersholawat, Eratkan Persaudaraan Umat Lampung Pesisir Lampung Waspada Banjir Rob, BMKG Ingatkan Pasang Maksimum 12-15 Oktober Hukum Pujianto Divonis 8 Bulan Penjara: Perdagangan Ajinomoto Palsu Merugikan Konsumen Lampung Lampung Diprediksi Cerah Berawan, Hujan Lokal Sambangi Beberapa Wilayah

Modul:Protection banner

Wikimedia module

Bagikan:
Dokumentasi modullihatsuntingriwayatsegarkan
WarningModul Lua ini digunakan pada sekitar 3.800 halaman dan perubahannya kemungkinan memicu perubahan massal pada semua halaman yang menggunakannya. Uji cobalah di subhalaman /bak pasir atau /kasus uji Modul:Protection banner, atau bak pasir modul Anda. Pertimbangkan untuk mendiskusikan perubahan di halaman pembicaraan sebelum mengimplementasikannya.
DiproteksiModul 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 digunakan untuk membuat tajuk pelindungan dan ikon gembok yang ditempatkan di atas halaman pelindungan.

PenggunaanPenggunaan

Tidak dapat digunakan secara langsung. Templat pelindungan memerlukan templat {{pp}}, atau menggunakan daftar templat di bawah

Suntingan Pemindahan Perubahan tertunda Unggahan
Umum {{pp}} {{pp-move}} {{pp-pc}} {{pp-upload}}
BLP {{pp-blp}} – – –
Halaman pembicaraan pengguna yang diblokir {{pp-usertalk}} – – –
Sengketa {{pp-dispute}} {{pp-move-dispute}} – –
Perlindungan terkonfirmasi lanjutan {{pp-extended}} – – –
Tak terbatas {{pp-semi-indef}} {{pp-move-indef}} – –
Halaman Utama gambar {{pp-main-page}} – – –
Resmi {{pp-office}} – – –
Pengguna siluman {{pp-sock}} – – –
Templat dan gambar {{pp-template}} – – {{pp-upload}}
Vandalisme {{pp-vandalism}} {{pp-move-vandalism}} – –
Halaman pembicaraan {{Permanently protected}} – – –

Dari teks wikiDari teks wiki

{{#invoke:Protection banner|main
| 1        = reason
| small    = yes/no
| action   = action
| date     = protection date
| user     = username
| section  = talk page section name
| category = no
}}

Sintaksis #invoke digunakan untuk templat yang lebih spesifik daripada {{pp}}. Misalnya, it is possible to create a protection template which always shows a padlock icon by using the code {{#invoke:Protection banner|main|small=yes}}. Pages which call this template will still be able to use other arguments, like action. However, this only works one level deep; a page calling a template which calls another template containing the above code will not automatically be able to use parameters like action.

Note: You should no longer specify the expiry, as it is automatically retrieved in all cases.

Dari luaDari lua

First, load the module.

localmProtectionBanner=require('Module:Protection banner')

Then you can make protection banners by using the _main function.

mProtectionBanner._main(args,cfg,titleObj)

args is a table of arguments to pass to the module. For possible keys and values for this table, see the parameters section. The cfg and titleObj variables are intended only for testing; cfg specifies a customised config table to use instead of Module:Protection banner/config, and titleObj specifies a mw.title object to use instead of the current title. args, cfg and titleObj are all optional.

ParametersParameters

All parameters are optional.

  • 1 – the reason that the page was protected. If set, this must be one of the values listed in the reasons table.
  • small – if set to "yes", "y", "1", or "true", a padlock icon is generated instead of a full protection banner.
  • action – the protection action. Must be one of "edit" (for normal protection), "move" (for move-protection) or "autoreview" (for pending changes). The default value is "edit".
  • date – the protection date. This must be valid input to the second parameter of the #time parser function. This argument has an effect for reasons that use the PROTECTIONDATE parameter in their configuration. As of July 2014, those were the "office" and "reset" reasons.
  • user – the username of the user to generate links for. As of July 2014, this only has an effect when the "usertalk" reason is specified.
  • section – the section name of the protected page's talk page where discussion is taking place. This works for most, but not all, values of reason.
  • category – categories are suppressed if this is set to "no", "n", "0", or "false".

ReasonsReasons

The following table contains the available reasons, plus the actions for which they are available.

Galat skrip: tidak ada modul tersebut "Protection banner/documentation".

ErrorsErrors

Below is a list of some of the common errors that this module can produce, and how to fix them.

Invalid protection dateInvalid protection date

Error: invalid protection date ("abc")

This error is produced if you supply an |date= parameter value that is not recognised as a valid date by the #time parser function. If in doubt, you can just use a date in the format "dd Month YYYY", e.g. "16 Oktober 2026". To see a full range of valid inputs, see the #time documentation (only the first parameter, the format string, may be specified).

Invalid actionInvalid action

Error: invalid action ("abc")

This error is produced if you specify an invalid protection action. There are only three valid actions: edit (the default, for normal protection), move (for move-protection), and autoreview (for pending changes). This should only be possible if you are using a template that supports manually specifying the protection action, such as {{pp}}, or if you are using #invoke directly. If this is not the case, please leave a message on Module talk:Protection banner.

Reasons cannot contain the pipe characterReasons cannot contain the pipe character

Error: reasons cannot contain the pipe character ("|")

Galat ini dihasilkan jika Anda memberikan alasan pada parameter |1= mengandung karakter pipa ("|"). Periksa bahwa Anda tidak memasukkan templat {{!}} ke parameter ini. Karakter ini dilarang karena modul ini menggunakan karakter tersebut secara internal. Alasan yang valid dapat dilihat di bagian alasan.

Galat yang lainGalat yang lain

Jika Anda melihat galat selain hal di atas, kemungkinan itu adalah kekutu atau kesalahan konfigurasi. Kirim pesan mengenai masalah ini di Pembicaraan Modul:Protection banner.

Detail teknisDetail teknis

Modul ini menggunakan konfigurasi Module:Protection banner/config. Kebanyakan perilaku modul, dikonfigurasi di sana sehingga sangat portabel di antara wiki dalam berbagai bahasa

Kasus uji umum modul ini dapat dilakukan di Modul:Protection banner/kasus uji, dan konfigurasinya dapat dilakukan di Modul:Protection banner/config/kasus uji.

Masalah kekutu dan fitur baru dapat dibicarakan di halaman pembicaraan modul ini.

Dokumentasi di atas ditransklusikan dari Modul:Protection banner/doc. (sunting | riwayat)
Penyunting dapat melakukan uji coba pada halaman bak pasir (sunting | beda) dan kasus uji (sunting) modul ini.
Subhalaman modul ini.
-- This module implements {{pp-meta}} and its daughter templates such as
-- {{pp-dispute}}, {{pp-vandalism}} and {{pp-sock}}.
-- Initialise necessary modules.
require('strict')
localmakeFileLink=require('Modul:File link')._main
localeffectiveProtectionLevel=require('Modul:Effective protection level')._main
localeffectiveProtectionExpiry=require('Modul:Effective protection expiry')._main
localyesno=require('Modul:Yesno')
-- Lazily initialise modules and objects we don't always need.
localgetArgs,makeMessageBox,lang
-- Set constants.
localCONFIG_MODULE='Modul:Protection banner/config'
--------------------------------------------------------------------------------
-- Helper functions
--------------------------------------------------------------------------------
localfunctionmakeCategoryLink(cat,sort)
ifcatthen
returnstring.format(
'[[%s:%s|%s]]',
mw.site.namespaces[14].name,
cat,
sort
)
end
end
-- Validation function for the expiry and the protection date
localfunctionvalidateDate(dateString,dateType)
ifnotlangthen
lang=mw.language.getContentLanguage()
end
localsuccess,result=pcall(lang.formatDate,lang,'U',dateString)
ifsuccessthen
result=tonumber(result)
ifresultthen
returnresult
end
end
error(string.format('%s tidak sah: %s',dateType,tostring(dateString)),4)
end
localfunctionmakeFullUrl(page,query,display)
returnstring.format(
'[%s %s]',
tostring(mw.uri.fullUrl(page,query)),
display
)
end
-- Given a directed graph formatted as node -> table of direct successors,
-- get a table of all nodes reachable from a given node (though always
-- including the given node).
localfunctiongetReachableNodes(graph,start)
localtoWalk,retval={[start]=true},{}
whiletruedo
-- Can't use pairs() since we're adding and removing things as we're iterating
localk=next(toWalk)-- This always gets the "first" key
ifk==nilthen
returnretval
end
toWalk[k]=nil
retval[k]=true
for_,vinipairs(graph[k])do
ifnotretval[v]then
toWalk[v]=true
end
end
end
end
--------------------------------------------------------------------------------
-- Protection class
--------------------------------------------------------------------------------
localProtection={}
Protection.__index=Protection
Protection.supportedActions={
edit=true,
move=true,
autoreview=true,
upload=true
}
Protection.bannerConfigFields={
'text',
'explanation',
'tooltip',
'alt',
'link',
'image'
}
functionProtection.new(args,cfg,title)
localobj={}
obj._cfg=cfg
obj.title=titleormw.title.getCurrentTitle()
-- Set action
ifnotargs.actionthen
obj.action='edit'
elseifProtection.supportedActions[args.action]then
obj.action=args.action
else
error(string.format('tindakan tidak sah: %s',tostring(args.action)),3)
end
-- Set level
obj.level=args.demoleveloreffectiveProtectionLevel(obj.action,obj.title)
ifnotobj.levelor(obj.action=='move'andobj.level=='autoconfirmed')then
-- Users need to be autoconfirmed to move pages anyway, so treat
-- semi-move-protected pages as unprotected.
obj.level='*'
end
-- Set expiry
localeffectiveExpiry=effectiveProtectionExpiry(obj.action,obj.title)
ifeffectiveExpiry=='infinity'then
obj.expiry='indef'
elseifeffectiveExpiry~='unknown'then
obj.expiry=validateDate(effectiveExpiry,'expiry date')
end
-- Set reason
ifargs[1]then
obj.reason=mw.ustring.lower(args[1])
ifobj.reason:find('|')then
error('alasan tidak boleh mengandung karakter pipa ("|")',3)
end
end
-- Set protection date
ifargs.datethen
obj.protectionDate=validateDate(args.date,'protection date')
end
-- Set banner config
do
obj.bannerConfig={}
localconfigTables={}
ifcfg.banners[obj.action]then
configTables[#configTables+1]=cfg.banners[obj.action][obj.reason]
end
ifcfg.defaultBanners[obj.action]then
configTables[#configTables+1]=cfg.defaultBanners[obj.action][obj.level]
configTables[#configTables+1]=cfg.defaultBanners[obj.action].default
end
configTables[#configTables+1]=cfg.masterBanner
fori,fieldinipairs(Protection.bannerConfigFields)do
forj,tinipairs(configTables)do
ift[field]then
obj.bannerConfig[field]=t[field]
break
end
end
end
end
returnsetmetatable(obj,Protection)
end
functionProtection:isUserScript()
-- Whether the page is a user JavaScript or CSS page.
localtitle=self.title
returntitle.namespace==2and(
title.contentModel=='javascript'ortitle.contentModel=='css'
)
end
functionProtection:isProtected()
returnself.level~='*'
end
functionProtection:shouldShowLock()
-- Whether we should output a banner/padlock
returnself:isProtected()andnotself:isUserScript()
end
-- Whether this page needs a protection category.
Protection.shouldHaveProtectionCategory=Protection.shouldShowLock
functionProtection:isTemporary()
returntype(self.expiry)=='number'
end
functionProtection:makeProtectionCategory()
ifnotself:shouldHaveProtectionCategory()then
return''
end
localcfg=self._cfg
localtitle=self.title
-- Get the expiry key fragment.
localexpiryFragment
ifself.expiry=='indef'then
expiryFragment=self.expiry
elseiftype(self.expiry)=='number'then
expiryFragment='temp'
end
-- Get the namespace key fragment.
localnamespaceFragment=cfg.categoryNamespaceKeys[title.namespace]
ifnotnamespaceFragmentandtitle.namespace%2==1then
namespaceFragment='talk'
end
-- Define the order that key fragments are tested in. This is done with an
-- array of tables containing the value to be tested, along with its
-- position in the cfg.protectionCategories table.
localorder={
{val=expiryFragment,keypos=1},
{val=namespaceFragment,keypos=2},
{val=self.reason,keypos=3},
{val=self.level,keypos=4},
{val=self.action,keypos=5}
}
--[[
	-- The old protection templates used an ad-hoc protection category system,
	-- with some templates prioritising namespaces in their categories, and
	-- others prioritising the protection reason. To emulate this in this module
	-- we use the config table cfg.reasonsWithNamespacePriority to set the
	-- reasons for which namespaces have priority over protection reason.
	-- If we are dealing with one of those reasons, move the namespace table to
	-- the end of the order table, i.e. give it highest priority. If not, the
	-- reason should have highest priority, so move that to the end of the table
	-- instead.
	--]]
table.insert(order,table.remove(order,self.reasonandcfg.reasonsWithNamespacePriority[self.reason]and2or3))
--[[
	-- Define the attempt order. Inactive subtables (subtables with nil "value"
	-- fields) are moved to the end, where they will later be given the key
	-- "all". This is to cut down on the number of table lookups in
	-- cfg.protectionCategories, which grows exponentially with the number of
	-- non-nil keys. We keep track of the number of active subtables with the
	-- noActive parameter.
	--]]
localnoActive,attemptOrder
do
localactive,inactive={},{}
fori,tinipairs(order)do
ift.valthen
active[#active+1]=t
else
inactive[#inactive+1]=t
end
end
noActive=#active
attemptOrder=active
fori,tinipairs(inactive)do
attemptOrder[#attemptOrder+1]=t
end
end
--[[
	-- Check increasingly generic key combinations until we find a match. If a
	-- specific category exists for the combination of key fragments we are
	-- given, that match will be found first. If not, we keep trying different
	-- key fragment combinations until we match using the key
	-- "all-all-all-all-all".
	--
	-- To generate the keys, we index the key subtables using a binary matrix
	-- with indexes i and j. j is only calculated up to the number of active
	-- subtables. For example, if there were three active subtables, the matrix
	-- would look like this, with 0 corresponding to the key fragment "all", and
	-- 1 corresponding to other key fragments.
	-- 
	--   j 1  2  3
	-- i  
	-- 1   1  1  1
	-- 2   0  1  1
	-- 3   1  0  1
	-- 4   0  0  1
	-- 5   1  1  0
	-- 6   0  1  0
	-- 7   1  0  0
	-- 8   0  0  0
	-- 
	-- Values of j higher than the number of active subtables are set
	-- to the string "all".
	--
	-- A key for cfg.protectionCategories is constructed for each value of i.
	-- The position of the value in the key is determined by the keypos field in
	-- each subtable.
	--]]
localcats=cfg.protectionCategories
fori=1,2^noActivedo
localkey={}
forj,tinipairs(attemptOrder)do
ifj>noActivethen
key[t.keypos]='all'
else
localquotient=i/2^(j-1)
quotient=math.ceil(quotient)
ifquotient%2==1then
key[t.keypos]=t.val
else
key[t.keypos]='all'
end
end
end
key=table.concat(key,'|')
localattempt=cats[key]
ifattemptthen
returnmakeCategoryLink(attempt,title.text)
end
end
return''
end
functionProtection:isIncorrect()
ifnotself:shouldHaveProtectionCategory()then
returntrue
end
iftype(self.expiry)~='number'then
returnfalse
end
localexpiry=os.date('*t',self.expiry)
-- Avoid checking today.day or os.time(), unless close. https://phabricator.wikimedia.org/T416616
localtoday=os.date('*t')
return(expiry.year<today.year)
or(expiry.year==today.yearandexpiry.month<today.month)
or(expiry.year==today.yearandexpiry.month==today.monthandexpiry.day<today.day)
or(expiry.year==today.yearandexpiry.month==today.monthandexpiry.day==today.dayandself.expiry<os.time())
end
functionProtection:isTemplateProtectedNonTemplate()
localaction,namespace=self.action,self.title.namespace
returnself.level=='templateeditor'
and(
(action~='edit'andaction~='move')
or(namespace~=10andnamespace~=828)
)
end
functionProtection:makeCategoryLinks()
localmsg=self._cfg.msg
localret={self:makeProtectionCategory()}
ifself:isIncorrect()then
ret[#ret+1]=makeCategoryLink(
msg['tracking-category-incorrect'],
self.title.text
)
end
ifself:isTemplateProtectedNonTemplate()then
ret[#ret+1]=makeCategoryLink(
msg['tracking-category-template'],
self.title.text
)
end
returntable.concat(ret)
end
--------------------------------------------------------------------------------
-- Blurb class
--------------------------------------------------------------------------------
localBlurb={}
Blurb.__index=Blurb
Blurb.bannerTextFields={
text=true,
explanation=true,
tooltip=true,
alt=true,
link=true
}
functionBlurb.new(protectionObj,args,cfg)
returnsetmetatable({
_cfg=cfg,
_protectionObj=protectionObj,
_args=args
},Blurb)
end
-- Private methods --
functionBlurb:_formatDate(num)
-- Formats a Unix timestamp into dd Month, YYYY format.
lang=langormw.language.getContentLanguage()
localsuccess,date=pcall(
lang.formatDate,
lang,
self._cfg.msg['expiry-date-format']or'j F Y',
'@'..tostring(num)
)
ifsuccessthen
returndate
end
end
functionBlurb:_getExpandedMessage(msgKey)
returnself:_substituteParameters(self._cfg.msg[msgKey])
end
functionBlurb:_substituteParameters(msg)
ifnotself._paramsthen
localparameterFuncs={}
parameterFuncs.CURRENTVERSION=self._makeCurrentVersionParameter
parameterFuncs.EDITREQUEST=self._makeEditRequestParameter
parameterFuncs.EXPIRY=self._makeExpiryParameter
parameterFuncs.EXPLANATIONBLURB=self._makeExplanationBlurbParameter
parameterFuncs.IMAGELINK=self._makeImageLinkParameter
parameterFuncs.INTROBLURB=self._makeIntroBlurbParameter
parameterFuncs.INTROFRAGMENT=self._makeIntroFragmentParameter
parameterFuncs.PAGETYPE=self._makePagetypeParameter
parameterFuncs.PROTECTIONBLURB=self._makeProtectionBlurbParameter
parameterFuncs.PROTECTIONDATE=self._makeProtectionDateParameter
parameterFuncs.PROTECTIONLEVEL=self._makeProtectionLevelParameter
parameterFuncs.PROTECTIONLOG=self._makeProtectionLogParameter
parameterFuncs.TALKPAGE=self._makeTalkPageParameter
parameterFuncs.TOOLTIPBLURB=self._makeTooltipBlurbParameter
parameterFuncs.TOOLTIPFRAGMENT=self._makeTooltipFragmentParameter
parameterFuncs.VANDAL=self._makeVandalTemplateParameter
self._params=setmetatable({},{
__index=function(t,k)
localparam
ifparameterFuncs[k]then
param=parameterFuncs[k](self)
end
param=paramor''
t[k]=param
returnparam
end
})
end
msg=msg:gsub('${(%u+)}',self._params)
returnmsg
end
functionBlurb:_makeCurrentVersionParameter()
-- A link to the page history or the move log, depending on the kind of
-- protection.
localpagename=self._protectionObj.title.prefixedText
ifself._protectionObj.action=='move'then
-- We need the move log link.
returnmakeFullUrl(
'Special:Log',
{type='move',page=pagename},
self:_getExpandedMessage('current-version-move-display')
)
else
-- We need the history link.
returnmakeFullUrl(
pagename,
{action='history'},
self:_getExpandedMessage('current-version-edit-display')
)
end
end
functionBlurb:_makeEditRequestParameter()
localmEditRequest=require('Modul:Submit an edit request')
localaction=self._protectionObj.action
locallevel=self._protectionObj.level
-- Get the edit request type.
localrequestType
ifaction=='edit'then
iflevel=='autoconfirmed'then
requestType='semi'
elseiflevel=='extendedconfirmed'then
requestType='extended'
elseiflevel=='templateeditor'then
requestType='template'
end
end
requestType=requestTypeor'full'
-- Get the display value.
localdisplay=self:_getExpandedMessage('edit-request-display')
returnmEditRequest._link{type=requestType,display=display}
end
functionBlurb:_makeExpiryParameter()
localexpiry=self._protectionObj.expiry
iftype(expiry)=='number'then
returnself:_formatDate(expiry)
else
returnexpiry
end
end
functionBlurb:_makeExplanationBlurbParameter()
-- Cover special cases first.
ifself._protectionObj.title.namespace==8then
-- MediaWiki namespace
returnself:_getExpandedMessage('explanation-blurb-nounprotect')
end
-- Get explanation blurb table keys
localaction=self._protectionObj.action
locallevel=self._protectionObj.level
localtalkKey=self._protectionObj.title.isTalkPageand'talk'or'subject'
-- Find the message in the explanation blurb table and substitute any
-- parameters.
localexplanations=self._cfg.explanationBlurbs
localmsg
ifexplanations[action][level]andexplanations[action][level][talkKey]then
msg=explanations[action][level][talkKey]
elseifexplanations[action][level]andexplanations[action][level].defaultthen
msg=explanations[action][level].default
elseifexplanations[action].defaultandexplanations[action].default[talkKey]then
msg=explanations[action].default[talkKey]
elseifexplanations[action].defaultandexplanations[action].default.defaultthen
msg=explanations[action].default.default
else
error(string.format(
'could not find explanation blurb for action "%s", level "%s" and talk key "%s"',
action,
level,
talkKey
),8)
end
returnself:_substituteParameters(msg)
end
functionBlurb:_makeImageLinkParameter()
localimageLinks=self._cfg.imageLinks
localaction=self._protectionObj.action
locallevel=self._protectionObj.level
localmsg
ifimageLinks[action][level]then
msg=imageLinks[action][level]
elseifimageLinks[action].defaultthen
msg=imageLinks[action].default
else
msg=imageLinks.edit.default
end
returnself:_substituteParameters(msg)
end
functionBlurb:_makeIntroBlurbParameter()
ifself._protectionObj:isTemporary()then
returnself:_getExpandedMessage('intro-blurb-expiry')
else
returnself:_getExpandedMessage('intro-blurb-noexpiry')
end
end
functionBlurb:_makeIntroFragmentParameter()
ifself._protectionObj:isTemporary()then
returnself:_getExpandedMessage('intro-fragment-expiry')
else
returnself:_getExpandedMessage('intro-fragment-noexpiry')
end
end
functionBlurb:_makePagetypeParameter()
localpagetypes=self._cfg.pagetypes
returnpagetypes[self._protectionObj.title.namespace]
orpagetypes.default
orerror('jenis halaman bawaan (pagetype) belum didefinisikan',8)
end
functionBlurb:_makeProtectionBlurbParameter()
localprotectionBlurbs=self._cfg.protectionBlurbs
localaction=self._protectionObj.action
locallevel=self._protectionObj.level
localmsg
ifprotectionBlurbs[action][level]then
msg=protectionBlurbs[action][level]
elseifprotectionBlurbs[action].defaultthen
msg=protectionBlurbs[action].default
elseifprotectionBlurbs.edit.defaultthen
msg=protectionBlurbs.edit.default
else
error('blurb perlindungan belum didefinisikan untuk protectionBlurbs.edit.default',8)
end
returnself:_substituteParameters(msg)
end
functionBlurb:_makeProtectionDateParameter()
localprotectionDate=self._protectionObj.protectionDate
iftype(protectionDate)=='number'then
returnself:_formatDate(protectionDate)
else
returnprotectionDate
end
end
functionBlurb:_makeProtectionLevelParameter()
localprotectionLevels=self._cfg.protectionLevels
localaction=self._protectionObj.action
locallevel=self._protectionObj.level
localmsg
ifprotectionLevels[action][level]then
msg=protectionLevels[action][level]
elseifprotectionLevels[action].defaultthen
msg=protectionLevels[action].default
elseifprotectionLevels.edit.defaultthen
msg=protectionLevels.edit.default
else
error('no protection level defined for protectionLevels.edit.default',8)
end
returnself:_substituteParameters(msg)
end
functionBlurb:_makeProtectionLogParameter()
localpagename=self._protectionObj.title.prefixedText
ifself._protectionObj.action=='autoreview'then
-- We need the pending changes log.
returnmakeFullUrl(
'Special:Log',
{type='stable',page=pagename},
self:_getExpandedMessage('pc-log-display')
)
else
-- We need the protection log.
returnmakeFullUrl(
'Special:Log',
{type='protect',page=pagename},
self:_getExpandedMessage('protection-log-display')
)
end
end
functionBlurb:_makeTalkPageParameter()
returnstring.format(
'[[%s:%s#%s|%s]]',
mw.site.namespaces[self._protectionObj.title.namespace].talk.name,
self._protectionObj.title.text,
self._args.sectionor'top',
self:_getExpandedMessage('talk-page-link-display')
)
end
functionBlurb:_makeTooltipBlurbParameter()
ifself._protectionObj:isTemporary()then
returnself:_getExpandedMessage('tooltip-blurb-expiry')
else
returnself:_getExpandedMessage('tooltip-blurb-noexpiry')
end
end
functionBlurb:_makeTooltipFragmentParameter()
ifself._protectionObj:isTemporary()then
returnself:_getExpandedMessage('tooltip-fragment-expiry')
else
returnself:_getExpandedMessage('tooltip-fragment-noexpiry')
end
end
functionBlurb:_makeVandalTemplateParameter()
returnmw.getCurrentFrame():expandTemplate{
title="vandal-m",
args={self._args.userorself._protectionObj.title.baseText}
}
end
-- Public methods --
functionBlurb:makeBannerText(key)
-- Validate input.
ifnotkeyornotBlurb.bannerTextFields[key]then
error(string.format(
'"%s" is not a valid banner config field',
tostring(key)
),2)
end
-- Generate the text.
localmsg=self._protectionObj.bannerConfig[key]
iftype(msg)=='string'then
returnself:_substituteParameters(msg)
elseiftype(msg)=='function'then
msg=msg(self._protectionObj,self._args)
iftype(msg)~='string'then
error(string.format(
'bad output from banner config function with key "%s"'
..' (expected string, got %s)',
tostring(key),
type(msg)
),4)
end
returnself:_substituteParameters(msg)
end
end
--------------------------------------------------------------------------------
-- BannerTemplate class
--------------------------------------------------------------------------------
localBannerTemplate={}
BannerTemplate.__index=BannerTemplate
functionBannerTemplate.new(protectionObj,cfg)
localobj={}
obj._cfg=cfg
-- Set the image filename.
localimageFilename=protectionObj.bannerConfig.image
ifimageFilenamethen
obj._imageFilename=imageFilename
else
-- If an image filename isn't specified explicitly in the banner config,
-- generate it from the protection status and the namespace.
localaction=protectionObj.action
locallevel=protectionObj.level
localnamespace=protectionObj.title.namespace
localreason=protectionObj.reason
-- Deal with special cases first.
if(
namespace==10
ornamespace==828
orreasonandobj._cfg.indefImageReasons[reason]
)
andaction=='edit'
andlevel=='sysop'
andnotprotectionObj:isTemporary()
then
-- Fully protected modules and templates get the special red "indef"
-- padlock.
obj._imageFilename=obj._cfg.msg['image-filename-indef']
else
-- Deal with regular protection types.
localimages=obj._cfg.images
ifimages[action]then
ifimages[action][level]then
obj._imageFilename=images[action][level]
elseifimages[action].defaultthen
obj._imageFilename=images[action].default
end
end
end
end
returnsetmetatable(obj,BannerTemplate)
end
functionBannerTemplate:renderImage()
localfilename=self._imageFilename
orself._cfg.msg['image-filename-default']
or'Transparent.gif'
returnmakeFileLink{
file=filename,
size=(self.imageWidthor20)..'px',
alt=self._imageAlt,
link=self._imageLink,
caption=self.imageCaption
}
end
--------------------------------------------------------------------------------
-- Banner class
--------------------------------------------------------------------------------
localBanner=setmetatable({},BannerTemplate)
Banner.__index=Banner
functionBanner.new(protectionObj,blurbObj,cfg)
localobj=BannerTemplate.new(protectionObj,cfg)-- This doesn't need the blurb.
obj.imageWidth=40
obj.imageCaption=blurbObj:makeBannerText('alt')-- Large banners use the alt text for the tooltip.
obj._reasonText=blurbObj:makeBannerText('text')
obj._explanationText=blurbObj:makeBannerText('explanation')
obj._page=protectionObj.title.prefixedText-- Only makes a difference in testing.
returnsetmetatable(obj,Banner)
end
functionBanner:__tostring()
-- Renders the banner.
makeMessageBox=makeMessageBoxorrequire('Modul:Message box').main
localreasonText=self._reasonTextorerror('tidak ada alasan diberikan',2)
localexplanationText=self._explanationText
localmbargs={
page=self._page,
type='protection',
image=self:renderImage(),
text=string.format(
"'''%s'''%s",
reasonText,
explanationTextand'<br />'..explanationTextor''
)
}
returnmakeMessageBox('mbox',mbargs)
end
--------------------------------------------------------------------------------
-- Padlock class
--------------------------------------------------------------------------------
localPadlock=setmetatable({},BannerTemplate)
Padlock.__index=Padlock
functionPadlock.new(protectionObj,blurbObj,cfg)
localobj=BannerTemplate.new(protectionObj,cfg)-- This doesn't need the blurb.
obj.imageWidth=20
obj.imageCaption=blurbObj:makeBannerText('tooltip')
obj._imageAlt=blurbObj:makeBannerText('alt')
obj._imageLink=blurbObj:makeBannerText('link')
obj._indicatorName=cfg.padlockIndicatorNames[protectionObj.action]
orcfg.padlockIndicatorNames.default
or'pp-default'
returnsetmetatable(obj,Padlock)
end
functionPadlock:__tostring()
localframe=mw.getCurrentFrame()
-- The nowiki tag helps prevent whitespace at the top of articles.
returnframe:extensionTag{name='nowiki'}..frame:extensionTag{
name='indicator',
args={name=self._indicatorName},
content=self:renderImage()
}
end
--------------------------------------------------------------------------------
-- Exports
--------------------------------------------------------------------------------
localp={}
functionp._exportClasses()
-- This is used for testing purposes.
return{
Protection=Protection,
Blurb=Blurb,
BannerTemplate=BannerTemplate,
Banner=Banner,
Padlock=Padlock,
}
end
functionp._main(args,cfg,title)
args=argsor{}
cfg=cfgorrequire(CONFIG_MODULE)
localprotectionObj=Protection.new(args,cfg,title)
localret={}
-- If a page's edit protection is equally or more restrictive than its
-- protection from some other action, then don't bother displaying anything
-- for the other action (except categories).
ifnotyesno(args.catonly)and(protectionObj.action=='edit'or
args.demolevelor
notgetReachableNodes(
cfg.hierarchy,
protectionObj.level
)[effectiveProtectionLevel('edit',protectionObj.title)])
then
-- Initialise the blurb object
localblurbObj=Blurb.new(protectionObj,args,cfg)
-- Render the banner
ifprotectionObj:shouldShowLock()then
ret[#ret+1]=tostring(
(yesno(args.small)andPadlockorBanner)
.new(protectionObj,blurbObj,cfg)
)
end
end
-- Render the categories
ifyesno(args.category)~=falsethen
ret[#ret+1]=protectionObj:makeCategoryLinks()
end
-- For arbitration enforcement, flagging [[WP:PIA]] pages to enable [[Special:AbuseFilter/1339]] to flag edits to them
ifprotectionObj.level=="extendedconfirmed"then
ifrequire("Modul:TableTools").inArray(protectionObj.title.talkPageTitle.categories,"Wikipedia pages subject to the extended confirmed restriction related to the Arab-Israeli conflict")then
ret[#ret+1]="<p class='PIA-flag' style='display:none; visibility:hidden;' title='Halaman ini tunduk pada pembatasan yang dikonfirmasi diperluas terkait konflik Arab-Israel.'></p>"
end
end
returntable.concat(ret)
end
functionp.main(frame,cfg)
cfg=cfgorrequire(CONFIG_MODULE)
-- Find default args, if any.
localparent=frame.getParentandframe:getParent()
localdefaultArgs=parentandcfg.wrappers[parent:getTitle():gsub('/sandbox$','')]
-- Find user args, and use the parent frame if we are being called from a
-- wrapper template.
getArgs=getArgsorrequire('Modul:Arguments').getArgs
localuserArgs=getArgs(frame,{
parentOnly=defaultArgs,
frameOnly=notdefaultArgs
})
-- Build the args table. User-specified args overwrite default args.
localargs={}
fork,vinpairs(defaultArgsor{})do
args[k]=v
end
fork,vinpairs(userArgs)do
args[k]=v
end
returnp._main(args,cfg)
end
returnp
Konten disalin dari Wikipedia Bahasa Indonesia (lisensi CC BY-SA) Lihat versi asli di Wikipedia

Rekomendasi Pilihan