66 604
contributi
mNessun oggetto della modifica |
(Fixed and improved ListAppearances function) |
||
Riga 12: | Riga 12: | ||
-- @frame Info from MW session | -- @frame Info from MW session | ||
-- @return A bullet list of appearances | -- @return A bullet list of appearances | ||
function p. | function p.ListAppearancesOLD(frame) | ||
-- See example | -- See example | ||
--[=[ | --[=[ | ||
Riga 150: | Riga 150: | ||
return queryResult | return queryResult | ||
end | |||
--- generates a list of backlink using SMW query. | |||
-- | |||
-- @frame Info from MW session | |||
-- @return A bullet list of appearances | |||
function p.ListAppearances(frame) | |||
local FinalArray = {} | |||
local FinalString = "" | |||
local Actor = mw.title.getCurrentTitle().text | |||
local QueryResult = mw.smw.getQueryResult('[[Interprete::' .. Actor .. ']]|?' .. Actor .. '|sort=Numero di produzione|order=asc') | |||
if QueryResult == nil then | |||
return "''Nessun risultato''" | |||
end | |||
if type(QueryResult) == "table" then | |||
for k, v in pairs(QueryResult.results) do | |||
-- v.fulltext represents EPISODE | |||
-- v.printouts[Actor][1].fulltext represents CHARACTER | |||
local Episode = v.fulltext | |||
local Character | |||
if v.printouts[Actor][1] == nil then | |||
Character = "''Senza pagina''" | |||
else | |||
for _, CurrChar in pairs(v.printouts[Actor]) do | |||
Character = CurrChar.fulltext | |||
if FinalArray[Character] == nil then | |||
FinalArray[Character] = {} | |||
end | |||
table.insert(FinalArray[Character], Episode) | |||
end | |||
end | |||
end | |||
else | |||
return "''Il risultato non è una TABLE''" | |||
end | |||
for ID, Group in pairs(FinalArray) do | |||
FinalString = FinalString .. "* [[" .. ID .. "]]: [[" .. table.concat(Group, "]], [[") .. "]]" .. string.char(10) | |||
end | |||
return FinalString | |||
end | end | ||
--- This dumps the variable (converts it into a string representation of itself) | --- This dumps the variable (converts it into a string representation of itself) |