Anonymous user
Module:Protection banner: Difference between revisions
allow individual banner config items to fall back to the same value in the defaults table, and add functions for making the blurb values
Enwikipedia>Mr. Stradivarius (use gsub instead of the mw.message library for substituting parameters, as mw.message:params doesn't work with metatables; also, a few bug fixes) |
Enwikipedia>Mr. Stradivarius (allow individual banner config items to fall back to the same value in the defaults table, and add functions for making the blurb values) |
||
Line 79:
self._cfg = data.cfg
self._msg = data.msg
self._bannerConfigTables = {}
end
Line 85 ⟶ 86:
local action = protectionStatusObj:getAction()
local reason = protectionStatusObj:getReason()
if cfg.banners[action][reason] then▼
if self._bannerConfigTables[protectionStatusObj] then
return self._bannerConfigTables[protectionStatusObj]
else
local ret = {}
return cfg.defaultBanners[action]▼
local fields = {
'text',
'explanation',
'tooltip',
'alt',
'image',
'categoryOrder',
'categoryReason'
}
local configTables = {}
for i, field in ipairs(fields) do
for j, t in ipairs(configTables) do
if t[field] then
ret[field] = t[field]
break
end
end
end
self._bannerConfigTables[protectionStatusObj] = ret
return ret
end
end
Line 432 ⟶ 456:
function Blurb:makeReasonText()
local msg = self._bannerConfig.text
return self:_substituteParameters(msg)
end
function Blurb:makeExplanationText()
local msg = self._bannerConfig.explanation
return self:_substituteParameters(msg)
end
function Blurb:makeTooltipText()
local msg = self._bannerConfig.tooltip
return self:_substituteParameters(msg)
end
function Blurb:makeAltText()
local msg = self._bannerConfig.alt
return self:_substituteParameters(msg)
end
|