Modul:Autoren: Unterschied zwischen den Versionen

Aus Splitterwiki
Zur Navigation springen Zur Suche springen
Zeile 28: Zeile 28:
 
for k,_ in pairs(AuthorList) do
 
for k,_ in pairs(AuthorList) do
 
     Authors[#Authors+1] = k
 
     Authors[#Authors+1] = k
end
+
end
 +
-- sort them alphabeticaly
 +
AuthorsSorted = {}
 +
    for n in pairs(Authors) do table.insert(AuthorsSorted, n) end
 +
    table.sort(AuthorsSorted)
 +
    -- display
 
     local n = 1
 
     local n = 1
     while n <= table.getn(Authors)  
+
     while n <= table.getn(a)  
 
     do
 
     do
 
     ReturnString = ReturnString .. Authors[n] .. "<br>"
 
     ReturnString = ReturnString .. Authors[n] .. "<br>"

Version vom 19. Dezember 2021, 19:16 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
					AuthorList[queryResult[i][1][n]] = 1
					n = n +1
				end
				
			else
				-- only one author
				AuthorList[queryResult[i][1]] = 1
			end
			i = i + 1
		end
	--transform table around
	local Authors = {}
	for k,_ in pairs(AuthorList) do
    	Authors[#Authors+1] = k
	end
	-- sort them alphabeticaly
	AuthorsSorted = {}
    for n in pairs(Authors) do table.insert(AuthorsSorted, n) end
    table.sort(AuthorsSorted)
    -- display
    local n = 1
    while n <= table.getn(a) 
    do
    	ReturnString = ReturnString .. Authors[n] .. "<br>"
    	n = n +1 
    end
    
    return ReturnString
end

return p