Modul:Wikidata/Population: Redaktələr arasındakı fərq
Silinən məzmun Əlavə edilmiş məzmun
Səhifə "local WDS = require('Module:WikidataSelectors'); local p = {}; local DEFAULT_COLUMNS = 4; local DEFAULT_WIDTH = 700; local DEFAULT_HEIGHT = 300; local COLLA..." məzmunu ilə yaradıldı |
yeniləmə Teq: Geri qaytarıldı |
||
Sətir 1:
local WDS = require('
local p = {};
Sətir 34:
local claims = context.selectClaims( options, options.property );
if (claims == nil) then
return nil
end
for i, j in ipairs(claims) do
if ( not j.qualifiers.P585[1]) then return nil end
end
Sətir 54:
local claims = formatPopulationPropertyImpl( context, options );
local formattedClaims = {}
local years = {}
local count = 0;
Sətir 74 ⟶ 75:
p585Time = mw.ustring.gsub(p585Time, "\-[0-9]+\-[0-9]+T", "-07-01T");
end
local year, month, day = mw.ustring.gmatch( p585Time, "(\-?[0-9]+)\-([0-9]+)\-([0-9]+)T" )(1);
local value = string.gsub( claim.mainsnak.datavalue.value.amount, '^%+', '' );▼
if not years[ year ] then
years[ year ] = true;
local value
local line = year .. ',' .. month .. ',' .. day .. ',' .. value;▼
if not claim.mainsnak.datavalue then value = ""
csv = csv .. '\\n' .. line;▼
count = count + 1;▼
▲ local line = year .. ',' .. month .. ',' .. day .. ',' .. value;
▲ csv = csv .. '\\n' .. line;
▲ count = count + 1;
end
end
Sətir 126 ⟶ 133:
local claims = formatPopulationPropertyImpl( context, options );
local formattedClaims = {}
local years = {}
local firstTime = false;
Sətir 136 ⟶ 144:
end
for i, claim in ipairs( claims ) do
-- обрезаем выводимую дату до года
local timeQualifier = claim.qualifiers.P585[1];
if ( timeQualifier.datavalue.value.precision > 9 ) then
timeQualifier = deepcopy( timeQualifier );
timeQualifier.datavalue.value.precision = 9;
end
local year = string.sub( timeQualifier.datavalue.value.time, 2, 5 );
if not years[ year ] then
years[ year ] = true;
local time = context.formatSnak( options, timeQualifier );
local value = context.formatSnak( options, claim.mainsnak );
if ( not firstTime ) then firstTime = time end;
lastTime = time;
local line = '\n|-\n! ' .. time
line = line .. '\n| style="text-align: right; border-right: none; padding-right: 0;" | ' .. ( value or "" );
line = line .. '\n| style="text-align: left; border-left: none; padding-left: 0;" | '
if options.references then line = line .. context.formatRefs( options, claim ); end▼
count = count + 1;
end
end
Sətir 178 ⟶ 194:
out = out .. '{| class="collapsible collapsed" |\n';
out = out .. '!
out = out .. '|-\n';
out = out .. '| class="ts-wikidata-population-table" |';
else
out = out .. '
end
for i, formattedClaim in ipairs(formattedClaims) do
if ( i % perColumn == 1 ) then
out = out .. '
end
out = out .. '\n' .. formattedClaim;
Sətir 196 ⟶ 213:
out = out .. '\n|}';
end
if ( perColumn > COLLAPSE_IF_ROWS_MORE_THAN ) then
else
out = out .. '\n</div>';
end
return out
▲end
end
|