Title: Module:Protection banner - freem
URL Source: https://freemwiki.com/wiki/Module:Protection_banner/
Published Time: Sun, 09 Aug 2026 01:29:03 GMT
Markdown Content:
[Jump to content](https://freemwiki.com/wiki/Module:Protection_banner/#bodyContent)
- [x] Main menu
Main menu
move to sidebar hide
Navigation
* [Main page](https://freemwiki.com/wiki/Main_Page "Visit the main page [alt-shift-z]")
* [Recent changes](https://freemwiki.com/wiki/Special:RecentChanges "A list of recent changes in the wiki [alt-shift-r]")
* [Random page](https://freemwiki.com/wiki/Special:Random "Load a random page [alt-shift-x]")
* [Help about MediaWiki](https://www.mediawiki.org/wiki/Special:MyLanguage/Help:Contents)
Legal
* [Terms](https://freemwiki.com/wiki/Terms_of_Service)
* [Privacy Policy](https://freemwiki.com/wiki/Privacy_Policy)
* [About](https://freemwiki.com/wiki/About)
* [Contact](https://freemwiki.com/wiki/Contact)
[**freem**](https://freemwiki.com/wiki/Main_Page)
[Search](https://freemwiki.com/wiki/Special:Search "Search freem [alt-shift-f]")
Search
- [x] Appearance
* [Create account](https://freemwiki.com/index.php?title=Special:CreateAccount&returnto=Module%3AProtection+banner "You are encouraged to create an account and log in; however, it is not mandatory")
* [Log in](https://freemwiki.com/index.php?title=Special:UserLogin&returnto=Module%3AProtection+banner "You are encouraged to log in; however, it is not mandatory [alt-shift-o]")
- [x] Personal tools
* [Create account](https://freemwiki.com/index.php?title=Special:CreateAccount&returnto=Module%3AProtection+banner "You are encouraged to create an account and log in; however, it is not mandatory")
* [Log in](https://freemwiki.com/index.php?title=Special:UserLogin&returnto=Module%3AProtection+banner "You are encouraged to log in; however, it is not mandatory [alt-shift-o]")
Pages for logged out editors [learn more](https://freemwiki.com/wiki/Help:Introduction)
* [Contributions](https://freemwiki.com/wiki/Special:MyContributions "A list of edits made from this IP address [alt-shift-y]")
* [Talk](https://freemwiki.com/wiki/Special:MyTalk "Discussion about edits from this IP address [alt-shift-n]")
# Module:Protection banner
- [x] Add languages
* [Module](https://freemwiki.com/wiki/Module:Protection_banner "View the module page [alt-shift-c]")
* [Discussion](https://freemwiki.com/index.php?title=Module_talk:Protection_banner&action=edit&redlink=1 "Discussion about the content page (page does not exist) [alt-shift-t]")
- [x] English
* [Read](https://freemwiki.com/wiki/Module:Protection_banner)
* [Edit source](https://freemwiki.com/index.php?title=Module:Protection_banner&action=edit "Edit the source code of this page [alt-shift-e]")
* [View history](https://freemwiki.com/index.php?title=Module:Protection_banner&action=history "Past revisions of this page [alt-shift-h]")
- [x] Tools
Tools
move to sidebar hide
Actions
* [Read](https://freemwiki.com/wiki/Module:Protection_banner)
* [Edit source](https://freemwiki.com/index.php?title=Module:Protection_banner&action=edit "Edit the source code of this page [alt-shift-e]")
* [View history](https://freemwiki.com/index.php?title=Module:Protection_banner&action=history)
General
* [What links here](https://freemwiki.com/wiki/Special:WhatLinksHere/Module:Protection_banner "A list of all wiki pages that link here [alt-shift-j]")
* [Related changes](https://freemwiki.com/wiki/Special:RecentChangesLinked/Module:Protection_banner "Recent changes in pages linked from this page [alt-shift-k]")
* [Special pages](https://freemwiki.com/wiki/Special:SpecialPages "A list of all special pages [alt-shift-q]")
* [Printable version](javascript:print(); "Printable version of this page [alt-shift-p]")
* [Permanent link](https://freemwiki.com/index.php?title=Module:Protection_banner&oldid=579588 "Permanent link to this revision of this page")
* [Page information](https://freemwiki.com/index.php?title=Module:Protection_banner&action=info "More information about this page")
Appearance
move to sidebar hide
From freem
(Redirected from [Module:Protection banner/](https://freemwiki.com/index.php?title=Module:Protection_banner/&redirect=no "Module:Protection banner/"))
_Documentation for this module may be created at [Module:Protection banner/doc](https://freemwiki.com/index.php?title=Module:Protection\_banner/doc&action=edit&redlink=1 "Module:Protection banner/doc (page does not exist)")_
[](https://freemwiki.com/wiki/Module:Protection_banner/#L-1)-- This module implements {{[pp-meta](https://freemwiki.com/wiki/Template:Pp-meta "Template:Pp-meta")}} and its daughter templates such as[](https://freemwiki.com/wiki/Module:Protection_banner/#L-2)-- {{[pp-dispute](https://freemwiki.com/wiki/Template:Pp-dispute "Template:Pp-dispute")}}, {{[pp-vandalism](https://freemwiki.com/wiki/Template:Pp-vandalism "Template:Pp-vandalism")}} and {{[pp-sock](https://freemwiki.com/wiki/Template:Pp-sock "Template:Pp-sock")}}.[](https://freemwiki.com/wiki/Module:Protection_banner/#L-3)[](https://freemwiki.com/wiki/Module:Protection_banner/#L-4)-- Initialise necessary modules.[](https://freemwiki.com/wiki/Module:Protection_banner/#L-5)require('strict')[](https://freemwiki.com/wiki/Module:Protection_banner/#L-6)local makeFileLink = require(['Module:File link'](https://freemwiki.com/wiki/Module:File_link))._main[](https://freemwiki.com/wiki/Module:Protection_banner/#L-7)local effectiveProtectionLevel = require(['Module:Effective protection level'](https://freemwiki.com/wiki/Module:Effective_protection_level))._main[](https://freemwiki.com/wiki/Module:Protection_banner/#L-8)local effectiveProtectionExpiry = require(['Module:Effective protection expiry'](https://freemwiki.com/wiki/Module:Effective_protection_expiry))._main[](https://freemwiki.com/wiki/Module:Protection_banner/#L-9)local yesno = require(['Module:Yesno'](https://freemwiki.com/wiki/Module:Yesno))[](https://freemwiki.com/wiki/Module:Protection_banner/#L-10)[](https://freemwiki.com/wiki/Module:Protection_banner/#L-11)-- Lazily initialise modules and objects we don't always need.[](https://freemwiki.com/wiki/Module:Protection_banner/#L-12)local getArgs, makeMessageBox, lang[](https://freemwiki.com/wiki/Module:Protection_banner/#L-13)[](https://freemwiki.com/wiki/Module:Protection_banner/#L-14)-- Set constants.[](https://freemwiki.com/wiki/Module:Protection_banner/#L-15)local CONFIG_MODULE = 'Module:Protection banner/config'[](https://freemwiki.com/wiki/Module:Protection_banner/#L-16)[](https://freemwiki.com/wiki/Module:Protection_banner/#L-17)--------------------------------------------------------------------------------[](https://freemwiki.com/wiki/Module:Protection_banner/#L-18)-- Helper functions[](https://freemwiki.com/wiki/Module:Protection_banner/#L-19)--------------------------------------------------------------------------------[](https://freemwiki.com/wiki/Module:Protection_banner/#L-20)[](https://freemwiki.com/wiki/Module:Protection_banner/#L-21)local function makeCategoryLink(cat, sort)[](https://freemwiki.com/wiki/Module:Protection_banner/#L-22)if cat then[](https://freemwiki.com/wiki/Module:Protection_banner/#L-23)return string.format([](https://freemwiki.com/wiki/Module:Protection_banner/#L-24)'[[%s:%s|%s]]',[](https://freemwiki.com/wiki/Module:Protection_banner/#L-25)mw.site.namespaces[14].name,[](https://freemwiki.com/wiki/Module:Protection_banner/#L-26)cat,[](https://freemwiki.com/wiki/Module:Protection_banner/#L-27)sort[](https://freemwiki.com/wiki/Module:Protection_banner/#L-28))[](https://freemwiki.com/wiki/Module:Protection_banner/#L-29)end[](https://freemwiki.com/wiki/Module:Protection_banner/#L-30)end[](https://freemwiki.com/wiki/Module:Protection_banner/#L-31)[](https://freemwiki.com/wiki/Module:Protection_banner/#L-32)-- Validation function for the expiry and the protection date[](https://freemwiki.com/wiki/Module:Protection_banner/#L-33)local function validateDate(dateString, dateType)[](https://freemwiki.com/wiki/Module:Protection_banner/#L-34)if not lang then[](https://freemwiki.com/wiki/Module:Protection_banner/#L-35)lang = mw.language.getContentLanguage()[](https://freemwiki.com/wiki/Module:Protection_banner/#L-36)end[](https://freemwiki.com/wiki/Module:Protection_banner/#L-37)local success, result = pcall(lang.formatDate, lang, 'U', dateString)[](https://freemwiki.com/wiki/Module:Protection_banner/#L-38)if success then[](https://freemwiki.com/wiki/Module:Protection_banner/#L-39)result = tonumber(result)[](https://freemwiki.com/wiki/Module:Protection_banner/#L-40)if result then[](https://freemwiki.com/wiki/Module:Protection_banner/#L-41)return result[](https://freemwiki.com/wiki/Module:Protection_banner/#L-42)end[](https://freemwiki.com/wiki/Module:Protection_banner/#L-43)end[](https://freemwiki.com/wiki/Module:Protection_banner/#L-44)error(string.format([](https://freemwiki.com/wiki/Module:Protection_banner/#L-45)'invalid %s: %s',[](https://freemwiki.com/wiki/Module:Protection_banner/#L-46)dateType,[](https://freemwiki.com/wiki/Module:Protection_banner/#L-47)tostring(dateString)[](https://freemwiki.com/wiki/Module:Protection_banner/#L-48)), 4)[](https://freemwiki.com/wiki/Module:Protection_banner/#L-49)end[](https://freemwiki.com/wiki/Module:Protection_banner/#L-50)[](https://freemwiki.com/wiki/Module:Protection_banner/#L-51)local function makeFullUrl(page, query, display)[](https://freemwiki.com/wiki/Module:Protection_banner/#L-52)return string.format([](https://freemwiki.com/wiki/Module:Protection_banner/#L-53)'[%s %s]',[](https://freemwiki.com/wiki/Module:Protection_banner/#L-54)tostring(mw.uri.fullUrl(page, query)),[](https://freemwiki.com/wiki/Module:Protection_banner/#L-55)display[](https://freemwiki.com/wiki/Module:Protection_banner/#L-56))[](https://freemwiki.com/wiki/Module:Protection_banner/#L-57)end[](https://freemwiki.com/wiki/Module:Protection_banner/#L-58)[](https://freemwiki.com/wiki/Module:Protection_banner/#L-59)-- Given a directed graph formatted as node -> table of direct successors,[](https://freemwiki.com/wiki/Module:Protection_banner/#L-60)-- get a table of all nodes reachable from a given node (though always[](https://freemwiki.com/wiki/Module:Protection_banner/#L-61)-- including the given node).[](https://freemwiki.com/wiki/Module:Protection_banner/#L-62)local function getReachableNodes(graph, start)[](https://freemwiki.com/wiki/Module:Protection_banner/#L-63)local toWalk, retval = {[start] = true}, {}[](https://freemwiki.com/wiki/Module:Protection_banner/#L-64)while true do[](https://freemwiki.com/wiki/Module:Protection_banner/#L-65)-- Can't use pairs() since we're adding and removing things as we're iterating[](https://freemwiki.com/wiki/Module:Protection_banner/#L-66)local k = next(toWalk) -- This always gets the "first" key[](https://freemwiki.com/wiki/Module:Protection_banner/#L-67)if k == nil then[](https://freemwiki.com/wiki/Module:Protection_banner/#L-68)return retval[](https://freemwiki.com/wiki/Module:Protection_banner/#L-69)end[](https://freemwiki.com/wiki/Module:Protection_banner/#L-70)toWalk[k] = nil[](https://freemwiki.com/wiki/Module:Protection_banner/#L-71)retval[k] = true[](https://freemwiki.com/wiki/Module:Protection_banner/#L-72)for _,v in ipairs(graph[k]) do[](https://freemwiki.com/wiki/Module:Protection_banner/#L-73)if not retval[v] then[](https://freemwiki.com/wiki/Module:Protection_banner/#L-74)toWalk[v] = true[](https://freemwiki.com/wiki/Module:Protection_banner/#L-75)end[](https://freemwiki.com/wiki/Module:Protection_banner/#L-76)end[](https://freemwiki.com/wiki/Module:Protection_banner/#L-77)end[](https://freemwiki.com/wiki/Module:Protection_banner/#L-78)end[](https://freemwiki.com/wiki/Module:Protection_banner/#L-79)[](https://freemwiki.com/wiki/Module:Protection_banner/#L-80)--------------------------------------------------------------------------------[](https://freemwiki.com/wiki/Module:Protection_banner/#L-81)-- Protection class[](https://freemwiki.com/wiki/Module:Protection_banner/#L-82)--------------------------------------------------------------------------------[](https://freemwiki.com/wiki/Module:Protection_banner/#L-83)[](https://freemwiki.com/wiki/Module:Protection_banner/#L-84)local Protection = {}[](https://freemwiki.com/wiki/Module:Protection_banner/#L-85)Protection.__index = Protection[](https://freemwiki.com/wiki/Module:Protection_banner/#L-86)[](https://freemwiki.com/wiki/Module:Protection_banner/#L-87)Protection.supportedActions = {[](https://freemwiki.com/wiki/Module:Protection_banner/#L-88)edit = true,[](https://freemwiki.com/wiki/Module:Protection_banner/#L-89)move = true,[](https://freemwiki.com/wiki/Module:Protection_banner/#L-90)autoreview = true,[](https://freemwiki.com/wiki/Module:Protection_banner/#L-91)upload = true[](https://freemwiki.com/wiki/Module:Protection_banner/#L-92)}[](https://freemwiki.com/wiki/Module:Protection_banner/#L-93)[](https://freemwiki.com/wiki/Module:Protection_banner/#L-94)Protection.bannerConfigFields = {[](https://freemwiki.com/wiki/Module:Protection_banner/#L-95)'text',[](https://freemwiki.com/wiki/Module:Protection_banner/#L-96)'explanation',[](https://freemwiki.com/wiki/Module:Protection_banner/#L-97)'tooltip',[](https://freemwiki.com/wiki/Module:Protection_banner/#L-98)'alt',[](https://freemwiki.com/wiki/Module:Protection_banner/#L-99)'link',[](https://freemwiki.com/wiki/Module:Protection_banner/#L-100)'image'[](https://freemwiki.com/wiki/Module:Protection_banner/#L-101)}[](https://freemwiki.com/wiki/Module:Protection_banner/#L-102)[](https://freemwiki.com/wiki/Module:Protection_banner/#L-103)function Protection.new(args, cfg, title)[](https://freemwiki.com/wiki/Module:Protection_banner/#L-104)local obj = {}[](https://freemwiki.com/wiki/Module:Protection_banner/#L-105)obj._cfg = cfg[](https://freemwiki.com/wiki/Module:Protection_banner/#L-106)obj.title = title or mw.title.getCurrentTitle()[](https://freemwiki.com/wiki/Module:Protection_banner/#L-107)[](https://freemwiki.com/wiki/Module:Protection_banner/#L-108)-- Set action[](https://freemwiki.com/wiki/Module:Protection_banner/#L-109)if not args.action then[](https://freemwiki.com/wiki/Module:Protection_banner/#L-110)obj.action = 'edit'[](https://freemwiki.com/wiki/Module:Protection_banner/#L-111)elseif Protection.supportedActions[args.action] then[](https://freemwiki.com/wiki/Module:Protection_banner/#L-112)obj.action = args.action[](https://freemwiki.com/wiki/Module:Protection_banner/#L-113)else[](https://freemwiki.com/wiki/Module:Protection_banner/#L-114)error(string.format([](https://freemwiki.com/wiki/Module:Protection_banner/#L-115)'invalid action: %s',[](https://freemwiki.com/wiki/Module:Protection_banner/#L-116)tostring(args.action)[](https://freemwiki.com/wiki/Module:Protection_banner/#L-117)), 3)[](https://freemwiki.com/wiki/Module:Protection_banner/#L-118)end[](https://freemwiki.com/wiki/Module:Protection_banner/#L-119)[](https://freemwiki.com/wiki/Module:Protection_banner/#L-120)-- Set level[](https://freemwiki.com/wiki/Module:Protection_banner/#L-121)obj.level = args.demolevel or effectiveProtectionLevel(obj.action, obj.title)[](https://freemwiki.com/wiki/Module:Protection_banner/#L-122)if not obj.level or (obj.action == 'move' and obj.level == 'autoconfirmed') then[](https://freemwiki.com/wiki/Module:Protection_banner/#L-123)-- Users need to be autoconfirmed to move pages anyway, so treat[](https://freemwiki.com/wiki/Module:Protection_banner/#L-124)-- semi-move-protected pages as unprotected.[](https://freemwiki.com/wiki/Module:Protection_banner/#L-125)obj.level = '*'[](https://freemwiki.com/wiki/Module:Protection_banner/#L-126)end[](https://freemwiki.com/wiki/Module:Protection_banner/#L-127)[](https://freemwiki.com/wiki/Module:Protection_banner/#L-128)-- Set expiry[](https://freemwiki.com/wiki/Module:Protection_banner/#L-129)local effectiveExpiry = effectiveProtectionExpiry(obj.action, obj.title)[](https://freemwiki.com/wiki/Module:Protection_banner/#L-130)if effectiveExpiry == 'infinity' then[](https://freemwiki.com/wiki/Module:Protection_banner/#L-131)obj.expiry = 'indef'[](https://freemwiki.com/wiki/Module:Protection_banner/#L-132)elseif effectiveExpiry ~= 'unknown' then[](https://freemwiki.com/wiki/Module:Protection_banner/#L-133)obj.expiry = validateDate(effectiveExpiry, 'expiry date')[](https://freemwiki.com/wiki/Module:Protection_banner/#L-134)end[](https://freemwiki.com/wiki/Module:Protection_banner/#L-135)[](https://freemwiki.com/wiki/Module:Protection_banner/#L-136)-- Set reason[](https://freemwiki.com/wiki/Module:Protection_banner/#L-137)if args[1] then[](https://freemwiki.com/wiki/Module:Protection_banner/#L-138)obj.reason = mw.ustring.lower(args[1])[](https://freemwiki.com/wiki/Module:Protection_banner/#L-139)if obj.reason:find('|') then[](https://freemwiki.com/wiki/Module:Protection_banner/#L-140)error('reasons cannot contain the pipe character ("|")', 3)[](https://freemwiki.com/wiki/Module:Protection_banner/#L-141)end[](https://freemwiki.com/wiki/Module:Protection_banner/#L-142)end[](https://freemwiki.com/wiki/Module:Protection_banner/#L-143)[](https://freemwiki.com/wiki/Module:Protection_banner/#L-144)-- Set protection date[](https://freemwiki.com/wiki/Module:Protection_banner/#L-145)if args.date then[](https://freemwiki.com/wiki/Module:Protection_banner/#L-146)obj.protectionDate = validateDate(args.date, 'protection date')[](https://freemwiki.com/wiki/Module:Protection_banner/#L-147)end[](https://freemwiki.com/wiki/Module:Protection_banner/#L-148)[](https://freemwiki.com/wiki/Module:Protection_banner/#L-149)-- Set banner config[](https://freemwiki.com/wiki/Module:Protection_banner/#L-150)do[](https://freemwiki.com/wiki/Module:Protection_banner/#L-151)obj.bannerConfig = {}[](https://freemwiki.com/wiki/Module:Protection_banner/#L-152)local configTables = {}[](https://freemwiki.com/wiki/Module:Protection_banner/#L-153)if cfg.banners[obj.action] then[](https://freemwiki.com/wiki/Module:Protection_banner/#L-154)configTables[#configTables + 1] = cfg.banners[obj.action][obj.reason][](https://freemwiki.com/wiki/Module:Protection_banner/#L-155)end[](https://freemwiki.com/wiki/Module:Protection_banner/#L-156)if cfg.defaultBanners[obj.action] then[](https://freemwiki.com/wiki/Module:Protection_banner/#L-157)configTables[#configTables + 1] = cfg.defaultBanners[obj.action][obj.level][](https://freemwiki.com/wiki/Module:Protection_banner/#L-158)configTables[#configTables + 1] = cfg.defaultBanners[obj.action].default[](https://freemwiki.com/wiki/Module:Protection_banner/#L-159)end[](https://freemwiki.com/wiki/Module:Protection_banner/#L-160)configTables[#configTables + 1] = cfg.masterBanner[](https://freemwiki.com/wiki/Module:Protection_banner/#L-161)for i, field in ipairs(Protection.bannerConfigFields) do[](https://freemwiki.com/wiki/Module:Protection_banner/#L-162)for j, t in ipairs(configTables) do[](https://freemwiki.com/wiki/Module:Protection_banner/#L-163)if t[field] then[](https://freemwiki.com/wiki/Module:Protection_banner/#L-164)obj.bannerConfig[field] = t[field][](https://freemwiki.com/wiki/Module:Protection_banner/#L-165)break[](https://freemwiki.com/wiki/Module:Protection_banner/#L-166)end[](https://freemwiki.com/wiki/Module:Protection_banner/#L-167)end[](https://freemwiki.com/wiki/Module:Protection_banner/#L-168)end[](https://freemwiki.com/wiki/Module:Protection_banner/#L-169)end[](https://freemwiki.com/wiki/Module:Protection_banner/#L-170)return setmetatable(obj, Protection)[](https://freemwiki.com/wiki/Module:Protection_banner/#L-171)end[](https://freemwiki.com/wiki/Module:Protection_banner/#L-172)[](https://freemwiki.com/wiki/Module:Protection_banner/#L-173)function Protection:isUserScript()[](https://freemwiki.com/wiki/Module:Protection_banner/#L-174)-- Whether the page is a user JavaScript or CSS page.[](https://freemwiki.com/wiki/Module:Protection_banner/#L-175)local title = self.title[](https://freemwiki.com/wiki/Module:Protection_banner/#L-176)return title.namespace == 2 and ([](https://freemwiki.com/wiki/Module:Protection_banner/#L-177)title.contentModel == 'javascript' or title.contentModel == 'css'[](https://freemwiki.com/wiki/Module:Protection_banner/#L-178))[](https://freemwiki.com/wiki/Module:Protection_banner/#L-179)end[](https://freemwiki.com/wiki/Module:Protection_banner/#L-180)[](https://freemwiki.com/wiki/Module:Protection_banner/#L-181)function Protection:isProtected()[](https://freemwiki.com/wiki/Module:Protection_banner/#L-182)return self.level ~= '*'[](https://freemwiki.com/wiki/Module:Protection_banner/#L-183)end[](https://freemwiki.com/wiki/Module:Protection_banner/#L-184)[](https://freemwiki.com/wiki/Module:Protection_banner/#L-185)function Protection:shouldShowLock()[](https://freemwiki.com/wiki/Module:Protection_banner/#L-186)-- Whether we should output a banner/padlock[](https://freemwiki.com/wiki/Module:Protection_banner/#L-187)return self:isProtected() and not self:isUserScript()[](https://freemwiki.com/wiki/Module:Protection_banner/#L-188)end[](https://freemwiki.com/wiki/Module:Protection_banner/#L-189)[](https://freemwiki.com/wiki/Module:Protection_banner/#L-190)-- Whether this page needs a protection category.[](https://freemwiki.com/wiki/Module:Protection_banner/#L-191)Protection.shouldHaveProtectionCategory = Protection.shouldShowLock[](https://freemwiki.com/wiki/Module:Protection_banner/#L-192)[](https://freemwiki.com/wiki/Module:Protection_banner/#L-193)function Protection:isTemporary()[](https://freemwiki.com/wiki/Module:Protection_banner/#L-194)return type(self.expiry) == 'number'[](https://freemwiki.com/wiki/Module:Protection_banner/#L-195)end[](https://freemwiki.com/wiki/Module:Protection_banner/#L-196)[](https://freemwiki.com/wiki/Module:Protection_banner/#L-197)function Protection:makeProtectionCategory()[](https://freemwiki.com/wiki/Module:Protection_banner/#L-198)if not self:shouldHaveProtectionCategory() then[](https://freemwiki.com/wiki/Module:Protection_banner/#L-199)return ''[](https://freemwiki.com/wiki/Module:Protection_banner/#L-200)end[](https://freemwiki.com/wiki/Module:Protection_banner/#L-201)[](https://freemwiki.com/wiki/Module:Protection_banner/#L-202)local cfg = self._cfg[](https://freemwiki.com/wiki/Module:Protection_banner/#L-203)local title = self.title[](https://freemwiki.com/wiki/Module:Protection_banner/#L-204)[](https://freemwiki.com/wiki/Module:Protection_banner/#L-205)-- Get the expiry key fragment.[](https://freemwiki.com/wiki/Module:Protection_banner/#L-206)local expiryFragment[](https://freemwiki.com/wiki/Module:Protection_banner/#L-207)if self.expiry == 'indef' then[](https://freemwiki.com/wiki/Module:Protection_banner/#L-208)expiryFragment = self.expiry[](https://freemwiki.com/wiki/Module:Protection_banner/#L-209)elseif type(self.expiry) == 'number' then[](https://freemwiki.com/wiki/Module:Protection_banner/#L-210)expiryFragment = 'temp'[](https://freemwiki.com/wiki/Module:Protection_banner/#L-211)end[](https://freemwiki.com/wiki/Module:Protection_banner/#L-212)[](https://freemwiki.com/wiki/Module:Protection_banner/#L-213)-- Get the namespace key fragment.[](https://freemwiki.com/wiki/Module:Protection_banner/#L-214)local namespaceFragment = cfg.categoryNamespaceKeys[title.namespace][](https://freemwiki.com/wiki/Module:Protection_banner/#L-215)if not namespaceFragment and title.namespace % 2 == 1 then[](https://freemwiki.com/wiki/Module:Protection_banner/#L-216)namespaceFragment = 'talk'[](https://freemwiki.com/wiki/Module:Protection_banner/#L-217)end[](https://freemwiki.com/wiki/Module:Protection_banner/#L-218)[](https://freemwiki.com/wiki/Module:Protection_banner/#L-219)-- Define the order that key fragments are tested in. This is done with an[](https://freemwiki.com/wiki/Module:Protection_banner/#L-220)-- array of tables containing the value to be tested, along with its[](https://freemwiki.com/wiki/Module:Protection_banner/#L-221)-- position in the cfg.protectionCategories table.[](https://freemwiki.com/wiki/Module:Protection_banner/#L-222)local order = {[](https://freemwiki.com/wiki/Module:Protection_banner/#L-223){val = expiryFragment, keypos = 1},[](https://freemwiki.com/wiki/Module:Protection_banner/#L-224){val = namespaceFragment, keypos = 2},[](https://freemwiki.com/wiki/Module:Protection_banner/#L-225){val = self.reason, keypos = 3},[](https://freemwiki.com/wiki/Module:Protection_banner/#L-226){val = self.level, keypos = 4},[](https://freemwiki.com/wiki/Module:Protection_banner/#L-227){val = self.action, keypos = 5}[](https://freemwiki.com/wiki/Module:Protection_banner/#L-228)}[](https://freemwiki.com/wiki/Module:Protection_banner/#L-229)[](https://freemwiki.com/wiki/Module:Protection_banner/#L-230)--[[[](https://freemwiki.com/wiki/Module:Protection_banner/#L-231) -- The old protection templates used an ad-hoc protection category system,[](https://freemwiki.com/wiki/Module:Protection_banner/#L-232) -- with some templates prioritising namespaces in their categories, and[](https://freemwiki.com/wiki/Module:Protection_banner/#L-233) -- others prioritising the protection reason. To emulate this in this module[](https://freemwiki.com/wiki/Module:Protection_banner/#L-234) -- we use the config table cfg.reasonsWithNamespacePriority to set the[](https://freemwiki.com/wiki/Module:Protection_banner/#L-235) -- reasons for which namespaces have priority over protection reason.[](https://freemwiki.com/wiki/Module:Protection_banner/#L-236) -- If we are dealing with one of those reasons, move the namespace table to[](https://freemwiki.com/wiki/Module:Protection_banner/#L-237) -- the end of the order table, i.e. give it highest priority. If not, the[](https://freemwiki.com/wiki/Module:Protection_banner/#L-238) -- reason should have highest priority, so move that to the end of the table[](https://freemwiki.com/wiki/Module:Protection_banner/#L-239) -- instead.[](https://freemwiki.com/wiki/Module:Protection_banner/#L-240) --]][](https://freemwiki.com/wiki/Module:Protection_banner/#L-241)table.insert(order, table.remove(order, self.reason and cfg.reasonsWithNamespacePriority[self.reason] and 2 or 3))[](https://freemwiki.com/wiki/Module:Protection_banner/#L-242) [](https://freemwiki.com/wiki/Module:Protection_banner/#L-243)--[[[](https://freemwiki.com/wiki/Module:Protection_banner/#L-244) -- Define the attempt order. Inactive subtables (subtables with nil "value"[](https://freemwiki.com/wiki/Module:Protection_banner/#L-245) -- fields) are moved to the end, where they will later be given the key[](https://freemwiki.com/wiki/Module:Protection_banner/#L-246) -- "all". This is to cut down on the number of table lookups in[](https://freemwiki.com/wiki/Module:Protection_banner/#L-247) -- cfg.protectionCategories, which grows exponentially with the number of[](https://freemwiki.com/wiki/Module:Protection_banner/#L-248) -- non-nil keys. We keep track of the number of active subtables with the[](https://freemwiki.com/wiki/Module:Protection_banner/#L-249) -- noActive parameter.[](https://freemwiki.com/wiki/Module:Protection_banner/#L-250) --]][](https://freemwiki.com/wiki/Module:Protection_banner/#L-251)local noActive, attemptOrder[](https://freemwiki.com/wiki/Module:Protection_banner/#L-252)do[](https://freemwiki.com/wiki/Module:Protection_banner/#L-253)local active, inactive = {}, {}[](https://freemwiki.com/wiki/Module:Protection_banner/#L-254)for i, t in ipairs(order) do[](https://freemwiki.com/wiki/Module:Protection_banner/#L-255)if t.val then[](https://freemwiki.com/wiki/Module:Protection_banner/#L-256)active[#active + 1] = t[](https://freemwiki.com/wiki/Module:Protection_banner/#L-257)else[](https://freemwiki.com/wiki/Module:Protection_banner/#L-258)inactive[#inactive + 1] = t[](https://freemwiki.com/wiki/Module:Protection_banner/#L-259)end[](https://freemwiki.com/wiki/Module:Protection_banner/#L-260)end[](https://freemwiki.com/wiki/Module:Protection_banner/#L-261)noActive = #active[](https://freemwiki.com/wiki/Module:Protection_banner/#L-262)attemptOrder = active[](https://freemwiki.com/wiki/Module:Protection_banner/#L-263)for i, t in ipairs(inactive) do[](https://freemwiki.com/wiki/Module:Protection_banner/#L-264)attemptOrder[#attemptOrder + 1] = t[](https://freemwiki.com/wiki/Module:Protection_banner/#L-265)end[](https://freemwiki.com/wiki/Module:Protection_banner/#L-266)end[](https://freemwiki.com/wiki/Module:Protection_banner/#L-267) [](https://freemwiki.com/wiki/Module:Protection_banner/#L-268)--[[[](https://freemwiki.com/wiki/Module:Protection_banner/#L-269) -- Check increasingly generic key combinations until we find a match. If a[](https://freemwiki.com/wiki/Module:Protection_banner/#L-270) -- specific category exists for the combination of key fragments we are[](https://freemwiki.com/wiki/Module:Protection_banner/#L-271) -- given, that match will be found first. If not, we keep trying different[](https://freemwiki.com/wiki/Module:Protection_banner/#L-272) -- key fragment combinations until we match using the key[](https://freemwiki.com/wiki/Module:Protection_banner/#L-273) -- "all-all-all-all-all".[](https://freemwiki.com/wiki/Module:Protection_banner/#L-274) --[](https://freemwiki.com/wiki/Module:Protection_banner/#L-275) -- To generate the keys, we index the key subtables using a binary matrix[](https://freemwiki.com/wiki/Module:Protection_banner/#L-276) -- with indexes i and j. j is only calculated up to the number of active[](https://freemwiki.com/wiki/Module:Protection_banner/#L-277) -- subtables. For example, if there were three active subtables, the matrix[](https://freemwiki.com/wiki/Module:Protection_banner/#L-278) -- would look like this, with 0 corresponding to the key fragment "all", and[](https://freemwiki.com/wiki/Module:Protection_banner/#L-279) -- 1 corresponding to other key fragments.[](https://freemwiki.com/wiki/Module:Protection_banner/#L-280) -- [](https://freemwiki.com/wiki/Module:Protection_banner/#L-281) -- j 1 2 3[](https://freemwiki.com/wiki/Module:Protection_banner/#L-282) -- i [](https://freemwiki.com/wiki/Module:Protection_banner/#L-283) -- 1 1 1 1[](https://freemwiki.com/wiki/Module:Protection_banner/#L-284) -- 2 0 1 1[](https://freemwiki.com/wiki/Module:Protection_banner/#L-285) -- 3 1 0 1[](https://freemwiki.com/wiki/Module:Protection_banner/#L-286) -- 4 0 0 1[](https://freemwiki.com/wiki/Module:Protection_banner/#L-287) -- 5 1 1 0[](https://freemwiki.com/wiki/Module:Protection_banner/#L-288) -- 6 0 1 0[](https://freemwiki.com/wiki/Module:Protection_banner/#L-289) -- 7 1 0 0[](https://freemwiki.com/wiki/Module:Protection_banner/#L-290) -- 8 0 0 0[](https://freemwiki.com/wiki/Module:Protection_banner/#L-291) -- [](https://freemwiki.com/wiki/Module:Protection_banner/#L-292) -- Values of j higher than the number of active subtables are set[](https://freemwiki.com/wiki/Module:Protection_banner/#L-293) -- to the string "all".[](https://freemwiki.com/wiki/Module:Protection_banner/#L-294) --[](https://freemwiki.com/wiki/Module:Protection_banner/#L-295) -- A key for cfg.protectionCategories is constructed for each value of i.[](https://freemwiki.com/wiki/Module:Protection_banner/#L-296) -- The position of the value in the key is determined by the keypos field in[](https://freemwiki.com/wiki/Module:Protection_banner/#L-297) -- each subtable.[](https://freemwiki.com/wiki/Module:Protection_banner/#L-298) --]][](https://freemwiki.com/wiki/Module:Protection_banner/#L-299)local cats = cfg.protectionCategories[](https://freemwiki.com/wiki/Module:Protection_banner/#L-300)for i = 1, 2^noActive do[](https://freemwiki.com/wiki/Module:Protection_banner/#L-301)local key = {}[](https://freemwiki.com/wiki/Module:Protection_banner/#L-302)for j, t in ipairs(attemptOrder) do[](https://freemwiki.com/wiki/Module:Protection_banner/#L-303)if j > noActive then[](https://freemwiki.com/wiki/Module:Protection_banner/#L-304)key[t.keypos] = 'all'[](https://freemwiki.com/wiki/Module:Protection_banner/#L-305)else[](https://freemwiki.com/wiki/Module:Protection_banner/#L-306)local quotient = i / 2 ^ (j - 1)[](https://freemwiki.com/wiki/Module:Protection_banner/#L-307)quotient = math.ceil(quotient)[](https://freemwiki.com/wiki/Module:Protection_banner/#L-308)if quotient % 2 == 1 then[](https://freemwiki.com/wiki/Module:Protection_banner/#L-309)key[t.keypos] = t.val[](https://freemwiki.com/wiki/Module:Protection_banner/#L-310)else[](https://freemwiki.com/wiki/Module:Protection_banner/#L-311)key[t.keypos] = 'all'[](https://freemwiki.com/wiki/Module:Protection_banner/#L-312)end[](https://freemwiki.com/wiki/Module:Protection_banner/#L-313)end[](https://freemwiki.com/wiki/Module:Protection_banner/#L-314)end[](https://freemwiki.com/wiki/Module:Protection_banner/#L-315)key = table.concat(key, '|')[](https://freemwiki.com/wiki/Module:Protection_banner/#L-316)local attempt = cats[key][](https://freemwiki.com/wiki/Module:Protection_banner/#L-317)if attempt then[](https://freemwiki.com/wiki/Module:Protection_banner/#L-318)return makeCategoryLink(attempt, title.text)[](https://freemwiki.com/wiki/Module:Protection_banner/#L-319)end[](https://freemwiki.com/wiki/Module:Protection_banner/#L-320)end[](https://freemwiki.com/wiki/Module:Protection_banner/#L-321)return ''[](https://freemwiki.com/wiki/Module:Protection_banner/#L-322)end[](https://freemwiki.com/wiki/Module:Protection_banner/#L-323)[](https://freemwiki.com/wiki/Module:Protection_banner/#L-324)function Protection:isIncorrect()[](https://freemwiki.com/wiki/Module:Protection_banner/#L-325)local expiry = self.expiry[](https://freemwiki.com/wiki/Module:Protection_banner/#L-326)return not self:shouldHaveProtectionCategory()[](https://freemwiki.com/wiki/Module:Protection_banner/#L-327)or type(expiry) == 'number' and expiry < os.time()[](https://freemwiki.com/wiki/Module:Protection_banner/#L-328)end[](https://freemwiki.com/wiki/Module:Protection_banner/#L-329)[](https://freemwiki.com/wiki/Module:Protection_banner/#L-330)function Protection:isTemplateProtectedNonTemplate()[](https://freemwiki.com/wiki/Module:Protection_banner/#L-331)local action, namespace = self.action, self.title.namespace[](https://freemwiki.com/wiki/Module:Protection_banner/#L-332)return self.level == 'templateeditor'[](https://freemwiki.com/wiki/Module:Protection_banner/#L-333)and ([](https://freemwiki.com/wiki/Module:Protection_banner/#L-334)(action ~= 'edit' and action ~= 'move')[](https://freemwiki.com/wiki/Module:Protection_banner/#L-335)or (namespace ~= 10 and namespace ~= 828)[](https://freemwiki.com/wiki/Module:Protection_banner/#L-336))[](https://freemwiki.com/wiki/Module:Protection_banner/#L-337)end[](https://freemwiki.com/wiki/Module:Protection_banner/#L-338)[](https://freemwiki.com/wiki/Module:Protection_banner/#L-339)function Protection:makeCategoryLinks()[](https://freemwiki.com/wiki/Module:Protection_banner/#L-340)local msg = self._cfg.msg[](https://freemwiki.com/wiki/Module:Protection_banner/#L-341)local ret = {self:makeProtectionCategory()}[](https://freemwiki.com/wiki/Module:Protection_banner/#L-342)if self:isIncorrect() then[](https://freemwiki.com/wiki/Module:Protection_banner/#L-343)ret[#ret + 1] = makeCategoryLink([](https://freemwiki.com/wiki/Module:Protection_banner/#L-344)msg['tracking-category-incorrect'],[](https://freemwiki.com/wiki/Module:Protection_banner/#L-345)self.title.text[](https://freemwiki.com/wiki/Module:Protection_banner/#L-346))[](https://freemwiki.com/wiki/Module:Protection_banner/#L-347)end[](https://freemwiki.com/wiki/Module:Protection_banner/#L-348)if self:isTemplateProtectedNonTemplate() then[](https://freemwiki.com/wiki/Module:Protection_banner/#L-349)ret[#ret + 1] = makeCategoryLink([](https://freemwiki.com/wiki/Module:Protection_banner/#L-350)msg['tracking-category-template'],[](https://freemwiki.com/wiki/Module:Protection_banner/#L-351)self.title.text[](https://freemwiki.com/wiki/Module:Protection_banner/#L-352))[](https://freemwiki.com/wiki/Module:Protection_banner/#L-353)end[](https://freemwiki.com/wiki/Module:Protection_banner/#L-354)return table.concat(ret)[](https://freemwiki.com/wiki/Module:Protection_banner/#L-355)end[](https://freemwiki.com/wiki/Module:Protection_banner/#L-356)[](https://freemwiki.com/wiki/Module:Protection_banner/#L-357)--------------------------------------------------------------------------------[](https://freemwiki.com/wiki/Module:Protection_banner/#L-358)-- Blurb class[](https://freemwiki.com/wiki/Module:Protection_banner/#L-359)--------------------------------------------------------------------------------[](https://freemwiki.com/wiki/Module:Protection_banner/#L-360)[](https://freemwiki.com/wiki/Module:Protection_banner/#L-361)local Blurb = {}[](https://freemwiki.com/wiki/Module:Protection_banner/#L-362)Blurb.__index = Blurb[](https://freemwiki.com/wiki/Module:Protection_banner/#L-363)[](https://freemwiki.com/wiki/Module:Protection_banner/#L-364)Blurb.bannerTextFields = {[](https://freemwiki.com/wiki/Module:Protection_banner/#L-365)text = true,[](https://freemwiki.com/wiki/Module:Protection_banner/#L-366)explanation = true,[](https://freemwiki.com/wiki/Module:Protection_banner/#L-367)tooltip = true,[](https://freemwiki.com/wiki/Module:Protection_banner/#L-368)alt = true,[](https://freemwiki.com/wiki/Module:Protection_banner/#L-369)link = true[](https://freemwiki.com/wiki/Module:Protection_banner/#L-370)}[](https://freemwiki.com/wiki/Module:Protection_banner/#L-371)[](https://freemwiki.com/wiki/Module:Protection_banner/#L-372)function Blurb.new(protectionObj, args, cfg)[](https://freemwiki.com/wiki/Module:Protection_banner/#L-373)return setmetatable({[](https://freemwiki.com/wiki/Module:Protection_banner/#L-374)_cfg = cfg,[](https://freemwiki.com/wiki/Module:Protection_banner/#L-375)_protectionObj = protectionObj,[](https://freemwiki.com/wiki/Module:Protection_banner/#L-376)_args = args[](https://freemwiki.com/wiki/Module:Protection_banner/#L-377)}, Blurb)[](https://freemwiki.com/wiki/Module:Protection_banner/#L-378)end[](https://freemwiki.com/wiki/Module:Protection_banner/#L-379)[](https://freemwiki.com/wiki/Module:Protection_banner/#L-380)-- Private methods --[](https://freemwiki.com/wiki/Module:Protection_banner/#L-381)[](https://freemwiki.com/wiki/Module:Protection_banner/#L-382)function Blurb:_formatDate(num)[](https://freemwiki.com/wiki/Module:Protection_banner/#L-383)-- Formats a Unix timestamp into dd Month, YYYY format.[](https://freemwiki.com/wiki/Module:Protection_banner/#L-384)lang = lang or mw.language.getContentLanguage()[](https://freemwiki.com/wiki/Module:Protection_banner/#L-385)local success, date = pcall([](https://freemwiki.com/wiki/Module:Protection_banner/#L-386)lang.formatDate,[](https://freemwiki.com/wiki/Module:Protection_banner/#L-387)lang,[](https://freemwiki.com/wiki/Module:Protection_banner/#L-388)self._cfg.msg['expiry-date-format'] or 'j F Y',[](https://freemwiki.com/wiki/Module:Protection_banner/#L-389)'@' .. tostring(num)[](https://freemwiki.com/wiki/Module:Protection_banner/#L-390))[](https://freemwiki.com/wiki/Module:Protection_banner/#L-391)if success then[](https://freemwiki.com/wiki/Module:Protection_banner/#L-392)return date[](https://freemwiki.com/wiki/Module:Protection_banner/#L-393)end[](https://freemwiki.com/wiki/Module:Protection_banner/#L-394)end[](https://freemwiki.com/wiki/Module:Protection_banner/#L-395)[](https://freemwiki.com/wiki/Module:Protection_banner/#L-396)function Blurb:_getExpandedMessage(msgKey)[](https://freemwiki.com/wiki/Module:Protection_banner/#L-397)return self:_substituteParameters(self._cfg.msg[msgKey])[](https://freemwiki.com/wiki/Module:Protection_banner/#L-398)end[](https://freemwiki.com/wiki/Module:Protection_banner/#L-399)[](https://freemwiki.com/wiki/Module:Protection_banner/#L-400)function Blurb:_substituteParameters(msg)[](https://freemwiki.com/wiki/Module:Protection_banner/#L-401)if not self._params then[](https://freemwiki.com/wiki/Module:Protection_banner/#L-402)local parameterFuncs = {}[](https://freemwiki.com/wiki/Module:Protection_banner/#L-403)[](https://freemwiki.com/wiki/Module:Protection_banner/#L-404)parameterFuncs.CURRENTVERSION = self._makeCurrentVersionParameter[](https://freemwiki.com/wiki/Module:Protection_banner/#L-405)parameterFuncs.EDITREQUEST = self._makeEditRequestParameter[](https://freemwiki.com/wiki/Module:Protection_banner/#L-406)parameterFuncs.EXPIRY = self._makeExpiryParameter[](https://freemwiki.com/wiki/Module:Protection_banner/#L-407)parameterFuncs.EXPLANATIONBLURB = self._makeExplanationBlurbParameter[](https://freemwiki.com/wiki/Module:Protection_banner/#L-408)parameterFuncs.IMAGELINK = self._makeImageLinkParameter[](https://freemwiki.com/wiki/Module:Protection_banner/#L-409)parameterFuncs.INTROBLURB = self._makeIntroBlurbParameter[](https://freemwiki.com/wiki/Module:Protection_banner/#L-410)parameterFuncs.INTROFRAGMENT = self._makeIntroFragmentParameter[](https://freemwiki.com/wiki/Module:Protection_banner/#L-411)parameterFuncs.PAGETYPE = self._makePagetypeParameter[](https://freemwiki.com/wiki/Module:Protection_banner/#L-412)parameterFuncs.PROTECTIONBLURB = self._makeProtectionBlurbParameter[](https://freemwiki.com/wiki/Module:Protection_banner/#L-413)parameterFuncs.PROTECTIONDATE = self._makeProtectionDateParameter[](https://freemwiki.com/wiki/Module:Protection_banner/#L-414)parameterFuncs.PROTECTIONLEVEL = self._makeProtectionLevelParameter[](https://freemwiki.com/wiki/Module:Protection_banner/#L-415)parameterFuncs.PROTECTIONLOG = self._makeProtectionLogParameter[](https://freemwiki.com/wiki/Module:Protection_banner/#L-416)parameterFuncs.TALKPAGE = self._makeTalkPageParameter[](https://freemwiki.com/wiki/Module:Protection_banner/#L-417)parameterFuncs.TOOLTIPBLURB = self._makeTooltipBlurbParameter[](https://freemwiki.com/wiki/Module:Protection_banner/#L-418)parameterFuncs.TOOLTIPFRAGMENT = self._makeTooltipFragmentParameter[](https://freemwiki.com/wiki/Module:Protection_banner/#L-419)parameterFuncs.VANDAL = self._makeVandalTemplateParameter[](https://freemwiki.com/wiki/Module:Protection_banner/#L-420)[](https://freemwiki.com/wiki/Module:Protection_banner/#L-421)self._params = setmetatable({}, {[](https://freemwiki.com/wiki/Module:Protection_banner/#L-422)__index = function (t, k)[](https://freemwiki.com/wiki/Module:Protection_banner/#L-423)local param[](https://freemwiki.com/wiki/Module:Protection_banner/#L-424)if parameterFuncs[k] then[](https://freemwiki.com/wiki/Module:Protection_banner/#L-425)param = parameterFuncs[k](self)[](https://freemwiki.com/wiki/Module:Protection_banner/#L-426)end[](https://freemwiki.com/wiki/Module:Protection_banner/#L-427)param = param or ''[](https://freemwiki.com/wiki/Module:Protection_banner/#L-428)t[k] = param[](https://freemwiki.com/wiki/Module:Protection_banner/#L-429)return param[](https://freemwiki.com/wiki/Module:Protection_banner/#L-430)end[](https://freemwiki.com/wiki/Module:Protection_banner/#L-431)})[](https://freemwiki.com/wiki/Module:Protection_banner/#L-432)end[](https://freemwiki.com/wiki/Module:Protection_banner/#L-433)[](https://freemwiki.com/wiki/Module:Protection_banner/#L-434)msg = msg:gsub('${(%u+)}', self._params)[](https://freemwiki.com/wiki/Module:Protection_banner/#L-435)return msg[](https://freemwiki.com/wiki/Module:Protection_banner/#L-436)end[](https://freemwiki.com/wiki/Module:Protection_banner/#L-437)[](https://freemwiki.com/wiki/Module:Protection_banner/#L-438)function Blurb:_makeCurrentVersionParameter()[](https://freemwiki.com/wiki/Module:Protection_banner/#L-439)-- A link to the page history or the move log, depending on the kind of[](https://freemwiki.com/wiki/Module:Protection_banner/#L-440)-- protection.[](https://freemwiki.com/wiki/Module:Protection_banner/#L-441)local pagename = self._protectionObj.title.prefixedText[](https://freemwiki.com/wiki/Module:Protection_banner/#L-442)if self._protectionObj.action == 'move' then[](https://freemwiki.com/wiki/Module:Protection_banner/#L-443)-- We need the move log link.[](https://freemwiki.com/wiki/Module:Protection_banner/#L-444)return makeFullUrl([](https://freemwiki.com/wiki/Module:Protection_banner/#L-445)'Special:Log',[](https://freemwiki.com/wiki/Module:Protection_banner/#L-446){type = 'move', page = pagename},[](https://freemwiki.com/wiki/Module:Protection_banner/#L-447)self:_getExpandedMessage('current-version-move-display')[](https://freemwiki.com/wiki/Module:Protection_banner/#L-448))[](https://freemwiki.com/wiki/Module:Protection_banner/#L-449)else[](https://freemwiki.com/wiki/Module:Protection_banner/#L-450)-- We need the history link.[](https://freemwiki.com/wiki/Module:Protection_banner/#L-451)return makeFullUrl([](https://freemwiki.com/wiki/Module:Protection_banner/#L-452)pagename,[](https://freemwiki.com/wiki/Module:Protection_banner/#L-453){action = 'history'},[](https://freemwiki.com/wiki/Module:Protection_banner/#L-454)self:_getExpandedMessage('current-version-edit-display')[](https://freemwiki.com/wiki/Module:Protection_banner/#L-455))[](https://freemwiki.com/wiki/Module:Protection_banner/#L-456)end[](https://freemwiki.com/wiki/Module:Protection_banner/#L-457)end[](https://freemwiki.com/wiki/Module:Protection_banner/#L-458)[](https://freemwiki.com/wiki/Module:Protection_banner/#L-459)function Blurb:_makeEditRequestParameter()[](https://freemwiki.com/wiki/Module:Protection_banner/#L-460)local mEditRequest = require(['Module:Submit an edit request'](https://freemwiki.com/wiki/Module:Submit_an_edit_request))[](https://freemwiki.com/wiki/Module:Protection_banner/#L-461)local action = self._protectionObj.action[](https://freemwiki.com/wiki/Module:Protection_banner/#L-462)local level = self._protectionObj.level[](https://freemwiki.com/wiki/Module:Protection_banner/#L-463)[](https://freemwiki.com/wiki/Module:Protection_banner/#L-464)-- Get the edit request type.[](https://freemwiki.com/wiki/Module:Protection_banner/#L-465)local requestType[](https://freemwiki.com/wiki/Module:Protection_banner/#L-466)if action == 'edit' then[](https://freemwiki.com/wiki/Module:Protection_banner/#L-467)if level == 'autoconfirmed' then[](https://freemwiki.com/wiki/Module:Protection_banner/#L-468)requestType = 'semi'[](https://freemwiki.com/wiki/Module:Protection_banner/#L-469)elseif level == 'extendedconfirmed' then[](https://freemwiki.com/wiki/Module:Protection_banner/#L-470)requestType = 'extended'[](https://freemwiki.com/wiki/Module:Protection_banner/#L-471)elseif level == 'templateeditor' then[](https://freemwiki.com/wiki/Module:Protection_banner/#L-472)requestType = 'template'[](https://freemwiki.com/wiki/Module:Protection_banner/#L-473)end[](https://freemwiki.com/wiki/Module:Protection_banner/#L-474)end[](https://freemwiki.com/wiki/Module:Protection_banner/#L-475)requestType = requestType or 'full'[](https://freemwiki.com/wiki/Module:Protection_banner/#L-476)[](https://freemwiki.com/wiki/Module:Protection_banner/#L-477)-- Get the display value.[](https://freemwiki.com/wiki/Module:Protection_banner/#L-478)local display = self:_getExpandedMessage('edit-request-display')[](https://freemwiki.com/wiki/Module:Protection_banner/#L-479)[](https://freemwiki.com/wiki/Module:Protection_banner/#L-480)return mEditRequest._link{type = requestType, display = display}[](https://freemwiki.com/wiki/Module:Protection_banner/#L-481)end[](https://freemwiki.com/wiki/Module:Protection_banner/#L-482)[](https://freemwiki.com/wiki/Module:Protection_banner/#L-483)function Blurb:_makeExpiryParameter()[](https://freemwiki.com/wiki/Module:Protection_banner/#L-484)local expiry = self._protectionObj.expiry[](https://freemwiki.com/wiki/Module:Protection_banner/#L-485)if type(expiry) == 'number' then[](https://freemwiki.com/wiki/Module:Protection_banner/#L-486)return self:_formatDate(expiry)[](https://freemwiki.com/wiki/Module:Protection_banner/#L-487)else[](https://freemwiki.com/wiki/Module:Protection_banner/#L-488)return expiry[](https://freemwiki.com/wiki/Module:Protection_banner/#L-489)end[](https://freemwiki.com/wiki/Module:Protection_banner/#L-490)end[](https://freemwiki.com/wiki/Module:Protection_banner/#L-491)[](https://freemwiki.com/wiki/Module:Protection_banner/#L-492)function Blurb:_makeExplanationBlurbParameter()[](https://freemwiki.com/wiki/Module:Protection_banner/#L-493)-- Cover special cases first.[](https://freemwiki.com/wiki/Module:Protection_banner/#L-494)if self._protectionObj.title.namespace == 8 then[](https://freemwiki.com/wiki/Module:Protection_banner/#L-495)-- MediaWiki namespace[](https://freemwiki.com/wiki/Module:Protection_banner/#L-496)return self:_getExpandedMessage('explanation-blurb-nounprotect')[](https://freemwiki.com/wiki/Module:Protection_banner/#L-497)end[](https://freemwiki.com/wiki/Module:Protection_banner/#L-498)[](https://freemwiki.com/wiki/Module:Protection_banner/#L-499)-- Get explanation blurb table keys[](https://freemwiki.com/wiki/Module:Protection_banner/#L-500)local action = self._protectionObj.action[](https://freemwiki.com/wiki/Module:Protection_banner/#L-501)local level = self._protectionObj.level[](https://freemwiki.com/wiki/Module:Protection_banner/#L-502)local talkKey = self._protectionObj.title.isTalkPage and 'talk' or 'subject'[](https://freemwiki.com/wiki/Module:Protection_banner/#L-503)[](https://freemwiki.com/wiki/Module:Protection_banner/#L-504)-- Find the message in the explanation blurb table and substitute any[](https://freemwiki.com/wiki/Module:Protection_banner/#L-505)-- parameters.[](https://freemwiki.com/wiki/Module:Protection_banner/#L-506)local explanations = self._cfg.explanationBlurbs[](https://freemwiki.com/wiki/Module:Protection_banner/#L-507)local msg[](https://freemwiki.com/wiki/Module:Protection_banner/#L-508)if explanations[action][level] and explanations[action][level][talkKey] then[](https://freemwiki.com/wiki/Module:Protection_banner/#L-509)msg = explanations[action][level][talkKey][](https://freemwiki.com/wiki/Module:Protection_banner/#L-510)elseif explanations[action][level] and explanations[action][level].default then[](https://freemwiki.com/wiki/Module:Protection_banner/#L-511)msg = explanations[action][level].default[](https://freemwiki.com/wiki/Module:Protection_banner/#L-512)elseif explanations[action].default and explanations[action].default[talkKey] then[](https://freemwiki.com/wiki/Module:Protection_banner/#L-513)msg = explanations[action].default[talkKey][](https://freemwiki.com/wiki/Module:Protection_banner/#L-514)elseif explanations[action].default and explanations[action].default.default then[](https://freemwiki.com/wiki/Module:Protection_banner/#L-515)msg = explanations[action].default.default[](https://freemwiki.com/wiki/Module:Protection_banner/#L-516)else[](https://freemwiki.com/wiki/Module:Protection_banner/#L-517)error(string.format([](https://freemwiki.com/wiki/Module:Protection_banner/#L-518)'could not find explanation blurb for action "%s", level "%s" and talk key "%s"',[](https://freemwiki.com/wiki/Module:Protection_banner/#L-519)action,[](https://freemwiki.com/wiki/Module:Protection_banner/#L-520)level,[](https://freemwiki.com/wiki/Module:Protection_banner/#L-521)talkKey[](https://freemwiki.com/wiki/Module:Protection_banner/#L-522)), 8)[](https://freemwiki.com/wiki/Module:Protection_banner/#L-523)end[](https://freemwiki.com/wiki/Module:Protection_banner/#L-524)return self:_substituteParameters(msg)[](https://freemwiki.com/wiki/Module:Protection_banner/#L-525)end[](https://freemwiki.com/wiki/Module:Protection_banner/#L-526)[](https://freemwiki.com/wiki/Module:Protection_banner/#L-527)function Blurb:_makeImageLinkParameter()[](https://freemwiki.com/wiki/Module:Protection_banner/#L-528)local imageLinks = self._cfg.imageLinks[](https://freemwiki.com/wiki/Module:Protection_banner/#L-529)local action = self._protectionObj.action[](https://freemwiki.com/wiki/Module:Protection_banner/#L-530)local level = self._protectionObj.level[](https://freemwiki.com/wiki/Module:Protection_banner/#L-531)local msg[](https://freemwiki.com/wiki/Module:Protection_banner/#L-532)if imageLinks[action][level] then[](https://freemwiki.com/wiki/Module:Protection_banner/#L-533)msg = imageLinks[action][level][](https://freemwiki.com/wiki/Module:Protection_banner/#L-534)elseif imageLinks[action].default then[](https://freemwiki.com/wiki/Module:Protection_banner/#L-535)msg = imageLinks[action].default[](https://freemwiki.com/wiki/Module:Protection_banner/#L-536)else[](https://freemwiki.com/wiki/Module:Protection_banner/#L-537)msg = imageLinks.edit.default[](https://freemwiki.com/wiki/Module:Protection_banner/#L-538)end[](https://freemwiki.com/wiki/Module:Protection_banner/#L-539)return self:_substituteParameters(msg)[](https://freemwiki.com/wiki/Module:Protection_banner/#L-540)end[](https://freemwiki.com/wiki/Module:Protection_banner/#L-541)[](https://freemwiki.com/wiki/Module:Protection_banner/#L-542)function Blurb:_makeIntroBlurbParameter()[](https://freemwiki.com/wiki/Module:Protection_banner/#L-543)if self._protectionObj:isTemporary() then[](https://freemwiki.com/wiki/Module:Protection_banner/#L-544)return self:_getExpandedMessage('intro-blurb-expiry')[](https://freemwiki.com/wiki/Module:Protection_banner/#L-545)else[](https://freemwiki.com/wiki/Module:Protection_banner/#L-546)return self:_getExpandedMessage('intro-blurb-noexpiry')[](https://freemwiki.com/wiki/Module:Protection_banner/#L-547)end[](https://freemwiki.com/wiki/Module:Protection_banner/#L-548)end[](https://freemwiki.com/wiki/Module:Protection_banner/#L-549)[](https://freemwiki.com/wiki/Module:Protection_banner/#L-550)function Blurb:_makeIntroFragmentParameter()[](https://freemwiki.com/wiki/Module:Protection_banner/#L-551)if self._protectionObj:isTemporary() then[](https://freemwiki.com/wiki/Module:Protection_banner/#L-552)return self:_getExpandedMessage('intro-fragment-expiry')[](https://freemwiki.com/wiki/Module:Protection_banner/#L-553)else[](https://freemwiki.com/wiki/Module:Protection_banner/#L-554)return self:_getExpandedMessage('intro-fragment-noexpiry')[](https://freemwiki.com/wiki/Module:Protection_banner/#L-555)end[](https://freemwiki.com/wiki/Module:Protection_banner/#L-556)end[](https://freemwiki.com/wiki/Module:Protection_banner/#L-557)[](https://freemwiki.com/wiki/Module:Protection_banner/#L-558)function Blurb:_makePagetypeParameter()[](https://freemwiki.com/wiki/Module:Protection_banner/#L-559)local pagetypes = self._cfg.pagetypes[](https://freemwiki.com/wiki/Module:Protection_banner/#L-560)return pagetypes[self._protectionObj.title.namespace][](https://freemwiki.com/wiki/Module:Protection_banner/#L-561)or pagetypes.default[](https://freemwiki.com/wiki/Module:Protection_banner/#L-562)or error('no default pagetype defined', 8)[](https://freemwiki.com/wiki/Module:Protection_banner/#L-563)end[](https://freemwiki.com/wiki/Module:Protection_banner/#L-564)[](https://freemwiki.com/wiki/Module:Protection_banner/#L-565)function Blurb:_makeProtectionBlurbParameter()[](https://freemwiki.com/wiki/Module:Protection_banner/#L-566)local protectionBlurbs = self._cfg.protectionBlurbs[](https://freemwiki.com/wiki/Module:Protection_banner/#L-567)local action = self._protectionObj.action[](https://freemwiki.com/wiki/Module:Protection_banner/#L-568)local level = self._protectionObj.level[](https://freemwiki.com/wiki/Module:Protection_banner/#L-569)local msg[](https://freemwiki.com/wiki/Module:Protection_banner/#L-570)if protectionBlurbs[action][level] then[](https://freemwiki.com/wiki/Module:Protection_banner/#L-571)msg = protectionBlurbs[action][level][](https://freemwiki.com/wiki/Module:Protection_banner/#L-572)elseif protectionBlurbs[action].default then[](https://freemwiki.com/wiki/Module:Protection_banner/#L-573)msg = protectionBlurbs[action].default[](https://freemwiki.com/wiki/Module:Protection_banner/#L-574)elseif protectionBlurbs.edit.default then[](https://freemwiki.com/wiki/Module:Protection_banner/#L-575)msg = protectionBlurbs.edit.default[](https://freemwiki.com/wiki/Module:Protection_banner/#L-576)else[](https://freemwiki.com/wiki/Module:Protection_banner/#L-577)error('no protection blurb defined for protectionBlurbs.edit.default', 8)[](https://freemwiki.com/wiki/Module:Protection_banner/#L-578)end[](https://freemwiki.com/wiki/Module:Protection_banner/#L-579)return self:_substituteParameters(msg)[](https://freemwiki.com/wiki/Module:Protection_banner/#L-580)end[](https://freemwiki.com/wiki/Module:Protection_banner/#L-581)[](https://freemwiki.com/wiki/Module:Protection_banner/#L-582)function Blurb:_makeProtectionDateParameter()[](https://freemwiki.com/wiki/Module:Protection_banner/#L-583)local protectionDate = self._protectionObj.protectionDate[](https://freemwiki.com/wiki/Module:Protection_banner/#L-584)if type(protectionDate) == 'number' then[](https://freemwiki.com/wiki/Module:Protection_banner/#L-585)return self:_formatDate(protectionDate)[](https://freemwiki.com/wiki/Module:Protection_banner/#L-586)else[](https://freemwiki.com/wiki/Module:Protection_banner/#L-587)return protectionDate[](https://freemwiki.com/wiki/Module:Protection_banner/#L-588)end[](https://freemwiki.com/wiki/Module:Protection_banner/#L-589)end[](https://freemwiki.com/wiki/Module:Protection_banner/#L-590)[](https://freemwiki.com/wiki/Module:Protection_banner/#L-591)function Blurb:_makeProtectionLevelParameter()[](https://freemwiki.com/wiki/Module:Protection_banner/#L-592)local protectionLevels = self._cfg.protectionLevels[](https://freemwiki.com/wiki/Module:Protection_banner/#L-593)local action = self._protectionObj.action[](https://freemwiki.com/wiki/Module:Protection_banner/#L-594)local level = self._protectionObj.level[](https://freemwiki.com/wiki/Module:Protection_banner/#L-595)local msg[](https://freemwiki.com/wiki/Module:Protection_banner/#L-596)if protectionLevels[action][level] then[](https://freemwiki.com/wiki/Module:Protection_banner/#L-597)msg = protectionLevels[action][level][](https://freemwiki.com/wiki/Module:Protection_banner/#L-598)elseif protectionLevels[action].default then[](https://freemwiki.com/wiki/Module:Protection_banner/#L-599)msg = protectionLevels[action].default[](https://freemwiki.com/wiki/Module:Protection_banner/#L-600)elseif protectionLevels.edit.default then[](https://freemwiki.com/wiki/Module:Protection_banner/#L-601)msg = protectionLevels.edit.default[](https://freemwiki.com/wiki/Module:Protection_banner/#L-602)else[](https://freemwiki.com/wiki/Module:Protection_banner/#L-603)error('no protection level defined for protectionLevels.edit.default', 8)[](https://freemwiki.com/wiki/Module:Protection_banner/#L-604)end[](https://freemwiki.com/wiki/Module:Protection_banner/#L-605)return self:_substituteParameters(msg)[](https://freemwiki.com/wiki/Module:Protection_banner/#L-606)end[](https://freemwiki.com/wiki/Module:Protection_banner/#L-607)[](https://freemwiki.com/wiki/Module:Protection_banner/#L-608)function Blurb:_makeProtectionLogParameter()[](https://freemwiki.com/wiki/Module:Protection_banner/#L-609)local pagename = self._protectionObj.title.prefixedText[](https://freemwiki.com/wiki/Module:Protection_banner/#L-610)if self._protectionObj.action == 'autoreview' then[](https://freemwiki.com/wiki/Module:Protection_banner/#L-611)-- We need the pending changes log.[](https://freemwiki.com/wiki/Module:Protection_banner/#L-612)return makeFullUrl([](https://freemwiki.com/wiki/Module:Protection_banner/#L-613)'Special:Log',[](https://freemwiki.com/wiki/Module:Protection_banner/#L-614){type = 'stable', page = pagename},[](https://freemwiki.com/wiki/Module:Protection_banner/#L-615)self:_getExpandedMessage('pc-log-display')[](https://freemwiki.com/wiki/Module:Protection_banner/#L-616))[](https://freemwiki.com/wiki/Module:Protection_banner/#L-617)else[](https://freemwiki.com/wiki/Module:Protection_banner/#L-618)-- We need the protection log.[](https://freemwiki.com/wiki/Module:Protection_banner/#L-619)return makeFullUrl([](https://freemwiki.com/wiki/Module:Protection_banner/#L-620)'Special:Log',[](https://freemwiki.com/wiki/Module:Protection_banner/#L-621){type = 'protect', page = pagename},[](https://freemwiki.com/wiki/Module:Protection_banner/#L-622)self:_getExpandedMessage('protection-log-display')[](https://freemwiki.com/wiki/Module:Protection_banner/#L-623))[](https://freemwiki.com/wiki/Module:Protection_banner/#L-624)end[](https://freemwiki.com/wiki/Module:Protection_banner/#L-625)end[](https://freemwiki.com/wiki/Module:Protection_banner/#L-626)[](https://freemwiki.com/wiki/Module:Protection_banner/#L-627)function Blurb:_makeTalkPageParameter()[](https://freemwiki.com/wiki/Module:Protection_banner/#L-628)return string.format([](https://freemwiki.com/wiki/Module:Protection_banner/#L-629)'[[%s:%s#%s|%s]]',[](https://freemwiki.com/wiki/Module:Protection_banner/#L-630)mw.site.namespaces[self._protectionObj.title.namespace].talk.name,[](https://freemwiki.com/wiki/Module:Protection_banner/#L-631)self._protectionObj.title.text,[](https://freemwiki.com/wiki/Module:Protection_banner/#L-632)self._args.section or 'top',[](https://freemwiki.com/wiki/Module:Protection_banner/#L-633)self:_getExpandedMessage('talk-page-link-display')[](https://freemwiki.com/wiki/Module:Protection_banner/#L-634))[](https://freemwiki.com/wiki/Module:Protection_banner/#L-635)end[](https://freemwiki.com/wiki/Module:Protection_banner/#L-636)[](https://freemwiki.com/wiki/Module:Protection_banner/#L-637)function Blurb:_makeTooltipBlurbParameter()[](https://freemwiki.com/wiki/Module:Protection_banner/#L-638)if self._protectionObj:isTemporary() then[](https://freemwiki.com/wiki/Module:Protection_banner/#L-639)return self:_getExpandedMessage('tooltip-blurb-expiry')[](https://freemwiki.com/wiki/Module:Protection_banner/#L-640)else[](https://freemwiki.com/wiki/Module:Protection_banner/#L-641)return self:_getExpandedMessage('tooltip-blurb-noexpiry')[](https://freemwiki.com/wiki/Module:Protection_banner/#L-642)end[](https://freemwiki.com/wiki/Module:Protection_banner/#L-643)end[](https://freemwiki.com/wiki/Module:Protection_banner/#L-644)[](https://freemwiki.com/wiki/Module:Protection_banner/#L-645)function Blurb:_makeTooltipFragmentParameter()[](https://freemwiki.com/wiki/Module:Protection_banner/#L-646)if self._protectionObj:isTemporary() then[](https://freemwiki.com/wiki/Module:Protection_banner/#L-647)return self:_getExpandedMessage('tooltip-fragment-expiry')[](https://freemwiki.com/wiki/Module:Protection_banner/#L-648)else[](https://freemwiki.com/wiki/Module:Protection_banner/#L-649)return self:_getExpandedMessage('tooltip-fragment-noexpiry')[](https://freemwiki.com/wiki/Module:Protection_banner/#L-650)end[](https://freemwiki.com/wiki/Module:Protection_banner/#L-651)end[](https://freemwiki.com/wiki/Module:Protection_banner/#L-652)[](https://freemwiki.com/wiki/Module:Protection_banner/#L-653)function Blurb:_makeVandalTemplateParameter()[](https://freemwiki.com/wiki/Module:Protection_banner/#L-654)return mw.getCurrentFrame():expandTemplate{[](https://freemwiki.com/wiki/Module:Protection_banner/#L-655)title="vandal-m",[](https://freemwiki.com/wiki/Module:Protection_banner/#L-656)args={self._args.user or self._protectionObj.title.baseText}[](https://freemwiki.com/wiki/Module:Protection_banner/#L-657)}[](https://freemwiki.com/wiki/Module:Protection_banner/#L-658)end[](https://freemwiki.com/wiki/Module:Protection_banner/#L-659)[](https://freemwiki.com/wiki/Module:Protection_banner/#L-660)-- Public methods --[](https://freemwiki.com/wiki/Module:Protection_banner/#L-661)[](https://freemwiki.com/wiki/Module:Protection_banner/#L-662)function Blurb:makeBannerText(key)[](https://freemwiki.com/wiki/Module:Protection_banner/#L-663)-- Validate input.[](https://freemwiki.com/wiki/Module:Protection_banner/#L-664)if not key or not Blurb.bannerTextFields[key] then[](https://freemwiki.com/wiki/Module:Protection_banner/#L-665)error(string.format([](https://freemwiki.com/wiki/Module:Protection_banner/#L-666)'"%s" is not a valid banner config field',[](https://freemwiki.com/wiki/Module:Protection_banner/#L-667)tostring(key)[](https://freemwiki.com/wiki/Module:Protection_banner/#L-668)), 2)[](https://freemwiki.com/wiki/Module:Protection_banner/#L-669)end[](https://freemwiki.com/wiki/Module:Protection_banner/#L-670)[](https://freemwiki.com/wiki/Module:Protection_banner/#L-671)-- Generate the text.[](https://freemwiki.com/wiki/Module:Protection_banner/#L-672)local msg = self._protectionObj.bannerConfig[key][](https://freemwiki.com/wiki/Module:Protection_banner/#L-673)if type(msg) == 'string' then[](https://freemwiki.com/wiki/Module:Protection_banner/#L-674)return self:_substituteParameters(msg)[](https://freemwiki.com/wiki/Module:Protection_banner/#L-675)elseif type(msg) == 'function' then[](https://freemwiki.com/wiki/Module:Protection_banner/#L-676)msg = msg(self._protectionObj, self._args)[](https://freemwiki.com/wiki/Module:Protection_banner/#L-677)if type(msg) ~= 'string' then[](https://freemwiki.com/wiki/Module:Protection_banner/#L-678)error(string.format([](https://freemwiki.com/wiki/Module:Protection_banner/#L-679)'bad output from banner config function with key "%s"'[](https://freemwiki.com/wiki/Module:Protection_banner/#L-680).. ' (expected string, got %s)',[](https://freemwiki.com/wiki/Module:Protection_banner/#L-681)tostring(key),[](https://freemwiki.com/wiki/Module:Protection_banner/#L-682)type(msg)[](https://freemwiki.com/wiki/Module:Protection_banner/#L-683)), 4)[](https://freemwiki.com/wiki/Module:Protection_banner/#L-684)end[](https://freemwiki.com/wiki/Module:Protection_banner/#L-685)return self:_substituteParameters(msg)[](https://freemwiki.com/wiki/Module:Protection_banner/#L-686)end[](https://freemwiki.com/wiki/Module:Protection_banner/#L-687)end[](https://freemwiki.com/wiki/Module:Protection_banner/#L-688)[](https://freemwiki.com/wiki/Module:Protection_banner/#L-689)--------------------------------------------------------------------------------[](https://freemwiki.com/wiki/Module:Protection_banner/#L-690)-- BannerTemplate class[](https://freemwiki.com/wiki/Module:Protection_banner/#L-691)--------------------------------------------------------------------------------[](https://freemwiki.com/wiki/Module:Protection_banner/#L-692)[](https://freemwiki.com/wiki/Module:Protection_banner/#L-693)local BannerTemplate = {}[](https://freemwiki.com/wiki/Module:Protection_banner/#L-694)BannerTemplate.__index = BannerTemplate[](https://freemwiki.com/wiki/Module:Protection_banner/#L-695)[](https://freemwiki.com/wiki/Module:Protection_banner/#L-696)function BannerTemplate.new(protectionObj, cfg)[](https://freemwiki.com/wiki/Module:Protection_banner/#L-697)local obj = {}[](https://freemwiki.com/wiki/Module:Protection_banner/#L-698)obj._cfg = cfg[](https://freemwiki.com/wiki/Module:Protection_banner/#L-699)[](https://freemwiki.com/wiki/Module:Protection_banner/#L-700)-- Set the image filename.[](https://freemwiki.com/wiki/Module:Protection_banner/#L-701)local imageFilename = protectionObj.bannerConfig.image[](https://freemwiki.com/wiki/Module:Protection_banner/#L-702)if imageFilename then[](https://freemwiki.com/wiki/Module:Protection_banner/#L-703)obj._imageFilename = imageFilename[](https://freemwiki.com/wiki/Module:Protection_banner/#L-704)else[](https://freemwiki.com/wiki/Module:Protection_banner/#L-705)-- If an image filename isn't specified explicitly in the banner config,[](https://freemwiki.com/wiki/Module:Protection_banner/#L-706)-- generate it from the protection status and the namespace.[](https://freemwiki.com/wiki/Module:Protection_banner/#L-707)local action = protectionObj.action[](https://freemwiki.com/wiki/Module:Protection_banner/#L-708)local level = protectionObj.level[](https://freemwiki.com/wiki/Module:Protection_banner/#L-709)local namespace = protectionObj.title.namespace[](https://freemwiki.com/wiki/Module:Protection_banner/#L-710)local reason = protectionObj.reason[](https://freemwiki.com/wiki/Module:Protection_banner/#L-711)[](https://freemwiki.com/wiki/Module:Protection_banner/#L-712)-- Deal with special cases first.[](https://freemwiki.com/wiki/Module:Protection_banner/#L-713)if ([](https://freemwiki.com/wiki/Module:Protection_banner/#L-714)namespace == 10[](https://freemwiki.com/wiki/Module:Protection_banner/#L-715)or namespace == 828[](https://freemwiki.com/wiki/Module:Protection_banner/#L-716)or reason and obj._cfg.indefImageReasons[reason][](https://freemwiki.com/wiki/Module:Protection_banner/#L-717))[](https://freemwiki.com/wiki/Module:Protection_banner/#L-718)and action == 'edit'[](https://freemwiki.com/wiki/Module:Protection_banner/#L-719)and level == 'sysop'[](https://freemwiki.com/wiki/Module:Protection_banner/#L-720)and not protectionObj:isTemporary()[](https://freemwiki.com/wiki/Module:Protection_banner/#L-721)then[](https://freemwiki.com/wiki/Module:Protection_banner/#L-722)-- Fully protected modules and templates get the special red "indef"[](https://freemwiki.com/wiki/Module:Protection_banner/#L-723)-- padlock.[](https://freemwiki.com/wiki/Module:Protection_banner/#L-724)obj._imageFilename = obj._cfg.msg['image-filename-indef'][](https://freemwiki.com/wiki/Module:Protection_banner/#L-725)else[](https://freemwiki.com/wiki/Module:Protection_banner/#L-726)-- Deal with regular protection types.[](https://freemwiki.com/wiki/Module:Protection_banner/#L-727)local images = obj._cfg.images[](https://freemwiki.com/wiki/Module:Protection_banner/#L-728)if images[action] then[](https://freemwiki.com/wiki/Module:Protection_banner/#L-729)if images[action][level] then[](https://freemwiki.com/wiki/Module:Protection_banner/#L-730)obj._imageFilename = images[action][level][](https://freemwiki.com/wiki/Module:Protection_banner/#L-731)elseif images[action].default then[](https://freemwiki.com/wiki/Module:Protection_banner/#L-732)obj._imageFilename = images[action].default[](https://freemwiki.com/wiki/Module:Protection_banner/#L-733)end[](https://freemwiki.com/wiki/Module:Protection_banner/#L-734)end[](https://freemwiki.com/wiki/Module:Protection_banner/#L-735)end[](https://freemwiki.com/wiki/Module:Protection_banner/#L-736)end[](https://freemwiki.com/wiki/Module:Protection_banner/#L-737)return setmetatable(obj, BannerTemplate)[](https://freemwiki.com/wiki/Module:Protection_banner/#L-738)end[](https://freemwiki.com/wiki/Module:Protection_banner/#L-739)[](https://freemwiki.com/wiki/Module:Protection_banner/#L-740)function BannerTemplate:renderImage()[](https://freemwiki.com/wiki/Module:Protection_banner/#L-741)local filename = self._imageFilename[](https://freemwiki.com/wiki/Module:Protection_banner/#L-742)or self._cfg.msg['image-filename-default'][](https://freemwiki.com/wiki/Module:Protection_banner/#L-743)or 'Transparent.gif'[](https://freemwiki.com/wiki/Module:Protection_banner/#L-744)return makeFileLink{[](https://freemwiki.com/wiki/Module:Protection_banner/#L-745)file = filename,[](https://freemwiki.com/wiki/Module:Protection_banner/#L-746)size = (self.imageWidth or 20) .. 'px',[](https://freemwiki.com/wiki/Module:Protection_banner/#L-747)alt = self._imageAlt,[](https://freemwiki.com/wiki/Module:Protection_banner/#L-748)link = self._imageLink,[](https://freemwiki.com/wiki/Module:Protection_banner/#L-749)caption = self.imageCaption[](https://freemwiki.com/wiki/Module:Protection_banner/#L-750)}[](https://freemwiki.com/wiki/Module:Protection_banner/#L-751)end[](https://freemwiki.com/wiki/Module:Protection_banner/#L-752)[](https://freemwiki.com/wiki/Module:Protection_banner/#L-753)--------------------------------------------------------------------------------[](https://freemwiki.com/wiki/Module:Protection_banner/#L-754)-- Banner class[](https://freemwiki.com/wiki/Module:Protection_banner/#L-755)--------------------------------------------------------------------------------[](https://freemwiki.com/wiki/Module:Protection_banner/#L-756)[](https://freemwiki.com/wiki/Module:Protection_banner/#L-757)local Banner = setmetatable({}, BannerTemplate)[](https://freemwiki.com/wiki/Module:Protection_banner/#L-758)Banner.__index = Banner[](https://freemwiki.com/wiki/Module:Protection_banner/#L-759)[](https://freemwiki.com/wiki/Module:Protection_banner/#L-760)function Banner.new(protectionObj, blurbObj, cfg)[](https://freemwiki.com/wiki/Module:Protection_banner/#L-761)local obj = BannerTemplate.new(protectionObj, cfg) -- This doesn't need the blurb.[](https://freemwiki.com/wiki/Module:Protection_banner/#L-762)obj.imageWidth = 40[](https://freemwiki.com/wiki/Module:Protection_banner/#L-763)obj.imageCaption = blurbObj:makeBannerText('alt') -- Large banners use the alt text for the tooltip.[](https://freemwiki.com/wiki/Module:Protection_banner/#L-764)obj._reasonText = blurbObj:makeBannerText('text')[](https://freemwiki.com/wiki/Module:Protection_banner/#L-765)obj._explanationText = blurbObj:makeBannerText('explanation')[](https://freemwiki.com/wiki/Module:Protection_banner/#L-766)obj._page = protectionObj.title.prefixedText -- Only makes a difference in testing.[](https://freemwiki.com/wiki/Module:Protection_banner/#L-767)return setmetatable(obj, Banner)[](https://freemwiki.com/wiki/Module:Protection_banner/#L-768)end[](https://freemwiki.com/wiki/Module:Protection_banner/#L-769)[](https://freemwiki.com/wiki/Module:Protection_banner/#L-770)function Banner:__tostring()[](https://freemwiki.com/wiki/Module:Protection_banner/#L-771)-- Renders the banner.[](https://freemwiki.com/wiki/Module:Protection_banner/#L-772)makeMessageBox = makeMessageBox or require(['Module:Message box'](https://freemwiki.com/wiki/Module:Message_box)).main[](https://freemwiki.com/wiki/Module:Protection_banner/#L-773)local reasonText = self._reasonText or error('no reason text set', 2)[](https://freemwiki.com/wiki/Module:Protection_banner/#L-774)local explanationText = self._explanationText[](https://freemwiki.com/wiki/Module:Protection_banner/#L-775)local mbargs = {[](https://freemwiki.com/wiki/Module:Protection_banner/#L-776)page = self._page,[](https://freemwiki.com/wiki/Module:Protection_banner/#L-777)type = 'protection',[](https://freemwiki.com/wiki/Module:Protection_banner/#L-778)image = self:renderImage(),[](https://freemwiki.com/wiki/Module:Protection_banner/#L-779)text = string.format([](https://freemwiki.com/wiki/Module:Protection_banner/#L-780)"'''%s'''%s",[](https://freemwiki.com/wiki/Module:Protection_banner/#L-781)reasonText,[](https://freemwiki.com/wiki/Module:Protection_banner/#L-782)explanationText and '
' .. explanationText or ''[](https://freemwiki.com/wiki/Module:Protection_banner/#L-783))[](https://freemwiki.com/wiki/Module:Protection_banner/#L-784)}[](https://freemwiki.com/wiki/Module:Protection_banner/#L-785)return makeMessageBox('mbox', mbargs)[](https://freemwiki.com/wiki/Module:Protection_banner/#L-786)end[](https://freemwiki.com/wiki/Module:Protection_banner/#L-787)[](https://freemwiki.com/wiki/Module:Protection_banner/#L-788)--------------------------------------------------------------------------------[](https://freemwiki.com/wiki/Module:Protection_banner/#L-789)-- Padlock class[](https://freemwiki.com/wiki/Module:Protection_banner/#L-790)--------------------------------------------------------------------------------[](https://freemwiki.com/wiki/Module:Protection_banner/#L-791)[](https://freemwiki.com/wiki/Module:Protection_banner/#L-792)local Padlock = setmetatable({}, BannerTemplate)[](https://freemwiki.com/wiki/Module:Protection_banner/#L-793)Padlock.__index = Padlock[](https://freemwiki.com/wiki/Module:Protection_banner/#L-794)[](https://freemwiki.com/wiki/Module:Protection_banner/#L-795)function Padlock.new(protectionObj, blurbObj, cfg)[](https://freemwiki.com/wiki/Module:Protection_banner/#L-796)local obj = BannerTemplate.new(protectionObj, cfg) -- This doesn't need the blurb.[](https://freemwiki.com/wiki/Module:Protection_banner/#L-797)obj.imageWidth = 20[](https://freemwiki.com/wiki/Module:Protection_banner/#L-798)obj.imageCaption = blurbObj:makeBannerText('tooltip')[](https://freemwiki.com/wiki/Module:Protection_banner/#L-799)obj._imageAlt = blurbObj:makeBannerText('alt')[](https://freemwiki.com/wiki/Module:Protection_banner/#L-800)obj._imageLink = blurbObj:makeBannerText('link')[](https://freemwiki.com/wiki/Module:Protection_banner/#L-801)obj._indicatorName = cfg.padlockIndicatorNames[protectionObj.action][](https://freemwiki.com/wiki/Module:Protection_banner/#L-802)or cfg.padlockIndicatorNames.default[](https://freemwiki.com/wiki/Module:Protection_banner/#L-803)or 'pp-default'[](https://freemwiki.com/wiki/Module:Protection_banner/#L-804)return setmetatable(obj, Padlock)[](https://freemwiki.com/wiki/Module:Protection_banner/#L-805)end[](https://freemwiki.com/wiki/Module:Protection_banner/#L-806)[](https://freemwiki.com/wiki/Module:Protection_banner/#L-807)function Padlock:__tostring()[](https://freemwiki.com/wiki/Module:Protection_banner/#L-808)local frame = mw.getCurrentFrame()[](https://freemwiki.com/wiki/Module:Protection_banner/#L-809)-- The nowiki tag helps prevent whitespace at the top of articles.[](https://freemwiki.com/wiki/Module:Protection_banner/#L-810)return frame:extensionTag{name = 'nowiki'} .. frame:extensionTag{[](https://freemwiki.com/wiki/Module:Protection_banner/#L-811)name = 'indicator',[](https://freemwiki.com/wiki/Module:Protection_banner/#L-812)args = {name = self._indicatorName},[](https://freemwiki.com/wiki/Module:Protection_banner/#L-813)content = self:renderImage()[](https://freemwiki.com/wiki/Module:Protection_banner/#L-814)}[](https://freemwiki.com/wiki/Module:Protection_banner/#L-815)end[](https://freemwiki.com/wiki/Module:Protection_banner/#L-816)[](https://freemwiki.com/wiki/Module:Protection_banner/#L-817)--------------------------------------------------------------------------------[](https://freemwiki.com/wiki/Module:Protection_banner/#L-818)-- Exports[](https://freemwiki.com/wiki/Module:Protection_banner/#L-819)--------------------------------------------------------------------------------[](https://freemwiki.com/wiki/Module:Protection_banner/#L-820)[](https://freemwiki.com/wiki/Module:Protection_banner/#L-821)local p = {}[](https://freemwiki.com/wiki/Module:Protection_banner/#L-822)[](https://freemwiki.com/wiki/Module:Protection_banner/#L-823)function p._exportClasses()[](https://freemwiki.com/wiki/Module:Protection_banner/#L-824)-- This is used for testing purposes.[](https://freemwiki.com/wiki/Module:Protection_banner/#L-825)return {[](https://freemwiki.com/wiki/Module:Protection_banner/#L-826)Protection = Protection,[](https://freemwiki.com/wiki/Module:Protection_banner/#L-827)Blurb = Blurb,[](https://freemwiki.com/wiki/Module:Protection_banner/#L-828)BannerTemplate = BannerTemplate,[](https://freemwiki.com/wiki/Module:Protection_banner/#L-829)Banner = Banner,[](https://freemwiki.com/wiki/Module:Protection_banner/#L-830)Padlock = Padlock,[](https://freemwiki.com/wiki/Module:Protection_banner/#L-831)}[](https://freemwiki.com/wiki/Module:Protection_banner/#L-832)end[](https://freemwiki.com/wiki/Module:Protection_banner/#L-833)[](https://freemwiki.com/wiki/Module:Protection_banner/#L-834)function p._main(args, cfg, title)[](https://freemwiki.com/wiki/Module:Protection_banner/#L-835)args = args or {}[](https://freemwiki.com/wiki/Module:Protection_banner/#L-836)cfg = cfg or require(CONFIG_MODULE)[](https://freemwiki.com/wiki/Module:Protection_banner/#L-837)[](https://freemwiki.com/wiki/Module:Protection_banner/#L-838)local protectionObj = Protection.new(args, cfg, title)[](https://freemwiki.com/wiki/Module:Protection_banner/#L-839)[](https://freemwiki.com/wiki/Module:Protection_banner/#L-840)local ret = {}[](https://freemwiki.com/wiki/Module:Protection_banner/#L-841)[](https://freemwiki.com/wiki/Module:Protection_banner/#L-842)-- If a page's edit protection is equally or more restrictive than its[](https://freemwiki.com/wiki/Module:Protection_banner/#L-843)-- protection from some other action, then don't bother displaying anything[](https://freemwiki.com/wiki/Module:Protection_banner/#L-844)-- for the other action (except categories).[](https://freemwiki.com/wiki/Module:Protection_banner/#L-845)if not yesno(args.catonly) and (protectionObj.action == 'edit' or[](https://freemwiki.com/wiki/Module:Protection_banner/#L-846)args.demolevel or[](https://freemwiki.com/wiki/Module:Protection_banner/#L-847)not getReachableNodes([](https://freemwiki.com/wiki/Module:Protection_banner/#L-848)cfg.hierarchy,[](https://freemwiki.com/wiki/Module:Protection_banner/#L-849)protectionObj.level[](https://freemwiki.com/wiki/Module:Protection_banner/#L-850))[effectiveProtectionLevel('edit', protectionObj.title)])[](https://freemwiki.com/wiki/Module:Protection_banner/#L-851)then[](https://freemwiki.com/wiki/Module:Protection_banner/#L-852)-- Initialise the blurb object[](https://freemwiki.com/wiki/Module:Protection_banner/#L-853)local blurbObj = Blurb.new(protectionObj, args, cfg)[](https://freemwiki.com/wiki/Module:Protection_banner/#L-854)[](https://freemwiki.com/wiki/Module:Protection_banner/#L-855)-- Render the banner[](https://freemwiki.com/wiki/Module:Protection_banner/#L-856)if protectionObj:shouldShowLock() then[](https://freemwiki.com/wiki/Module:Protection_banner/#L-857)ret[#ret + 1] = tostring([](https://freemwiki.com/wiki/Module:Protection_banner/#L-858)(yesno(args.small) and Padlock or Banner)[](https://freemwiki.com/wiki/Module:Protection_banner/#L-859).new(protectionObj, blurbObj, cfg)[](https://freemwiki.com/wiki/Module:Protection_banner/#L-860))[](https://freemwiki.com/wiki/Module:Protection_banner/#L-861)end[](https://freemwiki.com/wiki/Module:Protection_banner/#L-862)end[](https://freemwiki.com/wiki/Module:Protection_banner/#L-863)[](https://freemwiki.com/wiki/Module:Protection_banner/#L-864)-- Render the categories[](https://freemwiki.com/wiki/Module:Protection_banner/#L-865)if yesno(args.category) ~= false then[](https://freemwiki.com/wiki/Module:Protection_banner/#L-866)ret[#ret + 1] = protectionObj:makeCategoryLinks()[](https://freemwiki.com/wiki/Module:Protection_banner/#L-867)end[](https://freemwiki.com/wiki/Module:Protection_banner/#L-868)[](https://freemwiki.com/wiki/Module:Protection_banner/#L-869)-- For arbitration enforcement, flagging [[[WP:PIA]]](https://freemwiki.com/wiki/WP:PIA "WP:PIA") pages to enable [[[Special:AbuseFilter/1339]]](https://freemwiki.com/wiki/Special:AbuseFilter/1339 "Special:AbuseFilter/1339") to flag edits to them[](https://freemwiki.com/wiki/Module:Protection_banner/#L-870)if protectionObj.level == "extendedconfirmed" then[](https://freemwiki.com/wiki/Module:Protection_banner/#L-871)if require(["Module:TableTools"](https://freemwiki.com/wiki/Module:TableTools)).inArray(protectionObj.title.talkPageTitle.categories, "Wikipedia pages subject to the extended confirmed restriction related to the Arab-Israeli conflict") then[](https://freemwiki.com/wiki/Module:Protection_banner/#L-872)ret[#ret + 1] = "