Modul:Autoren: Unterschied zwischen den Versionen

Aus Splitterwiki
Zur Navigation springen Zur Suche springen
Zeile 3: Zeile 3:
 
function p.getOfficalAuthors( frame )
 
function p.getOfficalAuthors( frame )
 
local ReturnString =" "
 
local ReturnString =" "
 +
local AuthorList = {}
 
--liste aller Publikationen, Autoren sind ein attribut der liste
 
--liste aller Publikationen, Autoren sind ein attribut der liste
 
local queryResult =  mw.smw.ask('[[Hauptkategorie::Publikation]][[Kanon::offiziell]]|?Autoren=2|mainlabel=-|limit=500')
 
local queryResult =  mw.smw.ask('[[Hauptkategorie::Publikation]][[Kanon::offiziell]]|?Autoren=2|mainlabel=-|limit=500')
Zeile 9: Zeile 10:
 
do
 
do
 
if (type(queryResult[i][1]) == "table") then
 
if (type(queryResult[i][1]) == "table") then
 +
-- mutiple authors so we have a table
 
local n = 1
 
local n = 1
 
while n <= table.getn(queryResult[i][1])  
 
while n <= table.getn(queryResult[i][1])  
Zeile 18: Zeile 20:
 
 
 
else
 
else
 +
-- only one author
 +
AuthorList[table.getn(AuthorList +1)] = queryResult[i][1]
 
ReturnString = ReturnString .. queryResult[i][1] .. '<br>'
 
ReturnString = ReturnString .. queryResult[i][1] .. '<br>'
 
end
 
end

Version vom 19. Dezember 2021, 00:23 Uhr

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

local p = {} --local p = {} -- p steht für Paket (engl. package)

function p.getOfficalAuthors( frame )
	local ReturnString =" "
	local AuthorList = {}
	--liste aller Publikationen, Autoren sind ein attribut der liste
	local queryResult =  mw.smw.ask('[[Hauptkategorie::Publikation]][[Kanon::offiziell]]|?Autoren=2|mainlabel=-|limit=500')
	local i = 1
		while i <= table.getn(queryResult) 
		do
			if (type(queryResult[i][1]) == "table") then
				-- mutiple authors so we have a table
				local n = 1
				while n <= table.getn(queryResult[i][1]) 
				do
					ReturnString = ReturnString .. queryResult[i][1][n]
					n = n +1
				end
				ReturnString = ReturnString .. '<br>'
				
			else
				-- only one author
				AuthorList[table.getn(AuthorList +1)] = queryResult[i][1]
				ReturnString = ReturnString .. queryResult[i][1] .. '<br>'
			end
			i = i + 1
		end

    return ReturnString
end

return p