Изменения
Перейти к навигации
Перейти к поиску
Строка 33:
Строка 33:
− end
−
− local function getTimeBoundariesFromProperty( context, propertyId )
− local dateClaims = WDS.filter( context.entity.claims, propertyId );
− if not dateClaims or #dateClaims == 0 then
− return nil;
− end
−
− -- only support exact date so far, but need improvment
− local left = nil;
− local right = nil;
− for _, claim in pairs( dateClaims ) do
− if not claim.mainsnak then return nil; end
− local boundaries = context.parseTimeBoundariesFromSnak( claim.mainsnak );
− if not boundaries then return nil; end
− left = min( left, boundaries[ 1 ] );
− right = max( right, boundaries[ 2 ] );
− end
−
− if not left or not right then return nil; end
−
− return { left, right };
− end
−
− local function getTimeBoundariesFromProperties( context, propertyIds )
− for _, propertyId in ipairs( propertyIds ) do
− local result = getTimeBoundariesFromProperty( context, propertyId );
− if result then
− return result;
− end
− end
−
− return nil;
Строка 149:
Строка 116:
− +
Строка 461:
Строка 428:
− +
− +
Строка 523:
Строка 490:
− if not entityId then +
− return nil;
− end
− if (type(entityId) ~= 'string') then error('incorrect type of entityId argument'); end;
−
− local label = nil;
−
− -- name from properties
− local results = context.getPropertyInBoundaries( context, entityId, boundaries,
− historicNamesProperties, historicNamesPropertySelectors);
−
− for r, result in pairs( results ) do
− if result.datavalue and
− result.datavalue.value and
− result.datavalue.value.text
− then
− label = result.datavalue.value.text;
− break;
− end
− end
−
− -- name from label
− if label == nil then
− label = mw.wikibase.getLabel( entityId );
− end
−
− return label;
Строка 663:
Строка 604:
− +
Строка 673:
Строка 614:
− +
fix
return prev;
return prev;
end
end
end
end
local boundaries = nil;
local boundaries = nil;
if actualDateBoundariesProperties ~= nil then
if actualDateBoundariesProperties ~= nil then
boundaries = getTimeBoundariesFromProperties( context, actualDateBoundariesProperties );
boundaries = context.getTimeBoundariesFromProperties( context, actualDateBoundariesProperties );
if (boundaries == nil) and (property == 'P131' or property == 'P159') then
if (boundaries == nil) and (property == 'P131' or property == 'P159') then
boundaries = {os.time() * 1000, os.time() * 1000};
boundaries = {os.time() * 1000, os.time() * 1000};
result = result .. context.formatRefs( options, statement );
result = result .. context.formatRefs( options, statement );
end
end
if categorizeByPlace then
if not options.nocat and options.nocat ~= '' and categorizeByPlace then
if property == 'P19' then result = result .. getCategory( 'P1464', entriesToLookupCategory ); end
if property == 'P19' then result = result .. getCategory( 'P1464', entriesToLookupCategory ); end
if property == 'P20' then result = result .. getCategory( 'P1465', entriesToLookupCategory ); end
if property == 'P20' then result = result .. getCategory( 'P1465', entriesToLookupCategory ); end
-- get current of historic name of place
-- get current of historic name of place
function getLabel( context, entityId, boundaries )
function getLabel( context, entityId, boundaries )
return context.getLabelWithLang( context, {}, entityId, boundaries, historicNamesProperties, historicNamesPropertySelectors )
end
end
local countryEntityId = statement.mainsnak.datavalue.value.id;
local countryEntityId = statement.mainsnak.datavalue.value.id;
local endDateTimestamp = calculateEndDateTimestamp( context, options, statement );
local endDateTimestamp = calculateEndDateTimestamp( context, options, statement );
local boundaries = getTimeBoundariesFromProperties( context, {'P570', 'P577', 'P571'} );
local boundaries = context.getTimeBoundariesFromProperties( context, {'P570', 'P577', 'P571'} );
if deleteTwinAncestors( countryEntityId, string.upper(options.property), options.entity.id ) then
if deleteTwinAncestors( countryEntityId, string.upper(options.property), options.entity.id ) then
local flag = Flags.getFlag( context, countryEntityId, endDateTimestamp );
local flag = Flags.getFlag( context, countryEntityId, endDateTimestamp );
if flag then
if not options.noflag and options.noflag ~= '' and flag then
return flag .. ' <span class="country-name">' ..
return flag .. ' <span class="country-name">' ..
context.formatStatementDefault( context, countryOptions, statement ) ..
context.formatStatementDefault( context, countryOptions, statement ) ..