Jump to content

Module:Effective protection level: Difference between revisions

let one function work for other modules and for wikitext
(add PC detection, from sandbox)
(let one function work for other modules and for wikitext)
Line 3: Line 3:
-- Returns the permission required to perform a given action on a given title.
-- Returns the permission required to perform a given action on a given title.
-- If no title is specified, the title of the page being displayed is used.
-- If no title is specified, the title of the page being displayed is used.
function p.main(action, pagename, frame)
function p.main(frame, action, pagename)
if not frame then
frame = frame or mw.getCurrentFrame()
frame = mw.getCurrentFrame()
action = action or frame.args.action or frame.args[1]
end
pagename = pagename or frame.args.pagename or frame.args[2]
local title
local title
if type(pagename) == 'table' then
if type(pagename) == 'table' then
Line 62: Line 62:
end
end
end
end
end
-- Make the protection function usable from wikitext rather than just other lua modules
function p.p(frame)
local args = frame.args
local pargs = frame:getParent().args
return p.main(args.action or args[1] or pargs.action or pargs[1], args.title or args[2] or pargs.title or pargs[2], frame)
end
end


return p
return p
Anonymous user
Cookies help us deliver our services. By using our services, you agree to our use of cookies.