* @copyright 2007-2014 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 = '1.2.2'; $this->author = 'PrestaShop'; $this->need_instance = 0; parent::__construct(); $this->displayName = $this->l('Browsers and operating systems'); $this->description = $this->l('Adds a tab containing graphs about web browser and operating system usage to the Stats dashboard.'); $this->ps_versions_compliancy = array('min' => '1.6', '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')); else if (Tools::getValue('exportType') == 'os') $this->csvExport(array('type' => 'pie', 'option' => 'os')); $equipment = $this->getEquipment(); $this->html = '
'.$this->l('When managing a website, it is important to keep track of the software used by visitors in order 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 modify 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.').'
'.$this->l('Indicates the percentage of each web browser used by customers.').'
'.$this->l('Indicates the percentage of each operating system used by customers.').'
'.$this->l('Plugins').' | |
---|---|
'.$name.' | '.number_format(100 * $value, 2).'% |