Dieses Modul benötigt Modul:Arguments
Dieses Modul benötigt Modul:Common
Dieses Modul benötigt Modul:Infobox
Dieses Modul benötigt Modul:Localized
Diese Dokumentationsseite spiegelt den Inhalt der Seite Modul:Company/Doku wieder. |
Modulabhängigkeiten
Modulinfo
Dieses Modul setzt die Vorlage:Unternehmen um. Anweisungen zur Verwendung findest du auf der Vorlagenseite.
local Company = {}
local metatable = {}
local methodtable = {}
metatable.__index = methodtable
-- Needed Extensions
local infobox = require( 'Module:Infobox' )
local common = require( 'Module:Common' )
local localized = require( 'Module:Localized' )
--- Infobox columns in order
--- title is the title of the column
--- alt_args are alternative args that can be used
local attributes = {
[1] = {
title = 'Branche',
alt_args = 'industry'
},
[2] = {
title = 'Produkte',
alt_args = 'products'
},
[3] = {
title = 'Hersteller Code',
alt_args = 'Manufacturer code'
},
[4] = {
title = 'Volk',
alt_args = 'race'
},
[5] = {
title = 'Hauptsitz',
alt_args = 'headquarters'
},
[6] = {
title = 'Gebiet',
alt_args = 'areaserved'
},
[7] = {
title = 'Personen',
alt_args = 'keypeople'
},
[8] = {
title = 'Gründer',
alt_args = 'founder'
},
[9] = {
title = 'Gründung',
alt_args = 'founded'
},
[10] = {
title = 'Schicksal',
alt_args = 'fate'
},
[11] = {
title = 'Zerfall',
alt_args = 'defunct'
},
[12] = {
title = 'Ehemals',
alt_args = 'formerly'
},
[13] = {
title = 'Nachfolger',
alt_args = 'successor'
},
[14] = {
title = 'Muttergesellschaft',
alt_args = 'parent'
},
[15] = {
title = 'Tochtergesellschaften',
alt_args = 'subsidiaries'
},
[16] = {
title = 'Verbündete',
alt_args = 'allies'
},
[17] = {
title = 'Konkurrenten',
alt_args = 'rivals'
},
}
local function getDataForRow( row, args )
if args[ row.title ] ~= nil then
return args[ row.title ]
end
local targets = {}
if type( row.alt_args ) ~= 'table' then
targets = { row.alt_args }
else
targets = row.alt_args
end
for _, target in pairs( targets ) do
if args[ target ] ~= nil then
return args[ target ]
end
end
return nil
end
--- Extracts args and sets up the module
---
--- @param frame table - The current frame
function methodtable.init( self, frame )
self.frame = frame
self.args = require( 'Module:Arguments' ).getArgs( frame )
end
--- Builds the infobox
---
--- @return string
function methodtable.getInfobox( self )
local title = localized:getMainTitle( self.frame )
common.setDisplayTitle( self.frame, title )
local box = infobox.create( {
bodyClass = 'floatright',
} )
box:addImage( common.getImage( self.args.image ), {
'rahmenlos',
'600px',
} )
box:addTitle( title )
for _, row in ipairs( attributes ) do
local data = getDataForRow( row, self.args )
if data ~= nil then
box:addRow( row.title, data, nil, 'col2' )
end
end
return tostring( box ) .. tostring( table.concat( self.categories, '' ) )
end
--- Template entry
function Company.infoBox( frame )
local instance = Company:new()
instance:init( frame )
return instance:getInfobox()
end
--- New Instance
function Company.new( self )
local instance = {
frame = {},
args = {},
categories = {'[[Kategorie:Unternehmen]]'},
}
setmetatable( instance, metatable )
return instance
end
return Company