Modul:Protection banner: Unterschied zwischen den Versionen
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
(remove the Image class from _exportClasses) |
(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) |
||
Zeile 76: | Zeile 76: | ||
function Config:initialize() | function Config:initialize() | ||
local data = mw.loadData('Module:Protection banner/config') | |||
self._cfg = data.cfg | |||
self._msg = data.msg | |||
end | end | ||
Zeile 103: | Zeile 105: | ||
function Config:getMessage(key) | function Config:getMessage(key) | ||
return self. | return self._msg[key] | ||
end | end | ||
Zeile 172: | Zeile 174: | ||
self._params = params | self._params = params | ||
end | end | ||
local function getParameter(match) | |||
match = tonumber(match) | |||
return self._params[match] | |||
end | |||
msg = msg:gsub('$([1-9][0-9]*)', getParameter) | |||
return msg | |||
end | end | ||
Zeile 224: | Zeile 233: | ||
function Blurb:_makePagetypeParameter() | function Blurb:_makePagetypeParameter() | ||
-- parameter $4 | -- parameter $4 | ||
local pagetypes = self._configObj:getConfigTable(' | local pagetypes = self._configObj:getConfigTable('bannerPagetypes') | ||
local namespace = self._titleObj | local namespace = self._titleObj.namespace | ||
return pagetypes[namespace] or pagetypes.default or 'page' | return pagetypes[namespace] or pagetypes.default or 'page' | ||
end | end | ||
Zeile 419: | Zeile 428: | ||
self._configObj:getMessage('deletion-log-link-display') | self._configObj:getMessage('deletion-log-link-display') | ||
) | ) | ||
end | |||
function Blurb:makeReasonText() | |||
local msg = self._bannerConfig.text | |||
return self:_substituteParameters(msg) | |||
end | end | ||