Modulo:Wikidata: differenze tra le versioni
Contenuto cancellato Contenuto aggiunto
così il rank funziona anche in combinazione del parametro n= |
aggiunta funzione getStatementByRank, semplificata gestione rank |
||
Riga 32:
end
return prefix .. value['numeric-id']
-- Ritorna l'n-esimo statement con il rank richiesto, oppure nil se non trovato
function getStatementByRank(claims, n, rank)
local currPos = 1
for i = 0, #claims do
if currPos == n then
currPos = currPos + 1
end
return statement
end
Riga 38 ⟶ 56:
end
function formatStatements( options ) ▼
▲function formatStatements( options )
if not options.property then
return formatError( 'property-param-not-provided' )
end
--Get entity
Riga 50 ⟶ 69:
end
if (entity.claims == nil) or (not entity.claims[
return '' --TODO error?
end
Riga 71 ⟶ 90:
if options.n then
local n = tonumber( options.n )
local statement = options.rank and
getStatementByRank( entity.claims[property], n, options.rank ) or
entity.claims[property][n - 1]
▲ if statement then
▲ if statement.rank == options.rank then
else▼
▲ else
▲ local statement = entity.claims[property][n - 1]
▲ if statement then
▲ table.insert( formattedStatements, formatStatement( statement, options ) )
▲ end
end
end
for i, statement in pairs( entity.claims[
end
end
▲ else
▲ for i, statement in pairs( entity.claims[string.lower(options.property)] ) do
▲ end
end
if list_end then table.insert( formattedStatements, list_end ) end
return mw.text.listToText( formattedStatements, options.separator, options.conjunction )
end
|