Die Dokumentation für dieses Modul kann unter Modul:LPON/ModOutput/Doku erstellt werden
local modOutput = {}
local helper = require('Module:LPON/Helper')
-- Funktion zur Ausgabe der Mods innerhalb einer Projektseite oder Modseite
function modOutput.inside(cleanProjektname)
if not mw.smw then
return "Semantic MediaWiki-Erweiterung nicht gefunden."
end
-- Sicherstellen, dass der bereinigte Projektname angegeben wurde
if not cleanProjektname or cleanProjektname == "" then
return "Kein Projekt angegeben."
end
-- Abfrage-String erstellen
local query = string.format(
"[[LPON:Projekt::%s]][[LPON:Typ::Mod]]|?LPON:Modname|?LPON:Description|?LPON:Download-URL|?LPON:Download-Quelle|?LPON:Mod-Kategorie",
cleanProjektname
)
-- Abfrage ausführen
local queryResult = mw.smw.getQueryResult(query)
-- Kein Ergebnis gefunden
if not queryResult or not queryResult.results then
return "Keine Mods für dieses Projekt gefunden."
end
-- Kategorien sammeln
local categorizedMods = {}
for _, result in ipairs(queryResult.results) do
-- Mod-Informationen extrahieren
local modName = result.printouts["LPON:Modname"] and result.printouts["LPON:Modname"][1] or "Unbekannt"
local description = result.printouts["LPON:Description"] and result.printouts["LPON:Description"][1] or "Keine Beschreibung verfügbar"
local downloadURL = result.printouts["LPON:Download-URL"] and result.printouts["LPON:Download-URL"][1]
local downloadSource = result.printouts["LPON:Download-Quelle"] and result.printouts["LPON:Download-Quelle"][1] or "Unbekannt"
local category = result.printouts["LPON:Mod-Kategorie"] and result.printouts["LPON:Mod-Kategorie"][1] or "Allgemein"
-- Download-Link erstellen
local downloadLink = downloadURL and ('[' .. downloadURL .. ' ' .. downloadSource .. ']') or "PRIVAT"
-- Mod zur entsprechenden Kategorie hinzufügen
if not categorizedMods[category] then
categorizedMods[category] = {}
end
table.insert(categorizedMods[category], '<li><i>' .. modName .. '</i> - ' .. description .. ' - ' .. downloadLink .. '</li>')
end
-- Kategorien sortieren
local sortedCategories = {}
for category in pairs(categorizedMods) do
table.insert(sortedCategories, category)
end
table.sort(sortedCategories)
-- Ausgabe generieren
local output = '<div class="lpon-mods">'
for _, category in ipairs(sortedCategories) do
output = output .. '<p><b>' .. category .. ':</b></p>\n'
output = output .. '<ul>' .. table.concat(categorizedMods[category], "\n") .. '</ul>\n'
end
output = output .. '</div>'
return output
end
-- Funktion zur Ausgabe der Mods auf einer separaten Seite
function modOutput.outside(frame)
local args = require('Module:Arguments').getArgs(frame)
local projectName = args["Projekt"]
if not projectName or projectName == "" then
return "Kein Projektname angegeben."
end
-- DISPLAYTITLE setzen
helper.setDisplayTitle({title = projectName .. " - Mods"})
local cleanProjektname = helper.cleanString(projectName)
-- Abfrage-String erstellen
local query = string.format(
"[[LPON:Projekt::%s]][[LPON:Typ::Mod]]|?LPON:Modname|?LPON:Mod-Version|?LPON:Modautor|?LPON:Description|?LPON:Download-URL|?LPON:Download-Quelle|?LPON:Mod-Kategorie",
cleanProjektname
)
local queryResult = mw.smw.getQueryResult(query)
if not queryResult or not queryResult.results then
return "Keine Mods für dieses Projekt gefunden."
end
-- Kategorien sammeln
local categorizedMods = {}
for _, result in ipairs(queryResult.results) do
local modName = result.printouts["LPON:Modname"] and result.printouts["LPON:Modname"][1] or "Unbekannt"
local version = result.printouts["LPON:Mod-Version"] and result.printouts["LPON:Mod-Version"][1] or "N/A"
local author = result.printouts["LPON:Modautor"] and result.printouts["LPON:Modautor"][1] or "Unbekannt"
local description = result.printouts["LPON:Description"] and result.printouts["LPON:Description"][1] or "Keine Beschreibung verfügbar"
local downloadURL = result.printouts["LPON:Download-URL"] and result.printouts["LPON:Download-URL"][1]
local downloadSource = result.printouts["LPON:Download-Quelle"] and result.printouts["LPON:Download-Quelle"][1] or "Unbekannt"
local category = result.printouts["LPON:Mod-Kategorie"] and result.printouts["LPON:Mod-Kategorie"][1] or "Allgemein"
local downloadLink = downloadURL and ('[' .. downloadURL .. ' ' .. downloadSource .. ']') or "PRIVAT"
if not categorizedMods[category] then
categorizedMods[category] = {}
end
table.insert(categorizedMods[category], string.format(
'<tr><td>%s</td><td>%s</td><td>%s</td><td>%s</td><td>%s</td></tr>',
modName,
version,
author,
description,
downloadLink
))
end
local output = ""
-- Kategorien ausgeben
local sortedCategories = {}
for category in pairs(categorizedMods) do
table.insert(sortedCategories, category)
end
table.sort(sortedCategories)
for _, category in ipairs(sortedCategories) do
output = output .. string.format("== %s ==\n", category)
output = output .. '<table class="lpnon-mod-table sortable"><tr><th>Mod-Name</th><th>Version</th><th>Autor</th><th>Beschreibung</th><th>Download</th></tr>'
output = output .. table.concat(categorizedMods[category], "\n")
output = output .. '</table>\n'
end
output = output .. helper.addCategories({categories = "LPON:" .. cleanProjektname , sortkey = "!"})
return output
end
return modOutput