Jump to content
Main menu
Main menu
move to sidebar
hide
Navigation
Main page
Recent changes
Random page
Help about MediaWiki
Humanipedia
Search
Search
Appearance
Create account
Log in
Personal tools
Create account
Log in
Pages for logged out editors
learn more
Contributions
Talk
Editing
Module:Sandbox/Mr. Stradivarius/sandbox4
Module
Discussion
English
Read
Edit source
View history
Tools
Tools
move to sidebar
hide
Actions
Read
Edit source
View history
General
What links here
Related changes
Special pages
Page information
Appearance
move to sidebar
hide
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
-- This module implements {{pp-meta}}, a meta-template for protection templates. ---------------------------------------------------------------------- -- title object ---------------------------------------------------------------------- -- Get the title object for the current page and add data about protection level to it. -- We are only doing this for the current page, as this is all the {{PENDINGCHANGELEVEL}} -- magic word supports, as of November 2013. local title = {} function title.getCurrentTitle() local obj = mw.title.getCurrentTitle() local function getProtectionLevel(protectionType) -- Gets the protection level or pending change level of the current title. local frame = mw.getCurrentFrame() local level if protectionType == 'pc' then level = frame:preprocess('{{PENDINGCHANGELEVEL}}') else level = frame:callParserFunction('PROTECTIONLEVEL', protectionType) end if level == '' then -- Make unprotected pages return "unprotected" rather than the blank string. level = 'unprotected' end return level end obj.createProtection = getProtectionLevel('create') obj.editProtection = getProtectionLevel('edit') obj.moveProtection = getProtectionLevel('move') obj.pcProtection = getProtectionLevel('pc') return obj end ---------------------------------------------------------------------- -- icon class ---------------------------------------------------------------------- ---------------------------------------------------------------------- -- mbox class ---------------------------------------------------------------------- ---------------------------------------------------------------------- -- Process arguments and initialise objects ---------------------------------------------------------------------- local p = {} function p._main(args) local currentTitle = title.getCurrentTitle() return currentTitle[args[1]] end function p.main(frame) -- If called via #invoke, use the args passed into the invoking template, or the args passed to #invoke if any exist. -- Otherwise assume args are being passed directly in from the debug console or from another Lua module. local origArgs if frame == mw.getCurrentFrame() then origArgs = frame:getParent().args for k, v in pairs(frame.args) do origArgs = frame.args break end else origArgs = frame end -- Trim whitespace and remove blank arguments. local args = {} for k, v in pairs(origArgs) do if type(v) == 'string' then v = mw.text.trim(v) end if v ~= '' then args[k] = v end end return p._main(args) end return p
Summary:
Please note that all contributions to Humanipedia may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see
Humanipedia:Copyrights
for details).
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Template used on this page:
Module:Sandbox/Mr. Stradivarius/sandbox4/doc
(
edit
)