There are no reviewed versions of this page, so it may not have been checked for adherence to standards.

Documentation for this module may be created at Module:HenkvD/doc

local p = {}

function p.test( )
    local t = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11 }
          t[3] = { 3.1, 3.2, 3.3 }
          t[0] = 0
          t [ 'p123' ] = 123
    local indent = ""
    return  tabel ( t , indent )
end

-- examples for parameters for displaysnaks:
-- (nothing for the full table)
-- claims       or claims|p225
-- labels       or labels|de
-- aliases      or aliases|de
-- descriptions or descriptions|de
-- sitelinks    or sitelinks|dewiki
-- id
-- type
-- title ?

function p.displaysnaks(frame )
    local v1=frame.args[1] if v1==nil then v1='' end
    local v2=frame.args[2] if v2==nil then v2='' end
    local v3=frame.args[3] if v3==nil then v3='' end -- etc
    local indent = ""
    local entity = mw.wikibase.getEntityObject()
    if      v1== '' then return tabel ( entity,              indent )
    elseif  v2== '' then return tabel ( entity[v1] ,         indent )
    elseif  v3== '' then return tabel ( entity[v1][v2] ,     indent )
    else                 return tabel ( entity[v1][v2][v3] , indent )
    end
end
    
function tabel ( t , indent )
    local result = "" 
    if type (t) ~= "table" then
        return t
    end
    for i,v in pairs(t) do
        if t[i] then
            if type ( t[i] ) == "table" then
                result = result .. "<br>" .. indent .. "&lt;" .. i .. "&gt;"
                result = result .. tabel ( t[i], indent .. "&nbsp;&nbsp;&nbsp;" ) 
                result = result .. "<br>" .. indent .. "&lt;/" .. i .. "&gt;"
            else
                result = result .. "<br>" .. indent .. "&lt;" .. i .. "&gt;" .. t[i] .. "&lt;/" .. i .. "&gt;"
            end
        end
    end
    return result
end

function p.NumberOfClaims(frame) 
    entity = mw.wikibase.getEntity()
    if not entity then return nil end
    if not entity.claims then return nil end
    local count = 0
    for _ in pairs(entity.claims) do count = count + 1 end
    return count
end

function p.NumberOfClaimsPerProperty(frame) 
    property=string.lower(frame.args[1])
    entity = mw.wikibase.getEntity()
    if not entity then return nil end
    if not entity.claims then return nil end
    if not entity.claims[property] then return nil end
    local count = 0
    for _ in pairs(entity.claims[property]) do count = count + 1 end
    return count
end

return p