From 894b526effa22288fec4be4845869f95390fdff2 Mon Sep 17 00:00:00 2001
From: Simon Leblanc <contact@leblanc-simon.eu>
Date: Sat, 2 Jul 2011 23:13:56 +0200
Subject: [PATCH] Fix issue #11 : Google Analytics n'est plus obligatoire

---
 bandeaux.php           | 18 +++++++++---------
 variables.php.template |  3 +++
 2 files changed, 12 insertions(+), 9 deletions(-)

diff --git a/bandeaux.php b/bandeaux.php
index c79c3c90..f7d9f27e 100644
--- a/bandeaux.php
+++ b/bandeaux.php
@@ -51,21 +51,21 @@ function framanav()
 }
 
 function gAnalytics() {
-echo <<<gAnalytics
+  if (GOOGLE_ANALYTICS_ID !== false) {
+    echo '
 <script type="text/javascript">
-
   var _gaq = _gaq || [];
-  _gaq.push(['_setAccount', 'UA-896440-11']);
-  _gaq.push(['_trackPageview']);
+  _gaq.push([\'_setAccount\', \''.GOOGLE_ANALYTICS_ID.'\']);
+  _gaq.push([\'_trackPageview\']);
 
   (function() {
-    var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
-    ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
-    var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
+    var ga = document.createElement(\'script\'); ga.type = \'text/javascript\'; ga.async = true;
+    ga.src = (\'https:\' == document.location.protocol ? \'https://ssl\' : \'http://www\') + \'.google-analytics.com/ga.js\';
+    var s = document.getElementsByTagName(\'script\')[0]; s.parentNode.insertBefore(ga, s);
   })();
 
-</script>
-gAnalytics;
+</script>';
+  }
 }
 
 
diff --git a/variables.php.template b/variables.php.template
index c822c90e..e37ef0b1 100644
--- a/variables.php.template
+++ b/variables.php.template
@@ -78,6 +78,9 @@ define('LOGOLETTRE', '<chemin relatif suivi du nom du fichier du logo pour la le
 // Activation des URL propre (true pour activer, false sinon)
 define('URL_PROPRE', false);
 
+// Activation de Google Analytics (false si inactif, l'identifiant sinon)
+define('GOOGLE_ANALYTICS_ID', false);
+
 if (@file_exists('variables.local.php')) {
     include('variables.local.php');
 }
-- 
GitLab