Module:TabsAbstract

local util_args = require('Module:ArgsUtil') local util_cargo = require("Module:CargoUtil") local util_html = require("Module:HtmlUtil") local util_map = require('Module:MapUtil') local util_table = require("Module:TableUtil") local util_text = require("Module:TextUtil") local util_title = require("Module:TitleUtil") local util_vars = require("Module:VarsUtil") local i18n = require("Module:I18nUtil") local lang = mw.getLanguage('en')

local LCS = require('Module:LuaClassSystem').class

local h = {} local p = LCS.abstract function p:init -- this won't do anything but this is what we'll overwrite when we subclass self.tabClass = nil self.activeClass = nil self.outerClass = nil end

function p:run(args) self.args = args self.title = mw.title.getCurrentTitle.prefixedText self.sep = '%s*' .. (args.sep or ',') .. '%s*' self.basepage = args.basepage self.This = args.This and tonumber(args.This) or 1 self.links = self:getLinksFromArgs self:setThisVar return self:makeOutput end

function p:getLinksFromArgs if self.args.links then return self:getLinksFromSplitArgs end return self:getLinksFromNumberedArgs end

function p:getLinksFromSplitArgs local names = util_text.split(self.args.names, self.sep) local links = {} for i, linkPart in ipairs(util_text.split(self.args.links, self.sep)) do		linkPart = linkPart:gsub('_', ' ') local link = util_title.concatSubpage(self.basepage, linkPart) local defaultDisplay = linkPart ~= '' and linkPart or i		links[i] = self:getOneLinkInfo(			link,			self.args['name' .. i] or names[i] or defaultDisplay		) if link == self.title then self.This = i		end end return links end

function p:getLinksFromNumberedArgs local links = {} local i = 1 while self.args['link' .. i] do links[i] = self:getOneLinkInfo(self.args['link' .. i], self.args['name'.. i]) i = i + 1 end return links end

function p:getOneLinkInfo(link, name) local ret = { link = link, name = name, }	return ret end

function p:setThisVar local name = self.links[self.This].name util_vars.setVar('thisTab', name) util_vars.setVar('tabThis', self.This) end

function p:makeOutput local output = mw.html.create('div') :addClass(self.outerClass) for i, linkInfo in ipairs(self.links) do		local tab = self:printOneTab(output, self:makeTabLink(linkInfo)) self:setTabActiveState(i, tab) end return tostring(output) end

function p:printOneTab(output, tabDisplay) end

function p:makeTabLink(linkInfo) return util_text.intLink(linkInfo.link, linkInfo.name) end

function p:setTabActiveState(i, tab) if i ~= self.This then return end tab:addClass(self.activeClass) end

return p