Jump to content

Module:Documentation: Difference between revisions

internationalise the protection template code
m>Mr. Stradivarius
(internationalise the sandbox template notice call)
m>Mr. Stradivarius
(internationalise the protection template code)
Line 31: Line 31:
cfg.sandboxNoticeTemplate = 'template sandbox notice' -- The name of the template to display at the top of sandbox pages.
cfg.sandboxNoticeTemplate = 'template sandbox notice' -- The name of the template to display at the top of sandbox pages.
cfg.sandboxNoticeLivepageParam = 1 -- The parameter of the sandbox notice template to send the cfg.livepageArg to.
cfg.sandboxNoticeLivepageParam = 1 -- The parameter of the sandbox notice template to send the cfg.livepageArg to.
cfg.protectionTemplate = 'pp-template' -- The name of the template that displays the protection icon (a padlock on enwiki).
cfg.protectionTemplateArgs = {docusage = 'yes'} -- Any arguments to send to the protection template.


-- Display settings
-- Display settings
Line 148: Line 150:


function p.protectionTemplate()
function p.protectionTemplate()
if currentTitle.namespace == 10 then -- We are in the template namespace.
local protectionTemplate = cfg.protectionTemplate
local frame = mw.getCurrentFrame()
if not (protectionTemplate and currentTitle.namespace == 10) then
 
-- Don't display the protection template if we are not in the template namespace.
local function getProtectionLevel(protectionType)
return nil
-- Gets the protection level for the current page.
end
local level = frame:callParserFunction('PROTECTIONLEVEL', protectionType)
local frame = mw.getCurrentFrame()
if level ~= '' then
local function getProtectionLevel(protectionType)
return level
-- Gets the protection level for the current page.
else
local level = frame:callParserFunction('PROTECTIONLEVEL', protectionType)
return nil -- The parser function returns the blank string if there is no match.
if level ~= '' then
end
return level
end
else
 
return nil -- The parser function returns the blank string if there is no match.
if getProtectionLevel('move') == 'sysop' or getProtectionLevel('edit') then
-- The page is full-move protected, or full, template, or semi-protected.
return frame:expandTemplate{title = 'pp-template', args = {docusage = 'yes'}}
end
end
end
if getProtectionLevel('move') == 'sysop' or getProtectionLevel('edit') then
-- The page is full-move protected, or full, template, or semi-protected.
return frame:expandTemplate{title = protectionTemplate, args = cfg.protectionTemplateArgs}
end
end
return nil
return nil
Anonymous user
Cookies help us deliver our services. By using our services, you agree to our use of cookies.