Open main menu

Changes

Module:Protection banner

757 bytes added, 10:36, 16 March 2014
add a p.renderImageLink function so that we can share image generation code between the padlock and the banner
end
function p.renderPadlockrenderImageLink(dataimage, size, link, text, alt)
--[[
-- Renders the image link wikitext All parameters are optional -- apart from the display text. -- -- @parameters: -- image - the image name -- size - the image size, as a number -- link - page linked to by the image -- text - the tooltip text -- alt - the alt text -- -- All parameters are optional apart from the text parameter. --]] image = image or 'Transparent.gif' size = size or 20 if link then link = '|link=' .. link else link = '' end text = text or error('No text parameter supplied to p.renderImageLink') if alt then alt = '|alt=' .. alt else alt = '' end return string.format('[[Image:%s|%dpx%s|%s%s]]', image, size, link, text, alt)end function p.renderPadlock(image, right) --[[ -- Renders the html of the padlock seen in the top-right-hand corner or protected pages, -- using the data provided in the data tableof protected pages.
--
-- Data fields@parameters: -- data.right -image - data.the imagewikitext -- data.iconLinkright - the "right" css property value, as a string -- data.iconText -- dataBoth parameters are optional.altText
--]]
local root = mw.html.create('div')
:addClass('metadata topicon nopopups')
:attr('id', 'protected-icon')
:css{display = 'none', right = data.right or '55px'} :wikitext(format( '[[Image:%s|20px|link=%s|%s|alt=%s]]', data.image, data.iconLink, data.iconText, data.altText ))
return tostring(root)
end
function p.renderBanner(datapage, image, text)
--[[
-- Renders the large protection banner placed at the top of articles,
-- using the data provided in the data table.
--
-- Data fields@parameters: -- data.page- demo page parameter to pass to {{mbox}} -- data.image- the image wikitext -- text - the text to display -- data -- All parameters are optional.text
--]]
mMessageBox = require('Module:Message box')
local mbargs = { -- arguments for the message box module
page = data.page,
type = 'protection',
image = data.image, text = data.text
}
return mMessageBox.main('mbox', mbargs)
Anonymous user