יחידה:LocationAndCountry: הבדלים בין גרסאות בדף

מאין תקציר עריכה
מ גרסה אחת של הדף wikipedia:he:יחידה:LocationAndCountry יובאה
 
(6 גרסאות ביניים של 3 משתמשים אינן מוצגות)
שורה 118: שורה 118:


if timestamp then
if timestamp then
if before and HeDateUtils.le(timestamp, before) then --the claim list is sorted by before
if after == nil and before and not HeDateUtils.le(timestamp, before) then
break
elseif after == nil and before and not HeDateUtils.le(timestamp, before) then
table.insert(bestClaims, eachPropClaim)
table.insert(bestClaims, eachPropClaim)
elseif after and before and not HeDateUtils.le(timestamp, before) and HeDateUtils.le(timestamp, after)  then  
elseif after and before and not HeDateUtils.le(timestamp, before) and HeDateUtils.le(timestamp, after)  then  
שורה 159: שורה 157:
local claims = nil
local claims = nil
local workingEntityId = nil
local workingEntityId = nil
local countryProperty = 'P17'
local administrativeUnitProperty = 'P131'
if type(entity) == 'table' then
if type(entity) == 'table' then
workingEntityId = entity.id
workingEntityId = entity.id
שורה 183: שורה 183:
--attempt to also load administrative unit, but only if present as a qualifier
--attempt to also load administrative unit, but only if present as a qualifier
local unitQualifier = actualClaim.qualifiers and actualClaim.qualifiers['P131'] and actualClaim.qualifiers['P131'][1]
local unitQualifier = actualClaim.qualifiers and actualClaim.qualifiers[administrativeUnitProperty] and actualClaim.qualifiers[administrativeUnitProperty][1]
if unitQualifier and unitQualifier.snaktype == 'value' then
if unitQualifier and unitQualifier.snaktype == 'value' then
table.insert(locationEntitiesIds, unitQualifier.datavalue.value.id)
table.insert(locationEntitiesIds, unitQualifier.datavalue.value.id)
שורה 190: שורה 190:
-- attempt to identify country in the qualifier first, but if it's not, go to the entity
-- attempt to identify country in the qualifier first, but if it's not, go to the entity
local countryQualifier = actualClaim.qualifiers and actualClaim.qualifiers['P17'] and actualClaim.qualifiers['P17'][1]
local countryQualifier = actualClaim.qualifiers and actualClaim.qualifiers[countryProperty] and actualClaim.qualifiers[countryProperty][1]
local countryId = nil
local countryId = nil
local ts = nil
local ts = nil
שורה 220: שורה 220:
end
end
countryClaim = findClaimForTimestamp(locationEntityId, 'P17', ts)
countryClaim = findClaimForTimestamp(locationEntityId, countryProperty, ts)
if countryClaim and countryClaim.mainsnak and countryClaim.mainsnak.snaktype == 'value' then
if countryClaim and countryClaim.mainsnak and countryClaim.mainsnak.snaktype == 'value' then
countryId = countryClaim.mainsnak.datavalue.value.id
countryId = countryClaim.mainsnak.datavalue.value.id
שורה 247: שורה 247:
]]
]]
end
end
 
-- don't show in case of missing label
if not missingEntityLabel then
if not missingEntityLabel then
table.insert(locationNamesList, locationNames[eachLocationId])
table.insert(locationNamesList, locationNames[eachLocationId])