Modul:Klasse: Unterschied zwischen den Versionen

Aus FürthWiki

(- KlassenBild)
(+ getAttrData())
Zeile 1: Zeile 1:
local p = {} --p stands for package
local p = {}
local c = require("Module:Common")
 
local com = require("Module:Common")
local str = require("Module:String")
local atr = require("Module:Attribut")


function p.Faktenbox( frame )
function p.Faktenbox( frame )
Zeile 18: Zeile 21:
t=t..'<tr>'..
t=t..'<tr>'..
    '<td>[[Attribut:Bild|Bild dieser Klasse]]</td>'
    '<td>[[Attribut:Bild|Bild dieser Klasse]]</td>'
if not c.isEmpty(args.Bild) then
if not com.isEmpty(args.Bild) then
    t=t..'<td colspan="3"><div class="ImageLink">[[Datei:'..
    t=t..'<td colspan="3"><div class="ImageLink">[[Datei:'..
    args.Bild..'|48px]]</div></td>'
    args.Bild..'|48px]]</div></td>'
Zeile 34: Zeile 37:
t=t..'</tr><tr>'..
t=t..'</tr><tr>'..
    '<td>[[Attribut:KlassenKategorie|Kategorie]]</td>'
    '<td>[[Attribut:KlassenKategorie|Kategorie]]</td>'
if not c.isEmpty(args.KlassenKategorie) then
if not com.isEmpty(args.KlassenKategorie) then
    t=t..'<td colspan="3">[[KlassenKategorie::Kategorie:'..args.KlassenKategorie..']]</td>'
    t=t..'<td colspan="3">[[KlassenKategorie::Kategorie:'..args.KlassenKategorie..']]</td>'
end
end
Zeile 44: Zeile 47:
t=t..'</tr><tr>'..
t=t..'</tr><tr>'..
    '<td>[[Attribut:Suchformular|Suchformular]]</td>'
    '<td>[[Attribut:Suchformular|Suchformular]]</td>'
if not c.isEmpty(args.KlassenKategorie) then
if not com.isEmpty(args.KlassenKategorie) then
    t=t..'<td colspan="2">[[Suchformular::Abfrage_'..args.KlassenKategorie..']]</td>'..
    t=t..'<td colspan="2">[[Suchformular::Abfrage_'..args.KlassenKategorie..']]</td>'..
    '<td>[[Formular:Abfrage_'..args.KlassenKategorie..']]</td>'
    '<td>[[Formular:Abfrage_'..args.KlassenKategorie..']]</td>'
Zeile 51: Zeile 54:
t=t..'</tr><tr>'..
t=t..'</tr><tr>'..
    '<td>[[Attribut:Suchvorlage|Suchvorlage]]</td>'
    '<td>[[Attribut:Suchvorlage|Suchvorlage]]</td>'
if not c.isEmpty(args.KlassenKategorie) then
if not com.isEmpty(args.KlassenKategorie) then
    t=t..'<td colspan="2">[[Suchvorlage::Abfrage_'..args.KlassenKategorie..']]</td>'..
    t=t..'<td colspan="2">[[Suchvorlage::Abfrage_'..args.KlassenKategorie..']]</td>'..
    '<td>[[Spezial:Abfrage_ausführen/Abfrage_'..args.KlassenKategorie..']]</td>'
    '<td>[[Spezial:Abfrage_ausführen/Abfrage_'..args.KlassenKategorie..']]</td>'
Zeile 58: Zeile 61:
t=t..'</tr><tr>'..
t=t..'</tr><tr>'..
    '<td>[[Attribut:AttributListe|AttributListe]]</td>'
    '<td>[[Attribut:AttributListe|AttributListe]]</td>'
if not c.isEmpty(args.AttributListe) then
if not com.isEmpty(args.AttributListe) then
    t=t..'<td colspan="3">[[AttributListe::'..args.AttributListe..']]</td>'
    t=t..'<td colspan="3">[[AttributListe::'..args.AttributListe..']]</td>'
end
end
Zeile 68: Zeile 71:
t=t..'</table>'
t=t..'</table>'
return t
return t
end
function p.getAttrData(klasse)
local attr_data = {}
local query = {"[[Klasse:" .. klasse .. "]]",
"?AttributListe"}
query = mw.smw.ask(query)
if query ~= nil then
local attributliste = query[1]["AttributListe"]
attributliste = str.splitAndStrip(attributliste, ";")
if #attributliste > 0 then
attr_data.list = {}
for i, a in ipairs(attributliste) do
attr_data.list[i] = atr.getAttrAttributes(a, klasse)
attr_data.list[i]["Attribut"] = a
end
end
end
return attr_data
end
end


return p
return p

Version vom 16. Februar 2026, 16:25 Uhr

Seiten-Übersicht

Zur Klasse Klasse gehörende Seiten:
Hauptseite Unterseiten
Allgemein
Faktenbox Vorlagen
Formulare
Module
Abfrage Vorlagen


Formulare


Sonstige


Doku


local p = {}

local com = require("Module:Common")
local str = require("Module:String")
local atr = require("Module:Attribut")

function p.Faktenbox( frame )
	local args = frame:getParent().args
	local t = p.daten( frame, args )
	
	-- Use preprocess to render the factbox and all contens at once
	return frame:preprocess(t)
end

function p.daten(frame, args)
	local title = mw.title.getCurrentTitle().text
	local t = '<table class="wikitable">'..
	    '<th>[[FürthWiki:Semantik]]</th>'..
		'<th colspan="3">'..'[[KlassenName::'..title..']]</th>'

	t=t..'<tr>'..
	    '<td>[[Attribut:Bild|Bild dieser Klasse]]</td>'
	if not com.isEmpty(args.Bild) then
	    t=t..'<td colspan="3"><div class="ImageLink">[[Datei:'..
	    	args.Bild..'|48px]]</div></td>'
	    mw.smw.set{["Bild"] = "Datei:" .. args.Bild}
	end

	t=t..'</tr><tr>'..
	    '<td>[[Attribut:KlassenVorlage|Vorlage]]</td>'
	t=t..'<td colspan="3">[[KlassenVorlage::Vorlage:'..title..']]</td>'
	
	t=t..'</tr><tr>'..
	    '<td>[[Attribut:KlassenModul|Modul]]</td>'
	t=t..'<td colspan="3">[[KlassenModul::Modul:'..title..']]</td>'
	
	t=t..'</tr><tr>'..
	    '<td>[[Attribut:KlassenKategorie|Kategorie]]</td>'
	if not com.isEmpty(args.KlassenKategorie) then
	    t=t..'<td colspan="3">[[KlassenKategorie::Kategorie:'..args.KlassenKategorie..']]</td>'
	end
	
	t=t..'</tr><tr>'..
	    '<td>[[Attribut:KlassenFormular|Formular]]</td>'
	t=t..'<td colspan="3">[[KlassenFormular::Formular:'..title..']]</td>'
	
	t=t..'</tr><tr>'..
	    '<td>[[Attribut:Suchformular|Suchformular]]</td>'
	if not com.isEmpty(args.KlassenKategorie) then
	    t=t..'<td colspan="2">[[Suchformular::Abfrage_'..args.KlassenKategorie..']]</td>'..
	    	'<td>[[Formular:Abfrage_'..args.KlassenKategorie..']]</td>'
	end
	
	t=t..'</tr><tr>'..
	    '<td>[[Attribut:Suchvorlage|Suchvorlage]]</td>'
	if not com.isEmpty(args.KlassenKategorie) then
	    t=t..'<td colspan="2">[[Suchvorlage::Abfrage_'..args.KlassenKategorie..']]</td>'..
	    	'<td>[[Spezial:Abfrage_ausführen/Abfrage_'..args.KlassenKategorie..']]</td>'
	end
	
	t=t..'</tr><tr>'..
	    '<td>[[Attribut:AttributListe|AttributListe]]</td>'
	if not com.isEmpty(args.AttributListe) then
	    t=t..'<td colspan="3">[[AttributListe::'..args.AttributListe..']]</td>'
	end
	
	t=t..'<tr>'..
		'<td>[[Bild:IconSearch.svg|16px|semantisches Browsen|link=Spezial:Durchsuchen/{{NAMESPACE}}:{{PAGENAME}}]]</td>'..
		'<td colspan="3">[[Spezial:Durchsuchen/{{NAMESPACE}}:{{PAGENAME}}|semantisches Browsen]]</td>'..
	'</tr>'
	t=t..'</table>'
	return t
end

function p.getAttrData(klasse)
	local attr_data = {}
	local query = {"[[Klasse:" .. klasse .. "]]",
		"?AttributListe"}
	query = mw.smw.ask(query)
	if query ~= nil then
		local attributliste = query[1]["AttributListe"]
		attributliste = str.splitAndStrip(attributliste, ";")
		if #attributliste > 0 then
			attr_data.list = {}
			for i, a in ipairs(attributliste) do
				attr_data.list[i] = atr.getAttrAttributes(a, klasse)
				attr_data.list[i]["Attribut"] = a
			end
		end
	end
	return attr_data
end

return p