Module:Documentation: Difference between revisions
Jump to navigation
Jump to search
Content added Content deleted
(add the equivalent of {{clear}} before the sandbox notice - this was in the old {{documentation}} template, but somehow didn't find its way into the module before) |
(use title.protectionLevels instead of {{PROTECTIONLEVEL}} in p.protectionTemplate) |
||
Line 170: | Line 170: | ||
-- |
-- |
||
-- Data includes: |
-- Data includes: |
||
-- env.protectionLevels - the protection levels table of the title object. |
|||
-- env.subjectSpace - the number of the title's subject namespace. |
-- env.subjectSpace - the number of the title's subject namespace. |
||
-- env.docSpace - the number of the namespace the title puts its documentation in. |
-- env.docSpace - the number of the namespace the title puts its documentation in. |
||
Line 269: | Line 270: | ||
--]] |
--]] |
||
return env.templateTitle:subPageTitle(message('print-subpage')) |
return env.templateTitle:subPageTitle(message('print-subpage')) |
||
⚫ | |||
function envFuncs.protectionLevels() |
|||
-- The protection levels table of the title object. |
|||
return env.title.protectionLevels |
|||
end |
end |
||
Line 393: | Line 399: | ||
-- 'protection-template-args' --> {docusage = 'yes'} |
-- 'protection-template-args' --> {docusage = 'yes'} |
||
local title = env.title |
local title = env.title |
||
local protectionLevels |
|||
local protectionTemplate = message('protection-template') |
local protectionTemplate = message('protection-template') |
||
local namespace = title.namespace |
local namespace = title.namespace |
||
Line 399: | Line 406: | ||
return nil |
return nil |
||
end |
end |
||
protectionLevels = env.protectionLevels |
|||
⚫ | |||
local editLevels = protectionLevels.edit |
|||
local function getProtectionLevel(protectionType, page) |
|||
local moveLevels = protectionLevels.move |
|||
-- Gets the protection level for page, or for the current page if page is not specified. |
|||
if moveLevels and moveLevels[1] == 'sysop' or editLevels and editLevels[1] then |
|||
local level = frame:callParserFunction('PROTECTIONLEVEL', protectionType, page) |
|||
if level ~= '' then |
|||
⚫ | |||
⚫ | |||
return nil -- The parser function returns the blank string if there is no match. |
|||
end |
|||
⚫ | |||
local prefixedTitle = title.prefixedText |
|||
if getProtectionLevel('move', prefixedTitle) == 'sysop' or getProtectionLevel('edit', prefixedTitle) then |
|||
-- The page is full-move protected, or full, template, or semi-protected. |
-- The page is full-move protected, or full, template, or semi-protected. |
||
⚫ | |||
return frame:expandTemplate{title = protectionTemplate, args = message('protection-template-args', nil, 'table')} |
return frame:expandTemplate{title = protectionTemplate, args = message('protection-template-args', nil, 'table')} |
||
⚫ | |||
⚫ | |||
end |
end |
||
return nil |
|||
end |
end |
||