Modul:Organisation

Aus Star Citizen Wiki
Modul Dokumentation[view][edit][history][purge]
Diese Dokumentation wird von Modul:Organisation/doc aus übernommen. Änderungen können auf der Diskussionsseite vorgeschlagen werden.

Dieses Modul setzt die Vorlage:Organisation um. Anweisungen zur Verwendung findest du auf der Vorlagenseite.


local Organisation = {}

local metatable = {}
local methodtable = {}

metatable.__index = methodtable

local yesno = require( 'Module:Yesno' )
local capiunto = require( 'Module:Infobox' )
local common = require( 'Module:Common' )
local data = mw.loadJsonData( 'Module:Organisation/data.json' )

local function getFromData( haystack, needle)
    local low = mw.ustring.lower

    for key, values in pairs( data[haystack] ) do
        if low( needle ) == low( key ) then
            return key
        else
            for _, translation in pairs( values ) do
                if low( needle ) == low( translation ) then
                    return key
                end
            end
        end
    end

    error( needle .. ' not found in ' .. haystack .. ' Data!', 0 )
end

function methodtable.addLogo( self )
    local image = common.getImage( {
        'Organisation ' .. mw.title.getCurrentTitle().subpageText .. '_Logo.png',
        'Organisation ' .. mw.title.getCurrentTitle().subpageText .. '_Logo.jpg',
    } )

    if image ~= false then
        self.box:addImage( image, {
            [ 'alternativtext' ] = 'Logo ' .. mw.title.getCurrentTitle().subpageText,
            'rahmenlos',
            '350px'
        } )
    else
        table.insert( self.categories, '[[Kategorie:Organisation mit fehlendem Logo]]' )
    end
end

function methodtable.addType( self )
    if self.args.organisation_type then
        local type = getFromData( 'types', self.args.organisation_type )

        if type then
            self.box:addRow( 'Form', type, nil, 'col2' )
            table.insert( self.categories, '[[Kategorie:Organisationsform (' .. type .. ')]]' )
        end
    else
        table.insert( self.categories, '[[Kategorie:Organisation mit fehlender Organisationsform]]' )
    end
end

function methodtable.addOrientation( self )
    local orientations = {}

    if self.args.orientation_1 == nil and self.args.orientation_2 == nil then
        table.insert( self.categories, '[[Kategorie:Organisation mit fehlender Ausrichtung]]' )

        return nil
    end

    if self.args.orientation_1 then
        local orientation = getFromData( 'orientations', self.args.orientation_1 )

        if orientation then
            table.insert( self.categories, '[[Kategorie:Organisationsausrichtung (' .. orientation .. ')]]' )
            table.insert( orientations, '[[:Kategorie:Organisationsausrichtung (' .. orientation .. ')|' .. orientation .. ']]' )
        end
    end

    if self.args.orientation_2 then
        local orientation = getFromData( 'orientations', self.args.orientation_2 )

        if orientation then
            table.insert( self.categories, '[[Kategorie:Organisationsausrichtung (' .. orientation .. ')]]' )
            table.insert( orientations, '[[:Kategorie:Organisationsausrichtung (' .. orientation .. ')|' .. orientation .. ']]' )
        end
    end

    self.box:addRow( 'Ausrichtung', table.concat( orientations, ', ' ), nil, 'col2' )
end

function methodtable.addMemberCount( self )
    if self.args.member_count then
        self.box:addRow( 'Mitgliederanzahl', self.args.member_count, nil, 'col2' )
    else
        table.insert( self.categories, '[[Kategorie:Organisation mit fehlender Mitgliederanzahl]]' )
    end
end

function methodtable.addObligation( self )
    if self.args.obligation then
        local obligation = getFromData( 'obligations', self.args.obligation )

        if obligation then
            self.box:addRow( 'Verpflichtung', obligation, nil, 'col2' )
            table.insert( self.categories, '[[Kategorie:Organisationsverpflichtung (' .. obligation .. ')]]' )
        end
    else
        table.insert( self.categories, '[[Kategorie:Organisation mit fehlender Verpflichtung]]' )
    end
end

function methodtable.addRolePlay( self )
    if self.args.role_play then
        local string = 'Nein'

        if yesno( self.args.role_play ) then
            string = 'Ja'
            table.insert( self.categories, '[[Kategorie:Organisation (Rollenspiel)]]' )
        end

        self.box:addRow( 'Rollenspiel', string, nil, 'col2' )
    else
        table.insert( self.categories, '[[Kategorie:Organisation mit fehlender Rollenspielangabe]]' )
    end
end

function methodtable.addExclusiveMembership( self )
    if self.args.exclusive then
        local string = 'Nein'

        if yesno( self.args.exclusive ) then
            string = 'Ja'
            table.insert( self.categories, '[[Kategorie:Organisation (Exklusive Mitgliedschaft)]]' )
        end

        self.box:addRow( 'Exklusive Mitgliedschaft', string, nil, 'col2' )
    else
        table.insert( self.categories, '[[Kategorie:Organisation mit fehlender Exklusivitätsangabe]]' )
    end
end

function methodtable.addLanguage( self )
    if self.args.language then
        self.box:addRow( 'Sprache', self.args.language, nil, 'col2' )
    else
        table.insert( self.categories, '[[Kategorie:Organisation mit fehlender Amtssprache]]' )
    end
end

function methodtable.addWebsite( self )
    if self.args.website then
        if string.match( self.args.website, 'http' ) == nil then
            error( 'Webseite scheint kein valider Link zu sein', 0 )

            return nil
        end

        self.box:addRow( 'Webseite', '[' .. self.args.website .. ' ' .. mw.title.getCurrentTitle().subpageText .. ']', nil, 'col2' )

        mw.smw.set({
            Webseite = self.args.website,
        })
    end
end

function methodtable.addRSI( self )
    if self.args.rsi_handle then
        if string.match( self.args.rsi_handle, 'http' ) then
            error( 'Im Feld Spectrum ID keinen Link angeben', 0 )
        else
            self.box:addRow( 'RSI', '[https://robertsspaceindustries.com/orgs/' .. string.upper( self.args.rsi_handle ) .. ' ' .. string.upper( self.args.rsi_handle ) .. ' auf RSI]', nil, 'col2' )
        end
    end
end

function methodtable.addTeamspeak( self )
    if self.args.teamspeak then
        if string.match( self.args.teamspeak, 'http' ) then
            error( 'Teamspeak Adresse scheint nicht valide zu sein', 0 )
        else
            self.box:addRow( 'Teamspeak', '[ts3server://' .. self.args.teamspeak .. ' ' .. self.args.teamspeak .. ']', nil, 'col2' )
        end
    end
end

function methodtable.addDiscord( self )
    if self.args.discord then
        if not string.match( self.args.discord,'discord.gg' ) then
            error( 'Discord Einladungslink scheint nicht valide zu sein', 0 )
        else
            self.box:addRow( 'Discord', '[' .. self.args.discord .. ' ' .. mw.title.getCurrentTitle().subpageText .. ']', nil, 'col2' )
        end
    end
end

function methodtable.addGuilded( self )
    if self.args.guilded then
        if not string.match( self.args.guilded,'guilded.gg' ) then
            error( 'Guilded Link scheint nicht valide zu sein', 0 )
        else
            self.box:addRow( 'Guilded', '[' .. self.args.guilded .. ' ' .. mw.title.getCurrentTitle().subpageText .. ']', nil, 'col2' )
        end
    end
end

function methodtable.addOther( self )
    if self.args.other then
        self.box:addRow( 'Sonstiges', self.args.other, nil, 'col2' )
    end
end

function methodtable.infoBox( self )
    local config = {
        bodyClass = 'floatright',
    }

    if self.args.slogan ~= nil then
        config.top = self.args.slogan
    end

    self.box = capiunto.create( config )

    self:addLogo()
    self.box:addTitle( mw.title.getCurrentTitle().subpageText )
    self:addType()
    self:addOrientation()
    self:addMemberCount()
    self:addObligation()
    self:addRolePlay()
    self:addExclusiveMembership()
    self:addLanguage()
    self:addWebsite()
    self:addRSI()
    self:addTeamspeak()
    self:addDiscord()
    self:addGuilded()
    self:addOther()

    self.box:addRowsFromArgs( self.args, '!' )

    return tostring( self.box ) .. table.concat( self.categories )
end

function Organisation.infobox( frame )
    local instance = Organisation:new()
    instance.args = require( 'Module:Arguments' ).getArgs( frame )

    return instance:infoBox()
end

--- New Instance
function Organisation.new( self )
    local instance = {
        categories = {
            '[[Kategorie:Organisation]]',
        },
        box = nil,
        args = nil,
    }

    setmetatable( instance, metatable )

    return instance
end

return Organisation
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.