<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="fr">
	<id>https://dansunegalaxie.ca/index.php?action=history&amp;feed=atom&amp;title=Module%3AAdresse</id>
	<title>Module:Adresse - Historique des versions</title>
	<link rel="self" type="application/atom+xml" href="https://dansunegalaxie.ca/index.php?action=history&amp;feed=atom&amp;title=Module%3AAdresse"/>
	<link rel="alternate" type="text/html" href="https://dansunegalaxie.ca/index.php?title=Module:Adresse&amp;action=history"/>
	<updated>2026-04-05T11:44:59Z</updated>
	<subtitle>Historique des versions pour cette page sur le wiki</subtitle>
	<generator>MediaWiki 1.40.1</generator>
	<entry>
		<id>https://dansunegalaxie.ca/index.php?title=Module:Adresse&amp;diff=211&amp;oldid=prev</id>
		<title>Yuki : 1 version importée : Infobox</title>
		<link rel="alternate" type="text/html" href="https://dansunegalaxie.ca/index.php?title=Module:Adresse&amp;diff=211&amp;oldid=prev"/>
		<updated>2023-11-15T07:11:17Z</updated>

		<summary type="html">&lt;p&gt;1 version importée : Infobox&lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;fr&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Version précédente&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Version du 15 novembre 2023 à 03:11&lt;/td&gt;
				&lt;/tr&gt;
&lt;!-- diff cache key dugwiki:diff::1.12:old-210:rev-211 --&gt;
&lt;/table&gt;</summary>
		<author><name>Yuki</name></author>
	</entry>
	<entry>
		<id>https://dansunegalaxie.ca/index.php?title=Module:Adresse&amp;diff=210&amp;oldid=prev</id>
		<title>wikipedia&gt;GrandEscogriffe : deuxième résultat de fullAddress : variable booléenne indiquant si il existe un l&#039;igne d&#039; &quot;adresse&quot; proprement dite (rue)</title>
		<link rel="alternate" type="text/html" href="https://dansunegalaxie.ca/index.php?title=Module:Adresse&amp;diff=210&amp;oldid=prev"/>
		<updated>2023-07-04T23:22:28Z</updated>

		<summary type="html">&lt;p&gt;deuxième résultat de fullAddress : variable booléenne indiquant si il existe un l&amp;#039;igne d&amp;#039; &amp;quot;adresse&amp;quot; proprement dite (rue)&lt;/p&gt;
&lt;p&gt;&lt;b&gt;Nouvelle page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;local formats = require &amp;quot;Module:Adresse/Formats&amp;quot;&lt;br /&gt;
&lt;br /&gt;
local p = {}&lt;br /&gt;
local wikidata = require &amp;quot;Module:Wikidata&amp;quot;&lt;br /&gt;
local linguistic = require &amp;quot;Module:Linguistique&amp;quot;&lt;br /&gt;
local countrymodule = require &amp;quot;Module:Country data&amp;quot;&lt;br /&gt;
&lt;br /&gt;
local function getCountry(item) -- get country id for formatting&lt;br /&gt;
	local country = wikidata.getIds(item, {property = &amp;quot;P17&amp;quot;})&lt;br /&gt;
	if (not country) then&lt;br /&gt;
		return nil&lt;br /&gt;
	end&lt;br /&gt;
	if #country &amp;gt; 1 then&lt;br /&gt;
		return nil&lt;br /&gt;
	end&lt;br /&gt;
	return country[1] &lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
local function numberFromClaim(claim) -- récupère le numéro de l&amp;#039;immeuble à partir d&amp;#039;un qualificatif P670 d&amp;#039;une affirmation Wikidata&lt;br /&gt;
	if not claim.qualifiers or not claim.qualifiers.P670 then&lt;br /&gt;
		return nil&lt;br /&gt;
	end&lt;br /&gt;
	local vals = {}&lt;br /&gt;
	for i, j in pairs(claim.qualifiers.P670) do&lt;br /&gt;
		table.insert(vals, wikidata.formatSnak(j))&lt;br /&gt;
	end&lt;br /&gt;
	return table.concat(vals, &amp;#039;-&amp;#039;)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
local function directionFromClaim(claim, area) -- par exemple rue Sherbrooke Ouest&lt;br /&gt;
	if not claim.qualifiers or not claim.qualifiers.P560 then&lt;br /&gt;
		return nil&lt;br /&gt;
	end&lt;br /&gt;
	local str = &amp;#039;&amp;#039;&lt;br /&gt;
	for i, snak in pairs(claim.qualifiers.P560) do&lt;br /&gt;
		local directionlabels = area.directions or formats.default.directions&lt;br /&gt;
		str = str .. wikidata.formatSnak(snak,  {speciallabels = directionlabels})&lt;br /&gt;
	end&lt;br /&gt;
	return str&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
local function streetFromClaims(claim) -- réupère le nom de la rue à partir d&amp;#039;une affirmation P669 Wikidata&lt;br /&gt;
	return wikidata.formatStatement(claim)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
local function formatStreet(streetname, housenumber, direction, displayformat)&lt;br /&gt;
	local val = displayformat.streetline or formats.default.streetline&lt;br /&gt;
	val = mw.ustring.gsub(val, &amp;#039;$number&amp;#039;, housenumber or &amp;#039;&amp;#039;)&lt;br /&gt;
	val = mw.ustring.gsub(val, &amp;#039;$street&amp;#039;, streetname or &amp;#039;&amp;#039;)&lt;br /&gt;
	val = mw.ustring.gsub(val, &amp;#039;$direction&amp;#039;, direction or &amp;#039;&amp;#039;)&lt;br /&gt;
	return val&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
local function wikidatastreet(claim, area) --formate des données sur la rue à partir d&amp;#039;une affirmation Wikidata&lt;br /&gt;
	local streetname = streetFromClaims(claim, area)&lt;br /&gt;
	local housenumber =  numberFromClaim(claim, area)&lt;br /&gt;
	local direction = directionFromClaim(claim, area)&lt;br /&gt;
	return formatStreet(streetname, housenumber, direction, area)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function p.streetAddress(item, area) -- formate la ligne concernant la rue et le numéro de rue&lt;br /&gt;
	local streets -- châine contenant le ou les rues et numéros d&amp;#039;immeuble&lt;br /&gt;
	&lt;br /&gt;
	if not area then&lt;br /&gt;
		local country = getCountry(item)&lt;br /&gt;
		if country and formats[country] then&lt;br /&gt;
			area = formats[country]&lt;br /&gt;
		else&lt;br /&gt;
			area = formats.default&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
	&lt;br /&gt;
	-- essaye de remplir street, en priorité avec P669, type : élément&lt;br /&gt;
	local streetclaims = wikidata.getClaims{entity = item, property = &amp;#039;P669&amp;#039;}&lt;br /&gt;
	if streetclaims then&lt;br /&gt;
		for i, j in pairs(streetclaims) do&lt;br /&gt;
			streetclaims[i] = wikidatastreet(j, area)&lt;br /&gt;
		end&lt;br /&gt;
		streets = mw.text.listToText(streetclaims)&lt;br /&gt;
		streets = wikidata.formatAndCat{value = streets, entity = item, property = &amp;#039;P669&amp;#039;}&lt;br /&gt;
	end&lt;br /&gt;
	&lt;br /&gt;
	-- sinon : P6375, type : string -- remplace P969&lt;br /&gt;
	if not streets then&lt;br /&gt;
		streets = wikidata.formatAndCat{linkback = true, property = &amp;#039;P6375&amp;#039;, entity = item, isinlang = &amp;#039;fr&amp;#039;}&lt;br /&gt;
	end&lt;br /&gt;
	&lt;br /&gt;
	-- sinon : P969, type : string -- propriété obsolète&lt;br /&gt;
	if not streets then &lt;br /&gt;
		streets =  wikidata.formatAndCat{linkback = true, property = &amp;#039;P969&amp;#039;, entity = item}&lt;br /&gt;
	end&lt;br /&gt;
	&lt;br /&gt;
	return streets&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function p.adminDivList(item, country) -- returns a list of admin divisions matching the criteria defined in Module:Adresse/Formats&lt;br /&gt;
	country = country or getCountry(item)&lt;br /&gt;
	local query = {property = &amp;#039;P131&amp;#039;}&lt;br /&gt;
	local divs = wikidata.transitiveVals(item, query, 0, 10, country)&lt;br /&gt;
	local validDivs = {}	&lt;br /&gt;
	&lt;br /&gt;
	-- solution 1: looks for divs of a certain type&lt;br /&gt;
	local function setValue(targetclasses, depth)&lt;br /&gt;
		local test = {}&lt;br /&gt;
		for _, d in pairs(divs) do&lt;br /&gt;
			for j, divtype in pairs(targetclasses) do&lt;br /&gt;
				if (divtype == &amp;#039;-&amp;#039;) then&lt;br /&gt;
					if #validDivs &amp;gt; 0 then&lt;br /&gt;
						divs = wikidata.addVals(divs, query, 0, 1, country)&lt;br /&gt;
					end&lt;br /&gt;
					if divs[#divs] == country then&lt;br /&gt;
						return nil&lt;br /&gt;
					end&lt;br /&gt;
					return divs[#divs]&lt;br /&gt;
				end&lt;br /&gt;
				if wikidata.isInstance(divtype, d, 3) then&lt;br /&gt;
					 -- restrain list to new value, will be expanded only if needed&lt;br /&gt;
					divs = {d}&lt;br /&gt;
					return d&lt;br /&gt;
				end&lt;br /&gt;
			end&lt;br /&gt;
		end&lt;br /&gt;
		if depth &amp;gt;= 0 then&lt;br /&gt;
			local num = #divs&lt;br /&gt;
			divs = wikidata.addVals(divs, query, 0, 10, country)&lt;br /&gt;
			if #divs &amp;gt; num then return setValue(targetclasses, depth) end&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	-- solution2: looks for divs that are part of a closed list (way more efficient for big items)&lt;br /&gt;
	local function findInList(list, depth) &lt;br /&gt;
		for i, j in pairs(divs) do&lt;br /&gt;
			for k, l in pairs(list) do&lt;br /&gt;
				if j == l then&lt;br /&gt;
					divs = {l}&lt;br /&gt;
					return l&lt;br /&gt;
				end&lt;br /&gt;
			end&lt;br /&gt;
		end&lt;br /&gt;
		if depth &amp;gt;= 0 then&lt;br /&gt;
			local num = #divs&lt;br /&gt;
			divs = wikidata.addVals(divs, query, 0, 10, country)&lt;br /&gt;
			if #divs &amp;gt; num then return findInList(list, depth) end&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
					&lt;br /&gt;
	local displayformat = formats[country] or formats.default&lt;br /&gt;
	local maxdepth = 3&lt;br /&gt;
	if not divs then&lt;br /&gt;
		return nil&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	if displayformat.div1 then&lt;br /&gt;
		local val = setValue(displayformat.div1, maxdepth)&lt;br /&gt;
		if val and val ~= validDivs[#validDivs] then&lt;br /&gt;
			table.insert(validDivs, val)&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	if displayformat.div2 then&lt;br /&gt;
		local val = setValue(displayformat.div2, maxdepth)&lt;br /&gt;
		if val and val ~= validDivs[#validDivs] then&lt;br /&gt;
			table.insert(validDivs, val)&lt;br /&gt;
		end&lt;br /&gt;
	elseif displayformat.div2vals then&lt;br /&gt;
		local val =  findInList(displayformat.div2vals, 1)&lt;br /&gt;
		if val and val ~= validDivs[#validDivs] then&lt;br /&gt;
			table.insert(validDivs, val)&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
	&lt;br /&gt;
	if displayformat.div3 then&lt;br /&gt;
		local val = setValue(displayformat.div3, maxdepth)&lt;br /&gt;
		if val and val ~= validDivs[#validDivs] then&lt;br /&gt;
			table.insert(validDivs, val)&lt;br /&gt;
		end&lt;br /&gt;
	elseif displayformat.div3vals then&lt;br /&gt;
		local val =  findInList(displayformat.div3vals, 0)&lt;br /&gt;
		if val and val ~= validDivs[#validDivs] then&lt;br /&gt;
			table.insert(validDivs, val)&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
	&lt;br /&gt;
	return validDivs&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function p.cityLine(item, country, divlist, postcode) -- line with list of admin divisions + optional postcode&lt;br /&gt;
	country = country or getCountry(item)&lt;br /&gt;
	&lt;br /&gt;
	local postcode = postcode or wikidata.formatStatements{entity = item, property = &amp;#039;P281&amp;#039;} or &amp;#039;&amp;#039;&lt;br /&gt;
	if postcode == &amp;#039;-&amp;#039; then -- can be disabled when it is not useful&lt;br /&gt;
		postcode = &amp;#039;&amp;#039;&lt;br /&gt;
	end&lt;br /&gt;
	local divstr = &amp;#039;&amp;#039;&lt;br /&gt;
	&lt;br /&gt;
	if (not divlist) or (#divlist == 0) then&lt;br /&gt;
		divlist = p.adminDivList(item, country)&lt;br /&gt;
	end&lt;br /&gt;
	if (not divlist) or (#divlist == 0) then&lt;br /&gt;
		return -- add a maintenance category ?&lt;br /&gt;
	end&lt;br /&gt;
	for i, j in pairs(divlist) do&lt;br /&gt;
		if string.find(j, &amp;#039;^Q[0-9]+$&amp;#039;) then&lt;br /&gt;
			divlist[i] = wikidata.formatEntity(j)&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
	local divstr = linguistic.conj(divlist, &amp;#039;comma&amp;#039;)&lt;br /&gt;
&lt;br /&gt;
	local formatting = formats[country] or formats.default&lt;br /&gt;
	local str = formatting.cityline or formats.default.cityline&lt;br /&gt;
	str = str:gsub(&amp;quot;$postcode&amp;quot;, postcode or &amp;#039;&amp;#039;)&lt;br /&gt;
	str = str:gsub(&amp;quot;$admindivs&amp;quot;, divstr or &amp;#039;&amp;#039;)&lt;br /&gt;
	return str&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function p.fullAddress(item, country, divs, streetstr, divstr, showcountry, postcode)&lt;br /&gt;
	 -- country id used for formatting&lt;br /&gt;
	country = country or getCountry(item)&lt;br /&gt;
	local displayformat = formats[country] or formats.default&lt;br /&gt;
&lt;br /&gt;
	-- line 1 street&lt;br /&gt;
	local streetline = streetstr or p.streetAddress(item, country)&lt;br /&gt;
	&lt;br /&gt;
	-- line 2: administrative divisions, postcodes&lt;br /&gt;
	local cityline = divstr&lt;br /&gt;
	if not cityline then&lt;br /&gt;
		local partiallylocated = wikidata.formatAndCat{entity = item, property = {&amp;#039;P3179&amp;#039;, &amp;#039;P1382&amp;#039;}} -- pour les grandes entités &lt;br /&gt;
		cityline = p.cityLine(item, country, divs, postcode)&lt;br /&gt;
		cityline = linguistic.conj({ partiallylocated, cityline}, &amp;#039;new line&amp;#039;)&lt;br /&gt;
	end&lt;br /&gt;
	if (not cityline) or mw.text.trim(cityline) == &amp;#039;&amp;#039; then&lt;br /&gt;
		cityline = nil&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	-- line 3: country&lt;br /&gt;
	local countryline, success&lt;br /&gt;
	if (showcountry ~= &amp;#039;-&amp;#039;) then&lt;br /&gt;
		countryline, success = countrymodule.standarddisplay(country)&lt;br /&gt;
		if not success then&lt;br /&gt;
			if (type(country) == &amp;#039;string&amp;#039;) and string.find(country, &amp;quot;^Q[0-9]+$&amp;quot;) then&lt;br /&gt;
				countryline = wikidata.formatEntity(country)&lt;br /&gt;
			else&lt;br /&gt;
				countryline = country or wikidata.formatStatements{entity = item, property = &amp;#039;P17&amp;#039;}&lt;br /&gt;
			end&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
	local str = linguistic.conj({streetline, cityline, countryline}, &amp;#039;&amp;lt;br /&amp;gt;&amp;#039;)&lt;br /&gt;
	if str and (not streetstr) and (not divstr) then -- à peu près&lt;br /&gt;
		str = str .. &amp;#039;[[Category:Page utilisant une adresse fournie par Wikidata]]&amp;#039;&lt;br /&gt;
	end&lt;br /&gt;
	&lt;br /&gt;
	local hasstreetline&lt;br /&gt;
	if streetline then hasstreetline = true else hasstreetline = false end&lt;br /&gt;
&lt;br /&gt;
	return str, hasstreetline&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function p.wikidataAddress(item, country) -- fonction de transition&lt;br /&gt;
	local area = formats[country] or formats.default&lt;br /&gt;
	local val = p.streetAddress(item, area)&lt;br /&gt;
	if val then&lt;br /&gt;
		return val .. &amp;#039;[[Category:Page utilisant une adresse fournie par Wikidata]]&amp;#039;&lt;br /&gt;
	end&lt;br /&gt;
end&lt;br /&gt;
return p&lt;/div&gt;</summary>
		<author><name>wikipedia&gt;GrandEscogriffe</name></author>
	</entry>
</feed>