delahaye / dlh_googlemaps

Google Maps Extension für Contao
20 stars 26 forks source link

GoogleMap Opt-in & Cookie wird nicht gesetzt #104

Open operatorone opened 6 years ago

operatorone commented 6 years ago

Hallo zusammen,

ich habe die Erweiterungen delahaye/dlh_geocode 1.1.4 und delahaye/dlh_googlemaps 2.4.1 installiert um in einem Contao 4.4.19 eine Karte mit Opt-In anzuzeigen. Zuvor hatte ich heimrichhannot/dlh_googlemaps installiert, aber für das Opt-In bin ich dann umgestiegen. Leider wird beim Aufruf der Seite nun trotz der Einstellung "Karte hat Datenschutz-Bestätigung" die Karte gleich angezeigt. Das Opt-In DIV wird auch nicht mehr geladen, so dass es nicht erscheinen kann.

Hier ein Link dazu https://kn2.entwicklungs-server.net/ Benutzer/PW 123/456

Ich würde mich auch für einen hilfreichen Tipp erkenntlich zeigen. Support muss ja nicht umsonst sein.

Vielen Dank für die Mühen im Voraus, operatorone

Hier ist der Anfang des Script-Bereichs der unter der Karte ausgegeben wird:

<script> function gmap3_allow() { document.cookie = 'dlh_googlemaps=ok; max-age=31536000 ; path=/'; var mapsSrc = document.createElement('script'); mapsSrc.type = 'text/javascript'; mapsSrc.src = 'https://maps.googleapis.com/maps/api/js?key=AIzaSyD0_DrB6bQuj3yOzUM_4h_Qq6t-ynaMJAI&language=de'; document.getElementsByTagName('head')[0].appendChild(mapsSrc); window.setTimeout("gmap3_initialize()", 500); }

Hier meine installierten Erweiterungen:

contao-components/tinymce4 4.6.7.2 TinyMCE 4 integration for Contao Open Sou... contao/calendar-bundle 4.4.19 Adds calendar functionality to Contao 4 contao/comments-bundle 4.4.19 Adds comments functionality to Contao 4 contao/core-bundle 4.4.19 Contao 4 core bundle contao/faq-bundle 4.4.19 Adds FAQ functionality to Contao 4 contao/image 0.3.7 Contao image library contao/imagine-svg 0.2.1 Contao Imagine SVG library contao/installation-bundle 4.4.19 Required to install and update Contao 4 contao/listing-bundle 4.4.19 Allows to list arbitrary data in the Cont... contao/manager-bundle 4.4.19 Contao 4 manager bundle contao/manager-plugin 2.2.1 Contao 4 manager plugin contao/news-bundle 4.4.19 Adds news functionality to Contao 4 contao/newsletter-bundle 4.4.19 Adds newsletter functionality to Contao 4 delahaye/dlh_geocode 1.1.4 Get geo coordinates from a given address delahaye/dlh_googlemaps 2.4.1 Google maps module for Contao derhaeuptling/contao-seo-serp-preview 3.0.4 Contao SEO SERP Preview - shows how pages... dklemmt/contao_dk_mmenu 2.0.1 Implementation of mmenu as extension for ... do-while/contao-backupdb-bundle 1.2.1 Backup of the Contao database, automatic ... doctrine/annotations v1.6.0 Docblock Annotations Parser doctrine/cache v1.7.1 Caching library offering an object-orient... doctrine/collections v1.5.0 Collections Abstraction library doctrine/common v2.8.1 Common Library for Doctrine projects doctrine/dbal v2.7.1 Database Abstraction Layer doctrine/doctrine-bundle 1.9.1 Symfony DoctrineBundle doctrine/doctrine-cache-bundle 1.3.3 Symfony Bundle for Doctrine Cache doctrine/inflector v1.3.0 Common String Manipulations with regard t... doctrine/lexer v1.0.1 Base library for a lexer that can be used... fig/link-util 1.0.0 Common utility implementations for HTTP l... fipps/contao-downloadlists-bundle v0.1.1 Contao 4 Download Lists friendsofsymfony/http-cache 2.3.0 Tools to manage HTTP caching proxies with... friendsofsymfony/http-cache-bundle 2.4.0 Set path based HTTP cache headers and sen... fritzmg/contao-lightcase 2.0.1 Contao extension to integrate the Lightca... globalcitizen/php-iban v2.6.6 php-iban is a library for parsing and val... guzzlehttp/guzzle 6.3.3 Guzzle is a PHP HTTP client library guzzlehttp/promises v1.3.1 Guzzle promises library guzzlehttp/psr7 1.4.2 PSR-7 message implementation that also pr... heimrichhannot/contao-components 2.0.2 Components is a contao extension that giv... heimrichhannot/contao-haste_plus 1.9.14 An extension for the contao haste module. heimrichhannot/contao-tagsinput 2.2.6 Contao port of Bootstrap Tags Input that ... heimrichhannot/contao-youtube 1.4.11 Youtube Content Element, with responsive ... hofff/contao-opengraph 3.2.0 Define OpenGraph meta data in Contao html2text/html2text 4.1.0 Converts HTML to formatted plain text imagine/imagine v0.7.1 Image processing for PHP 5.3 jdorn/sql-formatter v1.2.17 a PHP SQL highlighting library jeremykendall/php-domain-parser 3.0.0 Public Suffix List based URL parsing impl... knplabs/knp-menu 2.3.0 An object oriented menu library knplabs/knp-menu-bundle v2.2.1 This bundle provides an integration of th... knplabs/knp-time-bundle 1.8.0 Knplabs time bundle makes your dates look... kriswallsmith/assetic v1.4.0 Asset Management for PHP leafo/scssphp v0.6.7 scssphp is a compiler for SCSS written in... league/uri 4.2.2 URI manipulation library lexik/maintenance-bundle v2.1.5 This bundle allows you to place your webs... ma3xl3/contao-easy-favicon 2.0.1 This extension allows you easily to add a... madeyourday/contao-rocksolid-antispam v2.0.0 Protect your site effectively from spam w... madeyourday/contao-rocksolid-columns v2.0.2 Arrange your content elements in responsi... madeyourday/contao-rocksolid-custom-elements v2.2.4 Create your own, nestable content element... madeyourday/contao-rocksolid-frontend-helper v2.0.2 Frontend Editing for Contao. Stop stumbli... madeyourday/contao-rocksolid-icon-picker v2.0.2 RockSolid Icon Picker Contao Extension. madeyourday/contao-rocksolid-slider v2.0.7 Responsive Slider. Full Contao integratio... matthiasmullie/minify 1.3.60 CSS & JavaScript minifier, in PHP. Remove... matthiasmullie/path-converter 1.1.1 Relative path converter menatwork/contao-multicolumnwizard 3.3.16 MultiColumWizard for Contao OpenSource CMS michelf/php-markdown 1.8.0 PHP Markdown mindbird/contao-uitotop 2.0.1 Small adjustable Button to go to top of t... monolog/monolog 1.23.0 Sends your logs to files, sockets, inboxe... nelmio/cors-bundle 1.5.4 Adds CORS (Cross-Origin Resource Sharing)... nelmio/security-bundle 2.5.1 Extra security-related features for Symfo... netzmacht/contao-font-awesome 4.7.2 Integrates Font Awesome into Contao front... netzmacht/contao-font-awesome-inserttag 2.0.1 Provides an insert tag for using font awe... netzmacht/contao-iconwizard 1.2.3 Provides an backend widget for choosing i... oyejorge/less.php v1.7.0.14 PHP port of the Javascript version of LES... paragonie/random_compat v2.0.15 PHP 5.x polyfill for randombytes() and r... patchwork/utf8 v1.3.1 Portable and performant UTF-8, Unicode an... php-http/client-common 1.7.0 Common HTTP Client implementations and to... php-http/discovery 1.4.0 Finds installed HTTPlug implementations a... php-http/guzzle6-adapter v1.1.1 Guzzle 6 HTTP Adapter php-http/httplug v1.1.0 HTTPlug, the HTTP client abstraction for PHP php-http/message 1.6.0 HTTP Message related tools php-http/message-factory v1.0.2 Factory interfaces for PSR-7 HTTP Message php-http/promise v1.0.0 Promise used for asynchronous HTTP requests phpfastcache/phpfastcache 5.0.21 PHP Cache Class - Reduce your database ca... phpfastcache/phpssdb 1.0.1 PHP SSDB Driver for phpFastCache phpspec/php-diff v1.1.0 A comprehensive library for generating di... phpunit/php-token-stream 1.4.12 Wrapper around PHP's tokenizer extension. predis/predis v1.1.1 Flexible and feature-complete Redis clien... psr/cache 1.0.1 Common interface for caching libraries psr/container 1.0.0 Common Container Interface (PHP FIG PSR-11) psr/http-message 1.0.1 Common interface for HTTP messages psr/link 1.0.0 Common interfaces for HTTP links psr/log 1.0.2 Common interface for logging libraries psr/simple-cache 1.0.1 Common interfaces for simple caching robloach/component-installer 0.2.3 Allows installation of Components via Com... roderik/pwgen-php 0.1.8 pwgen-php is a simple PHP class which aim... sensio/distribution-bundle v5.0.22 Base bundle for Symfony Distributions sensio/framework-extra-bundle v3.0.29 This bundle provides a way to configure y... sensiolabs/ansi-to-html v1.1.3 A library to convert a text with ANSI cod... sensiolabs/security-checker v4.1.8 A security checker for your composer.lock simplepie/simplepie 1.5.1 A simple Atom/RSS parsing library for PHP swiftmailer/swiftmailer v5.4.9 Swiftmailer, free feature-rich PHP mailer symfony/monolog-bundle v3.3.0 Symfony MonologBundle symfony/polyfill-apcu v1.8.0 Symfony polyfill backporting apcu* funct... symfony/polyfill-ctype v1.8.0 Symfony polyfill for ctype functions symfony/polyfill-intl-icu v1.8.0 Symfony polyfill for intl's ICU-related d... symfony/polyfill-mbstring v1.8.0 Symfony polyfill for the Mbstring extension symfony/polyfill-php56 v1.8.0 Symfony polyfill backporting some PHP 5.6... symfony/polyfill-php70 v1.8.0 Symfony polyfill backporting some PHP 7.0... symfony/polyfill-util v1.8.0 Symfony utilities for portability of PHP ... symfony/swiftmailer-bundle v2.6.7 Symfony SwiftmailerBundle symfony/symfony v3.4.10 The Symfony PHP framework tecnickcom/tcpdf 6.2.17 TCPDF is a PHP class for generating PDF d... terminal42/contao-ajaxform 1.0.7 Ajax Form extension for Contao Open Sourc... terminal42/contao-changelanguage 3.1.9 ChangeLanguage extension for Contao Open ... terminal42/contao-easy_themes 2.2.8 Contao Open Source CMS extension easy_themes terminal42/contao-folderpage 2.0.3 Provides a new page type for Contao that ... terminal42/contao-inserttags 1.9.4 Contao extension to create InsertTags to ... terminal42/contao-pageimage 3.3.1 [Contao CMS] Assign images to pages and o... terminal42/dcawizard 2.4.4 dcaWizard extension for Contao Open Sourc... terminal42/header-replay-bundle 1.4.4 Send preflight requests for user context ... terminal42/notification_center 1.4.5 Notification Center extension for Contao ... tijsverkoyen/css-to-inline-styles 1.5.5 CssToInlineStyles is a class that enables... true/punycode v2.1.1 A Bootstring encoding of Unicode for Inte... twig/twig v1.35.3 Twig, the flexible, fast, and secure temp... ua-parser/uap-php v3.5.0 A multi-language port of Browserscope's u... webmozart/assert 1.3.0 Assertions to validate method input/outpu... webmozart/path-util 2.3.0 A robust cross-platform utility for norma...

operatorone commented 5 years ago

Auch in diesem Projekt habe ich wieder das Problem, dass das Opt-In nicht angezeigt wird :-(

https://www.festivalsommerhausen.de

Xendiadyon commented 5 years ago

Ich bin auch über dieses Problem gestolpert. Wenn ich mir den Code anschaue, dann liegt es am ce_dlh_googlemaps_default.html5 Template: https://github.com/delahaye/dlh_googlemaps/blob/master/templates/frontend/ce_dlh_googlemaps_default.html5#L161

In Zeile 161 bis Zeile 171 wird hier die Google-Map (zeitverzögert) geladen. Das darf aber nur passieren, wenn das Cookie gesetzt wurde oder die Karte nicht geschützt ist.

Du musst also eine zusätzliche PHP-Abfrage von oben mit einbauen: image

<?php
if($_COOKIE['dlh_googlemaps'] || $this->map['protected']!='1'):
?>
if(window.addEvent) {
    window.addEvent('domready', function() {
        gmap<?= $this->map['id']; ?>_initialize();
    });
} else if(typeof jQuery == "function") {
    jQuery(document).ready(function(){
        gmap<?= $this->map['id']; ?>_initialize();
    });
} else {
    window.setTimeout("gmap<?= $this->map['id']; ?>_initialize()", 500);
}
<?php
endif;
?>

Aus irgendeinem Grund funktioniert es bei einigen Projekten - und bei anderen nicht. Ich verstehe noch nicht genau, warum; aber so müsste es in meinen Augen programmiert sein.

operatorone commented 5 years ago

Hat super funktioniert. Ganz lieben Dank für den Workaround. Vielleicht wandert das recht schnell in den Master. :-)