Skip to content

Commit

Permalink
Merge pull request #1124 from ucfcdl/dev/3.6.5
Browse files Browse the repository at this point in the history
Dev/3.6.5
  • Loading branch information
clpetersonucf authored Jun 19, 2018
2 parents a0bb3ba + 3b7003b commit 720f7a4
Show file tree
Hide file tree
Showing 8 changed files with 36 additions and 26 deletions.
18 changes: 18 additions & 0 deletions fuel/app/classes/trait/analytics.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?php
/**
* Materia
* License outlined in licenses folder
*/

trait Trait_Analytics
{
protected function insert_analytics()
{
if ($gid = Config::get('materia.google_tracking_id', false))
{
$this->theme->set_partial('google_analytics', 'partials/google_analytics')
->set('id', $gid);
}
}

}
8 changes: 3 additions & 5 deletions fuel/app/classes/trait/commoncontrollertemplate.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@

trait Trait_CommonControllerTemplate
{
use Trait_Analytics;

protected $_header = 'partials/header';
protected $_disable_browser_cache = false;

Expand All @@ -25,11 +27,7 @@ public function after($response)

$this->theme->set_partial('header', $this->_header)->set('me', $me);

// add google analytics
if ($gid = Config::get('materia.google_tracking_id', false))
{
Js::push_inline($this->theme->view('partials/google_analytics', ['id' => $gid]));
}
$this->insert_analytics();

$response = Response::forge(Theme::instance()->render());
}
Expand Down
6 changes: 2 additions & 4 deletions fuel/app/modules/lti/classes/controller/error.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

class Controller_Error extends \Controller
{
use Trait_Analytics;
protected $_content_partial = 'partials/error_general';
protected $_message = 'There was a problem';

Expand All @@ -27,10 +28,7 @@ public function after($response)
->set('title', "Error - {$msg}")
->set('system', $system);

if ($gid = \Config::get('materia.google_tracking_id', false))
{
\Js::push_inline($this->theme->view('partials/google_analytics', ['id' => $gid]));
}
$this->insert_analytics();

\Js::push_group(['angular', 'materia']);
\Js::push_inline('var BASE_URL = "'.\Uri::base().'";');
Expand Down
8 changes: 1 addition & 7 deletions fuel/app/modules/lti/classes/controller/lti.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

class Controller_Lti extends \Controller
{
use Trait_Analytics;

public function before()
{
Expand Down Expand Up @@ -127,11 +128,4 @@ public function action_success($inst_id)
return \Response::forge($this->theme->render());
}

protected function insert_analytics()
{
if ($gid = \Config::get('materia.google_tracking_id', false))
{
\Js::push_inline($this->theme->view('partials/google_analytics', ['id' => $gid]));
}
}
}
1 change: 1 addition & 0 deletions fuel/app/themes/default/layouts/main.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
<title><?= $title ?> | Materia</title>
<?= Css::render() ?>
<?= Js::render() ?>
<?= (isset($partials['google_analytics']) ? $partials['google_analytics']: '' ) ?>
</head>
<body class="<?= (isset($page_type) ? $page_type : '') ?>" ng-app="materia">
<?= (isset($partials['header']) ? $partials['header'] : '' ) ?>
Expand Down
16 changes: 7 additions & 9 deletions fuel/app/themes/default/partials/google_analytics.php
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
var _gaq = _gaq || [];
_gaq.push(['_setAccount', '<?= $id ?>']);
_gaq.push(['_trackPageview']);

(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
<script async src="https://www.googletagmanager.com/gtag/js?id=<?= $id ?>"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', '<?= $id ?>', {'anonymize_ip': true});
</script>
2 changes: 1 addition & 1 deletion fuel/packages/materia/tasks/widget.php
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ private static function login_as_admin()

if ($admin_ids->count() > 0)
{
\Auth::instance('Materiaauth')->force_login($admin_ids[0]['id']);
\Auth::instance()->force_login($admin_ids[0]['id']);
}
else
{
Expand Down
3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
"name": "@ucfcdl/materia",
"author": "University of Central Florida, Center for Distributed Learning",
"homepage": "https://github.com/ucfcdl/Materia",
"engines": {
"node": "^6.9.1"
},
"scripts": {
"build": "webpack -p",
"build-dev": "webpack",
Expand Down

0 comments on commit 720f7a4

Please sign in to comment.