Module:Infobox company: Difference between revisions

From TwogPedia
(Created page with "local getArgs = require('Module:Arguments').getArgs local Links = require('Module:Links') local Header = require('Module:Infobox/Widget/Header') local Subheader = require('Module:Infobox/Widget/Subheader') local LinksWidget = require('Module:Infobox/Widget/Links') local Flags = require('Module:Flags') local Infobox = {} function Infobox.main(frame) local args = getArgs(frame) local currentTitleSplit = mw.text.split(mw.title.getCurrentTitle().text, '/') local head...")
 
No edit summary
 
(25 intermediate revisions by 2 users not shown)
Line 4: Line 4:
local Subheader = require('Module:Infobox/Widget/Subheader')
local Subheader = require('Module:Infobox/Widget/Subheader')
local LinksWidget = require('Module:Infobox/Widget/Links')
local LinksWidget = require('Module:Infobox/Widget/Links')
local ListWidget = require('Module:Infobox/Widget/List')
local SponsorsWidget = require('Module:Infobox/Widget/Sponsors')
local LocationWidget = require('Module:Infobox/Widget/Location')
local RowWidget = require('Module:Infobox/Widget/Row')
VariablesLua = mw.ext.VariablesLua


local Flags = require('Module:Flags')
local Flags = require('Module:Flags')
Line 10: Line 16:
function Infobox.main(frame)
function Infobox.main(frame)
local args = getArgs(frame)
local args = getArgs(frame)
local headerNode
if args.logos then
local logoAll = VariablesLua.varexists( 'logoAll' ) and VariablesLua.var('logoAll') or nil
local logoLight = VariablesLua.varexists( 'logoLight' ) and VariablesLua.var('logoLight') or nil
local logoDark = VariablesLua.varexists( 'logoDark' ) and VariablesLua.var('logoDark') or nil
headerNode = Header.make(args.title or mw.title.getCurrentTitle().text, logoLight, logoDark, logoAll)
elseif args.logoAll or args.logoLight or args.logoDark then
headerNode = Header.make(args.title or mw.title.getCurrentTitle().text, args.logoLight, args.logoDark, args.logoAll)
end
local container = mw.html.create('div'):addClass('ib grid-infobox')
local titleContainer = mw.html.create('div')
        :addClass('carousel-image-container')
        :attr('id', 'image-container-small')
        :node(headerNode)


local currentTitleSplit = mw.text.split(mw.title.getCurrentTitle().text, '/')
    container:node(titleContainer)
local infoContainer = mw.html.create('div'):addClass('info-container grid')
-- local titleParts = mw.text.split(mw.title.getCurrentTitle().text, "/")
-- local companyName = titleParts[2] or mw.title.getCurrentTitle().text
local headerNode = Header.make(args.title or currentTitleSplit[2], args.image or '')
-- local companyRow = mw.html.create('div'):addClass('ib-row')
-- local labelDiv = mw.html.create('div'):addClass('ib-rowName')
-- local valueDiv = mw.html.create('div')
--    :wikitext(companyName)
--    :css('font-weight', '700')
--    :css('font-size', '24px')
--    :css('color', '#ECEBEB')
-- companyRow:node(labelDiv)
-- companyRow:node(valueDiv)
-- infoContainer:node(companyRow)
local container = mw.html.create('div')
local infoContainer = mw.html.create('div'):addClass('info-container grid')
:addClass('ib')
container:node(headerNode):node(Subheader.make(args.variant .. ' Information'))
if args.location then
local titleParts = mw.text.split(mw.title.getCurrentTitle().text, "/")
local countryName = Flags.CountryName(args.location)
local companyName = titleParts[2] or mw.title.getCurrentTitle().text
local flag = Flags.icon(args.location, currentTitleSplit[1])
local location = mw.html.create('div')
:addClass('ib-row')
local link = ':Category:' .. currentTitleSplit[1]  .. '/' .. countryName
local locationName = mw.html.create('span')
:wikitext('[[' .. link .. '|' .. countryName .. ']]')
local name = mw.html.create('div')
:addClass('ib-rowName')
:wikitext('Location: ')
local value = mw.html.create('div')
:wikitext(flag)
:node(locationName)
if args.location2 then
local companyRow = mw.html.create('div')
countryName = Flags.CountryName(args.location2)
    :addClass('ib-row')
flag = Flags.icon(args.location2, currentTitleSplit[1])
    :css('column-gap', '0', 'important')
link = ':Category:' .. currentTitleSplit[1]  .. '/' .. countryName
local labelDiv = mw.html.create('div'):addClass('ib-rowName')
local location2Name = mw.html.create('span')
local valueDiv = mw.html.create('div')
:wikitext('[[' .. link .. '|' .. countryName .. ']]')
    :wikitext(companyName)
local location2 = mw.html.create('div')
    :css('font-weight', '700')
:wikitext(flag)
    :css('font-size', '20px')
:node(location2Name)
    :css('color', '#ECEBEB')
value:wikitext('<br>'):node(location2)
companyRow:node(labelDiv)
end
companyRow:node(valueDiv)
container:node(location:node(name):node(value))
infoContainer:node(companyRow)
 
if args.country then
infoContainer:node(RowWidget.make('Headquarter', LocationWidget.make(args.country, args.city, 'Companies')))
end
end
if args.region then
if args.founded then
local countryName = Flags.CountryName(args.region)
infoContainer:node(RowWidget.make('Founded', args.founded))
local flag = Flags.icon(args.region, currentTitleSplit[1])
local region = mw.html.create('div')
:addClass('ib-row')
local link = ':Category:' .. currentTitleSplit[1]  .. '/' .. countryName
local regionName = mw.html.create('span')
:wikitext('[[' .. link .. '|' .. countryName .. ']]')
local name = mw.html.create('div')
:addClass('ib-rowName')
:wikitext('Region: ')
local value = mw.html.create('div')
:wikitext(flag)
:node(regionName)
container:node(region:node(name):node(value))
end
end
if args.founded then
if args.employees then  
local founded = mw.html.create('div')
infoContainer:node(RowWidget.make('Employees', args.employees))
:addClass('ib-row')
local name = mw.html.create('div')
:addClass('ib-rowName')
:wikitext('Founded: ')
local value = mw.html.create('div')
:wikitext(args.founded)
container:node(founded:node(name):node(value))
end
end
if args.coach then
if args.sponsors then
local coach = mw.html.create('div')
infoContainer:node(RowWidget.make('Sponsors', SponsorsWidget.make(args.sponsors, frame)))
:addClass('ib-row')
local name = mw.html.create('div')
:addClass('ib-rowName')
:wikitext('Coach: ')
local value = mw.html.create('div')
local pageExists = frame:callParserFunction('#ifexist', args.coach, 'yes', 'no' )
if ( pageExists == 'yes' ) then
value:wikitext('<span>[[' .. args.coach .. '|' .. args.coach .. ']]</span>')
else
value:wikitext(args.coach)
end
container:node(coach:node(name):node(value))
end
end
if args.manager then
if args.type then
local manager = mw.html.create('div')
infoContainer:node(RowWidget.make('Type', args.type))
:addClass('ib-row')
local name = mw.html.create('div')
:addClass('ib-rowName')
:wikitext('Manager: ')
local value = mw.html.create('div')
local pageExists = frame:callParserFunction('#ifexist', args.manager, 'yes', 'no' )
if ( pageExists == 'yes' ) then
value:wikitext('<span>[[' .. args.manager .. '|' .. args.manager .. ']]</span>')
else
value:wikitext(args.manager)
end
container:node(manager:node(name):node(value))
end
end
if args.captain then
if args.parentcompany then
local captain = mw.html.create('div')
infoContainer:node(RowWidget.make('Parent company', args.parentcompany, frame, 'Companies/'))
:addClass('ib-row')
local name = mw.html.create('div')
:addClass('ib-rowName')
:wikitext('Manager: ')
local value = mw.html.create('div')
local pageExists = frame:callParserFunction('#ifexist', args.captain, 'yes', 'no' )
if ( pageExists == 'yes' ) then
value:wikitext('<span>[[' .. args.captain .. '|' .. args.captain .. ']]</span>')
else
value:wikitext(args.captain)
end
container:node(captain:node(name):node(value))
end
end
container:node(Subheader.make('Links'))
if args.subsidiaries then
infoContainer:node(RowWidget.make('Subsidiaries', ListWidget.make(args.subsidiaries, 'Companies/')))
end
local linksContainer = mw.html.create('div'):addClass('ib-links-container')
local transformedLinks = Links.transform(args)
local transformedLinks = Links.transform(args)
local fullLinks = LinksWidget.make(transformedLinks, 'team')
local fullLinks = LinksWidget.make(transformedLinks, 'team')
container:node(fullLinks)
if fullLinks then
linksContainer:node(fullLinks)
end
container:node(infoContainer)
    container:node(linksContainer)
   
return container
return container
end
end


return Infobox
return Infobox

Latest revision as of 02:09, 26 April 2025

Documentation for this module may be created at Module:Infobox company/doc

local getArgs = require('Module:Arguments').getArgs
local Links = require('Module:Links')
local Header = require('Module:Infobox/Widget/Header')
local Subheader = require('Module:Infobox/Widget/Subheader')
local LinksWidget = require('Module:Infobox/Widget/Links')
local ListWidget = require('Module:Infobox/Widget/List')
local SponsorsWidget = require('Module:Infobox/Widget/Sponsors')
local LocationWidget = require('Module:Infobox/Widget/Location')
local RowWidget = require('Module:Infobox/Widget/Row')

VariablesLua = mw.ext.VariablesLua

local Flags = require('Module:Flags')
local Infobox = {}

function Infobox.main(frame)
	local args = getArgs(frame)
	local headerNode
	
	if args.logos then
		local logoAll = VariablesLua.varexists( 'logoAll' ) and VariablesLua.var('logoAll') or nil
		local logoLight = VariablesLua.varexists( 'logoLight' ) and VariablesLua.var('logoLight') or nil
		local logoDark = VariablesLua.varexists( 'logoDark' ) and VariablesLua.var('logoDark') or nil
		headerNode = Header.make(args.title or mw.title.getCurrentTitle().text, logoLight, logoDark, logoAll)
	elseif args.logoAll or args.logoLight or args.logoDark then
		 headerNode = Header.make(args.title or mw.title.getCurrentTitle().text, args.logoLight, args.logoDark, args.logoAll)
	end
	
	local container = mw.html.create('div'):addClass('ib grid-infobox')
	
	local titleContainer = mw.html.create('div')
        :addClass('carousel-image-container')
        :attr('id', 'image-container-small')
        :node(headerNode)

    container:node(titleContainer)
	
	local infoContainer = mw.html.create('div'):addClass('info-container grid')
	
	-- local titleParts = mw.text.split(mw.title.getCurrentTitle().text, "/")
	-- local companyName = titleParts[2] or mw.title.getCurrentTitle().text
	
	-- local companyRow = mw.html.create('div'):addClass('ib-row')
	-- local labelDiv = mw.html.create('div'):addClass('ib-rowName')
	-- local valueDiv = mw.html.create('div')
	--     :wikitext(companyName)
	--     :css('font-weight', '700')
	--     :css('font-size', '24px')
	--     :css('color', '#ECEBEB')
	-- companyRow:node(labelDiv)
	-- companyRow:node(valueDiv)
	-- infoContainer:node(companyRow)
	
	local infoContainer = mw.html.create('div'):addClass('info-container grid')
	
	local titleParts = mw.text.split(mw.title.getCurrentTitle().text, "/")
	local companyName = titleParts[2] or mw.title.getCurrentTitle().text
		
	local companyRow = mw.html.create('div')
	    :addClass('ib-row')
	    :css('column-gap', '0', 'important')
	local labelDiv = mw.html.create('div'):addClass('ib-rowName')
	local valueDiv = mw.html.create('div')
	    :wikitext(companyName)
	    :css('font-weight', '700')
	    :css('font-size', '20px')
	    :css('color', '#ECEBEB')
	companyRow:node(labelDiv)
	companyRow:node(valueDiv)
	infoContainer:node(companyRow)

	if args.country then
		infoContainer:node(RowWidget.make('Headquarter', LocationWidget.make(args.country, args.city, 'Companies')))
	end
	
	if args.founded then
		infoContainer:node(RowWidget.make('Founded', args.founded))
	end
	
	if args.employees then 
		infoContainer:node(RowWidget.make('Employees', args.employees))
	end
	
	if args.sponsors then
		infoContainer:node(RowWidget.make('Sponsors', SponsorsWidget.make(args.sponsors, frame)))
	end
	
	if args.type then
		infoContainer:node(RowWidget.make('Type', args.type))
	end
	
	if args.parentcompany then
		infoContainer:node(RowWidget.make('Parent company', args.parentcompany, frame, 'Companies/'))
	end
	
	if args.subsidiaries then
		infoContainer:node(RowWidget.make('Subsidiaries', ListWidget.make(args.subsidiaries, 'Companies/')))
	end
	
	local linksContainer = mw.html.create('div'):addClass('ib-links-container')
	local transformedLinks = Links.transform(args)
	local fullLinks = LinksWidget.make(transformedLinks, 'team')
	
	if fullLinks then
		linksContainer:node(fullLinks)
	end
	
	container:node(infoContainer)
    container:node(linksContainer)
    
	return container
end

return Infobox