Anonimo

Modulo:DTSem: differenze tra le versioni

Da Wikitrek.
m
nessun oggetto della modifica
mNessun oggetto della modifica
mNessun oggetto della modifica
 
(26 versioni intermedie di uno stesso utente non sono mostrate)
Riga 58: Riga 58:
function p.SeasonsQty(ShortName)
function p.SeasonsQty(ShortName)
local QueryResult
local QueryResult
local Max
local Max = 0
local PrefixText
local PrefixText
Riga 72: Riga 72:
-- See https://github.com/SemanticMediaWiki/SemanticScribunto/blob/master/docs/mw.smw.ask.md#result
-- See https://github.com/SemanticMediaWiki/SemanticScribunto/blob/master/docs/mw.smw.ask.md#result
-- for return value example
-- for return value example
Max = QueryResult[1]["Stagione"]
     if QueryResult == nil or Max < 0 then
     if QueryResult == nil or Max < 0 then
         return 0
         return 0
     else
     else
    Max = QueryResult[1]["Stagione"]
     return Max
     return Max
     end
     end
Riga 102: Riga 102:
Series = mw.wikibase.getLabel(Item.claims['P16'][1].mainsnak.datavalue.value.id)
Series = mw.wikibase.getLabel(Item.claims['P16'][1].mainsnak.datavalue.value.id)
if ShortName == "Serie Classica" or ShortName == "Serie Animata" then
if SeriesShort == "Serie Classica" or SeriesShort == "Serie Animata" then
CategoryText = '[[Category:Personaggi della ' .. SeriesShort .. "]]"
CategoryText = '[[Category:Personaggi della ' .. SeriesShort .. "]]"
else
else
Riga 136: Riga 136:
local SeriesShort
local SeriesShort
local Characters = {}
local Characters = {}
local PagesList = {}
if not Item then
if not Item then
Riga 147: Riga 148:
Series = mw.wikibase.getLabel(Item.claims['P16'][1].mainsnak.datavalue.value.id)
Series = mw.wikibase.getLabel(Item.claims['P16'][1].mainsnak.datavalue.value.id)
if ShortName == "Serie Classica" or ShortName == "Serie Animata" then
if SeriesShort == "Serie Classica" or SeriesShort == "Serie Originale" or SeriesShort == "Serie Animata" then
InstanceText = '[[Istanza::Episodio della ' .. SeriesShort .. "]]"
InstanceText = '[[Istanza::Episodio della ' .. SeriesShort .. "]]"
else
else
InstanceText = '[[Istanza::Episodio di ' .. SeriesShort .. "]]"
InstanceText = '[[Istanza::Episodio di ' .. SeriesShort .. "]]"
end
end
--[==[
Pages = mw.smw.ask(InstanceText .. "|?Personaggio|order=asc|sort=Numero di produzione")
Pages = mw.smw.ask(InstanceText .. "|?Personaggio|order=asc|sort=Numero di produzione")
if Pages == nil then
if Pages == nil then
         return "''Nessun risultato''"
         return "''Nessun risultato'' (<code>" .. mw.text.nowiki(InstanceText) .. "</code>, )"  
     else
     else
     --local myResult = ""
     --local myResult = ""
Riga 181: Riga 182:
         end
         end
end
end
]==]
NewPages = mw.smw.getQueryResult(InstanceText .. "|?Personaggio |order=asc|sort=Numero di produzione")
NewPages = mw.smw.getQueryResult(InstanceText .. "|?Personaggio|limit=500|order=asc|sort=Numero di produzione")
for _, Episode in ipairs(NewPages.results) do
for _, Episode in ipairs(NewPages.results) do
for _, Character in ipairs(Episode.printouts.Personaggio) do
for _, Character in ipairs(Episode.printouts.Personaggio) do
if Characters[Character.fulltext] == nil then
local CharText = Character.fulltext
table.insert(Characters, Character.fulltext .. " - " .. Characters[Character.fulltext])
if not Characters[CharText] then
table.insert(Characters, CharText)
Characters[CharText] = true
end
end
end
end
end
end
table.sort(Characters)
if type(Characters) == 'table' and Characters ~= nil then
if type(Characters) == 'table' and Characters ~= nil then
--return p.RecurringList(Characters, Series)
for _, Page in ipairs(Characters) do
return #Characters .. " - " .. table.concat(Characters, ", ")
    table.insert(PagesList, Page)
    end
return p.RecurringList(PagesList, Series, 3)
--return #Characters .. " - " .. #Characters .. " - " .. table.concat(PagesList, ", ")
else
else
return "No table"
return "No table"
Riga 205: Riga 215:
-- @param Pages Table containing characters' pages names
-- @param Pages Table containing characters' pages names
-- @param Series String with name of the Series
-- @param Series String with name of the Series
-- @param[opt=1] MinOccurr Integer with minimum value of occurencies
-- @return String Bullet list of characters and episodes
-- @return String Bullet list of characters and episodes
function p.RecurringList(Pages, Series)
function p.RecurringList(Pages, Series, MinOccurr)
local Results = {}
local Results = {}
if not MinOccurr or MinOccurr < 1 then
MinOccurr = 1
end
     if type(Pages) == "table" then
     if type(Pages) == "table" then
Riga 219: Riga 233:
         --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')
         Episodes = mw.smw.ask('[[Serie::' .. Series .. ']][[Personaggio::' .. Page .. ']]|sort=Numero di produzione|order=asc')
         Episodes = mw.smw.ask('[[Serie::' .. Series .. ']][[Personaggio::' .. Page .. ']]|limit=100|sort=Numero di produzione|order=asc')
        
        
         if (Episodes ~= nil) and (#Episodes > 0) then
         if (Episodes ~= nil) and (#Episodes > MinOccurr - 1) then
         --[=[
         --[=[
         Episodes = mw.smw.getQueryResult('[[Serie::' .. Series .. ']][[Personaggio::' .. Page.fulltext .. ']]|sort=Numero di produzione|order=asc')
         Episodes = mw.smw.getQueryResult('[[Serie::' .. Series .. ']][[Personaggio::' .. Page.fulltext .. ']]|sort=Numero di produzione|order=asc')
Riga 243: Riga 257:
         table.insert(Results, "* '''[[" .. Page .. "]]''' (" .. #Episodes .. "): " .. table.concat(List, ", "))
         table.insert(Results, "* '''[[" .. Page .. "]]''' (" .. #Episodes .. "): " .. table.concat(List, ", "))
         else
         else
         table.insert(Results, "* NULL or ZERO Episodes - " .. mw.text.nowiki('[[Serie::' .. Series .. ']][[Personaggio::' .. Page .. ']]|sort=Numero di produzione|order=asc'))
         -- Episode is NULL or number of episodes is LESS the set value
        --table.insert(Results, "* NULL or ZERO Episodes - " .. mw.text.nowiki('[[Serie::' .. Series .. ']][[Personaggio::' .. Page .. ']]|sort=Numero di produzione|order=asc'))
         end
         end
     end
     end