Skip to content

Commit

Permalink
Update web trackers #141
Browse files Browse the repository at this point in the history
  • Loading branch information
bodiapz committed Apr 2, 2015
1 parent 38c33fa commit e43b0c8
Show file tree
Hide file tree
Showing 4 changed files with 66 additions and 13 deletions.
2 changes: 1 addition & 1 deletion TGD/protected/components/Controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ class Controller extends CController
array('label'=>'Manage Transactions', 'url'=>array('/transactions/admin')),
array('label'=>'Manage Seniority Levels', 'url'=>array('/admin/seniorityLevels')),
array('label'=>'Manage Interest Categories', 'url'=>array('/admin/interestCategories')),
array('label'=>'Compare Web Trackers', 'url'=>array('/admin/webtrackers')),
array('label'=>'Manage Web Trackers', 'url'=>array('/admin/webtrackers')),
array('label'=>'Slow Query Logs', 'url'=>array('/admin/slowQueryLog/admin')),
array('label'=>'Caching', 'url'=>array('/admin/cache/index')),
//array('label'=>'Manage Achievement Types', 'url'=>array('/achievementsTypes/admin')),
Expand Down
28 changes: 22 additions & 6 deletions TGD/protected/modules/admin/controllers/WebtrackersController.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@ class WebtrackersController extends AdminModuleController
* Manages all models.
*/
public function actionIndex()
{
$this->render('index');
}

public function actionCompare()
{
$file1 = file_get_contents("https://raw.github.com/disconnectme/disconnect/master/firefox/content/disconnect.safariextension/opera/chrome/data/services.json");
$file2 = file_get_contents("https://raw.githubusercontent.com/thegooddata/extension/94d49837a68c5c9382b2c8e20b59d36c7d0d6fea/chrome/data/services.json");
Expand Down Expand Up @@ -35,18 +40,29 @@ public function actionIndex()
}
}

$trackers = $this->arrayRecursiveDiff($file1['categories'], $file2['categories']);
$trackers1 = $this->arrayRecursiveDiff($file1['categories'], $file2['categories']);

foreach($trackers1 as $index => $arr) {
foreach ($arr as $k => $value) {
foreach ($value as $key => $val)
$trackers1[$index][][$key] = array_values($val);
unset($trackers1[$index][$k]);
}
}
$trackers1 = json_encode($trackers1, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES);

$trackers2 = $this->arrayRecursiveDiff($file2['categories'], $file1['categories']);

foreach($trackers as $index => $arr) {
foreach($trackers2 as $index => $arr) {
foreach ($arr as $k => $value) {
foreach ($value as $key => $val)
$trackers[$index][][$key] = array_values($val);
unset($trackers[$index][$k]);
$trackers2[$index][][$key] = array_values($val);
unset($trackers2[$index][$k]);
}
}
$trackers = json_encode($trackers, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES);
$trackers2 = json_encode($trackers2, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES);

$this->render('index',array('trackers'=>$trackers));
$this->render('compare',array('trackers1'=>$trackers1, 'trackers2'=>$trackers2));
}

protected function arrayRecursiveDiff($aArray1, $aArray2) {
Expand Down
35 changes: 35 additions & 0 deletions TGD/protected/modules/admin/views/webtrackers/compare.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<?php
$this->breadcrumbs=array(
'Manage Web Tracks'=>array('index')
);

$this->layout='//layouts/column2';

?>

<h1>Compare Web Trackers</h1>
<a class="compare-link" data="h1" href="#">Trackers that are not longer in disconnect.me file but are still on our file</a>
<br/>
<a class="compare-link" data="h2" href="#">Trackers that have been added to disconnect.me and are still not on our file</a>

<br/>
<br/>

<div class="compare-block hide" id="h1">
<h4>Trackers that are not longer in disconnect.me file but are still on our file</h4>
<?php echo "<pre>$trackers2</pre>"; ?>
</div>

<div class="compare-block hide" id="h2">
<h4>Trackers that have been added to disconnect.me and are still not on our file</h4>
<?php echo "<pre>$trackers1</pre>"; ?>
</div>
<script>
$(function(){
$('.compare-link').click(function(){
$('.compare-block').addClass('hide')
$('#'+$(this).attr('data')).removeClass('hide');
return false;
})
})
</script>
14 changes: 8 additions & 6 deletions TGD/protected/modules/admin/views/webtrackers/index.php
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
<?php
$this->breadcrumbs=array(
'Compare Web Trackers'=>array('index')
'Manage Web Trackers'=>array('index')
);

$this->menu=array(

array('label'=>'Compare Web Trackers', 'url'=>array('/admin/webtrackers/compare')),
);

$this->layout='//layouts/column2';

?>
<h1>Manage Web Trackers</h1>

<h1>Compare Web Trackers</h1>

<div>
<?php echo "<pre>$trackers</pre>"; ?>
</div><!-- form -->
<?php echo CHtml::link('Compare Web Trackers', array("/admin/webtrackers/compare"), array('class' => 'btn btn-success'));?>

0 comments on commit e43b0c8

Please sign in to comment.