1+ <?php
2+ /**
3+ * 2007-2020 PrestaShop.
4+ *
5+ * NOTICE OF LICENSE
6+ *
7+ * This source file is subject to the Academic Free License (AFL 3.0)
8+ * that is bundled with this package in the file LICENSE.txt.
9+ * It is also available through the world-wide-web at this URL:
10+ * http://opensource.org/licenses/afl-3.0.php
11+ * If you did not receive a copy of the license and are unable to
12+ * obtain it through the world-wide-web, please send an email
13+ * to license@prestashop.com so we can send you a copy immediately.
14+ *
15+ * DISCLAIMER
16+ *
17+ * Do not edit or add to this file if you wish to upgrade PrestaShop to newer
18+ * versions in the future. If you wish to customize PrestaShop for your
19+ * needs please refer to http://www.prestashop.com for more information.
20+ *
21+ * @author PrestaShop SA <contact@prestashop.com>
22+ * @copyright 2007-2020 PrestaShop SA
23+ * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
24+ * International Registered Trademark & Property of PrestaShop SA
25+ */
26+
27+ namespace PrestaShop \Module \Ps_Googleanalytics \Handler ;
28+
29+ class GanalyticsJsHandler
30+ {
31+ private $ module ;
32+ private $ context ;
33+
34+ public function __construct (\Ps_googleanalytics $ module , \Context $ context ) {
35+ $ this ->module = $ module ;
36+ $ this ->context = $ context ;
37+ }
38+
39+ /**
40+ * Generate Google Analytics js
41+ *
42+ * @param string $jsCode
43+ * @param int $isBackoffice
44+ *
45+ * @return string
46+ */
47+ public function generate ($ jsCode , $ isBackoffice = 0 )
48+ {
49+ if (\Configuration::get ('GA_ACCOUNT_ID ' )) {
50+ $ this ->context ->smarty ->assign (
51+ array (
52+ 'jsCode ' => $ jsCode ,
53+ 'isoCode ' => \Tools::safeOutput ($ this ->context ->currency ->iso_code ),
54+ 'jsState ' => $ this ->module ->js_state ,
55+ 'isBackoffice ' => $ isBackoffice ,
56+ )
57+ );
58+
59+ return $ this ->module ->display (
60+ $ this ->module ->getLocalPath () . $ this ->module ->name ,
61+ 'ga_tag.tpl '
62+ );
63+ }
64+ }
65+
66+ }
0 commit comments