diff --git a/src/Controller/PublicController.php b/src/Controller/PublicController.php index aa95e2f..63159da 100644 --- a/src/Controller/PublicController.php +++ b/src/Controller/PublicController.php @@ -12,9 +12,12 @@ use Symfony\Component\Routing\Annotation\Route; use GuzzleHttp\Client; use Symfony\Component\HttpFoundation\Request; + class PublicController extends AbstractController { + private $hide_filled_inputs = true; + public function __construct( private EntityManagerInterface $entityManager, private Motocultrice $motocultrice @@ -65,6 +68,7 @@ class PublicController extends AbstractController 'commerce_overpass' => $commerce_overpass, 'name' => $name, 'commerce' => $place, + 'hide_filled_inputs' => $this->hide_filled_inputs, 'excluded_tags_to_render' => $this->motocultrice->excluded_tags_to_render, 'osm_kind' => $place->getOsmKind(), "mapbox_token" => $_ENV['MAPBOX_TOKEN'], @@ -108,7 +112,7 @@ class PublicController extends AbstractController $request_post = $this->motocultrice->map_post_values($request_post); foreach ($request_post as $key => $value) { - // var_dump($key, $value); + if (strpos($key, 'commerce_tag_value__') === 0) { $tagKey = str_replace('commerce_tag_value__', '', $key); if (!empty($value)) { @@ -225,9 +229,13 @@ class PublicController extends AbstractController // après envoi on récupère les données $commerce = $this->motocultrice->get_osm_object_data($osm_kind, $osm_object_id); + + + return $this->render('public/view.html.twig', [ 'controller_name' => 'PublicController', 'commerce' => $commerce, + 'status' => $status, 'exception' => $exception, 'exception_message' => $exception_message, diff --git a/src/Service/Motocultrice.php b/src/Service/Motocultrice.php index 56007fe..3ea75c0 100644 --- a/src/Service/Motocultrice.php +++ b/src/Service/Motocultrice.php @@ -26,9 +26,39 @@ class Motocultrice 'addr:street', 'contact:website', 'contact:mastodon', - 'image', + 'image', 'note' ]; + + // quand un commerce a fermé, on peut supprimer ces tags + public $obsolete_tags = ["phone", "website", "email", "description", "brand", "opening_hours", + "check_date:opening_hours", "internet_access", + "indoor_seating", "takeaway", "female", "male", "unisex", + "ref:FR:NAF", "ref:FR:FINESS", "ref:FR:SIRET", "ref:FR:SIREN", "ref:vatin", + "healthcare", "dispensing", "lawyer", "vending", "vending_machine", + "self_service", "second_hand", "branch", "delivery", "start_date", + "beauty", "facebook", "tobacco", "bulk_purchase", + "drive_through", "pastry", "stroller", "fax", "trade", "network", + "mobile", "sport", "produce", "lottery", "supermarket", "information", + "tourism", "government", "brewery" + ]; + public $tags_to_remove = ["diet:", "contact:", "name:", "payment:", "delivery:", "type:FR:", "ref:FR:SDIS:", + "brand:", "fuel:", "service:", "description:", "operator:", "tickets:", "healthcare:" + ]; + public $tags_to_convert = ["shop" => "was:shop", +"information" => "was:information", +"office" => "was:office", +"amenity" => "was:amenity", +"craft" => "was:craft", +"operator" => "was:operator", +"clothes" => "was:clothes", +"cuisine" => "was:cuisine", +"official_name" => "was:official_name", +"short_name" => "was:short_name", +"alt_name" => "was:alt_name" + +]; + private $more_tags = ['image', 'ref:FR:SIRET']; public function __construct( private HttpClientInterface $client, @@ -41,6 +71,11 @@ class Motocultrice $has_ask_angela = false; $remove_ask_angela = false; $has_opening_hours = false; + // $has_phone = false; + // $has_contact_phone = false; + + // $has_email = false; + // $has_contact_email = false; $modified_request_post = []; @@ -171,12 +206,14 @@ QUERY; foreach ($osm_object_data['node']['tag'] as $attribute) { $osm_object_data['node']['tags_converted'][$attribute['@attributes']['k']] = $attribute['@attributes']['v']; } + $osm_object_data['node']['tags_converted'] = $this->migrate_tags($osm_object_data['node']['tags_converted']); return $osm_object_data['node']; } if(isset($osm_object_data['way'])){ foreach ($osm_object_data['way']['tag'] as $attribute) { $osm_object_data['way']['tags_converted'][$attribute['@attributes']['k']] = $attribute['@attributes']['v']; } + $osm_object_data['way']['tags_converted'] = $this->migrate_tags($osm_object_data['way']['tags_converted']); return $osm_object_data['way']; } @@ -184,6 +221,29 @@ QUERY; } + public function migrate_tags($osm_object_data) { + + // migrer email vers contact:email + if(isset($osm_object_data['email']) && !isset($osm_object_data['contact:email'])){ + $osm_object_data['contact:email'] = $osm_object_data['email']; + unset($osm_object_data['email']); + } + // migrer phone vers contact:phone + if(isset($osm_object_data['phone']) && !isset($osm_object_data['contact:phone'])){ + $osm_object_data['contact:phone'] = $osm_object_data['phone']; + unset($osm_object_data['phone']); + } + // migrer website vers contact:website + if(isset($osm_object_data['website']) && !isset($osm_object_data['contact:website'])){ + $osm_object_data['contact:website'] = $osm_object_data['website']; + unset($osm_object_data['website']); + } + + return $osm_object_data; + } + + + public function uuid_create() { return sprintf( '%04x%04x-%04x-%04x-%04x-%04x%04x%04x', // 32 bits for "time_low" @@ -212,7 +272,7 @@ QUERY; $essentialTags = [ 'name', 'opening_hours', - 'phone', + // 'phone', 'contact:email', 'contact:phone', 'website', diff --git a/templates/base.html.twig b/templates/base.html.twig index 631395f..ad2e7eb 100644 --- a/templates/base.html.twig +++ b/templates/base.html.twig @@ -35,7 +35,8 @@ min-height: 100vh; } .main-footer{ - padding-bottom: 3rem; + padding-bottom: 15rem; + margin-top: 5rem; } {# table tr:nth-child(odd){ background-color:rgb(235, 235, 235); @@ -53,10 +54,14 @@
-
-
+
+
+ +
+
+
+
-
@@ -84,7 +89,7 @@
{% block body %}{% endblock %}
-
+
@@ -96,9 +101,11 @@

OpenStreetMap Mon Commerce

Licence AGPLv3+, - fait par Tykayn de + fait par Tykayn de CipherBliss EI, membre de la fédération des professionels d'OpenStreetMap, Sources des données : OpenStreetMap. -
OpenStreetMap France

+
OpenStreetMap France. +
Sources du logiciel.. +

diff --git a/templates/public/edit.html.twig b/templates/public/edit.html.twig index 802ab07..4c409f8 100644 --- a/templates/public/edit.html.twig +++ b/templates/public/edit.html.twig @@ -6,35 +6,16 @@ {{ parent() }} {% endblock %} {% block body %}
- - - - - - -
@@ -43,8 +24,6 @@
{% if commerce_overpass is not empty %} - -
@@ -69,51 +47,55 @@ {% endif %}

{{ 'display.attributes'|trans }}

- -
-
+
-
-
- -
- +
+ +
+
+ + {% if hide_filled_inputs and + (commerce_overpass.tags_converted['addr:street']) is defined and commerce_overpass.tags_converted['addr:street'] is not empty + %} + {% include 'public/edit/address.html.twig' %} + {% endif %} + + + {% if hide_filled_inputs and (commerce_overpass.tags_converted.opening_hours) is defined and commerce_overpass.tags_converted.opening_hours is not empty %} + {% include 'public/edit/opening_hours.html.twig' %} + {% endif %} + {% if hide_filled_inputs and (commerce_overpass.tags_converted.wheelchair) is defined and commerce_overpass.tags_converted.wheelchair is not empty %} + {% include 'public/edit/wheelchair.html.twig' %} + {% endif %} + {% if hide_filled_inputs and (commerce_overpass.tags_converted.ask_angela) is defined and commerce_overpass.tags_converted.ask_angela is not empty %} + {% include 'public/edit/ask_angela.html.twig' %} + {% endif %} - {% include 'public/edit/address.html.twig' %} - {% include 'public/edit/opening_hours.html.twig' %} - {% include 'public/edit/wheelchair.html.twig' %} - {% include 'public/edit/ask_angela.html.twig' %} {% include 'public/edit/tags.html.twig' %}
+ + {{ 'display.submit'|trans }} +
{% endif %}
- - -
{{ 'display.last_modification'|trans }}: {{ commerce_overpass['@attributes'].timestamp }}, - - {{ 'display.days_ago'|trans({'%days%': date(commerce_overpass['@attributes'].timestamp).diff(date()).days}) }} + {{ 'display.days_ago'|trans({'%days%': date(commerce_overpass['@attributes'].timestamp).diff(date()).days}) }} {{ 'display.by'|trans }} {{ commerce_overpass['@attributes'].user }} - -

@@ -123,31 +105,24 @@

- -
{% block javascripts %} {{ parent() }} - {% endblock %} {% endblock %} diff --git a/templates/public/edit/opening_hours.html.twig b/templates/public/edit/opening_hours.html.twig index 899323d..428a9e7 100644 --- a/templates/public/edit/opening_hours.html.twig +++ b/templates/public/edit/opening_hours.html.twig @@ -5,20 +5,24 @@

{{ 'display.opening_hours_description'|trans }}

{% if commerce_overpass.tags_converted.opening_hours is defined and commerce_overpass.tags_converted.opening_hours != '' %} - {{ dump(commerce_overpass.tags_converted.opening_hours) }} + {# {{ dump(commerce_overpass.tags_converted.opening_hours) }} #} {% else %}
ajoutez les horaires au format OSM {% endif %} - Exemples : +
+ + Exemples : + +
{# Lundi de diff --git a/templates/public/edit/tags.html.twig b/templates/public/edit/tags.html.twig index 527bba8..ee403ef 100644 --- a/templates/public/edit/tags.html.twig +++ b/templates/public/edit/tags.html.twig @@ -4,14 +4,14 @@ {% for k, v in commerce_overpass.tags_converted %} -
+
- {% if k not in excluded_tags_to_render %} + {% if k not in excluded_tags_to_render %} {% if k == 'phone' or k == 'contact:phone' %} {% elseif k == 'addr:housenumber' or k == 'addr:street' or k == 'addr:city' or k == 'addr:postcode' or k == 'addr:country' %} - {% elseif k == 'mastodon' %} + {% elseif k == 'contact:mastodon' %} {% elseif k == 'email' or k == 'contact:email' %} diff --git a/templates/public/edit/wheelchair.html.twig b/templates/public/edit/wheelchair.html.twig index e19a7bb..f134e71 100644 --- a/templates/public/edit/wheelchair.html.twig +++ b/templates/public/edit/wheelchair.html.twig @@ -13,18 +13,27 @@ +

+ toutes les pièces sont accessibles sans marche. +

+

+ les pièces principales sont accessibles sans marche. +

+

+ autres cas. une marche fait plus de 7cm, entrée trop étroite ou bien plusieurs marches. +

diff --git a/translations/messages.fr.yaml b/translations/messages.fr.yaml index c479924..cf6988c 100644 --- a/translations/messages.fr.yaml +++ b/translations/messages.fr.yaml @@ -64,6 +64,7 @@ display: source: "Source" ref:FR:SIRET: "SIRET" image: "URL vers une Image" + note: "Champ libre, pour des informations complémentaires. Ne pas mettre de publicité" disclaimer: title: "Attention" text: "Ce site est un travail en cours, ceci est une démonstration sur un objet fictif qui utilise les données de l'API OpenStreetMap."