Modul:Protection banner: Unterschied zwischen den Versionen
start converting the blurb class to the new parameter system
K (check the right action variable) |
(start converting the blurb class to the new parameter system) |
||
Zeile 39: | Zeile 39: | ||
'tooltip', | 'tooltip', | ||
'alt', | 'alt', | ||
'image | 'image' | ||
} | } | ||
local configTables = {} | local configTables = {} | ||
Zeile 51: | Zeile 49: | ||
configTables[#configTables + 1] = cfg.defaultBanners[action].default | configTables[#configTables + 1] = cfg.defaultBanners[action].default | ||
end | end | ||
configTables[#configTables + 1] = cfg.masterBanner | |||
for i, field in ipairs(fields) do | for i, field in ipairs(fields) do | ||
for j, t in ipairs(configTables) do | for j, t in ipairs(configTables) do | ||
Zeile 67: | Zeile 66: | ||
local blacklist = { | local blacklist = { | ||
banners = true, | banners = true, | ||
defaultBanners = true | defaultBanners = true, | ||
masterBanner = true | |||
} | } | ||
if not blacklist[key] then | if not blacklist[key] then | ||
Zeile 190: | Zeile 190: | ||
self._titleObj = titleObj | self._titleObj = titleObj | ||
end | end | ||
-- Static methods -- | |||
function Blurb.makeFullUrl(page, query, display) | function Blurb.makeFullUrl(page, query, display) | ||
Zeile 198: | Zeile 200: | ||
function Blurb.formatDate(num) | function Blurb.formatDate(num) | ||
-- Formats a Unix timestamp into dd | -- Formats a Unix timestamp into dd Month, YYYY format. | ||
lang = lang or mw.language.getContentLanguage() | lang = lang or mw.language.getContentLanguage() | ||
local success, date = pcall( | local success, date = pcall( | ||
Zeile 211: | Zeile 213: | ||
end | end | ||
-- Private methods -- | |||
function Blurb:_substituteParameters(msg) | function Blurb:_substituteParameters(msg) | ||
Zeile 237: | Zeile 229: | ||
end | end | ||
}) | }) | ||
parameterFuncs | parameterFuncs.CURRENTVERSION = self._makeCurrentVersionParameter | ||
parameterFuncs | parameterFuncs.DELETIONDISCUSSION = self._makeDeletionDiscussionParameter | ||
parameterFuncs | parameterFuncs.DISPUTESECTION = self._makeDisputesParameter | ||
parameterFuncs | parameterFuncs.EDITREQUEST = self._makeEditRequestParameter | ||
parameterFuncs | parameterFuncs.EXPIRY = self._makeExpiryParameter | ||
parameterFuncs | parameterFuncs.EXPLANATIONBLURB = self._makeExplanationBlurbParameter | ||
parameterFuncs | parameterFuncs.INTROBLURB = self._makeIntroBlurbParameter | ||
parameterFuncs | parameterFuncs.PAGETYPE = self._makePagetypeParameter | ||
parameterFuncs | parameterFuncs.PROTECTIONDATE = self._makeProtectionDateParameter | ||
parameterFuncs.PROTECTIONLEVEL = self._makeProtectionLevelParameter | |||
parameterFuncs | parameterFuncs.PROTECTIONLOG = self._makeProtectionLogParameter | ||
parameterFuncs.TALKPAGE = self._makeTalkPageParameter | |||
parameterFuncs | parameterFuncs.VANDAL = self._makeVandalTemplateParameter | ||
parameterFuncs | |||
parameterFuncs | |||
self._params = params | self._params = params | ||
end | end | ||
msg = msg:gsub('${(%u+)}', self._params) | |||
msg = msg:gsub('$( | |||
return msg | return msg | ||
end | end | ||
function Blurb: | function Blurb:_makeIntroBlurbParameter() | ||
-- parameter $1 | -- parameter $1 | ||
local key | local key | ||
Zeile 287: | Zeile 269: | ||
end | end | ||
function Blurb: | function Blurb:_makeDisputeSectionParameter() | ||
-- parameter $3 | -- parameter $3 | ||
-- "disputes", with or without a section link | -- "disputes", with or without a section link | ||
Zeile 379: | Zeile 350: | ||
end | end | ||
function Blurb: | function Blurb:_makeCurrentVersionParameter() | ||
-- parameter $9 | -- parameter $9 | ||
-- A link to the page history or the move log, depending on the kind of | -- A link to the page history or the move log, depending on the kind of | ||
Zeile 423: | Zeile 394: | ||
end | end | ||
function Blurb: | function Blurb:_makeTalkPageParameter() | ||
-- parameter $11 | -- parameter $11 | ||
local section = self._section | local section = self._section | ||
Zeile 513: | Zeile 484: | ||
end | end | ||
function Blurb: | function Blurb:_makeExplanationBlurbParameter() | ||
-- parameter $18 | -- parameter $18 | ||
local action = self._protectionStatusObj:getAction() | local action = self._protectionStatusObj:getAction() | ||
Zeile 529: | Zeile 500: | ||
local msg = self._configObj:getMessage(key) | local msg = self._configObj:getMessage(key) | ||
return self:_substituteParameters(msg) | return self:_substituteParameters(msg) | ||
end | |||
-- Public methods -- | |||
function Blurb:setDeletionDiscussionPage(page) | |||
self._deletionDiscussionPage = page | |||
end | |||
function Blurb:setUsername(username) | |||
self._username = username | |||
end | |||
function Blurb:setSection(section) | |||
self._section = section | |||
end | end | ||