الفرق بين المراجعتين لصفحة: «وحدة:Protection banner»
use require('strict') instead of require('Module:No globals')
Mohsenmadani (نقاش | مساهمات) (أنشأ الصفحة ب'-- This module implements {{pp-meta}} and its daughter templates such as -- {{pp-dispute}}, {{pp-vandalism}} and {{pp-sock}}. -- Initialise necessary modules. require('...') |
ar>Wikivahdat (use require('strict') instead of require('Module:No globals')) |
||
سطر ٣: | سطر ٣: | ||
-- Initialise necessary modules. | -- Initialise necessary modules. | ||
require(' | require('strict') | ||
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 | ||
سطر ١٦٩: | سطر ١٦٩: | ||
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 | ||
سطر ١٧٤: | سطر ١٨٢: | ||
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() | ||
سطر ١٨٠: | سطر ١٩٦: | ||
function Protection:makeProtectionCategory() | function Protection:makeProtectionCategory() | ||
if not self:shouldHaveProtectionCategory() then | |||
return '' | |||
end | |||
local cfg = self._cfg | local cfg = self._cfg | ||
local title = self.title | local title = self.title | ||
-- Get the expiry key fragment. | -- Get the expiry key fragment. | ||
سطر ٢٠١: | سطر ٢١٦: | ||
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 | ||
سطر ٣٠٩: | سطر ٣٢٤: | ||
function Protection:isIncorrect() | function Protection:isIncorrect() | ||
local expiry = self.expiry | local expiry = self.expiry | ||
return not self: | return not self:shouldHaveProtectionCategory() | ||
or type(expiry) == 'number' and expiry < os.time() | or type(expiry) == 'number' and expiry < os.time() | ||
end | end | ||
سطر ٣٢٤: | سطر ٣٣٩: | ||
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( | ||
سطر ٦٣٧: | سطر ٦٥٢: | ||
function Blurb:_makeVandalTemplateParameter() | function Blurb:_makeVandalTemplateParameter() | ||
return | return mw.getCurrentFrame():expandTemplate{ | ||
self._args.user or self._protectionObj.title.baseText | title="vandal-m", | ||
args={self._args.user or self._protectionObj.title.baseText} | |||
} | } | ||
end | end | ||
سطر ٨٢٧: | سطر ٨٤٣: | ||
-- 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 protectionObj.action == 'edit' or | if not yesno(args.catonly) and (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 | ||
سطر ٨٣٨: | سطر ٨٥٤: | ||
-- Render the banner | -- Render the banner | ||
if protectionObj: | if protectionObj:shouldShowLock() then | ||
ret[#ret + 1] = tostring( | ret[#ret + 1] = tostring( | ||
(yesno(args.small) and Padlock or Banner) | (yesno(args.small) and Padlock or Banner) |