Modul:Company

Aus Star Citizen Wiki
Modul Dokumentation[view][edit][history][purge]
Diese Dokumentation wird von Modul:Company/doc aus übernommen. Änderungen können auf der Diskussionsseite vorgeschlagen werden.
Function list
L 87 — getDataForRow
L 112 — methodtable.init
L 120 — methodtable.getInfobox
L 149 — Company.infoBox
L 157 — Company.new

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:InfoboxNeue' )
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:new()

    box:renderImage( common.getImage( self.args.image ) )

    box:renderHeader( title )

    local section = {}

    for _, row in ipairs( attributes ) do
        local data = getDataForRow( row, self.args )

        if data ~= nil then
            table.insert( section, box:renderItem( row.title, data ) )
        end
    end

	box:renderSection( {
		col = 2,
		content = section
	} )

    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
Cookies helfen uns bei der Bereitstellung dieses Wikis. Durch die Nutzung des Star Citizen Wiki erklärst du dich damit einverstanden, dass wir Cookies speichern.