From 6ad75f5b41dcf61eb1b49d5eb403563df11e1bb4 Mon Sep 17 00:00:00 2001
From: Hypolite Petovan <hypolite@mrpetovan.com>
Date: Wed, 9 Sep 2020 01:21:56 -0400
Subject: [PATCH] Remove over-specific location fields from vcard in favor of
 "location"

---
 src/Model/Profile.php                            | 12 +-----------
 view/templates/profile/vcard.tpl                 | 16 ++++++----------
 .../duepuntozero/templates/profile/vcard.tpl     | 16 ++++++----------
 view/theme/frio/templates/profile/vcard.tpl      |  9 ++-------
 view/theme/quattro/templates/profile/vcard.tpl   | 16 ++++++----------
 view/theme/smoothly/style.css                    |  5 -----
 view/theme/vier/templates/profile/vcard.tpl      | 16 ++++++----------
 7 files changed, 27 insertions(+), 63 deletions(-)

diff --git a/src/Model/Profile.php b/src/Model/Profile.php
index 3cd3afe6cb..0ed393022b 100644
--- a/src/Model/Profile.php
+++ b/src/Model/Profile.php
@@ -354,13 +354,7 @@ class Profile
 		// Fetch the account type
 		$account_type = Contact::getAccountType($profile);
 
-		if (!empty($profile['address'])
-			|| !empty($profile['location'])
-			|| !empty($profile['locality'])
-			|| !empty($profile['region'])
-			|| !empty($profile['postal-code'])
-			|| !empty($profile['country-name'])
-		) {
+		if (!empty($profile['address'])	|| !empty($profile['location'])) {
 			$location = DI::l10n()->t('Location:');
 		}
 
@@ -427,10 +421,6 @@ class Profile
 			$p['about'] = BBCode::convert($p['about']);
 		}
 
-		if (empty($p['address']) && !empty($p['location'])) {
-			$p['address'] = $p['location'];
-		}
-
 		if (isset($p['address'])) {
 			$p['address'] = BBCode::convert($p['address']);
 		}
diff --git a/view/templates/profile/vcard.tpl b/view/templates/profile/vcard.tpl
index ccf3a10bd5..c4e9ea1d15 100644
--- a/view/templates/profile/vcard.tpl
+++ b/view/templates/profile/vcard.tpl
@@ -13,16 +13,12 @@
 	{{if $account_type}}<div class="account-type">{{$account_type}}</div>{{/if}}
 	{{if $profile.network_link}}<dl class="network"><dt class="network-label">{{$network}}</dt><dd class="x-network">{{$profile.network_link nofilter}}</dd></dl>{{/if}}
 	{{if $location}}
-		<dl class="location"><dt class="location-label">{{$location}}</dt> 
-		<dd class="adr h-adr">
-			{{if $profile.address}}<div class="street-address p-street-address">{{$profile.address nofilter}}</div>{{/if}}
-			<span class="city-state-zip">
-				<span class="locality p-locality">{{$profile.locality}}</span>{{if $profile.locality}}, {{/if}}
-				<span class="region p-region">{{$profile.region}}</span>
-				<span class="postal-code p-postal-code">{{$profile.postal_code}}</span>
-			</span>
-			{{if $profile.country_name}}<span class="country-name p-country-name">{{$profile.country_name}}</span>{{/if}}
-		</dd>
+		<dl class="location">
+			<dt class="location-label">{{$location}}</dt>
+			<dd class="adr h-adr">
+				{{if $profile.address}}<p class="street-address p-street-address">{{$profile.address nofilter}}</p>{{/if}}
+				{{if $profile.location}}<p class="p-location">{{$profile.location}}</p>{{/if}}
+			</dd>
 		</dl>
 	{{/if}}
 
diff --git a/view/theme/duepuntozero/templates/profile/vcard.tpl b/view/theme/duepuntozero/templates/profile/vcard.tpl
index f40e98e464..ed6d522494 100644
--- a/view/theme/duepuntozero/templates/profile/vcard.tpl
+++ b/view/theme/duepuntozero/templates/profile/vcard.tpl
@@ -12,16 +12,12 @@
 	{{if $profile.network_link}}<dl class="network"><dt class="network-label">{{$network}}</dt><dd class="x-network">{{$profile.network_link nofilter}}</dd></dl>{{/if}}
 
 	{{if $location}}
-		<dl class="location"><dt class="location-label">{{$location}}</dt> 
-		<dd class="adr h-adr">
-			{{if $profile.address}}<div class="street-address p-street-address">{{$profile.address nofilter}}</div>{{/if}}
-			<span class="city-state-zip">
-				<span class="locality p-locality">{{$profile.locality}}</span>{{if $profile.locality}}, {{/if}}
-				<span class="region p-region">{{$profile.region}}</span>
-				<span class="postal-code p-postal-code">{{$profile.postal_code}}</span>
-			</span>
-			{{if $profile.country_name}}<span class="country-name p-country-name">{{$profile.country_name}}</span>{{/if}}
-		</dd>
+		<dl class="location">
+			<dt class="location-label">{{$location}}</dt>
+			<dd class="adr h-adr">
+				{{if $profile.address}}<p class="street-address p-street-address">{{$profile.address nofilter}}</p>{{/if}}
+				{{if $profile.location}}<p class="p-location">{{$profile.location}}</p>{{/if}}
+			</dd>
 		</dl>
 	{{/if}}
 
diff --git a/view/theme/frio/templates/profile/vcard.tpl b/view/theme/frio/templates/profile/vcard.tpl
index 550bb6265e..b1d4ada2d5 100644
--- a/view/theme/frio/templates/profile/vcard.tpl
+++ b/view/theme/frio/templates/profile/vcard.tpl
@@ -80,13 +80,8 @@
 		<div class="location detail">
 			<span class="location-label icon"><i class="fa fa-map-marker"></i></span>
 			<span class="adr">
-				{{if $profile.address}}<span class="street-address p-street-address">{{$profile.address nofilter}}</span>{{/if}}
-				<span class="city-state-zip">
-					<span class="locality p-locality">{{$profile.locality}}</span>{{if $profile.locality}}, {{/if}}
-					<span class="region p-region">{{$profile.region}}</span>
-					<span class="postal-code p-postal-code">{{$profile.postal_code}}</span>
-				</span>
-				{{if $profile.country_name}}<span class="country-name p-country-name">{{$profile.country_name}}</span>{{/if}}
+				{{if $profile.address}}<p class="street-address p-street-address">{{$profile.address nofilter}}</p>{{/if}}
+				{{if $profile.location}}<p class="p-location">{{$profile.location}}</p>{{/if}}
 			</span>
 		</div>
 		{{/if}}
diff --git a/view/theme/quattro/templates/profile/vcard.tpl b/view/theme/quattro/templates/profile/vcard.tpl
index 66422dd980..992700f108 100644
--- a/view/theme/quattro/templates/profile/vcard.tpl
+++ b/view/theme/quattro/templates/profile/vcard.tpl
@@ -24,16 +24,12 @@
 	{{if $profile.network_link}}<dl class="network"><dt class="network-label">{{$network}}</dt><dd class="x-network">{{$profile.network_link nofilter}}</dd></dl>{{/if}}
 
 	{{if $location}}
-		<dl class="location"><dt class="location-label">{{$location}}</dt> 
-		<dd class="adr h-adr">
-			{{if $profile.address}}<div class="street-address p-street-address">{{$profile.address nofilter}}</div>{{/if}}
-			<span class="city-state-zip">
-				<span class="locality p-locality">{{$profile.locality}}</span>{{if $profile.locality}}, {{/if}}
-				<span class="region p-region">{{$profile.region}}</span>
-				<span class="postal-code p-postal-code">{{$profile.postal_code}}</span>
-			</span>
-			{{if $profile.country_name}}<span class="country-name p-country-name">{{$profile.country_name}}</span>{{/if}}
-		</dd>
+		<dl class="location">
+			<dt class="location-label">{{$location}}</dt>
+			<dd class="adr h-adr">
+				{{if $profile.address}}<p class="street-address p-street-address">{{$profile.address nofilter}}</p>{{/if}}
+				{{if $profile.location}}<p class="p-location">{{$profile.location}}</p>{{/if}}
+			</dd>
 		</dl>
 	{{/if}}
 
diff --git a/view/theme/smoothly/style.css b/view/theme/smoothly/style.css
index f997f2545f..207aebbef2 100644
--- a/view/theme/smoothly/style.css
+++ b/view/theme/smoothly/style.css
@@ -4500,11 +4500,6 @@ hr.line-dots {
 #page-footer {}
 #live-profile {}
 
-.city-state-zip {}
-.country-name {}
-.locality {}
-.region {}
-.postal-code {}
 .mpfriend {}
 .toplevel_item {}
 
diff --git a/view/theme/vier/templates/profile/vcard.tpl b/view/theme/vier/templates/profile/vcard.tpl
index 5f8e718f08..06c7a0235b 100644
--- a/view/theme/vier/templates/profile/vcard.tpl
+++ b/view/theme/vier/templates/profile/vcard.tpl
@@ -20,16 +20,12 @@
 	{{if $account_type}}<div class="account-type">{{$account_type}}</div>{{/if}}
 	{{if $profile.network_link}}<dl class="network"><dt class="network-label">{{$network}}</dt><dd class="x-network">{{$profile.network_link nofilter}}</dd></dl>{{/if}}
 	{{if $location}}
-		<dl class="location"><dt class="location-label">{{$location}}</dt> 
-		<dd class="adr h-adr">
-			{{if $profile.address}}<div class="street-address p-street-address">{{$profile.address nofilter}}</div>{{/if}}
-			<span class="city-state-zip">
-				<span class="locality p-locality">{{$profile.locality}}</span>{{if $profile.locality}}, {{/if}}
-				<span class="region p-region">{{$profile.region}}</span>
-				<span class="postal-code p-postal-code">{{$profile.postal_code}}</span>
-			</span>
-			{{if $profile.country_name}}<span class="country-name p-country-name">{{$profile.country_name}}</span>{{/if}}
-		</dd>
+		<dl class="location">
+			<dt class="location-label">{{$location}}</dt>
+			<dd class="adr h-adr">
+				{{if $profile.address}}<p class="street-address p-street-address">{{$profile.address nofilter}}</p>{{/if}}
+				{{if $profile.location}}<p class="p-location">{{$profile.location}}</p>{{/if}}
+			</dd>
 		</dl>
 	{{/if}}