Modulo:Wikidata: differenze tra le versioni
Contenuto cancellato Contenuto aggiunto
traduzione |
m from http://test2.wikipedia.org/wiki/Module:Wikidata |
||
Riga 21:
return mw.wikibase.getEntity()
end
function getEntityIdFromValue( value )
local prefix = ''
Riga 33:
return prefix .. value['numeric-id']
end
function formatError( key )
return '<span class="error">' .. i18n.errors[key] .. '</span>'
end
function formatStatements( options )
if not options.property then
return formatError( 'property-param-not-provided' )
end
--Get entity
local entity = getEntityFromId( options.entityId )
Riga 49:
return formatError( 'entity-not-found' )
end
if (entity.claims == nil) or (not entity.claims[options.property]) then
return '' --TODO error?
end
--Format statement and concat them cleanly
local formattedStatements = {}
Riga 61:
return mw.text.listToText( formattedStatements, options.separator, options.conjunction )
end
function formatStatement( statement, options )
if not statement.type or statement.type ~= 'statement' then
return formatError( 'unknown-claim-type' )
end
return formatSnak( statement.mainsnak, options )
--TODO reference and qualifiers
end
function formatSnak( snak, options )
if snak.snaktype == 'somevalue' then
Riga 82:
end
end
function formatDatavalue( datavalue, options )
--Use the customize handler if provided
Riga 99:
return fun( datavalue.value, options )
end
--Default formatters
if datavalue.type == 'wikibase-entityid' then
Riga 109:
end
end
function formatEntityId( entityId, options )
local label = mw.wikibase.label( entityId )
Riga 123:
end
end
local p = {}
function p.formatStatements( frame )
local args = frame.args
--If a value if already set, use it
if args.value and args.value ~= '' then
Riga 135:
return formatStatements( frame.args )
end
return p
|