Modulo:DTSem: differenze tra le versioni

Vai alla navigazione Vai alla ricerca
m
nessun oggetto della modifica
mNessun oggetto della modifica
mNessun oggetto della modifica
Riga 81: Riga 81:
--- Function to extract recurring characters and list them
--- Function to extract recurring characters and list them
--  
--  
-- @param ShortName The short name of the series as in P24
-- @param frame Context from MediaWiki
-- @return Integer Number of seasons
-- @return String Bullet list of characters and episodes
function p.RecurringListFromCategory(frame)
function p.RecurringListFromCategory(frame)
local Results = {}
local Results = {}
Riga 113: Riga 113:
if Pages == nil then
if Pages == nil then
         return "''Nessun risultato''"
         return "''Nessun risultato''"
     end
     else
 
    return RecurringList(Pages)   
end
     if type(Pages) == "table" then
     if type(Pages) == "table" then
     for _, Page in ipairs(Pages.results) do
     for _, Page in ipairs(Pages.results) do
Riga 122: Riga 124:
         -- Page.fulltext represents Page name
         -- Page.fulltext represents Page name
        
        
         Count = mw.smw.ask('[[Serie::' .. Series .. ']][[Personaggio::' .. Page.fulltext .. ']]|format=count')
         --Count = mw.smw.ask('[[Serie::' .. Series .. ']][[Personaggio::' .. Page.fulltext .. ']]|format=count')
         Episodes = mw.smw.ask('[[Serie::' .. Series .. ']][[Personaggio::' .. Page.fulltext .. ']]|sort=Numero di produzione|order=asc')
         Episodes = mw.smw.ask('[[Serie::' .. Series .. ']][[Personaggio::' .. Page.fulltext .. ']]|sort=Numero di produzione|order=asc')
        
        
Riga 147: Riga 149:
         end
         end
         table.insert(Results, "* '''[[" .. Page.fulltext .. "]]''' (" .. Count .. "): " .. table.concat(List, ", ").. " - " .. #Episodes)
         table.insert(Results, "* '''[[" .. Page.fulltext .. "]]''' (" .. Count .. "): " .. table.concat(List, ", ").. " - " .. #Episodes)
        end
    end
    else
    return "''Il risultato non è una TABLE''"
    end
--return mw.text.nowiki(CategoryText) .. #Pages
return table.concat(Results, string.char(10))
end
--- Helper to extract recurring characters and list them
--
-- @param Pages Array of characters' page name
-- @return String Bullet list of characters and episodes
function p.RecurringList(Pages)
local Results = {}
    if type(Pages) == "table" then
    for _, Page in ipairs(Pages.results) do
    local Count
    local Episodes = {}
        local List = {}
        -- Page.fulltext represents Page name
       
        --Count = mw.smw.ask('[[Serie::' .. Series .. ']][[Personaggio::' .. Page.fulltext .. ']]|format=count')
        Episodes = mw.smw.ask('[[Serie::' .. Series .. ']][[Personaggio::' .. Page.fulltext .. ']]|sort=Numero di produzione|order=asc')
       
        if (Episodes ~= nil) and (#Episodes > 0) then
        --[=[
        Episodes = mw.smw.getQueryResult('[[Serie::' .. Series .. ']][[Personaggio::' .. Page.fulltext .. ']]|sort=Numero di produzione|order=asc')
       
        for _, Episode in ipairs(Episodes.results) do
        table.insert(List, "[[" .. Episode.fulltext .. "]]")
        end
        ]=]
       
        for num, Episode in pairs(Episodes) do
        --myResult = myResult .. '* This is result #' .. num .. '\n'
            for _, Data in pairs(Episode) do
            if type(Data) == 'table' then
            table.insert(List, table.concat(Data))
            else
            table.insert(List, Data)
            end
       
            end
        end
        table.insert(Results, "* '''[[" .. Page.fulltext .. "]]''' (" .. Count .. "): " .. table.concat(List, ", "))
         end
         end
     end
     end

Menu di navigazione