Anonimo

Modulo:DTFunzioniComuni: differenze tra le versioni

Da Wikitrek.
SkipItem and QList implemented
(New "Tree" functions)
(SkipItem and QList implemented)
Riga 77: Riga 77:
-- @param Depth How far to go on the tree: 1 - item only, 2 - item and Instance, 3 - item, Instance and Instance of Instance
-- @param Depth How far to go on the tree: 1 - item only, 2 - item and Instance, 3 - item, Instance and Instance of Instance
-- @param Aggregate Wether to aggregate results or return the first found
-- @param Aggregate Wether to aggregate results or return the first found
-- @param SkipItem Don't return value for current item, Instance and Instance of Instance only
-- @return Table withs strings or wikilinks
-- @return Table withs strings or wikilinks
function p.PropertiesOnTree(Property, Depth, Aggregate)
function p.PropertiesOnTree(Property, Depth, Aggregate, SkipItem)
local CurrentItem = mw.wikibase.getEntity()
local CurrentItem = mw.wikibase.getEntity()
local InstanceItem = nil
local InstanceItem = nil
Riga 93: Riga 94:
if Depth > 3 then
if Depth > 3 then
Depth = 3
Depth = 3
end
if SkipItem == nil then
SkipItem = false
end
end
Riga 117: Riga 121:
end]=]
end]=]
for _, Item in pairs({CurrentItem, InstanceItem, InstanceInstanceItem}) do
local QList = {}
if SkipItem then
QList = {InstanceItem, InstanceInstanceItem}
else
QList = {CurrentItem, InstanceItem, InstanceInstanceItem}
end
--for _, Item in pairs({CurrentItem, InstanceItem, InstanceInstanceItem}) do
for _, Item in pairs(QList) do
--ResultsArray[#ResultsArray + 1] = "For - " .. Item.id  
--ResultsArray[#ResultsArray + 1] = "For - " .. Item.id  
if Item ~= nil and Item.claims[Property] then
if Item ~= nil and Item.claims[Property] then