diff --git a/modules/statsgeolocation/config.php b/modules/statsgeolocation/config.php deleted file mode 100644 index c8f582fee..000000000 --- a/modules/statsgeolocation/config.php +++ /dev/null @@ -1,109 +0,0 @@ - -* @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 = ' - '; - $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) ? ' | ' : '
'; - $output .= ''.$row['name'] . ' (' . $row['iso_code'] . ')'; - $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 = ' - '; - - $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 .= ' - -
-
'; - 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
"); - 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); -} - - diff --git a/modules/statsgeolocation/config.xml b/modules/statsgeolocation/config.xml deleted file mode 100755 index 94f7f3c0f..000000000 --- a/modules/statsgeolocation/config.xml +++ /dev/null @@ -1,12 +0,0 @@ - - - statsgeolocation - - - - - - 1 - 0 - - \ No newline at end of file diff --git a/modules/statsgeolocation/drawer.php b/modules/statsgeolocation/drawer.php deleted file mode 100644 index 7d5646a21..000000000 --- a/modules/statsgeolocation/drawer.php +++ /dev/null @@ -1,89 +0,0 @@ - -* @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); - diff --git a/modules/statsgeolocation/img/cross.png b/modules/statsgeolocation/img/cross.png deleted file mode 100644 index c53f6810f..000000000 Binary files a/modules/statsgeolocation/img/cross.png and /dev/null differ diff --git a/modules/statsgeolocation/img/index.php b/modules/statsgeolocation/img/index.php deleted file mode 100644 index 3f6561f72..000000000 --- a/modules/statsgeolocation/img/index.php +++ /dev/null @@ -1,35 +0,0 @@ - -* @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; \ No newline at end of file diff --git a/modules/statsgeolocation/img/map.png b/modules/statsgeolocation/img/map.png deleted file mode 100644 index 74504a206..000000000 Binary files a/modules/statsgeolocation/img/map.png and /dev/null differ diff --git a/modules/statsgeolocation/index.php b/modules/statsgeolocation/index.php deleted file mode 100644 index 3f6561f72..000000000 --- a/modules/statsgeolocation/index.php +++ /dev/null @@ -1,35 +0,0 @@ - -* @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; \ No newline at end of file diff --git a/modules/statsgeolocation/logo.gif b/modules/statsgeolocation/logo.gif deleted file mode 100644 index 5ae4d1d37..000000000 Binary files a/modules/statsgeolocation/logo.gif and /dev/null differ diff --git a/modules/statsgeolocation/logo.png b/modules/statsgeolocation/logo.png deleted file mode 100755 index a4b55f7d6..000000000 Binary files a/modules/statsgeolocation/logo.png and /dev/null differ diff --git a/modules/statsgeolocation/statsgeolocation.js b/modules/statsgeolocation/statsgeolocation.js deleted file mode 100644 index 0e233e58f..000000000 --- a/modules/statsgeolocation/statsgeolocation.js +++ /dev/null @@ -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 -* @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 }; -} diff --git a/modules/statsgeolocation/statsgeolocation.php b/modules/statsgeolocation/statsgeolocation.php deleted file mode 100644 index 000bef722..000000000 --- a/modules/statsgeolocation/statsgeolocation.php +++ /dev/null @@ -1,190 +0,0 @@ - -* @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 = ' -
'.$this->displayName.' -
-

'.$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.').'

-
-

- -

- -

-
'.$this->l('Guide').' -

'.$this->l('Open to the world').'

-

-

-

-
'; - return $this->_html; - } - - public function getContent() - { - $output = '

'.$this->displayName.'

'; - 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 = ' - - -
'.$this->l('Update coordinates').' -
'.$this->l('Click on a country\'s name and define its position on the map').'

-
- -
-
'.$wait.'
- - - - - - - - - - - - - -
'; - return $output; - } -} - diff --git a/modules/statsgeolocation/translations/index.php b/modules/statsgeolocation/translations/index.php deleted file mode 100644 index 3f6561f72..000000000 --- a/modules/statsgeolocation/translations/index.php +++ /dev/null @@ -1,35 +0,0 @@ - -* @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; \ No newline at end of file