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'
'categoryOrder',
'categoryReason'
}
}
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 M, YYYY format.
-- 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


function Blurb:setDeletionDiscussionPage(page)
-- Private methods --
self._deletionDiscussionPage = page
end
 
function Blurb:setUsername(username)
self._username = username
end
 
function Blurb:setSection(section)
self._section = section
end


function Blurb:_substituteParameters(msg)
function Blurb:_substituteParameters(msg)
Zeile 237: Zeile 229:
end
end
})
})
 
parameterFuncs[1] = self._makeIntroParameter
parameterFuncs.CURRENTVERSION = self._makeCurrentVersionParameter
parameterFuncs[2] = self._makeUntilParameter
parameterFuncs.DELETIONDISCUSSION = self._makeDeletionDiscussionParameter
parameterFuncs[3] = self._makeDisputesParameter
parameterFuncs.DISPUTESECTION = self._makeDisputesParameter
parameterFuncs[4] = self._makePagetypeParameter
parameterFuncs.EDITREQUEST = self._makeEditRequestParameter
parameterFuncs[5] = self._makeProtectionDateParameter
parameterFuncs.EXPIRY = self._makeExpiryParameter
parameterFuncs[6] = self._makeVandalTemplateParameter
parameterFuncs.EXPLANATIONBLURB = self._makeExplanationBlurbParameter
parameterFuncs[7] = self._makeProtectionLevelParameter
parameterFuncs.INTROBLURB = self._makeIntroBlurbParameter
parameterFuncs[8] = self._makeExpiryParameter
parameterFuncs.PAGETYPE = self._makePagetypeParameter
parameterFuncs[9] = self._makeDisputeLinkParameter -- A link to the page history or the move log
parameterFuncs.PROTECTIONDATE = self._makeProtectionDateParameter
parameterFuncs[10] = self._makeProtectionLogParameter
parameterFuncs.PROTECTIONLEVEL = self._makeProtectionLevelParameter
parameterFuncs[11] = self._makeTalkLinkParameter
parameterFuncs.PROTECTIONLOG = self._makeProtectionLogParameter
parameterFuncs[12] = self._makeEditRequestParameter
parameterFuncs.TALKPAGE = self._makeTalkPageParameter
parameterFuncs[13] = self._makeRequestUnprotectionParameter
parameterFuncs.VANDAL = self._makeVandalTemplateParameter
parameterFuncs[14] = self._makeSubjectPageLinksParameter -- Adds links to edit requests and the talk page if we are on a subject page
parameterFuncs[15] = self._makeDeletionBlurbParameter
parameterFuncs[16] = self._makeDeletionDiscussionLinkParameter
parameterFuncs[17] = self._makeDeletionLogParameter
parameterFuncs[18] = self._makeExplanationTextParameter
self._params = params
self._params = params
end
end
 
local function getParameter(match)
msg = msg:gsub('${(%u+)}', self._params)
match = tonumber(match)
return self._params[match]
end
 
msg = msg:gsub('$([1-9][0-9]*)', getParameter)
return msg
return msg
end
end


function Blurb:_makeIntroParameter()
function Blurb:_makeIntroBlurbParameter()
-- parameter $1
-- parameter $1
local key
local key
Zeile 287: Zeile 269:
end
end


function Blurb:_makeUntilParameter()
function Blurb:_makeDisputeSectionParameter()
-- parameter $2
-- "until" or "or until" depending on the expiry
local expiry = self._protectionStatusObj:getExpiry()
if expiry then
return 'or until'
else
return 'until'
end
end
 
function Blurb:_makeDisputesParameter()
-- 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:_makeDisputeLinkParameter()
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:_makeTalkLinkParameter()
function Blurb:_makeTalkPageParameter()
-- parameter $11
-- parameter $11
local section = self._section
local section = self._section
Zeile 513: Zeile 484:
end
end


function Blurb:_makeExplanationTextParameter()
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


Anonymer Benutzer