Module:Protection banner: Difference between revisions

make outline of the main function
en>Mr. Stradivarius
(new structure for the banners table)
en>Mr. Stradivarius
(make outline of the main function)
Line 175: Line 175:
}
}


--[[
cfg.errorCategories = {
-- Not currently used
local error_categories = {
incorrect = 'Wikipedia pages with incorrect protection templates',
incorrect = 'Wikipedia pages with incorrect protection templates',
no_expiry = 'Wikipedia protected pages without expiry',
noExpiry = 'Wikipedia protected pages without expiry',
create = 'Wikipedia pages tagged as create-protected',
create = 'Wikipedia pages tagged as create-protected',
template = 'Wikipedia template-protected pages other than templates and modules'
template = 'Wikipedia template-protected pages other than templates and modules'
}
}
--]]


--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
Line 215: Line 212:


function p._main(args)
function p._main(args)
local title
-- Get the protection level of the title we are working on.
if args.page then
local protectionLevel
title = mw.title.new(args.page)
do
else
local title
title = mw.title.getCurrentTitle()
if args.page then
title = mw.title.new(args.page)
else
title = mw.title.getCurrentTitle()
end
local protectionData = p.getProtectionData(title)
protectionLevel = protectionData[args.action or 'edit']
protectionLevel = protectionLevel or '*'
end
end
local protectionData = p.getProtectionData(title)
-- Generate the banner or padlock output.
local ret = ''
ret = ret .. p.renderBannerOrPadlock(protectionLevel, args)
-- Add protection category
if protectionLevel ~= '*' then
ret = ret .. p.renderProtectionCategory(protectionLevel, args)
end
-- Add tracking categories
ret = ret .. p.renderTrackingCategories(protectionLevel, args)
return ret
end
end


Anonymous user