Modul:Autoren: Unterschied zwischen den Versionen

Aus Splitterwiki
Zur Navigation springen Zur Suche springen
Zeile 6: Zeile 6:
 
--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')
 +
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 alphabetical
 +
table.sort(Authors)
 +
 +
-- loop over authors, find publikationen of each author, display them
 +
    local n = 1
 +
    while n <= table.getn(Authors)
 +
    do
 +
    queryResult =  mw.smw.ask('[[Hauptkategorie::Publikation]][[Kanon::offiziell]][[Autoren::'.. Authors[n] ..']]|limit=500')
 +
    ReturnString = ReturnString .. '<h3>[['  .. Authors[n]  .. ']]</h3> hat an ' .. table.getn(queryResult) .. ' Publikationen als Autor_in mitgearbeitet: <br>'
 +
    m = 1
 +
    if queryResult ~= nil then
 +
    while m <= table.getn(queryResult)
 +
    do
 +
    ReturnString = ReturnString .. queryResult[m][1] ..', '
 +
    m = m+1
 +
    end
 +
    ReturnString = ReturnString .. '<br><br>'
 +
    end
 +
    n = n +1
 +
    end
 +
   
 +
    return ReturnString
 +
end
 +
 +
function p.getInofficalAuthors( frame )
 +
local ReturnString ="<h2>Offizielle Autor_innen</h2>"
 +
local AuthorList = {}
 +
--liste aller Publikationen, Autoren sind ein attribut der liste
 +
local queryResult =  mw.smw.ask('[[Hauptkategorie::Publikation]][[Kanon::inoffiziell]]|?Autoren#-=2|mainlabel=-|limit=500')
 
local i = 1
 
local i = 1
 
while i <= table.getn(queryResult)  
 
while i <= table.getn(queryResult)  

Version vom 19. Dezember 2021, 21:14 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 ="<h2>Offizielle Autor_innen</h2>"
	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 alphabetical
	table.sort(Authors)
	
	-- loop over authors, find publikationen of each author, display them
    local n = 1
    while n <= table.getn(Authors) 
    do
    	queryResult =  mw.smw.ask('[[Hauptkategorie::Publikation]][[Kanon::offiziell]][[Autoren::'.. Authors[n] ..']]|limit=500')
    	ReturnString = ReturnString .. '<h3>[['  .. Authors[n]  .. ']]</h3> hat an ' .. table.getn(queryResult) .. ' Publikationen als Autor_in mitgearbeitet: <br>'
    	m = 1
    	if queryResult ~= nil then
    	while m <= table.getn(queryResult)
    		do
    			ReturnString = ReturnString .. queryResult[m][1] ..', '
    			m = m+1
    		end
    		ReturnString = ReturnString .. '<br><br>'
    	end
    	n = n +1 
    end
    
    return ReturnString
end

function p.getInofficalAuthors( frame )
	local ReturnString ="<h2>Offizielle Autor_innen</h2>"
	local AuthorList = {}
	--liste aller Publikationen, Autoren sind ein attribut der liste
	local queryResult =  mw.smw.ask('[[Hauptkategorie::Publikation]][[Kanon::inoffiziell]]|?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 alphabetical
	table.sort(Authors)
	
	-- loop over authors, find publikationen of each author, display them
    local n = 1
    while n <= table.getn(Authors) 
    do
    	queryResult =  mw.smw.ask('[[Hauptkategorie::Publikation]][[Kanon::offiziell]][[Autoren::'.. Authors[n] ..']]|limit=500')
    	ReturnString = ReturnString .. '<h3>[['  .. Authors[n]  .. ']]</h3> hat an ' .. table.getn(queryResult) .. ' Publikationen als Autor_in mitgearbeitet: <br>'
    	m = 1
    	if queryResult ~= nil then
    	while m <= table.getn(queryResult)
    		do
    			ReturnString = ReturnString .. queryResult[m][1] ..', '
    			m = m+1
    		end
    		ReturnString = ReturnString .. '<br><br>'
    	end
    	n = n +1 
    end
    
    return ReturnString
end

return p