// Removed deprecated module
This commit is contained in:
@@ -1,109 +0,0 @@
|
||||
<?php
|
||||
/*
|
||||
* 2007-2013 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-2013 PrestaShop SA
|
||||
* @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);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,12 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<module>
|
||||
<name>statsgeolocation</name>
|
||||
<displayName><![CDATA[Geolocation]]></displayName>
|
||||
<version><![CDATA[1]]></version>
|
||||
<description><![CDATA[Display your customers' origin]]></description>
|
||||
<author><![CDATA[PrestaShop]]></author>
|
||||
<tab><![CDATA[analytics_stats]]></tab>
|
||||
<is_configurable>1</is_configurable>
|
||||
<need_instance>0</need_instance>
|
||||
<limited_countries></limited_countries>
|
||||
</module>
|
||||
@@ -1,89 +0,0 @@
|
||||
<?php
|
||||
/*
|
||||
* 2007-2013 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-2013 PrestaShop SA
|
||||
* @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);
|
||||
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 1.2 KiB |
@@ -1,35 +0,0 @@
|
||||
<?php
|
||||
/*
|
||||
* 2007-2013 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-2013 PrestaShop SA
|
||||
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
|
||||
* International Registered Trademark & Property of PrestaShop SA
|
||||
*/
|
||||
|
||||
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
|
||||
header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT");
|
||||
|
||||
header("Cache-Control: no-store, no-cache, must-revalidate");
|
||||
header("Cache-Control: post-check=0, pre-check=0", false);
|
||||
header("Pragma: no-cache");
|
||||
|
||||
header("Location: ../");
|
||||
exit;
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 65 KiB |
@@ -1,35 +0,0 @@
|
||||
<?php
|
||||
/*
|
||||
* 2007-2013 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-2013 PrestaShop SA
|
||||
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
|
||||
* International Registered Trademark & Property of PrestaShop SA
|
||||
*/
|
||||
|
||||
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
|
||||
header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT");
|
||||
|
||||
header("Cache-Control: no-store, no-cache, must-revalidate");
|
||||
header("Cache-Control: post-check=0, pre-check=0", false);
|
||||
header("Pragma: no-cache");
|
||||
|
||||
header("Location: ../");
|
||||
exit;
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 1.0 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 2.0 KiB |
@@ -1,236 +0,0 @@
|
||||
/*
|
||||
* 2007-2013 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-2013 PrestaShop SA
|
||||
* @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' + '?rand=' + new Date().getTime(),
|
||||
type: 'POST',
|
||||
headers: { "cache-control": "no-cache" },
|
||||
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,190 +0,0 @@
|
||||
<?php
|
||||
/*
|
||||
* 2007-2013 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-2013 PrestaShop SA
|
||||
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
|
||||
* International Registered Trademark & Property of PrestaShop SA
|
||||
*/
|
||||
|
||||
if (!defined('_PS_VERSION_'))
|
||||
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';
|
||||
$this->need_instance = 0;
|
||||
|
||||
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()
|
||||
{
|
||||
$map_size;
|
||||
$cross_size;
|
||||
$id_lang = (int)$this->context->language->id;
|
||||
$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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,35 +0,0 @@
|
||||
<?php
|
||||
/*
|
||||
* 2007-2013 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-2013 PrestaShop SA
|
||||
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
|
||||
* International Registered Trademark & Property of PrestaShop SA
|
||||
*/
|
||||
|
||||
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
|
||||
header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT");
|
||||
|
||||
header("Cache-Control: no-store, no-cache, must-revalidate");
|
||||
header("Cache-Control: post-check=0, pre-check=0", false);
|
||||
header("Pragma: no-cache");
|
||||
|
||||
header("Location: ../");
|
||||
exit;
|
||||
Reference in New Issue
Block a user