Module:Update

local p = {}

local File = require("Module:File") local Franchise = require("Module:Franchise") local utilsArg = require("Module:UtilsArg") local utilsMarkup = require("Module:UtilsMarkup") local utilsTable = require("Module:UtilsTable")

function p.Main(frame) local args, err = utilsArg.parse(frame:getParent.args, p.Templates.Update) local result = p.main(args.infoSources or {}) if err then result = result .. utilsMarkup.categories(err.categories) end return result end

function p.main(infoSources) local logo, image if infoSources[1] then local exists logo, exists = File.logo(infoSources[1], { size = "100x100px" }) logo = exists and logo or nil -- only use logo if it actually exists. In other words, don't display the "No Image Upload" thumbnail end if not logo then image = utilsMarkup.file("File:OoT Ocarina of Time Render.png", { size = "75px" }) else image = logo end local info if #infoSources == 1 then info = string.format("It needs to be updated with information from %s.", Franchise.link(infoSources[1])) elseif #infoSources > 1 then local links = utilsTable.map(infoSources, Franchise.link) local list = utilsMarkup.bulletList(links) info = string.format("It needs to be updated with information from:" .. list) else info = "It needs to be updated to be accurate with information available at the present time." end local mbox = mw.getCurrentFrame:expandTemplate({		title = "Mbox",		args = {			image = image,			header = "This article or section is out of date.",			info = info		}	})

local categories = {"Articles to be updated"} for _, infoSource in ipairs(infoSources) do		local cat = string.format("Articles lacking information from %s", Franchise.shortName(infoSource)) table.insert(categories, cat) end categories = utilsMarkup.categories(categories) return mbox..categories end

p.Templates = { Update = { purpose = "This template is used to notify editors of articles that are out of date following the release of new information, namely new Zelda games.", format = "inline", params = { [1] = {				name = "infoSources", type = "string", enum = Franchise.enum({ includeNonfiction = true }), desc = "Used to identify one or more specific sources of new information as a comma-separated list.", split = true, sortAndRemoveDuplicates = true, }		},		examples = { {},			{"BotW"}, {"E"}, {"E, BotW"}, {"fakeGame"}, },	}, }

return p