Star Citizen Wiki
Wir laden dich herzlich auf unseren Star Citizen Wiki Discord Server ein! Dein direkter Draht für Fragen, Anmerkungen oder Kritik.

Modul:Spectrum Dispatch

Aus Star Citizen Wiki

Dokumentation unvollständig.


local p = {}

-- Data about series name and type
local showData = mw.loadData( 'Module:Spectrum_Dispatch/Data' )

-- Needed Extensions
local arguments = require( 'Module:Arguments' )
local infobox = require( 'Module:Infobox' )
local common = require( 'Module:Common' )

-- Local Vars
local frame = {}
local args = {}
local smwData = {
    [ 'Serientyp' ] = nil,
    [ 'Serienname' ] = nil,
    [ 'Veröffentlichung' ] = nil,
    [ 'Episode' ] = nil,
    [ 'Thema' ] = {},
    [ 'Besetzung' ] = {},

}
local categories = {}
local commLinks = {}

-- Local Functions
--
local function setSemanticProperties()
    local result = mw.smw.set( smwData )

    common.checkSmwResult( result )
end

-- Parses the shows type
local function getShowType()
    local title = mw.title.getCurrentTitle().text

    for name, type in pairs( showData.name ) do
        if string.match( title, name ) then
            return type
        end
    end

    if ( args[ 'show_type' ] ~= nil ) then
        return args[ 'show_type' ]
    end

    table.insert( categories, '[[Category:Spectrum Artikel mit fehlerhaftem Serientyp]]' )
end

-- Parses the shows name
local function getShowName()
    local title = mw.title.getCurrentTitle().text

    for name, type in pairs( showData.name ) do
        if string.match( title, name ) then
            return name
        end
    end

    if ( args[ 'show_name' ] ~= nil ) then
        return args[ 'show_name' ]
    end

    table.insert( categories, '[[Category:Spectrum Artikel mit fehlerhaftem Seriennamen]]' )
end

-- Adds the main category
local function setMainCategory()
    local cat = ''
    local showType = smwData[ 'Serientyp' ]

    if ( smwData[ 'Episode' ] ~= nil or showType == 'Time Capsule' or showType == 'News Update' ) then
        cat = smwData[ 'Serienname' ]
    else
        cat = smwData[ 'Serientyp' ]
    end

    if ( cat ~= nil ) then
        table.insert( categories, '[[Category:' .. cat .. ']]' )
    end
end

-- Title above infobox
local function getTopTitle()
    local output = ''

    if ( smwData[ 'Serienname' ] ) then
        if ( args[ 'show_name' ] == nil ) then
            output = smwData[ 'Serienname' ] .. ': '
        end
    end

    output = output .. mw.title.getCurrentTitle().subpageText

    return output
end

-- Infobox title
local function getTitle()
    local title = smwData[ 'Serientyp' ];

    if ( smwData[ 'Serientyp' ] == 'Galactic Guide' ) then
        title = 'Galactic Guide / Portfolio'
    else

    end

    return title
end

--
local function getTitleImage()
    local suffix = '_Titelbild'

    local names = {
    	args[ 'image' ]
    }
    
    if ( smwData[ 'Serienname' ] ~= nil ) then
        table.insert( names, smwData[ 'Serienname' ] .. '_' .. mw.title.getCurrentTitle().subpageText .. suffix )
        table.insert( names, smwData[ 'Serienname' ] .. suffix )

        if ( smwData[ 'Serientyp' ] ~= nil ) then
            table.insert( names, smwData[ 'Serientyp' ] .. '_' .. smwData[ 'Serienname' ] .. suffix )
        end
    end
    
    return common.getImage( names )
end

-- UGLY, refactor
local function getPageTitle()
    local title = ''

    if ( smwData[ 'Serientyp' ] == 'Time Capsule' or smwData[ 'Serientyp' ] == 'News Update' ) then
        title = smwData[ 'Serienname' ] .. ' - '
        if ( smwData[ 'Episode' ]  ~= nil and smwData[ 'Serientyp' ] ~= 'Time Capsule' ) then
            title = title .. 'Episode ' .. smwData[ 'Episode' ]
        else
            title = title .. mw.title.getCurrentTitle().subpageText
        end
    else
        title = smwData[ 'Serienname' ]
        if ( smwData[ 'Episode' ]  ~= nil ) then
            title = title .. ' - Episode ' .. smwData[ 'Episode' ]
        end
    end

    return title
end

-- Extracts args and sets up the module
local function init( args )
    smwData[ 'Serientyp' ] = getShowType()
    smwData[ 'Serienname' ] = getShowName()
    smwData[ 'Veröffentlichung' ] = args[ 'release' ]
    smwData[ 'Episode' ] = tonumber( args[ 'episode' ] )
    smwData[ 'Thema' ] = common.extractDataFromPrefix( 'topic', args )
    smwData[ 'Besetzung' ] = common.extractDataFromPrefix( 'cast', args )
    smwData[ 'Quelle' ] = {
        args[ 'source_url_rsi' ] or nil,
        args[ 'source_url_translation' ] or nil,
    }

    local commLinkIds = common.extractDataFromPrefix( 'comm_link_id', args )

    for _, id in pairs( commLinkIds ) do
        table.insert( commLinks, 'Comm-Link:' .. id )
    end

    if ( #commLinks > 0 ) then
        smwData[ 'Comm-Link' ] = commLinks
    end

    setSemanticProperties()
    setMainCategory()
end


-- Public functions
--
function p.infoBox( frame )
    args = arguments.getArgs( frame )
    init( args )
    common.setDisplayTitle( frame, getPageTitle() )

    local box = infobox.create( {
        --top = getTopTitle(),
        --title = getTitle(),
        bodyClass = 'floatright',
    } )

    local titleImage = getTitleImage()

    if ( titleImage ~= false ) then
        box:addImage( titleImage, {
        	'rahmenlos'
        } )
    else
    	table.insert( categories, '[[Category:Spectrum Artikel mit fehlendem Titelbild]]' )
    end

	box:addTitle( getTitle() )
	   :addHeader( getTopTitle() )

    if ( smwData[ 'Episode' ] ) then
        box:addRow( 'Episode', smwData[ 'Episode' ], nil, 'col2' )
    end

    if ( smwData[ 'Veröffentlichung' ] ) then
        box:addRow( 'Veröffentlichung', smwData[ 'Veröffentlichung' ], nil, 'col2' )
    end

    if ( #smwData[ 'Besetzung' ] > 0 ) then
        local persons = {}

        for _, v in pairs( smwData[ 'Besetzung' ] ) do
            table.insert( persons, '[[' .. v .. ']]' )
        end

        box:addRow( 'Personenliste', table.concat( persons, '<br>' ), nil, 'col2' )
    end

    if ( #smwData[ 'Thema' ] > 0 ) then
        box:addRow( 'Themenliste', table.concat( smwData[ 'Thema' ], '<br>' ), nil, 'col2' )
    end

    if ( #commLinks > 0 ) then
        local commLinkLinks = {}
        for _, id in pairs( commLinks ) do
            table.insert( commLinkLinks, '[[' .. id .. ']]' )
        end

        box:addRow( 'Comm-Link', table.concat( commLinkLinks, '<br>' ), nil, 'col2' )
    end

    if ( args[ 'source_url_rsi' ] ~= nil ) then
        box:addRow( 'RSI', '[' .. args[ 'source_url_rsi' ] .. ' RSI]', nil, 'col2' )
    end

    if ( args[ 'source_url_translation' ] ~= nil ) then
        box:addRow( 'Übersetzung', '[' .. args[ 'source_url_translation' ] .. ' Übersetzung]', nil, 'col2' )
    end
    
    box:addRowsFromArgs( args, '!' )

    return tostring( box ) .. tostring( table.concat( categories, '' ) )
end

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