Anonymous user
Module:Protection banner: Difference between revisions
add some more to the banner.new function
(start converting this to an object-oriented approach - the banner seems naturally suited to object-based code) |
(add some more to the banner.new function) |
||
Line 5:
local mArguments = require('Module:Arguments')
local mProtectionLevel = require('Module:Effective protection level')._main
local yesno = require('Module:Yesno')
local mMessageBox -- only needs to be loaded if we are outputting a banner, so lazily initialise
Line 235 ⟶ 236:
obj.protectionLevel = protectionLevel or '*'
end
-- Fetch the banner data and copy it into the object.
-- This could be problematic if the data table and the banner object have
obj.reason = args.reason▼
-- any duplicate keys, so check for those.
do
and cfg.banners[obj.action]▼
local data
then▼
obj.data = cfg.defaultBanners[obj.action]▼
elseif cfg.defaultBanners and cfg.defaultBanners.edit then▼
else▼
error('no banner data found; please define data for cfg.defaultBanners')
end▼
local usedFields = {}
for k in pairs(banner) do
usedFields[k] = true
end
for k in pairs(obj) do
usedFields[k] = true
end
for k, v in pairs(data) do
if usedFields[k] then
error('banner.new: duplicate config key "' .. tostring(k) .. '" detected')
else
obj[k] = v
end
end
end
return obj
end
Line 323 ⟶ 342:
}
return mMessageBox.main('mbox', mbargs)
end
function banner:export()
-- Add the banner/padlock, protection category, and tracking categories.▼
local ret = ''▼
return ret▼
end
Line 334 ⟶ 362:
local args = mArguments.getArgs(frame)
return p._main(args)
▲end
▲ -- Add the banner/padlock, protection category, and tracking categories.
▲ local ret = ''
▲ ret = ret .. p.renderBannerOrPadlock(action, protectionLevel, args)
▲ ret = ret .. p.renderProtectionCategory(action, protectionLevel, args)
▲ ret = ret .. p.renderTrackingCategories(action, protectionLevel, args)
▲ return ret
end
|