Anonimo

Modulo:DTFunzioniComuni: differenze tra le versioni

Da Wikitrek.
Species category added
mNessun oggetto della modifica
(Species category added)
 
(6 versioni intermedie di uno stesso utente non sono mostrate)
Riga 141: Riga 141:
if Item ~= nil and Item.claims[Property] then
if Item ~= nil and Item.claims[Property] then
local Values = Item.claims[Property]
local Values = Item.claims[Property]
-- Only initialize ResultsArray if the Property exist at least once along the tree
if ResultsArray == nil then
if ResultsArray == nil then
ResultsArray = {}
ResultsArray = {}
Riga 159: Riga 159:
end
end
if not Aggregate then
if not Aggregate then
return ResultsArray[1]
return table.concat(ResultsArray)
end
end
end
end
Riga 170: Riga 170:
return p.PropertiesOnTree("P16", 3, false)
return p.PropertiesOnTree("P16", 3, false)
end
end
--------------------------------------------------------------------------------
-- Build and return the list of categories for a specific page
--
-- @param {Frame} Info from MW session
-- @return {string} List of properties in Wikitext
--------------------------------------------------------------------------------
function p.CategoryTree(frame)
function p.CategoryTree(frame)
local AZInstancesMember = {Q23 = "Personaggi", Q18 = "Specie", Q95 = "Pianeti", Q19 = "Cast", Q52 = "Cast"}
local AZInstancesMember = {Q23 = "Personaggi", Q18 = "Specie", Q95 = "Pianeti", Q19 = "Cast", Q52 = "Cast"}
Riga 176: Riga 182:
local UpperCategories
local UpperCategories
local AZCategory = ''
local AZCategory = ''
local SpeciesCategory = ''
if mw.wikibase.getEntity() then
if mw.wikibase.getEntity() then
Riga 204: Riga 211:
AZCategory = "[[Category:" .. AZInstancesMember[CurrentQ] .. " - " .. FirstLetter .. "]]"
AZCategory = "[[Category:" .. AZInstancesMember[CurrentQ] .. " - " .. FirstLetter .. "]]"
return (p.PropertiesOnTree("P68", 1, false)) .. AZCategory
-- Check if item has Species (P65) property
if mw.wikibase.getEntity().claims['P65'] ~= nil then
SpeciesCategory = "[[Category:" .. AZInstancesMember[CurrentQ] .. " - " .. mw.wikibase.getLabelByLang(mw.wikibase.getEntity().claims['P65'][1].mainsnak.datavalue.value.id, "it") .. "]]"
end
return (p.PropertiesOnTree("P68", 1, false) or "") .. AZCategory .. SpeciesCategory
else
else
UpperCategories = p.PropertiesOnTree("P68", 2, true)
UpperCategories = p.PropertiesOnTree("P68", 2, true)
if type(UpperCategories) == "table" then
if type(UpperCategories) == "table" then
--return table.concat(UpperCategories)
return table.concat(UpperCategories)
return UpperCategories
else
else
return UpperCategories
return UpperCategories