「モジュール:Protection banner」の版間の差分
ナビゲーションに移動
検索に移動
strict
bsd>WOSlinker (use require('strict') instead of require('Module:No globals')) |
bsd>ネイ (strict) |
||
13行目: | 13行目: | ||
-- Set constants. | -- Set constants. | ||
local CONFIG_MODULE = ' | local CONFIG_MODULE = 'モジュール:Protection banner/config' | ||
-------------------------------------------------------------------------------- | -------------------------------------------------------------------------------- | ||
169行目: | 169行目: | ||
end | end | ||
return setmetatable(obj, Protection) | return setmetatable(obj, Protection) | ||
end | end | ||
182行目: | 174行目: | ||
return self.level ~= '*' | return self.level ~= '*' | ||
end | end | ||
function Protection:isTemporary() | function Protection:isTemporary() | ||
196行目: | 180行目: | ||
function Protection:makeProtectionCategory() | function Protection:makeProtectionCategory() | ||
if not self: | local cfg = self._cfg | ||
local title = self.title | |||
-- Exit if the page is not protected. | |||
if not self:isProtected() then | |||
return '' | return '' | ||
end | end | ||
-- Get the expiry key fragment. | -- Get the expiry key fragment. | ||
216行目: | 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 | ||
324行目: | 309行目: | ||
function Protection:isIncorrect() | function Protection:isIncorrect() | ||
local expiry = self.expiry | local expiry = self.expiry | ||
return not self: | return not self:isProtected() | ||
or type(expiry) == 'number' and expiry < os.time() | or type(expiry) == 'number' and expiry < os.time() | ||
end | |||
-- 日本語版独自 | |||
function Protection:isMismatched() | |||
return self.reason == 'dispute' and self.level ~= 'sysop' | |||
end | end | ||
339行目: | 329行目: | ||
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( | ||
msg['tracking-category-incorrect'], | msg['tracking-category-incorrect'], | ||
self.title.text | |||
) | |||
elseif self:isMismatched() then | |||
ret[#ret + 1] = makeCategoryLink( | |||
msg['tracking-category-mismatch'], | |||
self.title.text | self.title.text | ||
) | ) | ||
652行目: | 647行目: | ||
function Blurb:_makeVandalTemplateParameter() | function Blurb:_makeVandalTemplateParameter() | ||
return | return require('Module:Vandal-m')._main{ | ||
self._args.user or self._protectionObj.title.baseText | |||
} | } | ||
end | end | ||
701行目: | 695行目: | ||
local imageFilename = protectionObj.bannerConfig.image | local imageFilename = protectionObj.bannerConfig.image | ||
if imageFilename then | if imageFilename then | ||
obj._imageFilename = imageFilename | |||
-- 日本語版独自の条件分岐 | |||
if type(imageFilename) == 'string' then | |||
obj._imageFilename = imageFilename | |||
elseif type(imageFilename) == 'function' then | |||
obj._imageFilename = imageFilename(protectionObj) | |||
end | |||
else | else | ||
-- If an image filename isn't specified explicitly in the banner config, | -- If an image filename isn't specified explicitly in the banner config, | ||
744行目: | 744行目: | ||
return makeFileLink{ | return makeFileLink{ | ||
file = filename, | file = filename, | ||
size = (self. | size = (self.imageSize or 'x20') .. 'px', -- 日本語版独自の変更 | ||
alt = self._imageAlt, | alt = self._imageAlt, | ||
link = self._imageLink, | link = self._imageLink, | ||
760行目: | 760行目: | ||
function Banner.new(protectionObj, blurbObj, cfg) | function Banner.new(protectionObj, blurbObj, cfg) | ||
local obj = BannerTemplate.new(protectionObj, cfg) -- This doesn't need the blurb. | local obj = BannerTemplate.new(protectionObj, cfg) -- This doesn't need the blurb. | ||
obj. | obj.imageSize = 40 -- 日本語版独自の変更: フィールド名 | ||
obj.imageCaption = blurbObj:makeBannerText('alt') -- Large banners use the alt text for the tooltip. | obj.imageCaption = blurbObj:makeBannerText('alt') -- Large banners use the alt text for the tooltip. | ||
obj._reasonText = blurbObj:makeBannerText('text') | obj._reasonText = blurbObj:makeBannerText('text') | ||
795行目: | 795行目: | ||
function Padlock.new(protectionObj, blurbObj, cfg) | function Padlock.new(protectionObj, blurbObj, cfg) | ||
local obj = BannerTemplate.new(protectionObj, cfg) -- This doesn't need the blurb. | local obj = BannerTemplate.new(protectionObj, cfg) -- This doesn't need the blurb. | ||
obj. | obj.imageSize = 'x20' -- 日本語版独自の変更: フィールド名、高さのみ指定 | ||
obj.imageCaption = blurbObj:makeBannerText('tooltip') | obj.imageCaption = blurbObj:makeBannerText('tooltip') | ||
obj._imageAlt = blurbObj:makeBannerText('alt') | obj._imageAlt = blurbObj:makeBannerText('alt') | ||
843行目: | 843行目: | ||
-- 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 | 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 | ||
854行目: | 854行目: | ||
-- Render the banner | -- Render the banner | ||
if protectionObj: | 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) |