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('ModuleModul:WikidataSelectors');
 
local p = {};
Sətir 34:
local claims = context.selectClaims( options, options.property );
if (claims == nil) then
return nil --TODO error?
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;
local else value = string.gsub( claim.mainsnak.datavalue.value.amount, '^%+', '' ); end
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
table.insert( formattedClaims, line )
counttable.insert( =formattedClaims, countline + 1;)
count = count + 1;
end
end
 
Sətir 178 ⟶ 194:
 
out = out .. '{| class="collapsible collapsed" |\n';
out = out .. '! colspan=' .. columns .. ' | ' .. caption .. '\n';
out = out .. '|-\n';
out = out .. '| class="ts-wikidata-population-table" |';
else
out = out .. '{|<div styleclass="display: inlinets-block; verticalwikidata-align: bottom;population-table" cellpadding=5 |>';
end
 
for i, formattedClaim in ipairs(formattedClaims) do
if ( i % perColumn == 1 ) then
out = out .. '\n| align="center" valign="top" | \n{| class="wikitable" \n|-\n! ' .. TABLE_COLUMN_HEADER_YEAR .. ' !! colspan=2 | ' .. TABLE_COLUMN_HEADER_POPULATION .. '\n|-';
end
out = out .. '\n' .. formattedClaim;
Sətir 196 ⟶ 213:
out = out .. '\n|}';
end
if ( perColumn > COLLAPSE_IF_ROWS_MORE_THAN ) then
out = out .. '\n|}';
else
out = out .. '\n</div>';
end
return out
end
 
function p.formatPopulationClaimForTable( context, options, statement )
return '';
end