Hello,
It must someting like that ?
<?php
/**
*
* @copyright 2008 - https://www.clicshopping.org
* @Brand : ClicShopping(Tm) at Inpi all right Reserved
* @Licence GPL 2 & MIT
* @licence MIT - Portion of osCommerce 2.4
* @Info : https://www.clicshopping.org/forum/trademark/
*
*/
use ClicShopping\OM\Registry;
use ClicShopping\OM\CLICSHOPPING;
class ht_google_analytics
{
public $code;
public $group;
public string $title;
public string $description;
public ?int $sort_order = 0;
public bool $enabled = false;
public function __construct()
{
$this->code = get_class($this);
$this->group = basename(__DIR__);
$this->title = CLICSHOPPING::getDef('module_header_tags_ganalytics_title');
$this->description = CLICSHOPPING::getDef('module_header_tags_ganalytics_description');
if (defined('MODULES_HEADER_TAGS_GANALYTICS_STATUS')) {
$this->sort_order = MODULES_HEADER_TAGS_GANALYTICS_SORT_ORDER;
$this->enabled = (MODULES_HEADER_TAGS_GANALYTICS_STATUS == 'True');
}
}
public function execute()
{
$CLICSHOPPING_Template = Registry::get('Template');
$header_flow = '<!--Start of Google analytics Script-->' . "\n";
$header_flow .= '
<script async src="https://www.googletagmanager.com/gtag/js?id="' . MODULES_HEADER_TAGS_GANALYTICS_KEY .'"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag(\'js\', new Date());
gtag(\'config\', " . MODULES_HEADER_TAGS_GANALYTICS_KEY .");
';.
$header_flow .= '</script>' . "\n";
$header_flow .= '<script type="text/javascript">mixpanel.track("' . MODULES_HEADER_TAGS_GANALYTICS_SPEUDO . '");</script>' . "\n";
$header_flow .= '<!--End Mixpanel Script-->' . "\n";
$CLICSHOPPING_Template->addBlock($header_flow, $this->group);
}
public function isEnabled()
{
return $this->enabled;
}
public function check()
{
return defined('MODULES_HEADER_TAGS_GANALYTICS_STATUS');
}
public function install()
{
$CLICSHOPPING_Db = Registry::get('Db');
$CLICSHOPPING_Db->save('configuration', [
'configuration_title' => 'Do you want to install this module ?',
'configuration_key' => 'MODULES_HEADER_TAGS_GANALYTICS_STATUS',
'configuration_value' => 'True',
'configuration_description' => 'Do you want to install this module ?',
'configuration_group_id' => '6',
'sort_order' => '1',
'set_function' => 'clic_cfg_set_boolean_value(array(\'True\', \'False\'))',
'date_added' => 'now()'
]
);
$CLICSHOPPING_Db->save('configuration', [
'configuration_title' => 'Veuillez insérer la clef (https://mixpanel.com)',
'configuration_key' => 'MODULES_HEADER_TAGS_GANALYTICS_KEY',
'configuration_value' => '',
'configuration_description' => 'Cette clef est nécessaire pour pouvoir afficher les statistiques<br> ex : 203927b013fdbf2f7322b1865b4ea54e',
'configuration_group_id' => '6',
'sort_order' => '60',
'set_function' => '',
'date_added' => 'now()'
]
);
$CLICSHOPPING_Db->save('configuration', [
'configuration_title' => 'Sort Order',
'configuration_key' => 'MODULES_HEADER_TAGS_GANALYTICS_SORT_ORDER',
'configuration_value' => '80',
'configuration_description' => 'Sort order. Lowest is displayed in first',
'configuration_group_id' => '6',
'sort_order' => '60',
'set_function' => '',
'date_added' => 'now()'
]
);
}
public function remove()
{
return Registry::get('Db')->exec('delete from :table_configuration where configuration_key in ("' . implode('", "', $this->keys()) . '")');
}
public function keys()
{
return array('MODULES_HEADER_TAGS_GANALYTICS_STATUS',
'MODULES_HEADER_TAGS_GANALYTICS_KEY',
'MODULES_HEADER_TAGS_GANALYTICS_SORT_ORDER'
);
}
}