This commit is contained in:
rGaillard
2011-07-06 10:10:43 +00:00
parent 31d94236ac
commit d1a13007b9
4695 changed files with 0 additions and 339293 deletions
-110
View File
@@ -1,110 +0,0 @@
<?php
/*
* 2007-2011 PrestaShop
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License (AFL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/afl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to http://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2011 PrestaShop SA
* @version Release: $Revision: 1.4 $
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
include(dirname(__FILE__).'/../../config/config.inc.php');
function show_countries($id_lang, $nb_by_line = 7)
{
if (!is_numeric($id_lang) || !is_numeric($nb_by_line))
return ("error");
$output = '<style type="text/css">.country{cursor: pointer;} .country:hover{text-decoration: underline;}</style>
<script type="text/javascript">$(document).ready(_registerClickOnCountry);</script>';
$result = Db::getInstance(_PS_USE_SQL_SLAVE_)->ExecuteS('SELECT cl.`id_country`, `name`, `iso_code` FROM `'._DB_PREFIX_.'country_lang` cl
LEFT JOIN `'._DB_PREFIX_.'country` c ON c.`id_country` = cl.`id_country`
WHERE `id_lang` = \''.(int)($id_lang).'\' ORDER BY `name` ASC;');
$separator = 0;
foreach ($result as $index => $row)
{
if ($separator)
$output .= ($separator % $nb_by_line) ? ' | ' : '<br />';
$output .= '<a class="country" id="'.$row['id_country'].'">'.$row['name'] . ' (' . $row['iso_code'] . ')</a>';
$separator++;
}
return ($output);
}
function show_buttons($id_lang, $id_country)
{
if (!is_numeric($id_lang) || !is_numeric($id_country))
return ("error");
$coord_x = -1;
$coord_y = -1;
$output = '<script type="text/javascript">$(document).ready(_registerClickButtons);</script>
<span id="selectinfo" style="text-align: center;"></span> ';
$result = Db::getInstance(_PS_USE_SQL_SLAVE_)->ExecuteS('SELECT cl.`id_country`, `name`, `iso_code`, `x`, `y` FROM `'._DB_PREFIX_.'country_lang` cl
LEFT JOIN `'._DB_PREFIX_.'country` c ON c.`id_country` = cl.`id_country`
LEFT JOIN `'._DB_PREFIX_.'location_coords` lc ON c.`id_country` = lc.`id_country`
WHERE `id_lang` = \''.(int)($id_lang).'\' AND cl.`id_country`= \''.(int)($id_country).'\';');
if (isset($result[0]['id_country']))
{
$output .= $result[0]['name'].' ('.$result[0]['iso_code'].')';
if (isset($result[0]['x']) && isset($result[0]['y']))
{
$coord_x = $result[0]['x'];
$coord_y = $result[0]['y'];
}
}
$output .= '<input type="hidden" id="hiddenx" value="'.$coord_x.'" />
<input type="hidden" id="hiddeny" value="'.$coord_y.'" />
<center><input type="button" id="cancel_id" class="button" value="Cancel" />
<input type="button" id="validate_id" class="button" value="Validate" /></center>';
return ($output);
}
function insert_coords($id_lang, $id_country, $x, $y)
{
if (!is_numeric($id_lang) || !is_numeric($id_country) || !is_numeric($x) || !is_numeric($y))
return ("error");
Db::getInstance()->Execute('DELETE FROM `'._DB_PREFIX_.'location_coords` WHERE `id_country` = \''.$id_country.'\';');
if (!Db::getInstance()->Execute('INSERT INTO `'._DB_PREFIX_.'location_coords` (`x`, `y`, `id_country`) VALUES (\''.(int)($x).'\', \''.(int)($y).'\', \''.(int)($id_country).'\');'))
echo("error while inserting data<br />");
return (show_countries($id_lang));
}
$option = Tools::getValue('opt', 0);
$id_lang = Tools::getValue('id_lang');
if ($option == 1)
{
echo show_countries($id_lang);
}
else if ($option == 2)
{
$id_country = Tools::getValue('id_country');
echo show_buttons($id_lang, $id_country);
}
else if ($option == 3)
{
$id_country = Tools::getValue('id_country');
$x = Tools::getValue('x');
$y = Tools::getValue('y');
echo insert_coords($id_lang, $id_country, $x, $y);
}
-11
View File
@@ -1,11 +0,0 @@
<?xml version="1.0" encoding="UTF-8" ?>
<module>
<name>statsgeolocation</name>
<displayName>Geolocation</displayName>
<version>1</version>
<description>Display your customers\' origin</description>
<author>PrestaShop</author>
<tab>analytics_stats</tab>
<is_configurable>1</is_configurable>
<need_instance>1</need_instance>
</module>
-18
View File
@@ -1,18 +0,0 @@
<?php
global $_MODULE;
$_MODULE = array();
$_MODULE['<{statsgeolocation}prestashop>statsgeolocation_323d4eb70b252acb4a04eaf9e0882597'] = 'Geotargeting';
$_MODULE['<{statsgeolocation}prestashop>statsgeolocation_621bd20bc26d0f67bacffc7785616372'] = 'Anzeige des Kundenstandorts';
$_MODULE['<{statsgeolocation}prestashop>statsgeolocation_60503475047260bb2e6b815e3dcad910'] = 'Dieses Modul zeigt die Länderverteilung der Kunden durch Punkte in verschiedenen Größen auf der Weltkarte an. Zeigen Sie den Ruf Ihrer Webseite rund um die Welt an sowie die Kontinente, die Sie noch nicht erobert haben.';
$_MODULE['<{statsgeolocation}prestashop>statsgeolocation_6602bbeb2956c035fb4cb5e844a4861b'] = 'Guide';
$_MODULE['<{statsgeolocation}prestashop>statsgeolocation_e346362c256cd1ff6efd70288f769d89'] = 'Ein Tor zur Welt';
$_MODULE['<{statsgeolocation}prestashop>statsgeolocation_1b625393440dce51a25ccb43a38ddf67'] = 'Hinzufügen neuer Sprachen zu Ihrem Shop, wenn Sie sehen, dass ein ausreichender Teil Ihrer Kunden aus dem Ausland kommt.';
$_MODULE['<{statsgeolocation}prestashop>statsgeolocation_a2f24ad94046ee38db78c336564acd30'] = 'Vergrößern Sie Ihre Versand-Bereich, um der potenziellen Nachfrage gerecht zu werden.';
$_MODULE['<{statsgeolocation}prestashop>statsgeolocation_25e8f2fd2871c8423bbe4e254066cd98'] = 'Bitte warten ...';
$_MODULE['<{statsgeolocation}prestashop>statsgeolocation_e7173e323991c8c33ad2dae1d528fc2e'] = 'Koordinaten aktualisieren';
$_MODULE['<{statsgeolocation}prestashop>statsgeolocation_60e421611f85e8faa9f6950ce71dab7a'] = 'Klicken Sie auf einen Ländernamen und bestimmen Sie seine Position auf der Karte';
$_MODULE['<{statsgeolocation}prestashop>statsgeolocation_64d80b7a177f4bd0a1f1dde09741852d'] = 'Klicken Sie auf die Karte, um die Position von einzustellen:';
$_MODULE['<{statsgeolocation}prestashop>statsgeolocation_dc25612aeb2ba1c2705fc2e9c947f084'] = 'Fehler: Sie müssen auf die Karte klicken oder auf die Schaltfläche Abbrechen';
$_MODULE['<{statsgeolocation}prestashop>statsgeolocation_ea4788705e6873b424c65e91c2846b19'] = 'Abbrechen';
$_MODULE['<{statsgeolocation}prestashop>statsgeolocation_ad3d06d03d94223fa652babc913de686'] = 'Bestätigen';
-90
View File
@@ -1,90 +0,0 @@
<?php
/*
* 2007-2011 PrestaShop
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License (AFL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/afl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to http://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2011 PrestaShop SA
* @version Release: $Revision: 1.4 $
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
include(dirname(__FILE__).'/../../config/config.inc.php');
$img_path="./img/map.png";
function loadBaseImage($img_path)
{
$img_size = getimagesize($img_path);
$img_png = imagecreatefrompng($img_path); if (!$img_png) exit(1);
$img_tc = imagecreatetruecolor($img_size[0], $img_size[1]);
imagealphablending($img_tc, false);
imagesavealpha($img_tc, true);
imagecopy($img_tc, $img_png, 0, 0, 0, 0, $img_size[0], $img_size[1]);
imagedestroy($img_png);
if (function_exists('imageantialias'))
imageantialias($img_tc, true);
return ($img_tc);
}
function drawImage($image)
{
header("Content-type: image/png");
imagepng($image);
imagedestroy($image);
}
function drawCircle($image, $x, $y, $size)
{
$color = imagecolorallocate($image, 255, 122, 56);
imagefilledellipse($image, $x, $y, $size, $size, $color);
}
function drawCircles($image)
{
$max = 12;
$min = 2;
$gap = ($max - $min);
$total = getTotalElements();
$result = getCoords();
foreach ($result as $row)
drawCircle($image, $row['x'], $row['y'], $min + ($gap * ($row['total'] / $total)));
}
function getTotalElements()
{
$result = Db::getInstance()->ExecuteS('SELECT COUNT(`id_address`) as total FROM `'._DB_PREFIX_.'address` WHERE deleted = 0 AND id_customer IS NOT NULL AND id_customer != 0');
return (isset($result[0]) ? $result[0]['total'] : 0);
}
function getCoords()
{
return (Db::getInstance(_PS_USE_SQL_SLAVE_)->ExecuteS('SELECT `x`, `y`, COUNT(`id_address`) AS total
FROM `'._DB_PREFIX_.'address` a
LEFT JOIN `'._DB_PREFIX_.'location_coords` lc ON lc.`id_country`=a.`id_country`
WHERE deleted = 0 AND id_customer IS NOT NULL AND id_customer != 0
GROUP BY a.`id_country`
ORDER BY `total` DESC'));
}
$image = loadBaseImage($img_path);
drawCircles($image);
drawImage($image);
-4
View File
@@ -1,4 +0,0 @@
<?php
global $_MODULE;
$_MODULE = array();
-18
View File
@@ -1,18 +0,0 @@
<?php
global $_MODULE;
$_MODULE = array();
$_MODULE['<{statsgeolocation}prestashop>statsgeolocation_323d4eb70b252acb4a04eaf9e0882597'] = 'Loaclización';
$_MODULE['<{statsgeolocation}prestashop>statsgeolocation_621bd20bc26d0f67bacffc7785616372'] = 'Muestre el origen de sus clientes';
$_MODULE['<{statsgeolocation}prestashop>statsgeolocation_60503475047260bb2e6b815e3dcad910'] = 'Este módulo muestra la distribución del país de sus clientes mostrando diversos puntos clasificados en el mapamundi mostrado abajo. Vea desde donde ven su tienda toda en el mundo y que continente no ha conquistado todavía.';
$_MODULE['<{statsgeolocation}prestashop>statsgeolocation_6602bbeb2956c035fb4cb5e844a4861b'] = 'Guía';
$_MODULE['<{statsgeolocation}prestashop>statsgeolocation_e346362c256cd1ff6efd70288f769d89'] = 'Abrir al mundo';
$_MODULE['<{statsgeolocation}prestashop>statsgeolocation_1b625393440dce51a25ccb43a38ddf67'] = 'Añada nuevos idiomas a su tienda si ve que gran parte de sus posibles clientes viene de un país extranjero.';
$_MODULE['<{statsgeolocation}prestashop>statsgeolocation_a2f24ad94046ee38db78c336564acd30'] = 'Aumente su área de envío para cubrir una demanda potencial.';
$_MODULE['<{statsgeolocation}prestashop>statsgeolocation_25e8f2fd2871c8423bbe4e254066cd98'] = 'Espere por favor..';
$_MODULE['<{statsgeolocation}prestashop>statsgeolocation_e7173e323991c8c33ad2dae1d528fc2e'] = 'Coordenadas de la actualización';
$_MODULE['<{statsgeolocation}prestashop>statsgeolocation_60e421611f85e8faa9f6950ce71dab7a'] = 'Haga clic sobre el país deseado para definir su posición en el mapa';
$_MODULE['<{statsgeolocation}prestashop>statsgeolocation_64d80b7a177f4bd0a1f1dde09741852d'] = 'Haga clic en el mapa para definir la posición de:';
$_MODULE['<{statsgeolocation}prestashop>statsgeolocation_dc25612aeb2ba1c2705fc2e9c947f084'] = 'Error: tiene que hacer clic en el mapa o en el botón cancelar';
$_MODULE['<{statsgeolocation}prestashop>statsgeolocation_ea4788705e6873b424c65e91c2846b19'] = 'Cancelar';
$_MODULE['<{statsgeolocation}prestashop>statsgeolocation_ad3d06d03d94223fa652babc913de686'] = 'Validar';
-18
View File
@@ -1,18 +0,0 @@
<?php
global $_MODULE;
$_MODULE = array();
$_MODULE['<{statsgeolocation}prestashop>statsgeolocation_323d4eb70b252acb4a04eaf9e0882597'] = 'Géolocalisation';
$_MODULE['<{statsgeolocation}prestashop>statsgeolocation_621bd20bc26d0f67bacffc7785616372'] = 'Affiche la provenance de vos clients';
$_MODULE['<{statsgeolocation}prestashop>statsgeolocation_60503475047260bb2e6b815e3dcad910'] = 'Ce module montre la répartition de vos clients par un point plus ou moins gros sur la carte ci-dessous. Constatez la popularité qu\'a votre boutique à l\'échelle du monde et sachez quels continents vous n\'avez pas encore conquis.';
$_MODULE['<{statsgeolocation}prestashop>statsgeolocation_6602bbeb2956c035fb4cb5e844a4861b'] = 'Guide';
$_MODULE['<{statsgeolocation}prestashop>statsgeolocation_e346362c256cd1ff6efd70288f769d89'] = 'S\'ouvrir au monde';
$_MODULE['<{statsgeolocation}prestashop>statsgeolocation_1b625393440dce51a25ccb43a38ddf67'] = 'Ajoutez une nouvelle langue à votre boutique si vous constatez que suffisamment de clients viennent d\'un autre pays.';
$_MODULE['<{statsgeolocation}prestashop>statsgeolocation_a2f24ad94046ee38db78c336564acd30'] = 'Elargissez votre zone de livraison pour répondre à une potentielle demande.';
$_MODULE['<{statsgeolocation}prestashop>statsgeolocation_25e8f2fd2871c8423bbe4e254066cd98'] = 'Patientez...';
$_MODULE['<{statsgeolocation}prestashop>statsgeolocation_e7173e323991c8c33ad2dae1d528fc2e'] = 'Mise à jour des coordonnées';
$_MODULE['<{statsgeolocation}prestashop>statsgeolocation_60e421611f85e8faa9f6950ce71dab7a'] = 'Cliquez sur le nom d\'un pays puis sur la carte afin de définir son emplacement';
$_MODULE['<{statsgeolocation}prestashop>statsgeolocation_64d80b7a177f4bd0a1f1dde09741852d'] = 'Cliquez sur la carte pour mettre à jour les coordonnées de :';
$_MODULE['<{statsgeolocation}prestashop>statsgeolocation_dc25612aeb2ba1c2705fc2e9c947f084'] = 'Erreur : vous devez cliquer sur la carte ou sur le bouton Annuler';
$_MODULE['<{statsgeolocation}prestashop>statsgeolocation_ea4788705e6873b424c65e91c2846b19'] = 'Annuler';
$_MODULE['<{statsgeolocation}prestashop>statsgeolocation_ad3d06d03d94223fa652babc913de686'] = 'Valider';
Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 65 KiB

-18
View File
@@ -1,18 +0,0 @@
<?php
global $_MODULE;
$_MODULE = array();
$_MODULE['<{statsgeolocation}prestashop>statsgeolocation_323d4eb70b252acb4a04eaf9e0882597'] = 'Geolocalizzazione';
$_MODULE['<{statsgeolocation}prestashop>statsgeolocation_621bd20bc26d0f67bacffc7785616372'] = 'Mostra l\'origine dei tuoi clienti ';
$_MODULE['<{statsgeolocation}prestashop>statsgeolocation_60503475047260bb2e6b815e3dcad910'] = 'Questo modulo indica la distribuzione dei Paesi dei tuoi clienti, mostrando i diversi punti di grandezza sulla mappa mondiale sotto. Vedi la fama del tuo sito web in tutto il mondo e quale continente non hai ancora conquistato.';
$_MODULE['<{statsgeolocation}prestashop>statsgeolocation_6602bbeb2956c035fb4cb5e844a4861b'] = 'Guida';
$_MODULE['<{statsgeolocation}prestashop>statsgeolocation_e346362c256cd1ff6efd70288f769d89'] = 'Apriti al mondo';
$_MODULE['<{statsgeolocation}prestashop>statsgeolocation_1b625393440dce51a25ccb43a38ddf67'] = 'Aggiungi nuove lingue al tuo negozio se si vede che una parte sufficiente dei tuoi clienti provengono da un paese straniero.';
$_MODULE['<{statsgeolocation}prestashop>statsgeolocation_a2f24ad94046ee38db78c336564acd30'] = 'Amplia l\'area di spedizione per soddisfare la domanda potenziale.';
$_MODULE['<{statsgeolocation}prestashop>statsgeolocation_25e8f2fd2871c8423bbe4e254066cd98'] = 'Si prega di attendere ...';
$_MODULE['<{statsgeolocation}prestashop>statsgeolocation_e7173e323991c8c33ad2dae1d528fc2e'] = 'Aggiorna le coordinate';
$_MODULE['<{statsgeolocation}prestashop>statsgeolocation_60e421611f85e8faa9f6950ce71dab7a'] = 'Clicca sul nome di un paese e definisci la sua posizione sulla mappa';
$_MODULE['<{statsgeolocation}prestashop>statsgeolocation_64d80b7a177f4bd0a1f1dde09741852d'] = 'Clicca sulla mappa per impostare la posizione di:';
$_MODULE['<{statsgeolocation}prestashop>statsgeolocation_dc25612aeb2ba1c2705fc2e9c947f084'] = 'Errore: devi cliccare sulla mappa o sul pulsante Annulla';
$_MODULE['<{statsgeolocation}prestashop>statsgeolocation_ea4788705e6873b424c65e91c2846b19'] = 'Annulla';
$_MODULE['<{statsgeolocation}prestashop>statsgeolocation_ad3d06d03d94223fa652babc913de686'] = 'Convalida';
Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.0 KiB

@@ -1,236 +0,0 @@
/*
* 2007-2011 PrestaShop
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License (AFL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/afl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to http://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2011 PrestaShop SA
* @version Release: $Revision: 1.4 $
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
function wait()
{
var wait = document.getElementById('wait').value;
if (typeof(wait) == 'number') //should never appear...
wait="wait...";
document.getElementById("belowmap").innerHTML=wait;
}
/**
* Launch the url page in background and write its content in the selected div
*/
function doAjax(dataform)
{
$.ajax({
url: '../modules/statsgeolocation/config.php',
type: 'POST',
data: dataform,
dataType: 'html',
error: function()
{
$("#belowmap").html("Cannot load countries' list");
},
success: function(data)
{
$("#belowmap").html(data);
}
});
}
/**
* Show the cross in the map
*/
function displayMarker(x, y)
{
var m = $("#marker").get(0);
var size = $('#marker_size').val();
m.style.display='';
m.style.width=size+'px';
m.style.height=size+'px';
m.style.left=(x - (size/2))+'px';
m.style.top=(y - (size/2))+'px';
$("#form_x").val(x);
$("#form_y").val(y);
}
/**
* For jQuery to register events on the different buttons
*/
_registerClickButtons=function()
{
var x=$('#hiddenx').val();
var y=$('#hiddeny').val();
if (x != -1 && y != -1)
displayMarker(x, y);
$('#selectinfo').html($('#lang_info').val());
$('#cancel_id').val($('#lang_cancel').val());
$('#validate_id').val($('#lang_validate').val());
$("#cancel_id").click(function()
{
var dataform="opt=1&id_lang="+$('#id_lang').val();
wait();
$('#opt').val(1);
document.getElementById("marker").style.display='none';
doAjax(dataform);
});
$("#validate_id").click(function()
{
if (document.getElementById("marker").style.display == 'none')
alert(document.getElementById("lang_error").value);
else
{
var dataform="opt=3&id_lang="+$('#id_lang').val()+"&id_country="+document.getElementById("country_selected").value;
dataform +="&x="+document.getElementById("form_x").value+"&y="+document.getElementById("form_y").value;
wait();
$('#opt').val(1);
document.getElementById("marker").style.display='none';
doAjax(dataform);
}
});
}
/**
* For jQuery to register events while clicking on a country
*/
_registerClickOnCountry=function()
{
var dataform="opt=2&id_lang="+$('#id_lang').val();
$('#country_selected').val(0);
$(".country").click(function()
{
wait();
$('#country_selected').val($(this).attr("id"));
dataform += "&id_country="+$(this).attr("id");
doAjax(dataform);
});
}
/**
* The first thing jQuery should do once the fist page is loaded
*/
_firstOfAll=function()
{
var dataform="opt=1&id_lang=" + $('#id_lang').val();
doAjax(dataform);
};
/**
* This is what happens when someone is doing a mouse click on the map
*/
function clickOnImage(event)
{
if ($("#country_selected").val() != '0')
{
var e = event || window.event;
var pos = getRelativeCoordinates(event, $("#reference").get(0));
var m = $("#marker").get(0);
displayMarker(pos.x, pos.y);
}
}
/**
* Retrieve the absolute coordinates of an element.
*
* @param element
* A DOM element.
* @return
* A hash containing keys 'x' and 'y'.
*/
function getAbsolutePosition(element)
{
var r = { x: element.offsetLeft, y: element.offsetTop };
if (element.offsetParent)
{
var tmp = getAbsolutePosition(element.offsetParent);
r.x += tmp.x;
r.y += tmp.y;
}
return r;
};
/**
* Retrieve the coordinates of the given event relative to the center
* of the widget.
*
* @param event
* A mouse-related DOM event.
* @param reference
* A DOM element whose position we want to transform the mouse coordinates to.
* @return
* A hash containing keys 'x' and 'y'.
*/
function getRelativeCoordinates(event, reference)
{
var x, y;
event = event || window.event;
var el = event.target || event.srcElement;
if (!window.opera && typeof event.offsetX != 'undefined')
{
// Use offset coordinates and find common offsetParent
var pos = { x: event.offsetX, y: event.offsetY };
// Send the coordinates upwards through the offsetParent chain.
var e = el;
while (e)
{
e.mouseX = pos.x;
e.mouseY = pos.y;
pos.x += e.offsetLeft;
pos.y += e.offsetTop;
e = e.offsetParent;
}
// Look for the coordinates starting from the reference element.
var e = reference;
var offset = { x: 0, y: 0 }
while (e)
{
if (typeof e.mouseX != 'undefined')
{
x = e.mouseX - offset.x;
y = e.mouseY - offset.y;
break;
}
offset.x += e.offsetLeft;
offset.y += e.offsetTop;
e = e.offsetParent;
}
// Reset stored coordinates
e = el;
while (e)
{
e.mouseX = undefined;
e.mouseY = undefined;
e = e.offsetParent;
}
}
else
{
// Use absolute coordinates
var pos = getAbsolutePosition(reference);
x = event.pageX - pos.x;
y = event.pageY - pos.y;
}
// Subtract distance to middle
return { x: x, y: y };
}
@@ -1,192 +0,0 @@
<?php
/*
* 2007-2011 PrestaShop
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License (AFL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/afl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to http://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2011 PrestaShop SA
* @version Release: $Revision: 1.4 $
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
if (!defined('_CAN_LOAD_FILES_'))
exit;
class StatsGeoLocation extends Module
{
private $_map_path = 'img/map.png';
private $_cross_path = 'img/cross.png';
function __construct()
{
$this->name = 'statsgeolocation';
$this->tab = 'analytics_stats';
$this->version = 1.0;
$this->author = 'PrestaShop';
parent::__construct();
$this->displayName = $this->l('Geolocation');
$this->description = $this->l('Display your customers\' origin');
}
function install()
{
$countries = array('AT' => array('x' => 294, 'y' => 68),
'AU' => array('x' => 534, 'y' => 228),
'BE' => array('x' => 276, 'y' => 62),
'BO' => array('x' => 135, 'y' => 210),
'CA' => array('x' => 84, 'y' => 45),
'CH' => array('x' => 281, 'y' => 69),
'CI' => array('x' => 253, 'y' => 156),
'CN' => array('x' => 470, 'y' => 99),
'CZ' => array('x' => 293, 'y' => 63),
'DE' => array('x' => 285, 'y' => 61),
'DK' => array('x' => 284, 'y' => 51),
'ES' => array('x' => 260, 'y' => 85),
'FI' => array('x' => 310, 'y' => 35),
'FR' => array('x' => 271, 'y' => 69),
'GB' => array('x' => 265, 'y' => 55),
'GR' => array('x' => 308, 'y' => 87),
'HK' => array('x' => 491, 'y' => 123),
'IE' => array('x' => 253, 'y' => 58),
'IL' => array('x' => 334, 'y' => 106),
'IT' => array('x' => 292, 'y' => 80),
'JP' => array('x' => 531, 'y' => 92),
'KR' => array('x' => 509, 'y' => 93),
'LU' => array('x' => 277, 'y' => 63),
'NG' => array('x' => 282, 'y' => 153),
'NL' => array('x' => 278, 'y' => 58),
'NO' => array('x' => 283, 'y' => 41),
'NZ' => array('x' => 590, 'y' => 264),
'PL' => array('x' => 300, 'y' => 59),
'PT' => array('x' => 251, 'y' => 86),
'TG' => array('x' => 267, 'y' => 154),
'SE' => array('x' => 294, 'y' => 40),
'SG' => array('x' => 475, 'y' => 169),
'US' => array('x' => 71, 'y' => 87),
'ZA' => array('x' => 311, 'y' => 239));
if ( !parent::install() OR !$this->registerHook('AdminStatsModules'))
return false;
if (!Db::getInstance()->Execute('
CREATE TABLE `'._DB_PREFIX_.'location_coords` (
`id_location_coords` INTEGER UNSIGNED NOT NULL AUTO_INCREMENT,
`x` int(4) NOT NULL,
`y` int(4) NOT NULL,
`id_country` INTEGER UNSIGNED NOT NULL,
PRIMARY KEY(`id_location_coords`)
) ENGINE='._MYSQL_ENGINE_.' DEFAULT CHARSET=utf8'))
return false;
$flag = 0;
$query = 'INSERT INTO `'._DB_PREFIX_.'location_coords` (`x`, `y`, `id_country`) VALUES ';
$result = Db::getInstance()->ExecuteS('SELECT `id_country`, `iso_code` FROM `'._DB_PREFIX_.'country`;');
foreach ($result as $index => $row)
{
if (isset($countries[$row['iso_code']]))
{
if ($flag)
$query .= ', ';
$query .= '(\''.$countries[$row['iso_code']]['x'].'\', \''.$countries[$row['iso_code']]['y'].'\', \''.$row['id_country'].'\')';
$flag = 1;
}
}
return Db::getInstance()->Execute($query.';');
}
function uninstall()
{
if (!parent::uninstall())
return false;
return (Db::getInstance()->Execute('DROP TABLE `'._DB_PREFIX_.'location_coords`'));
}
function hookAdminStatsModules()
{
$this->_html = '
<fieldset class="width3"><legend><img src="'.$this->_path.'logo.gif" alt="" title="" /> '.$this->displayName.'</legend>
<center>
<p><img src="../img/admin/down.gif" />'.$this->l('This module shows the distribution of the countries of your customers by displaying different sized points on the worldmap below. See the fame of your website all around the world and which continent you have yet to conquer.').'</p>
</center>
<p class="space">
<img src="'.$this->_path.'drawer.php" alt="" title="" />
</p>
</fieldset><br />
<fieldset class="width3"><legend><img src="../img/admin/comment.gif" /> '.$this->l('Guide').'</legend>
<h2>'.$this->l('Open to the world').'</h2>
<p>
<ul>
<li class="bullet">'.$this->l('Add new languages to your shop if you see that a sufficient part of your customers come from a foreign country.').'</li>
<li class="bullet">'.$this->l('Enlarge your shipping area to meet the potential demand.').'</li>
</ul>
</p>
</fieldset>';
return $this->_html;
}
public function getContent()
{
$output = '<h2>'.$this->displayName.'</h2>';
return $output.$this->displayForm();
}
public function displayForm()
{
global $cookie;
$map_size;
$cross_size;
$id_lang = (isset($cookie->id_lang) ? (int)($cookie->id_lang) : Configuration::get('PS_LANG_DEFAULT'));
$wait = $this->l('Please wait...');
if ((file_exists('../modules/'.$this->name.'/'.$this->_map_path) == FALSE) ||
(file_exists('../modules/'.$this->name.'/'.$this->_cross_path) == FALSE) ||
(!($map_size = getimagesize('../modules/'.$this->name.'/'.$this->_map_path))) ||
(!($cross_size = getimagesize('../modules/'.$this->name.'/'.$this->_cross_path))))
return ("Error: cannot load images");
$output = '<script type="text/javascript" src="'.$this->_path.'statsgeolocation.js"></script>
<script type="text/javascript">$(document).ready(_firstOfAll);</script>
<form><fieldset><legend><img src="'.$this->_path.'logo.gif" alt="" title="" />'.$this->l('Update coordinates').'</legend>
<div style="font-weight:bold;" id="divtitle">'.$this->l('Click on a country\'s name and define its position on the map').'</div><br />
<div id="reference" onclick="clickOnImage(event)" style="background-image:url(\''.$this->_path.$this->_map_path.'\');width:'.$map_size[0].'px; height:'.$map_size[1].'px; z-index:5;">
<div id="marker" style= "display:none;background-image:url(\''.$this->_path.$this->_cross_path.'\');width:0px; height:0px; z-index:20; position:relative;"></div>
</div>
<div id="belowmap">'.$wait.'</div>
<noscript>You should enable javascript to configure this module</noscript>
<input type="hidden" id="opt" value="1" />
<input type="hidden" id="id_lang" value="'.$id_lang.'" />
<input type="hidden" id="lang_info" value="'.$this->l('Click on the map to set the position of:').'" />
<input type="hidden" id="lang_error" value="'.$this->l('Error: click on the map or the cancel button').'" />
<input type="hidden" id="lang_cancel" value="'.$this->l('Cancel').'" />
<input type="hidden" id="lang_validate" value="'.$this->l('Validate').'" />
<input type="hidden" id="marker_size" value="'.$cross_size[0].'" />
<input type="hidden" id="form_x" value="0" />
<input type="hidden" id="form_y" value="0" />
<input type="hidden" id="wait" value="'.$wait.'" />
<input type="hidden" id="country_selected" value="0" />
</fieldset></form>';
return $output;
}
}