first commit
This commit is contained in:
12
modules/statsequipment/config.xml
Normal file
12
modules/statsequipment/config.xml
Normal file
@@ -0,0 +1,12 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<module>
|
||||
<name>statsequipment</name>
|
||||
<displayName><![CDATA[Browsers and operating systems]]></displayName>
|
||||
<version><![CDATA[2.0.0]]></version>
|
||||
<description><![CDATA[Adds a tab containing graphs about web browser and operating system usage to the Stats dashboard.]]></description>
|
||||
<author><![CDATA[PrestaShop]]></author>
|
||||
<tab><![CDATA[analytics_stats]]></tab>
|
||||
<is_configurable>0</is_configurable>
|
||||
<need_instance>0</need_instance>
|
||||
<limited_countries></limited_countries>
|
||||
</module>
|
||||
12
modules/statsequipment/config_pl.xml
Normal file
12
modules/statsequipment/config_pl.xml
Normal file
@@ -0,0 +1,12 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<module>
|
||||
<name>statsequipment</name>
|
||||
<displayName><![CDATA[Przeglądarki i systemy operacyjne]]></displayName>
|
||||
<version><![CDATA[2.0.0]]></version>
|
||||
<description><![CDATA[Dodaje zakładkę zawierającą wykresy dotyczące przeglądarki i użytkowania systemu operacyjnego w panelu statystyk.]]></description>
|
||||
<author><![CDATA[PrestaShop]]></author>
|
||||
<tab><![CDATA[analytics_stats]]></tab>
|
||||
<is_configurable>0</is_configurable>
|
||||
<need_instance>0</need_instance>
|
||||
<limited_countries></limited_countries>
|
||||
</module>
|
||||
36
modules/statsequipment/index.php
Normal file
36
modules/statsequipment/index.php
Normal file
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
/*
|
||||
* 2007-2016 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-2016 PrestaShop SA
|
||||
* @version Release: $Revision$
|
||||
* @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;
|
||||
BIN
modules/statsequipment/logo.gif
Normal file
BIN
modules/statsequipment/logo.gif
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.0 KiB |
BIN
modules/statsequipment/logo.png
Normal file
BIN
modules/statsequipment/logo.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 2.1 KiB |
217
modules/statsequipment/statsequipment.php
Normal file
217
modules/statsequipment/statsequipment.php
Normal file
@@ -0,0 +1,217 @@
|
||||
<?php
|
||||
/*
|
||||
* 2007-2015 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-2015 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 statsequipment extends ModuleGraph
|
||||
{
|
||||
private $html = '';
|
||||
private $query = '';
|
||||
private $query2 = '';
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->name = 'statsequipment';
|
||||
$this->tab = 'analytics_stats';
|
||||
$this->version = '2.0.0';
|
||||
$this->author = 'PrestaShop';
|
||||
$this->need_instance = 0;
|
||||
|
||||
parent::__construct();
|
||||
|
||||
$this->displayName = $this->trans('Browsers and operating systems', array(), 'Modules.Statsequipment.Admin');
|
||||
$this->description = $this->trans('Adds a tab containing graphs about web browser and operating system usage to the Stats dashboard.', array(), 'Modules.Statsequipment.Admin');
|
||||
$this->ps_versions_compliancy = array('min' => '1.7.1.0', 'max' => _PS_VERSION_);
|
||||
}
|
||||
|
||||
public function install()
|
||||
{
|
||||
return (parent::install() && $this->registerHook('AdminStatsModules'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array Get list of browser "plugins" (javascript, media player, etc.)
|
||||
*/
|
||||
private function getEquipment()
|
||||
{
|
||||
$sql = 'SELECT DISTINCT g.*
|
||||
FROM `'._DB_PREFIX_.'connections` c
|
||||
LEFT JOIN `'._DB_PREFIX_.'guest` g ON g.`id_guest` = c.`id_guest`
|
||||
WHERE c.`date_add` BETWEEN '.ModuleGraph::getDateBetween().'
|
||||
'.Shop::addSqlRestriction(false, 'c');
|
||||
$result = Db::getInstance(_PS_USE_SQL_SLAVE_)->query($sql);
|
||||
|
||||
$calc_array = array(
|
||||
'jsOK' => 0,
|
||||
'jsKO' => 0,
|
||||
'javaOK' => 0,
|
||||
'javaKO' => 0,
|
||||
'wmpOK' => 0,
|
||||
'wmpKO' => 0,
|
||||
'qtOK' => 0,
|
||||
'qtKO' => 0,
|
||||
'realOK' => 0,
|
||||
'realKO' => 0,
|
||||
'flashOK' => 0,
|
||||
'flashKO' => 0,
|
||||
'directorOK' => 0,
|
||||
'directorKO' => 0
|
||||
);
|
||||
while ($row = Db::getInstance(_PS_USE_SQL_SLAVE_)->nextRow($result)) {
|
||||
if (!$row['javascript']) {
|
||||
++$calc_array['jsKO'];
|
||||
continue;
|
||||
}
|
||||
++$calc_array['jsOK'];
|
||||
($row['windows_media']) ? ++$calc_array['wmpOK'] : ++$calc_array['wmpKO'];
|
||||
($row['real_player']) ? ++$calc_array['realOK'] : ++$calc_array['realKO'];
|
||||
($row['adobe_flash']) ? ++$calc_array['flashOK'] : ++$calc_array['flashKO'];
|
||||
($row['adobe_director']) ? ++$calc_array['directorOK'] : ++$calc_array['directorKO'];
|
||||
($row['sun_java']) ? ++$calc_array['javaOK'] : ++$calc_array['javaKO'];
|
||||
($row['apple_quicktime']) ? ++$calc_array['qtOK'] : ++$calc_array['qtKO'];
|
||||
}
|
||||
|
||||
if (!$calc_array['jsOK']) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$equip = array(
|
||||
'Windows Media Player' => $calc_array['wmpOK'] / ($calc_array['wmpOK'] + $calc_array['wmpKO']),
|
||||
'Real Player' => $calc_array['realOK'] / ($calc_array['realOK'] + $calc_array['realKO']),
|
||||
'Apple Quicktime' => $calc_array['qtOK'] / ($calc_array['qtOK'] + $calc_array['qtKO']),
|
||||
'Sun Java' => $calc_array['javaOK'] / ($calc_array['javaOK'] + $calc_array['javaKO']),
|
||||
'Adobe Flash' => $calc_array['flashOK'] / ($calc_array['flashOK'] + $calc_array['flashKO']),
|
||||
'Adobe Shockwave' => $calc_array['directorOK'] / ($calc_array['directorOK'] + $calc_array['directorKO'])
|
||||
);
|
||||
arsort($equip);
|
||||
|
||||
return $equip;
|
||||
}
|
||||
|
||||
public function hookAdminStatsModules($params)
|
||||
{
|
||||
if (Tools::getValue('export')) {
|
||||
if (Tools::getValue('exportType') == 'browser') {
|
||||
$this->csvExport(array('type' => 'pie', 'option' => 'wb'));
|
||||
} elseif (Tools::getValue('exportType') == 'os') {
|
||||
$this->csvExport(array('type' => 'pie', 'option' => 'os'));
|
||||
}
|
||||
}
|
||||
|
||||
$equipment = $this->getEquipment();
|
||||
$this->html = '
|
||||
<div class="panel-heading">'
|
||||
.$this->displayName.'
|
||||
</div>
|
||||
<h4>'.$this->trans('Guide', array(), 'Admin.Global').'</h4>
|
||||
<div class="alert alert-warning">
|
||||
<h4>'.$this->trans('Making sure that your website is accessible to as many people as possible', array(), 'Modules.Statsequipment.Admin').'</h4>
|
||||
<p>
|
||||
'.$this->trans('When managing a website, it is important to keep track of the software used by visitors so as to be sure that the site displays the same way for everyone. PrestaShop was built to be compatible with the most recent Web browsers and computer operating systems (OS). However, because you may end up adding advanced features to your website or even modifying the core PrestaShop code, these additions may not be accessible to everyone. That is why it is a good idea to keep track of the percentage of users for each type of software before adding or changing something that only a limited number of users will be able to access.', array(), 'Modules.Statsequipment.Admin').'
|
||||
</p>
|
||||
</div>
|
||||
<div class="row row-margin-bottom">
|
||||
<div class="col-lg-12">
|
||||
<div class="col-lg-8">
|
||||
'.$this->engine(array('type' => 'pie', 'option' => 'wb')).'
|
||||
</div>
|
||||
<div class="col-lg-4">
|
||||
<p>'.$this->trans('Indicates the percentage of each web browser used by customers.', array(), 'Modules.Statsequipment.Admin').'</p>
|
||||
<hr/>
|
||||
<a class="btn btn-default export-csv" href="'.Tools::safeOutput($_SERVER['REQUEST_URI'].'&export=1&exportType=browser').'">
|
||||
<i class="icon-cloud-upload"></i>'.$this->trans('CSV Export', array(), 'Modules.Statsequipment.Admin').'
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row row-margin-bottom">
|
||||
<div class="col-lg-12">
|
||||
<div class="col-lg-8">
|
||||
'.$this->engine(array('type' => 'pie', 'option' => 'os')).'
|
||||
</div>
|
||||
<div class="col-lg-4">
|
||||
<p>'.$this->trans('Indicates the percentage of each operating system used by customers.', array(), 'Modules.Statsequipment.Admin').'</p>
|
||||
<hr/>
|
||||
<a class="btn btn-default export-csv" href="'.Tools::safeOutput($_SERVER['REQUEST_URI'].'&export=1&exportType=os').'">
|
||||
<i class="icon-cloud-upload"></i>'.$this->trans('CSV Export', array(), 'Modules.Statsequipment.Admin').'
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>';
|
||||
if ($equipment) {
|
||||
$this->html .= '<table class="table">
|
||||
<tr><th><span class="title_box active">'.$this->trans('Plugins', array(), 'Modules.Statsequipment.Admin').'</th></span><th></th></tr>';
|
||||
foreach ($equipment as $name => $value) {
|
||||
$this->html .= '<tr><td>'.$name.'</td><td>'.number_format(100 * $value, 2).'%</td></tr>';
|
||||
}
|
||||
$this->html .= '</table>';
|
||||
}
|
||||
|
||||
return $this->html;
|
||||
}
|
||||
|
||||
public function setOption($option, $layers = 1)
|
||||
{
|
||||
switch ($option) {
|
||||
case 'wb':
|
||||
$this->_titles['main'] = $this->trans('Web browser used', array(), 'Modules.Statsequipment.Admin');
|
||||
$this->query = 'SELECT wb.`name`, COUNT(g.`id_web_browser`) AS total
|
||||
FROM `'._DB_PREFIX_.'web_browser` wb
|
||||
LEFT JOIN `'._DB_PREFIX_.'guest` g ON g.`id_web_browser` = wb.`id_web_browser`
|
||||
LEFT JOIN `'._DB_PREFIX_.'connections` c ON g.`id_guest` = c.`id_guest`
|
||||
WHERE 1
|
||||
'.Shop::addSqlRestriction(false, 'c').'
|
||||
AND c.`date_add` BETWEEN ';
|
||||
$this->query2 = ' GROUP BY g.`id_web_browser`';
|
||||
break;
|
||||
|
||||
case 'os':
|
||||
$this->_titles['main'] = $this->trans('Operating system used', array(), 'Modules.Statsequipment.Admin');
|
||||
$this->query = 'SELECT os.`name`, COUNT(g.`id_operating_system`) AS total
|
||||
FROM `'._DB_PREFIX_.'operating_system` os
|
||||
LEFT JOIN `'._DB_PREFIX_.'guest` g ON g.`id_operating_system` = os.`id_operating_system`
|
||||
LEFT JOIN `'._DB_PREFIX_.'connections` c ON g.`id_guest` = c.`id_guest`
|
||||
WHERE 1
|
||||
'.Shop::addSqlRestriction(false, 'c').'
|
||||
AND c.`date_add` BETWEEN ';
|
||||
$this->query2 = ' GROUP BY g.`id_operating_system`';
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
protected function getData($layers)
|
||||
{
|
||||
$result = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($this->query.$this->getDate().$this->query2);
|
||||
$this->_values = array();
|
||||
$i = 0;
|
||||
foreach ($result as $row) {
|
||||
$this->_values[$i] = $row['total'];
|
||||
$this->_legend[$i++] = $row['name'];
|
||||
}
|
||||
}
|
||||
}
|
||||
35
modules/statsequipment/translations/index.php
Normal file
35
modules/statsequipment/translations/index.php
Normal file
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
/*
|
||||
* 2007-2016 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-2016 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;
|
||||
0
modules/statsequipment/translations/pl.php
Normal file
0
modules/statsequipment/translations/pl.php
Normal file
Reference in New Issue
Block a user