Zuletzt bearbeitet vor einem Monat
von Xineohp1506

Unterrichtsfilm

Die Dokumentation für dieses Modul kann unter Modul:Unterrichtsfilm/Doku erstellt werden

local p = {}
local getArgs = require('Module:Arguments').getArgs
local helper = require('Module:Unterrichtsfilm/Helper')
local frame = mw.getCurrentFrame()

function p.render(frame)
    local args = getArgs(frame)
    local html = mw.html.create('div'):addClass('uf-block')

    -- Kurzbeschreibung berechnen
    local shortDesc = helper.cleanAndTruncate(args.Beschreibung, 250)

    -- Semantische Speicherung
    helper.setProperty({args = {["FilmTitel"] = args.Titel}})
    helper.setProperty({args = {["FilmFach"] = args.Fach}})
    helper.setProperty({args = {["FilmThema"] = args.Thema}})
    helper.setProperty({args = {["FilmKlassenstufe"] = args.Klassenstufe}})
    helper.setProperty({args = {["FilmAltersfreigabe"] = args.Altersfreigabe}})
    helper.setProperty({args = {["FilmTyp"] = args.Typ}})
    helper.setProperty({args = {["FilmErscheinungsjahr"] = args.Erscheinungsjahr}})
    helper.setProperty({args = {["FilmLänge"] = args.Laenge}})
    helper.setProperty({args = {["FilmKurzbeschreibung"] = shortDesc}})
    
    -- Titel setzen
    helper.setDisplayTitle{ title = args.Titel ..' ('..args.Erscheinungsjahr..')' }

    -- Kategorien
    html:wikitext(helper.addCategories{
        categories = {
            '' .. (args.Fach or 'Unbekannt'),
            'Klassenstufe ' .. (args.Klassenstufe or 'Unbekannt'),
            'FSK '..args.Altersfreigabe,
            args.Typ,
        },
        sortkey = args.Titel or mw.title.getCurrentTitle().text
    })

    -- Layout
    local container = html:tag('div'):addClass('uf-container')
    local left = container:tag('div'):addClass('uf-left')
    local right = container:tag('div'):addClass('uf-right')

	-- Metabox-Wrapper
	local metabox = left:tag('div'):addClass('uf-metabox')
	
	-- Zeile 0: Überschrift
	metabox:tag('h5'):addClass('uf-meta-title'):wikitext('Metadaten')
	
	-- Zeile 1: Typ, Erscheinungsjahr, Länge, FSK
	do
	    local zeile1 = {}
	    if args.Typ then
	        table.insert(zeile1, frame:preprocess('{{#fas:' .. helper.getIcon(args.Typ) .. '}} ' .. args.Typ))
	    end
	    if args.Erscheinungsjahr then
	        table.insert(zeile1, frame:preprocess('{{#fas:calendar}}️ ' .. args.Erscheinungsjahr))
	    end
	    if args.Laenge then
	        table.insert(zeile1, frame:preprocess('{{#fas:clock}} ' .. args.Laenge))
	    end
	    if args.Altersfreigabe then
	        table.insert(zeile1, frame:preprocess('{{#fas:user-shield}} FSK: ' .. args.Altersfreigabe))
	    end
	    if #zeile1 > 0 then
	        metabox:tag('div'):addClass('uf-meta-line')
	            :wikitext(table.concat(zeile1, '    '))
	    end
	end
	
	-- Zeile 2: Fach, Thema, InfoLink
	do
	    local zeile2 = {}
	    if args.Fach then
	        table.insert(zeile2, frame:preprocess('{{#fas:book-open}} ' .. args.Fach))
	    end
	    if args.Thema then
	        table.insert(zeile2, frame:preprocess('{{#fas:tags}} ' .. args.Thema))
	    end
	    if args.InfoLink then
	        table.insert(zeile2, frame:preprocess('{{#fas:external-link-alt}} [' .. args.InfoLink .. ' Weiterführende Informationen]'))
	    end
	    if #zeile2 > 0 then
	        metabox:tag('div'):addClass('uf-meta-line')
	            :wikitext(table.concat(zeile2, '    '))
	    end
	end
	
	-- Zeile 3: Warnung (optional)
	if args.Warnung and args.Warnung ~= "" then
	    metabox:tag('div'):addClass('uf-meta-line uf-warn')
	        :wikitext(frame:preprocess('{{#fas:skull-crossbones}} ' .. args.Warnung))
	end
	
	-- Zeile 4: Interner Zugriff (UNC-Link o. Ä.)
	if args.InternLink and args.InternLink ~= "" then
	    metabox:tag('div')
	        :addClass('uf-meta-line uf-intern')
	        :wikitext(frame:preprocess('{{#fas:lock}} {{unc|'.. args.InternLink ..'|'.. args.InternLink ..'}}'))
	end


    left:tag('h2'):wikitext('Beschreibung')
    left:tag('p'):wikitext(args.Beschreibung or '')

	left:tag('h2'):wikitext('Fragestellungen')
	
	-- Empfehlung (optional)
	if args.Empfehlung and args.Empfehlung ~= '' then
	    local emp = left:tag('div'):addClass('uf-bewertung')
	    emp:tag('div'):wikitext(frame:preprocess('{{#fas:thumbs-up}} Empfehlung: ' .. args.Empfehlung))
	end
	
	-- Hinweis (optional)
	if args.Hinweise and args.Hinweise ~= '' then
	    left:tag('div'):addClass('uf-hinweis')
	        :wikitext(frame:preprocess('{{#fas:exclamation-triangle}} ' .. args.Hinweise))
	end
	
	-- Fragestellungen (immer)
	left:tag('div'):addClass('uf-fragen')
    	:wikitext('<!-- -->\n' .. args.Fragestellungen)

    
	if args.Service and args.ID then
	    left:tag('h2'):wikitext('Trailer zum Film')
	    local embed = '{{#ev:' .. args.Service .. '|' .. args.ID .. '||center|Trailer ' .. args.Titel .. '|||autoresize}}'
	    left:tag('div')
	        :addClass('uf-video-container')
	        :wikitext(frame:preprocess(embed))
	end
    
    local bild = args.Bild or ('Default_' .. (args.Typ or 'Film') .. '.jpg')
    right:wikitext('[[Datei:' .. bild .. '|300px|rahmen|right]]')
    return tostring(html)
end

return p