Changes
no edit summary
-- This is a meta-module for producing message box templates, including
-- {{mbox}}, {{ambox}}, {{imbox}}, {{tmbox}}, {{ombox}}, {{cmbox}} and {{fmbox}}.
-- Require necessary modules.
local getArgs = require('Module:Arguments').getArgs
local categoryHandler = require('Module:Category handler').main
local yesno = require('Module:Yesno')
-- Load the configuration page.
local cfgTables = mw.loadData('Module:Message box/configuration')
-- Get a language object for formatDate and ucfirst.
local lang = mw.language.getContentLanguage()
-- Set aliases for often-used functions to reduce table lookups.
local format = mw.ustring.format
local tconcat = table.concat
local trim = mw.text.trim
--------------------------------------------------------------------------------
-- Helper functions
--------------------------------------------------------------------------------
local function getTitleObject(page, ...)
if type(page) == 'string' then
end
end
local function union(t1, t2)
-- Returns the union of two arrays.
return ret
end
local function getArgNums(args, prefix)
local nums = {}
return nums
end
--------------------------------------------------------------------------------
-- Box class definition
--------------------------------------------------------------------------------
local box = {}
box.__index = box
function box.new()
local obj = {}
return obj
end
function box.getNamespaceId(ns)
if not ns then return end
end
end
function box.getMboxType(nsid)
-- Gets the mbox type from a namespace number.
end
end
function box:addCat(ns, cat, sort)
if type(cat) ~= 'string' then return end
end
end
function box:addClass(class)
if type(class) ~= 'string' then return end
tinsert(self.classes, class)
end
function box:addAttr(attr, val)
if type(attr) ~= 'string' or type(val) ~= 'string' then return end
tinsert(self.attrs, attr)
end
function box:setTitle(args)
-- Get the title object and the namespace.
self.nsid = box.getNamespaceId(self.demospace) or self.title.namespace
end
function box:getConfig(boxType)
-- Get the box config data from the data page.
return cfg
end
function box:removeBlankArgs(cfg, args)
-- Only allow blank arguments for the parameter names listed in
return newArgs
end
function box:setBoxParameters(cfg, args)
-- Get type data.
self.typeClass = typeData.class
self.typeImage = typeData.image
-- Find if the box has been wrongly substituted.
if cfg.substCheck and args.subst == 'SUBST' then
self.isSubstituted = true
end
-- Find whether we are using a small message box.
if cfg.allowSmall and (
self.isSmall = false
end
-- Add attributes, classes and styles.
if cfg.allowId then
self.style = args.style
self.attrs = args.attrs
-- Set text style.
self.textstyle = args.textstyle
-- Find if we are on the template page or not. This functionality is only
-- used if useCollapsibleTextFields is set, or if both cfg.templateCategory
or false
end
-- Process data for collapsible text fields. At the moment these are only
-- used in {{ambox}}.
self.issue = tconcat(issues, ' ')
end
-- Get the self.talk value.
local talk = args.talk
end
end
-- Get other values.
self.fix = args.fix ~= '' and args.fix or nil
self.info = args.info
end
-- Set the non-collapsible text field. At the moment this is used by all box
-- types other than ambox, and also by ambox when small=yes.
self.text = args.text
end
-- Set the below row.
self.below = cfg.below and args.below
-- General image settings.
self.imageCellDiv = not self.isSmall and cfg.imageCellDiv and true or false
self.imageEmptyCellStyle = 'border:none;padding:0px;width:1px'
end
-- Left image settings.
local imageLeft = self.isSmall and args.smallimage or args.image
end
end
-- Right image settings.
local imageRight = self.isSmall and args.smallimageright or args.imageright
self.imageRight = imageRight
end
-- Add mainspace categories. At the moment these are only used in {{ambox}}.
if cfg.allowMainspaceCategories then
end
end
-- Add template-namespace categories.
if cfg.templateCategory then
end
end
-- Add template error category.
if cfg.templateErrorCategory then
self:addCat('template', templateCat, templateSort)
end
-- Categories for all namespaces.
if self.invalidTypeError then
self:addCat('all', 'Pages with incorrectly substituted templates')
end
-- Convert category tables to strings and pass them through
-- [[Module:Category handler]].
}
end
function box:export()
local root = htmlBuilder.create()
-- Add the subst check error.
if self.isSubstituted and self.name then
))
end
-- Create the box table.
local boxTable = root.tag('table')
.attr(attr, val)
end
-- Add the left-hand image.
local row = boxTable.tag('tr')
.cssText(self.imageEmptyCellStyle)
end
-- Add the text.
local textCell = row.tag('td').addClass('mbox-text')
.wikitext(self.text)
end
-- Add the right-hand image.
if self.imageRight then
.wikitext(self.imageRight)
end
-- Add the below row.
if self.below then
.wikitext(self.below)
end
-- Add error message for invalid type parameters.
if self.invalidTypeError then
))
end
-- Add categories.
root
.wikitext(self.categories)
return tostring(root)
end
local function main(boxType, args)
local outputBox = box.new()
return outputBox:export()
end
local function makeWrapper(boxType)
return function (frame)
end
end
local p = {
main = main,
mbox = makeWrapper('mbox')
}
for boxType in pairs(cfgTables) do
p[boxType] = makeWrapper(boxType)
end
return p