差分
ナビゲーションに移動
検索に移動
細
「モジュール:Protection banner」を保護しました: Wikipedia:保護依頼による: Wikipedia:保護の方針#半永久的な保護「影響が特に大きいテンプレート」 ([編集=管理者のみ許可] (無期限) [移動=管理者のみ許可] (無期限))
13行目:
13行目:
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'
− )
−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
+
− local cfg = self._cfg
− local title = self.title
+
+
-- Set constants.
-- Set constants.
−local CONFIG_MODULE = 'Module:Protection banner/config'
+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: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
− -- 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:shouldHaveProtectionCategory()
+ 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
)
)
700行目:
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,
853行目:
854行目:
-- 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)