Module:WikiProjectBanner/TaskForce
MyWikiBiz, Author Your Legacy — Friday November 15, 2024
Jump to navigationJump to searchDocumentation for this module may be created at Module:WikiProjectBanner/TaskForce/doc
------------------------------------------------------------------------------- -- TaskForce class -- -- This module contains the TaskForce class used in -- -- Module:WikiProjectBanner. It is used to generate the task force rows. -- ------------------------------------------------------------------------------- -- Load necessary modules local Row = require('Module:WikiProjectBanner/Row') -- Lazily load modules we don't always need local mShared, Grade local TaskForce = setmetatable({}, Row) TaskForce.__index = TaskForce function TaskForce.new(args, bannerData, cfg, rowCfg) local obj = Row.new(args, bannerData, cfg, rowCfg) setmetatable(obj, TaskForce) -- Quality grade obj.qualityGrade = obj.bannerData.grades.quality if obj.quality and obj.qualityGrade then local qualityData = obj.qualityGrade:exportData() obj.qualityCategory = obj.qualityGrade:makeAssessmentCategory{ grade = qualityData.short, assessmentCategory = obj.rowCfg.assessmentCategory } obj.forceImportance = qualityData.forceImportance end -- Importance grade if obj.qualityGrade and obj.rowCfg.importance then local gradeCfg = {} gradeCfg.forceGrade = obj.forceImportance gradeCfg.assessmentCategory = obj.rowCfg.assessmentCategory gradeCfg.param = obj.rowCfg.importanceParams Grade = Grade or require('Module:WikiProjectBanner/Grade') obj.importanceGrade = Grade.new( 'importance', obj.args, obj.bannerData, obj.cfg, gradeCfg ) obj.importanceCategory = obj.importanceGrade:exportData().assessmentCategory end -- Image if rowCfg.image then obj:setIcon(string.format( '[[File:%s|x25px|center|alt=Task force icon]]', rowCfg.image )) end local text = '' -- Portal if rowCfg.portal then mShared = mShared or require('Module:WikiProjectBanner/shared') local portal = mShared.makePortal( rowCfg.portal, {height = '15', margin = '0'} ) text = text .. portal end -- Text if rowCfg.text then text = text .. rowCfg.text else local msg if obj.importanceGrade then msg = "This $1 is supported by '''[[$2|$3]]''' (marked as $4)." else msg = "This $1 is supported by '''[[$2|$3]]'''." end local pageType = obj.bannerData.pageType local link = rowCfg.link local name = rowCfg.name local importance if obj.importanceGrade then importance = obj.importanceGrade:exportData().full else importance = '' end mShared = mShared or require('Module:WikiProjectBanner/shared') text = text .. mShared.substituteParams( msg, pageType, link, name, importance ) end obj:setText(text) -- Categories obj:addCategory(obj.rowCfg.mainCategory) obj:addCategory(obj.qualityCategory) obj:addCategory(obj.importanceCategory) return obj end return TaskForce