-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathanalyticsblock.php
63 lines (46 loc) · 1.36 KB
/
analyticsblock.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
<?php
if (!defined('_PS_VERSION_'))
exit;
class AnalyticsBlock extends Module
{
public function __construct()
{
$this->name = 'analyticsblock';
$this->tab = 'front_office_features';
$this->version = '1.0.1';
$this->author = 'waterwhite';
$this->need_instance = 0;
$this->ps_versions_compliancy = array('min' => '1.6', 'max' => _PS_VERSION_);
$this->bootstrap = true;
parent::__construct();
$this->displayName = $this->l('AnalyticsBlock');
$this->description = $this->l('Adds template page to <header> for placing your codes for Analytics.');
$this->confirmUninstall = $this->l('Are you sure you want to uninstall?');
}
// install and register hooks
public function install()
{
if (Shop::isFeatureActive())
Shop::setContext(Shop::CONTEXT_ALL);
if (!parent::install() ||
!$this->registerHook('header') ||
!Configuration::updateValue('ANALYTICSBLOCK_TOKEN', substr(md5(time()), -15, 7))
)
return false;
return true;
}
// uninstall
public function uninstall()
{
if (!parent::uninstall() ||
!Configuration::deleteByName('ANALYTICSBLOCK_TOKEN')
)
return false;
return true;
}
// set files to header
public function hookDisplayHeader()
{
return $this->display(__FILE__, 'analyticsblock.tpl');
}
}