// Fixed norm
This commit is contained in:
1 parent
981ce70594
commit
0ff6b25f56
2 files changed
+33
-9
No files matched your search
@@ -29,8 +29,8 @@ if (!defined('_PS_VERSION_'))
|
|||||||
|
|
||||||
class Gapi extends Module
|
class Gapi extends Module
|
||||||
{
|
{
|
||||||
public function __construct($type = null)
|
public function __construct()
|
||||||
{
|
{
|
||||||
$this->name = 'gapi';
|
$this->name = 'gapi';
|
||||||
$this->tab = 'administration';
|
$this->tab = 'administration';
|
||||||
$this->version = 0.9;
|
$this->version = 0.9;
|
||||||
@@ -40,7 +40,7 @@ class Gapi extends Module
|
|||||||
parent::__construct();
|
parent::__construct();
|
||||||
|
|
||||||
$this->displayName = $this->l('Google Analytics API');
|
$this->displayName = $this->l('Google Analytics API');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function isConfigured()
|
public function isConfigured()
|
||||||
{
|
{
|
||||||
@@ -64,7 +64,7 @@ class Gapi extends Module
|
|||||||
'.(($curl && $allow_url_fopen) ? '' : '<li>'.$this->l('You are not allowed to open external URLs').'</li>').'
|
'.(($curl && $allow_url_fopen) ? '' : '<li>'.$this->l('You are not allowed to open external URLs').'</li>').'
|
||||||
'.(($curl && $allow_url_fopen) ? '' : '<li>'.$this->l('cURL is not enabled').'</li>').'
|
'.(($curl && $allow_url_fopen) ? '' : '<li>'.$this->l('cURL is not enabled').'</li>').'
|
||||||
'.($openssl ? '' : '<li>'.$this->l('OpenSSL is not enabled').'</li>').'
|
'.($openssl ? '' : '<li>'.$this->l('OpenSSL is not enabled').'</li>').'
|
||||||
'.(($allow_url_fopen AND $openssl AND !$ping) ? '<li>'.$this->l('Google is unreachable').' ('.$this->l('check your firewall').')</li>' : '').'
|
'.(($allow_url_fopen && $openssl && !$ping) ? '<li>'.$this->l('Google is unreachable').' ('.$this->l('check your firewall').')</li>' : '').'
|
||||||
'.($online ? '' : '<li>'.$this->l('Your store is not online').'</li>').'
|
'.($online ? '' : '<li>'.$this->l('Your store is not online').'</li>').'
|
||||||
</ul>');
|
</ul>');
|
||||||
}
|
}
|
||||||
@@ -338,7 +338,7 @@ class Gapi extends Module
|
|||||||
{
|
{
|
||||||
$metrics = array();
|
$metrics = array();
|
||||||
$dimensions = array();
|
$dimensions = array();
|
||||||
foreach($row as $key => $value)
|
foreach ($row as $key => $value)
|
||||||
if ($response['columnHeaders'][$key]['columnType'] == 'DIMENSION')
|
if ($response['columnHeaders'][$key]['columnType'] == 'DIMENSION')
|
||||||
$dimensions[str_replace('ga:', '', $response['columnHeaders'][$key]['name'])] = $value;
|
$dimensions[str_replace('ga:', '', $response['columnHeaders'][$key]['name'])] = $value;
|
||||||
elseif ($response['columnHeaders'][$key]['columnType'] == 'METRIC')
|
elseif ($response['columnHeaders'][$key]['columnType'] == 'METRIC')
|
||||||
@@ -453,7 +453,7 @@ class Gapi extends Module
|
|||||||
$stream_context = stream_context_create(array(
|
$stream_context = stream_context_create(array(
|
||||||
'http' => array(
|
'http' => array(
|
||||||
'method'=> 'GET',
|
'method'=> 'GET',
|
||||||
'header' => "Authorization: GoogleLogin auth=".$this->auth_token."\r\n",
|
'header' => 'Authorization: GoogleLogin auth='.$this->auth_token."\r\n",
|
||||||
'timeout' => 5,
|
'timeout' => 5,
|
||||||
)
|
)
|
||||||
));
|
));
|
||||||
@@ -486,16 +486,16 @@ class Gapi extends Module
|
|||||||
$metrics = array();
|
$metrics = array();
|
||||||
foreach ($entry->children('http://schemas.google.com/analytics/2009')->metric as $metric)
|
foreach ($entry->children('http://schemas.google.com/analytics/2009')->metric as $metric)
|
||||||
{
|
{
|
||||||
$key = str_replace('ga:','',$metric->attributes()->name);
|
$key = str_replace('ga:', '', $metric->attributes()->name);
|
||||||
$metric_value = strval($metric->attributes()->value);
|
$metric_value = strval($metric->attributes()->value);
|
||||||
if (preg_match('/^(\d+\.\d+)|(\d+E\d+)|(\d+.\d+E\d+)$/',$metric_value))
|
if (preg_match('/^(\d+\.\d+)|(\d+E\d+)|(\d+.\d+E\d+)$/', $metric_value))
|
||||||
$metrics[$key] = floatval($metric_value);
|
$metrics[$key] = floatval($metric_value);
|
||||||
else
|
else
|
||||||
$metrics[$key] = intval($metric_value);
|
$metrics[$key] = intval($metric_value);
|
||||||
}
|
}
|
||||||
|
|
||||||
$dimensions = array();
|
$dimensions = array();
|
||||||
foreach($entry->children('http://schemas.google.com/analytics/2009')->dimension as $dimension)
|
foreach ($entry->children('http://schemas.google.com/analytics/2009')->dimension as $dimension)
|
||||||
$dimensions[str_replace('ga:', '', $dimension->attributes()->name)] = strval($dimension->attributes()->value);
|
$dimensions[str_replace('ga:', '', $dimension->attributes()->name)] = strval($dimension->attributes()->value);
|
||||||
|
|
||||||
$result[] = array('metrics' => $metrics, 'dimensions' => $dimensions);
|
$result[] = array('metrics' => $metrics, 'dimensions' => $dimensions);
|
||||||
|
|||||||
@@ -1,4 +1,28 @@
|
|||||||
<?php
|
<?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');
|
include(dirname(__FILE__).'/../../config/config.inc.php');
|
||||||
include(dirname(__FILE__).'/gapi.php');
|
include(dirname(__FILE__).'/gapi.php');
|
||||||
|
|||||||
Reference in new issue
Block a user