Skip to content

Commit

Permalink
Better format (#16)
Browse files Browse the repository at this point in the history
Coding style format updates
  • Loading branch information
thiagotalma authored and Pe Ell committed Jun 23, 2016
1 parent 70a765c commit 6314c2d
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 15 deletions.
15 changes: 12 additions & 3 deletions src/widgets/GATracking.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@
*/
class GATracking extends Widget
{

/**
* Render <script></script>
* Render <script></script>
* @var bool
*/
public $omitScriptTag = false;

/**
* The GA tracking ID
* @var string
Expand Down Expand Up @@ -64,13 +64,19 @@ class GATracking extends Widget
*/
private $_trackingFilename = 'analytics.js';

/**
* @var string
*/
private $_trackingDebugTraceInit = '';

/**
* @var array
*/
private $_viewParams;

/**
* @inheritdoc
*/
public function init()
{
parent::init();
Expand Down Expand Up @@ -103,6 +109,9 @@ public function init()
];
}

/**
* @inheritdoc
*/
public function run()
{
echo $this->render('tracking', $this->_viewParams);
Expand Down
29 changes: 17 additions & 12 deletions src/widgets/views/tracking.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,27 +2,32 @@
/**
* @var boolean $omitScriptTag
* @var string $trackingId
* @var array $trackingParams
* @var array $tackingPlugins
* @var array $trackingConfig
* @var array $fields
* @var array $plugins
* @var string $trackingFilename
* @var string $trackingDebugTraceInit
*/

if (!$omitScriptTag) {
echo "\n<script>";
}
echo $trackingDebugTraceInit;
?>
<?php if (!$omitScriptTag) {
echo '<script>';
} ?>
<?= $trackingDebugTraceInit ?>

(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','//www.google-analytics.com/<?= $trackingFilename ?>','ga');

ga('create', '<?= $trackingId ?>', <?= $trackingConfig ?>);
ga('send', 'pageview');
<?php foreach($fields as $field => $value) : ?>
<?php foreach ($fields as $field => $value) : ?>
ga('set', '<?= $field ?>', <?= $value ?>);
<?php endforeach ?>
<?php foreach($plugins as $plugin => $options) : ?>
<?php endforeach ?>
<?php foreach ($plugins as $plugin => $options) : ?>
ga('require', '<?= $plugin ?>', <?= $options ?>);
<?php endforeach ?>
<?php endforeach ?>
<?php if (!$omitScriptTag) {
echo '</script>';
} ?>
echo "</script>\n";
}

0 comments on commit 6314c2d

Please sign in to comment.