Editing Module:Protection banner

Jump to: navigation, search

Warning: You are not logged in. Your IP address will be publicly visible if you make any edits. If you log in or create an account, your edits will be attributed to your username, along with other benefits.

The edit can be undone. Please check the comparison below to verify that this is what you want to do, and then save the changes below to finish undoing the edit.

This page is not enabled for semantic in-text annotations due to namespace restrictions. Details about how to enable the namespace can be found on the configuration help page.

Latest revision Your text
Line 3: Line 3:
  
 
-- Initialise necessary modules.
 
-- Initialise necessary modules.
--require('strict')
+
require('Module:No globals')
 
local makeFileLink = require('Module:File link')._main
 
local makeFileLink = require('Module:File link')._main
 
local effectiveProtectionLevel = require('Module:Effective protection level')._main
 
local effectiveProtectionLevel = require('Module:Effective protection level')._main
Line 169: Line 169:
 
end
 
end
 
return setmetatable(obj, Protection)
 
return setmetatable(obj, Protection)
end
 
 
function Protection:isUserScript()
 
-- Whether the page is a user JavaScript or CSS page.
 
local title = self.title
 
return title.namespace == 2 and (
 
title.contentModel == 'javascript' or title.contentModel == 'css'
 
)
 
 
end
 
end
  
Line 182: Line 174:
 
return self.level ~= '*'
 
return self.level ~= '*'
 
end
 
end
 
function Protection:shouldShowLock()
 
-- Whether we should output a banner/padlock
 
return self:isProtected() and not self:isUserScript()
 
end
 
 
-- Whether this page needs a protection category.
 
Protection.shouldHaveProtectionCategory = Protection.shouldShowLock
 
  
 
function Protection:isTemporary()
 
function Protection:isTemporary()
Line 196: Line 180:
  
 
function Protection:makeProtectionCategory()
 
function Protection:makeProtectionCategory()
if not self:shouldHaveProtectionCategory() then
+
local cfg = self._cfg
 +
local title = self.title
 +
 +
-- Exit if the page is not protected.
 +
if not self:isProtected() then
 
return ''
 
return ''
 
end
 
end
 
local cfg = self._cfg
 
local title = self.title
 
 
 
 
-- Get the expiry key fragment.
 
-- Get the expiry key fragment.
Line 216: Line 201:
 
namespaceFragment = 'talk'
 
namespaceFragment = 'talk'
 
end
 
end
 
+
 
-- Define the order that key fragments are tested in. This is done with an
 
-- 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
 
-- array of tables containing the value to be tested, along with its
Line 324: Line 309:
 
function Protection:isIncorrect()
 
function Protection:isIncorrect()
 
local expiry = self.expiry
 
local expiry = self.expiry
return not self:shouldHaveProtectionCategory()
+
return not self:isProtected()
 
or type(expiry) == 'number' and expiry < os.time()
 
or type(expiry) == 'number' and expiry < os.time()
 
end
 
end
Line 339: Line 324:
 
function Protection:makeCategoryLinks()
 
function Protection:makeCategoryLinks()
 
local msg = self._cfg.msg
 
local msg = self._cfg.msg
local ret = {self:makeProtectionCategory()}
+
local ret = { self:makeProtectionCategory() }
 
if self:isIncorrect() then
 
if self:isIncorrect() then
 
ret[#ret + 1] = makeCategoryLink(
 
ret[#ret + 1] = makeCategoryLink(
Line 652: Line 637:
  
 
function Blurb:_makeVandalTemplateParameter()
 
function Blurb:_makeVandalTemplateParameter()
return mw.getCurrentFrame():expandTemplate{
+
return require('Module:Vandal-m')._main{
title="vandal-m",
+
self._args.user or self._protectionObj.title.baseText
args={self._args.user or self._protectionObj.title.baseText}
 
 
}
 
}
 
end
 
end
Line 843: Line 827:
 
-- protection from some other action, then don't bother displaying anything
 
-- protection from some other action, then don't bother displaying anything
 
-- for the other action (except categories).
 
-- for the other action (except categories).
if not yesno(args.catonly) and (protectionObj.action == 'edit' or
+
if protectionObj.action == 'edit' or
 
args.demolevel or
 
args.demolevel or
 
not getReachableNodes(
 
not getReachableNodes(
 
cfg.hierarchy,
 
cfg.hierarchy,
 
protectionObj.level
 
protectionObj.level
)[effectiveProtectionLevel('edit', protectionObj.title)])
+
)[effectiveProtectionLevel('edit', protectionObj.title)]
 
then
 
then
 
-- Initialise the blurb object
 
-- Initialise the blurb object
Line 854: Line 838:
 
 
 
-- Render the banner
 
-- Render the banner
if protectionObj:shouldShowLock() then
+
if protectionObj:isProtected() then
 
ret[#ret + 1] = tostring(
 
ret[#ret + 1] = tostring(
 
(yesno(args.small) and Padlock or Banner)
 
(yesno(args.small) and Padlock or Banner)

Please note that all contributions to Yugipedia are considered to be released under the Creative Commons Attribution-ShareAlike 4.0 International License (see Yugipedia:Licensing for more details). If you do not want your writing to be edited mercilessly and redistributed at will, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource. Do not submit copyrighted work without permission!

Cancel Editing help (opens in new window)
Preview page with this template
Below are some commonly used wiki markup codes. Simply click on what you want to use and it will appear in the edit box above.

View this template