|
@@ -58,25 +58,25 @@ discard block |
|
|
block discarded – undo |
|
58
|
58
|
{ |
|
59
|
59
|
$source = $args->getReturn(); |
|
60
|
60
|
|
|
61
|
|
- if(strpos($source, '<html') === false && !$this->container->get('front')->Request()->isXmlHttpRequest()) { |
|
|
61
|
+ if (strpos($source, '<html') === false && !$this->container->get('front')->Request()->isXmlHttpRequest()) { |
|
62
|
62
|
return $source; |
|
63
|
63
|
} |
|
64
|
64
|
|
|
65
|
65
|
$containerId = $this->container->get('config')->getByNamespace('WbmTagManager', 'wbmTagManagerContainer'); |
|
66
|
66
|
$prettyPrint = $this->container->get('config')->getByNamespace('WbmTagManager', 'wbmTagManagerJsonPrettyPrint'); |
|
67
|
67
|
|
|
68
|
|
- if( |
|
|
68
|
+ if ( |
|
69
|
69
|
!empty($containerId) && |
|
70
|
70
|
strtolower($this->container->get('front')->Request()->getModuleName()) != 'backend' |
|
71
|
71
|
) { |
|
72
|
|
- if(!$this->container->get('front')->Request()->isXmlHttpRequest()) { |
|
|
72
|
+ if (!$this->container->get('front')->Request()->isXmlHttpRequest()) { |
|
73
|
73
|
$headTag = file_get_contents($this->container->getParameter('wbm_tag_manager.plugin_dir') . '/Resources/tags/head.html'); |
|
74
|
74
|
$bodyTag = file_get_contents($this->container->getParameter('wbm_tag_manager.plugin_dir') . '/Resources/tags/body.html'); |
|
75
|
75
|
|
|
76
|
76
|
$headTag = sprintf($headTag, $containerId); |
|
77
|
77
|
$bodyTag = sprintf($bodyTag, $containerId); |
|
78
|
78
|
|
|
79
|
|
- if($dataLayer = $this->container->get('wbm_tag_manager.variables')->getVariables()) { |
|
|
79
|
+ if ($dataLayer = $this->container->get('wbm_tag_manager.variables')->getVariables()) { |
|
80
|
80
|
array_walk_recursive($dataLayer, array($this, 'castArrayValues')); |
|
81
|
81
|
|
|
82
|
82
|
$headTag = "<script>window.dataLayer = window.dataLayer || []; window.dataLayer.push(" . |
|
@@ -101,15 +101,15 @@ discard block |
|
|
block discarded – undo |
|
101
|
101
|
*/ |
|
102
|
102
|
$matches = preg_split('/(<body.*?>)/i', $source, 2, PREG_SPLIT_NO_EMPTY | PREG_SPLIT_DELIM_CAPTURE); |
|
103
|
103
|
|
|
104
|
|
- if(!empty($matches)) { |
|
|
104
|
+ if (!empty($matches)) { |
|
105
|
105
|
/* assemble the HTML output back with the iframe code in it */ |
|
106
|
106
|
$source = $matches[0] . $matches[1] . $bodyTag . $matches[2]; |
|
107
|
107
|
} |
|
108
|
|
- } else if($dataLayer = $this->container->get('wbm_tag_manager.variables')->getVariables()) { |
|
|
108
|
+ } else if ($dataLayer = $this->container->get('wbm_tag_manager.variables')->getVariables()) { |
|
109
|
109
|
array_walk_recursive($dataLayer, array($this, 'castArrayValues')); |
|
110
|
110
|
|
|
111
|
111
|
$source = "<script>window.dataLayer.push(" . |
|
112
|
|
- json_encode($dataLayer,($prettyPrint) ? JSON_PRETTY_PRINT : null) . |
|
|
112
|
+ json_encode($dataLayer, ($prettyPrint) ? JSON_PRETTY_PRINT : null) . |
|
113
|
113
|
");</script>" . |
|
114
|
114
|
$source; |
|
115
|
115
|
|