cinasstore_googleanalytics - Version 0.1.0

Version Notes

No License Key.
Only one time Charge (No Charge after Purchase)
Fully Customizable and Non-Encrypted Code. Free Support Supporting Magento Versions 1.7 +

Note- Before Installing the extension, please take the backup of the website

Download this release

Release Info

Developer Cinas Technologies
Extension cinasstore_googleanalytics
Version 0.1.0
Comparing to
See all releases


Version 0.1.0

Files changed (29) hide show
  1. app/code/local/Cinasstore/Googleanalytics/Block/Adminhtml/Dashboard.php +239 -0
  2. app/code/local/Cinasstore/Googleanalytics/Block/Adminhtml/Googleanalytics.php +11 -0
  3. app/code/local/Cinasstore/Googleanalytics/Block/Adminhtml/Googleanalytics/Edit.php +45 -0
  4. app/code/local/Cinasstore/Googleanalytics/Block/Adminhtml/Googleanalytics/Edit/Form.php +19 -0
  5. app/code/local/Cinasstore/Googleanalytics/Block/Adminhtml/Googleanalytics/Edit/Tab/Form.php +58 -0
  6. app/code/local/Cinasstore/Googleanalytics/Block/Adminhtml/Googleanalytics/Edit/Tabs.php +24 -0
  7. app/code/local/Cinasstore/Googleanalytics/Block/Adminhtml/Googleanalytics/Grid.php +116 -0
  8. app/code/local/Cinasstore/Googleanalytics/Block/Googleanalytics.php +12 -0
  9. app/code/local/Cinasstore/Googleanalytics/Helper/Dashboard.php +4 -0
  10. app/code/local/Cinasstore/Googleanalytics/Helper/Data.php +28 -0
  11. app/code/local/Cinasstore/Googleanalytics/Model/Gapi.php +822 -0
  12. app/code/local/Cinasstore/Googleanalytics/Model/Googleanalytics.php +10 -0
  13. app/code/local/Cinasstore/Googleanalytics/Model/Mysql4/Googleanalytics.php +10 -0
  14. app/code/local/Cinasstore/Googleanalytics/Model/Mysql4/Googleanalytics/Collection.php +10 -0
  15. app/code/local/Cinasstore/Googleanalytics/Model/Observer.php +26 -0
  16. app/code/local/Cinasstore/Googleanalytics/Model/Status.php +15 -0
  17. app/code/local/Cinasstore/Googleanalytics/Model/System/Config/Language.php +118 -0
  18. app/code/local/Cinasstore/Googleanalytics/controllers/Adminhtml/DashboardController.php +18 -0
  19. app/code/local/Cinasstore/Googleanalytics/controllers/Adminhtml/GoogleanalyticsController.php +186 -0
  20. app/code/local/Cinasstore/Googleanalytics/controllers/IndexController.php +26 -0
  21. app/code/local/Cinasstore/Googleanalytics/etc/adminhtml.xml +39 -0
  22. app/code/local/Cinasstore/Googleanalytics/etc/config.xml +147 -0
  23. app/code/local/Cinasstore/Googleanalytics/etc/system.xml +63 -0
  24. app/code/local/Cinasstore/Googleanalytics/sql/Googleanalytics_setup/mysql4-install-0.1.0.php +18 -0
  25. app/code/local/Cinasstore/Googleanalytics/sql/Googleanalytics_setup/mysql4-upgrade-0.1.0-0.1.1.php +7 -0
  26. app/design/adminhtml/default/default/layout/googleanalytics.xml +14 -0
  27. app/design/adminhtml/default/default/template/googleanalytics/report.phtml +65 -0
  28. app/etc/modules/Cinasstore_GoogleAnalytics.xml +9 -0
  29. package.xml +22 -0
app/code/local/Cinasstore/Googleanalytics/Block/Adminhtml/Dashboard.php ADDED
@@ -0,0 +1,239 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Cinasstore_Googleanalytics_Block_Adminhtml_Dashboard extends Mage_Adminhtml_Block_Template
3
+ {
4
+ public $auth_token;
5
+ public $ga_profile_id;
6
+ public $ga_email_id;
7
+ public $ga_password;
8
+
9
+ public function __construct()
10
+ {
11
+ $this->_controller = 'adminhtml_dashboard';
12
+ $this->_blockGroup = 'googleanalytics';
13
+ $this->_headerText = Mage::helper('googleanalytics/dashboard')->__('Settings');
14
+ $this->ga_profile_id = Mage::getStoreConfig('googleanalytics/general/analytic_profile_id');
15
+ $this->ga_email_id = Mage::getStoreConfig('googleanalytics/general/analytic_email_id');
16
+ $this->ga_password = Mage::getStoreConfig('googleanalytics/general/analytic_password');
17
+
18
+ parent::__construct();
19
+ }
20
+
21
+ public function getAuthToken()
22
+ {
23
+ if(isset($this->auth_token))
24
+ {
25
+ return $this->auth_token;
26
+ }
27
+ else
28
+ {
29
+ try
30
+ {
31
+ return $this->auth_token = Mage::getModel('googleanalytics/gapi')->authenticateUser($this->ga_email_id,$this->ga_password)->getAuthToken();
32
+ }
33
+ catch (Exception $e)
34
+ {
35
+ echo '<ul class="messages"><li class="error-msg"><ul><li><span>'.$e->getMessage().'</span></li></ul></li></ul>';
36
+ exit;
37
+ }
38
+ }
39
+ }
40
+
41
+
42
+ protected function _toHtml()
43
+ {
44
+ $processor = Mage::getModel('googleanalytics/gapi')->setAuthToken($this->getAuthToken());
45
+
46
+ $this->topReffer = $this->showTopReferrer($processor, $this->ga_profile_id);
47
+ $this->PageViews = $this->showPageViews($processor, $this->ga_profile_id);
48
+ $this->CountryVisits = $this->showCountryVisits($processor, $this->ga_profile_id);
49
+ $this->TopPages = $this->showTopPages($processor, $this->ga_profile_id);
50
+ $this->PageVisitHistory = $this->getPageVisitHistory($processor, $this->ga_profile_id);
51
+
52
+ $html = parent::_toHtml();
53
+ return $html;
54
+ }
55
+
56
+ public function showTopReferrer($ga, $ga_profile_id)
57
+ {
58
+
59
+ $ga->requestReportData($ga_profile_id, array('source','medium'),array('visits'),'-visits', '', '', '', 1,5);
60
+ $results = $ga->getResults();
61
+
62
+ foreach($results as $result)
63
+ {
64
+ $ga_dash_top_referrers .="['".$result->getSource()."',".$result->getVisits()."],";
65
+ }
66
+
67
+
68
+
69
+ $code.='
70
+ google.load("visualization", "1", {packages:["corechart"]});
71
+ google.setOnLoadCallback(ga_dash_drawrd);
72
+
73
+ function ga_dash_drawrd()
74
+ {
75
+ var data = google.visualization.arrayToDataTable([
76
+ [\'Source\', \'Visits\'],
77
+ '.$ga_dash_top_referrers.'
78
+ ]);
79
+ var options = {
80
+ title: \'\'
81
+ };
82
+
83
+ var chart = new google.visualization.PieChart(document.getElementById("ga_dash_rdata"));
84
+ chart.draw(data, options);
85
+
86
+ }';
87
+ return $code;
88
+ }
89
+
90
+ public function showTopPages($ga, $ga_profile_id)
91
+ {
92
+ $ga->requestReportData($ga_profile_id, array('pagePath','pageTitle'),array('pageviews'),'-pageviews');
93
+ $results = $ga->getResults();
94
+
95
+ foreach($results as $result)
96
+ {
97
+ $ga_dash_top_pages .="['".$result->getpagePath()."',".$result->getpageViews()."],";
98
+ }
99
+ $code.='
100
+ google.load("visualization", "1", {packages:["table"]})
101
+ google.setOnLoadCallback(ga_dash_drawpgd);
102
+ function ga_dash_drawpgd() {
103
+ var data = google.visualization.arrayToDataTable(['."
104
+ ['Top Pages', 'Visits'],"
105
+ .$ga_dash_top_pages.
106
+ "
107
+ ]);
108
+
109
+ var options = {
110
+ page: 'enable',
111
+ pageSize: 5,
112
+ width: '100%'
113
+ };
114
+
115
+ var chart = new google.visualization.Table(document.getElementById('ga_dash_pgddata'));
116
+ chart.draw(data, options);
117
+
118
+ }";
119
+ return $code;
120
+ }
121
+
122
+ public function getPageVisitHistory($ga, $ga_profile_id)
123
+ {
124
+ $ga->requestReportData($ga_profile_id, 'pagePath', array('pageviews', 'uniquePageviews', 'exitRate', 'avgTimeOnPage', 'entranceBounceRate'), null, 'pagePath == \'/\'');
125
+ $results = $ga->getResults();
126
+
127
+ foreach($results as $result)
128
+ {
129
+ $ga_dash_top_pages .="['Page Views','".number_format($result->getPageviews())."'],";
130
+ $ga_dash_top_pages .="['Unique Views','".number_format($result->getUniquepageviews())."'],";
131
+ $ga_dash_top_pages .="['Avg time on page','".$this->secondMinute($result->getAvgtimeonpage())."'],";
132
+ $ga_dash_top_pages .="['Bounce rate','".round($result->getEntrancebouncerate(), 2)."'],";
133
+ $ga_dash_top_pages .="['Exit rate','".round($result->getExitrate(), 2)."%'],";
134
+ }
135
+
136
+
137
+ $code.='
138
+ google.load("visualization", "1", {packages:["table"]})
139
+ google.setOnLoadCallback(ga_dash_drawVisitHistory);
140
+ function ga_dash_drawVisitHistory() {
141
+ var data = google.visualization.arrayToDataTable(['."
142
+ ['Title', 'Total'],"
143
+ .$ga_dash_top_pages.
144
+ "
145
+ ]);
146
+
147
+ var options = {
148
+ page: 'enable',
149
+ pageSize: 5,
150
+ width: '100%'
151
+ };
152
+
153
+ var chart = new google.visualization.Table(document.getElementById('ga_dash_historydata'));
154
+ chart.draw(data, options);
155
+
156
+ }";
157
+
158
+ return $code;
159
+ }
160
+
161
+
162
+ public function secondMinute($seconds)
163
+ {
164
+ $minResult = floor($seconds/60);
165
+ if($minResult < 10){$minResult = 0 . $minResult;}
166
+ $secResult = ($seconds/60 - $minResult)*60;
167
+ if($secResult < 10){$secResult = 0 . round($secResult);}
168
+ else { $secResult = round($secResult); }
169
+ return $minResult.":".$secResult;
170
+ }
171
+
172
+ public function showCountryVisits($ga, $ga_profile_id)
173
+ {
174
+ $ga->requestReportData($ga_profile_id, array('country'),array('visits'), 'visits');
175
+ $results = $ga->getResults();
176
+
177
+
178
+ $code='
179
+ google.load("visualization", "1", {packages:["geochart"]});
180
+ google.setOnLoadCallback(ga_dash_drawmap);
181
+ function ga_dash_drawmap() {
182
+ var dataChart = google.visualization.arrayToDataTable(['."
183
+ ['Country', 'Visits'],";
184
+ $countryVar = '';
185
+ foreach($results as $result) {
186
+ $countryVar.='["'.$result->getCountry().'", '.$result->getVisits().'],';
187
+ }
188
+
189
+ $code .= $countryVar."
190
+ ]);
191
+
192
+ var optionsChart = {
193
+ colors: ['white', 'orange'], title:''
194
+ };
195
+
196
+ var chart = new google.visualization.GeoChart(document.getElementById('ga_dash_mapdata'));
197
+ chart.draw(dataChart, optionsChart);
198
+
199
+ }";
200
+
201
+ return $code;
202
+ }
203
+
204
+
205
+ public function showPageViews($ga, $ga_profile_id)
206
+ {
207
+
208
+ $ga->requestReportData($ga_profile_id, array('date'),array('pageviews'), 'date');
209
+ $results = $ga->getResults();
210
+ $code='
211
+ google.load("visualization", "1", {packages:["corechart"]});
212
+ google.setOnLoadCallback(drawChart);
213
+ function drawChart() {
214
+ var data = new google.visualization.DataTable();
215
+ data.addColumn(\'string\',\'Day\');
216
+ data.addColumn(\'number\', \'Pageviews\');
217
+ data.addRows([';
218
+
219
+ $varDataRows='';
220
+ foreach($results as $result) {
221
+ $varDataRows .= '["'.date('M j',strtotime($result->getDate())).'", '.$result->getPageviews().'],';
222
+ }
223
+
224
+ $code .=$varDataRows."]);
225
+
226
+ var chart = new google.visualization.AreaChart(document.getElementById('chart'));
227
+ chart.draw(data, {title: '".date('M j, Y',strtotime('-30 day')).' - '.date('M j, Y')."',
228
+ colors:['#058dc7','#e6f4fa'],
229
+ areaOpacity: 0.1,
230
+ hAxis: {textPosition: 'in', showTextEvery: 5, slantedText: false, textStyle: { color: '#058dc7', fontSize: 10 } },
231
+ pointSize: 5,
232
+ legend: 'none'
233
+ });
234
+ }";
235
+ return $code;
236
+ }
237
+
238
+
239
+ }
app/code/local/Cinasstore/Googleanalytics/Block/Adminhtml/Googleanalytics.php ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Cinasstore_Googleanalytics_Block_Adminhtml_Googleanalytics extends Mage_Adminhtml_Block_Template
3
+ {
4
+ public function __construct()
5
+ {
6
+ $this->_controller = 'adminhtml_googleanalytics';
7
+ $this->_blockGroup = 'googleanalytics';
8
+ $this->_headerText = Mage::helper('googleanalytics')->__('Item Manager');
9
+ parent::__construct();
10
+ }
11
+ }
app/code/local/Cinasstore/Googleanalytics/Block/Adminhtml/Googleanalytics/Edit.php ADDED
@@ -0,0 +1,45 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Cinasstore_Googleanalytics_Block_Adminhtml_Googleanalytics_Edit extends Mage_Adminhtml_Block_Widget_Form_Container
4
+ {
5
+ public function __construct()
6
+ {
7
+ parent::__construct();
8
+
9
+ $this->_objectId = 'id';
10
+ $this->_blockGroup = 'googleanalytics';
11
+ $this->_controller = 'adminhtml_googleanalytics';
12
+
13
+ $this->_updateButton('save', 'label', Mage::helper('googleanalytics')->__('Save Item'));
14
+ $this->_updateButton('delete', 'label', Mage::helper('googleanalytics')->__('Delete Item'));
15
+
16
+ $this->_addButton('saveandcontinue', array(
17
+ 'label' => Mage::helper('adminhtml')->__('Save And Continue Edit'),
18
+ 'onclick' => 'saveAndContinueEdit()',
19
+ 'class' => 'save',
20
+ ), -100);
21
+
22
+ $this->_formScripts[] = "
23
+ function toggleEditor() {
24
+ if (tinyMCE.getInstanceById('googleanalytics_content') == null) {
25
+ tinyMCE.execCommand('mceAddControl', false, 'googleanalytics_content');
26
+ } else {
27
+ tinyMCE.execCommand('mceRemoveControl', false, 'googleanalytics_content');
28
+ }
29
+ }
30
+
31
+ function saveAndContinueEdit(){
32
+ editForm.submit($('edit_form').action+'back/edit/');
33
+ }
34
+ ";
35
+ }
36
+
37
+ public function getHeaderText()
38
+ {
39
+ if( Mage::registry('googleanalytics_data') && Mage::registry('googleanalytics_data')->getId() ) {
40
+ return Mage::helper('googleanalytics')->__("Edit Item '%s'", $this->htmlEscape(Mage::registry('googleanalytics_data')->getTitle()));
41
+ } else {
42
+ return Mage::helper('googleanalytics')->__('Add Item');
43
+ }
44
+ }
45
+ }
app/code/local/Cinasstore/Googleanalytics/Block/Adminhtml/Googleanalytics/Edit/Form.php ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Cinasstore_Googleanalytics_Block_Adminhtml_Googleanalytics_Edit_Form extends Mage_Adminhtml_Block_Widget_Form
4
+ {
5
+ protected function _prepareForm()
6
+ {
7
+ $form = new Varien_Data_Form(array(
8
+ 'id' => 'edit_form',
9
+ 'action' => $this->getUrl('*/*/save', array('id' => $this->getRequest()->getParam('id'))),
10
+ 'method' => 'post',
11
+ 'enctype' => 'multipart/form-data'
12
+ )
13
+ );
14
+
15
+ $form->setUseContainer(true);
16
+ $this->setForm($form);
17
+ return parent::_prepareForm();
18
+ }
19
+ }
app/code/local/Cinasstore/Googleanalytics/Block/Adminhtml/Googleanalytics/Edit/Tab/Form.php ADDED
@@ -0,0 +1,58 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Cinasstore_Googleanalytics_Block_Adminhtml_Googleanalytics_Edit_Tab_Form extends Mage_Adminhtml_Block_Widget_Form
4
+ {
5
+ protected function _prepareForm()
6
+ {
7
+ $form = new Varien_Data_Form();
8
+ $this->setForm($form);
9
+ $fieldset = $form->addFieldset('googleanalytics_form', array('legend'=>Mage::helper('googleanalytics')->__('Item information')));
10
+
11
+ $fieldset->addField('title', 'text', array(
12
+ 'label' => Mage::helper('googleanalytics')->__('Title'),
13
+ 'class' => 'required-entry',
14
+ 'required' => true,
15
+ 'name' => 'title',
16
+ ));
17
+
18
+ $fieldset->addField('filename', 'file', array(
19
+ 'label' => Mage::helper('googleanalytics')->__('File'),
20
+ 'required' => false,
21
+ 'name' => 'filename',
22
+ ));
23
+
24
+ $fieldset->addField('status', 'select', array(
25
+ 'label' => Mage::helper('googleanalytics')->__('Status'),
26
+ 'name' => 'status',
27
+ 'values' => array(
28
+ array(
29
+ 'value' => 1,
30
+ 'label' => Mage::helper('googleanalytics')->__('Enabled'),
31
+ ),
32
+
33
+ array(
34
+ 'value' => 2,
35
+ 'label' => Mage::helper('googleanalytics')->__('Disabled'),
36
+ ),
37
+ ),
38
+ ));
39
+
40
+ $fieldset->addField('content', 'editor', array(
41
+ 'name' => 'content',
42
+ 'label' => Mage::helper('googleanalytics')->__('Content'),
43
+ 'title' => Mage::helper('googleanalytics')->__('Content'),
44
+ 'style' => 'width:700px; height:500px;',
45
+ 'wysiwyg' => false,
46
+ 'required' => true,
47
+ ));
48
+
49
+ if ( Mage::getSingleton('adminhtml/session')->getGoogleanalyticsData() )
50
+ {
51
+ $form->setValues(Mage::getSingleton('adminhtml/session')->getGoogleanalyticsData());
52
+ Mage::getSingleton('adminhtml/session')->setGoogleanalyticsData(null);
53
+ } elseif ( Mage::registry('googleanalytics_data') ) {
54
+ $form->setValues(Mage::registry('googleanalytics_data')->getData());
55
+ }
56
+ return parent::_prepareForm();
57
+ }
58
+ }
app/code/local/Cinasstore/Googleanalytics/Block/Adminhtml/Googleanalytics/Edit/Tabs.php ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Cinasstore_Googleanalytics_Block_Adminhtml_Googleanalytics_Edit_Tabs extends Mage_Adminhtml_Block_Widget_Tabs
4
+ {
5
+
6
+ public function __construct()
7
+ {
8
+ parent::__construct();
9
+ $this->setId('googleanalytics_tabs');
10
+ $this->setDestElementId('edit_form');
11
+ $this->setTitle(Mage::helper('googleanalytics')->__('Item Information'));
12
+ }
13
+
14
+ protected function _beforeToHtml()
15
+ {
16
+ $this->addTab('form_section', array(
17
+ 'label' => Mage::helper('googleanalytics')->__('Item Information'),
18
+ 'title' => Mage::helper('googleanalytics')->__('Item Information'),
19
+ 'content' => $this->getLayout()->createBlock('googleanalytics/adminhtml_googleanalytics_edit_tab_form')->toHtml(),
20
+ ));
21
+
22
+ return parent::_beforeToHtml();
23
+ }
24
+ }
app/code/local/Cinasstore/Googleanalytics/Block/Adminhtml/Googleanalytics/Grid.php ADDED
@@ -0,0 +1,116 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Cinasstore_Googleanalytics_Block_Adminhtml_Googleanalytics_Grid extends Mage_Adminhtml_Block_Widget_Grid
4
+ {
5
+ public function __construct()
6
+ {
7
+ parent::__construct();
8
+ $this->setId('googleanalyticsGrid');
9
+ $this->setDefaultSort('googleanalytics_id');
10
+ $this->setDefaultDir('ASC');
11
+ $this->setSaveParametersInSession(true);
12
+ }
13
+
14
+ protected function _prepareCollection()
15
+ {
16
+ $collection = Mage::getModel('googleanalytics/googleanalytics')->getCollection();
17
+ $this->setCollection($collection);
18
+ return parent::_prepareCollection();
19
+ }
20
+
21
+ protected function _prepareColumns()
22
+ {
23
+ $this->addColumn('googleanalytics_id', array(
24
+ 'header' => Mage::helper('googleanalytics')->__('ID'),
25
+ 'align' =>'right',
26
+ 'width' => '50px',
27
+ 'index' => 'googleanalytics_id',
28
+ ));
29
+
30
+ $this->addColumn('title', array(
31
+ 'header' => Mage::helper('googleanalytics')->__('Title'),
32
+ 'align' =>'left',
33
+ 'index' => 'title',
34
+ ));
35
+
36
+ /*
37
+ $this->addColumn('content', array(
38
+ 'header' => Mage::helper('googleanalytics')->__('Item Content'),
39
+ 'width' => '150px',
40
+ 'index' => 'content',
41
+ ));
42
+ */
43
+
44
+ $this->addColumn('status', array(
45
+ 'header' => Mage::helper('googleanalytics')->__('Status'),
46
+ 'align' => 'left',
47
+ 'width' => '80px',
48
+ 'index' => 'status',
49
+ 'type' => 'options',
50
+ 'options' => array(
51
+ 1 => 'Enabled',
52
+ 2 => 'Disabled',
53
+ ),
54
+ ));
55
+
56
+ $this->addColumn('action',
57
+ array(
58
+ 'header' => Mage::helper('googleanalytics')->__('Action'),
59
+ 'width' => '100',
60
+ 'type' => 'action',
61
+ 'getter' => 'getId',
62
+ 'actions' => array(
63
+ array(
64
+ 'caption' => Mage::helper('googleanalytics')->__('Edit'),
65
+ 'url' => array('base'=> '*/*/edit'),
66
+ 'field' => 'id'
67
+ )
68
+ ),
69
+ 'filter' => false,
70
+ 'sortable' => false,
71
+ 'index' => 'stores',
72
+ 'is_system' => true,
73
+ ));
74
+
75
+ $this->addExportType('*/*/exportCsv', Mage::helper('googleanalytics')->__('CSV'));
76
+ $this->addExportType('*/*/exportXml', Mage::helper('googleanalytics')->__('XML'));
77
+
78
+ return parent::_prepareColumns();
79
+ }
80
+
81
+ protected function _prepareMassaction()
82
+ {
83
+ $this->setMassactionIdField('googleanalytics_id');
84
+ $this->getMassactionBlock()->setFormFieldName('googleanalytics');
85
+
86
+ $this->getMassactionBlock()->addItem('delete', array(
87
+ 'label' => Mage::helper('googleanalytics')->__('Delete'),
88
+ 'url' => $this->getUrl('*/*/massDelete'),
89
+ 'confirm' => Mage::helper('googleanalytics')->__('Are you sure?')
90
+ ));
91
+
92
+ $statuses = Mage::getSingleton('googleanalytics/status')->getOptionArray();
93
+
94
+ array_unshift($statuses, array('label'=>'', 'value'=>''));
95
+ $this->getMassactionBlock()->addItem('status', array(
96
+ 'label'=> Mage::helper('googleanalytics')->__('Change status'),
97
+ 'url' => $this->getUrl('*/*/massStatus', array('_current'=>true)),
98
+ 'additional' => array(
99
+ 'visibility' => array(
100
+ 'name' => 'status',
101
+ 'type' => 'select',
102
+ 'class' => 'required-entry',
103
+ 'label' => Mage::helper('googleanalytics')->__('Status'),
104
+ 'values' => $statuses
105
+ )
106
+ )
107
+ ));
108
+ return $this;
109
+ }
110
+
111
+ public function getRowUrl($row)
112
+ {
113
+ return $this->getUrl('*/*/edit', array('id' => $row->getId()));
114
+ }
115
+
116
+ }
app/code/local/Cinasstore/Googleanalytics/Block/Googleanalytics.php ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Cinasstore_Googleanalytics_Block_Googleanalytics extends Mage_Core_Block_Template
3
+ {
4
+ public function _prepareLayout()
5
+ {
6
+ return parent::_prepareLayout();
7
+ }
8
+
9
+ public function getTemplate(){
10
+ return parent::getTemplate();
11
+ }
12
+ }
app/code/local/Cinasstore/Googleanalytics/Helper/Dashboard.php ADDED
@@ -0,0 +1,4 @@
 
 
 
 
1
+ <?php
2
+ class Cinasstore_Googleanalytics_Helper_Dashboard extends Mage_Core_Helper_Abstract
3
+ {
4
+ }
app/code/local/Cinasstore/Googleanalytics/Helper/Data.php ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Cinasstore_Googleanalytics_Helper_Data extends Mage_Core_Helper_Abstract
4
+ {
5
+ public function isHiddenLike(){
6
+ return Mage::getStoreConfig('googleanalytics/general/hidden_like');
7
+ }
8
+
9
+ public function isHiddenComment(){
10
+ return Mage::getStoreConfig('googleanalytics/general/hidden_comment');
11
+ }
12
+
13
+ public function isCustomLike(){
14
+ return Mage::getStoreConfig('googleanalytics/like/custom');
15
+ }
16
+
17
+ public function isCustomComment(){
18
+ return Mage::getStoreConfig('googleanalytics/comment/custom');
19
+ }
20
+
21
+ public function getLikeCssStyle(){
22
+ return Mage::getStoreConfig('googleanalytics/like/css_style');
23
+ }
24
+
25
+ public function getCommentCssStyle(){
26
+ return Mage::getStoreConfig('googleanalytics/comment/css_style');
27
+ }
28
+ }
app/code/local/Cinasstore/Googleanalytics/Model/Gapi.php ADDED
@@ -0,0 +1,822 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * GAPI - Google Analytics PHP Interface
4
+ *
5
+ * http://code.google.com/p/gapi-google-analytics-php-interface/
6
+ *
7
+ * @copyright Stig Manning 2009
8
+ *
9
+ * This program is free software: you can redistribute it and/or modify
10
+ * it under the terms of the GNU General Public License as published by
11
+ * the Free Software Foundation, either version 3 of the License, or
12
+ * (at your option) any later version.
13
+ *
14
+ * This program is distributed in the hope that it will be useful,
15
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
16
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17
+ * GNU General Public License for more details.
18
+ *
19
+ * You should have received a copy of the GNU General Public License
20
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
21
+ *
22
+ * @author Stig Manning <stig@sdm.co.nz>
23
+ * @version 1.3
24
+ *
25
+ */
26
+
27
+ class Cinasstore_Googleanalytics_Model_Gapi extends Mage_Core_Model_Abstract
28
+ {
29
+ const http_interface = 'auto'; //'auto': autodetect, 'curl' or 'fopen'
30
+
31
+ const client_login_url = 'https://www.google.com/accounts/ClientLogin';
32
+ const account_data_url = 'https://www.google.com/analytics/feeds/accounts/default';
33
+ const report_data_url = 'https://www.google.com/analytics/feeds/data';
34
+ const interface_name = 'GAPI-1.3';
35
+ const dev_mode = false;
36
+
37
+ private $auth_token = null;
38
+ private $account_entries = array();
39
+ private $account_root_parameters = array();
40
+ private $report_aggregate_metrics = array();
41
+ private $report_root_parameters = array();
42
+ private $results = array();
43
+
44
+ /**
45
+ * Constructor function for all new gapi instances
46
+ *
47
+ * Set up authenticate with Google and get auth_token
48
+ *
49
+ * @param String $email
50
+ * @param String $password
51
+ * @param String $token
52
+ * @return gapi
53
+ */
54
+ public function __construct()
55
+ {
56
+ parent::__construct();
57
+ }
58
+
59
+ /**
60
+ * Return the auth token, used for storing the auth token in the user session
61
+ *
62
+ * @return String
63
+ */
64
+ public function getAuthToken()
65
+ {
66
+ return $this->auth_token;
67
+ }
68
+
69
+ public function setAuthToken($token)
70
+ {
71
+ $this->auth_token = $token;
72
+ return $this;
73
+ }
74
+
75
+ /**
76
+ * Request account data from Google Analytics
77
+ *
78
+ * @param Int $start_index OPTIONAL: Start index of results
79
+ * @param Int $max_results OPTIONAL: Max results returned
80
+ */
81
+ public function requestAccountData($start_index=1, $max_results=20)
82
+ {
83
+ $response = $this->httpRequest(self::account_data_url, array('start-index'=>$start_index,'max-results'=>$max_results), null, $this->generateAuthHeader());
84
+
85
+ if(substr($response['code'],0,1) == '2')
86
+ {
87
+ return $this->accountObjectMapper($response['body']);
88
+ }
89
+ else
90
+ {
91
+ throw new Exception('GAPI: Failed to request account data. Error: "' . strip_tags($response['body']) . '"');
92
+ }
93
+ }
94
+
95
+ /**
96
+ * Request report data from Google Analytics
97
+ *
98
+ * $report_id is the Google report ID for the selected account
99
+ *
100
+ * $parameters should be in key => value format
101
+ *
102
+ * @param String $report_id
103
+ * @param Array $dimensions Google Analytics dimensions e.g. array('browser')
104
+ * @param Array $metrics Google Analytics metrics e.g. array('pageviews')
105
+ * @param Array $sort_metric OPTIONAL: Dimension or dimensions to sort by e.g.('-visits')
106
+ * @param String $filter OPTIONAL: Filter logic for filtering results
107
+ * @param String $start_date OPTIONAL: Start of reporting period
108
+ * @param String $end_date OPTIONAL: End of reporting period
109
+ * @param Int $start_index OPTIONAL: Start index of results
110
+ * @param Int $max_results OPTIONAL: Max results returned
111
+ */
112
+ public function requestReportData($report_id, $dimensions, $metrics, $sort_metric=null, $filter=null, $start_date=null, $end_date=null, $start_index=1, $max_results=30)
113
+ {
114
+ $parameters = array('ids'=>'ga:' . $report_id);
115
+
116
+ if(is_array($dimensions))
117
+ {
118
+ $dimensions_string = '';
119
+ foreach($dimensions as $dimesion)
120
+ {
121
+ $dimensions_string .= ',ga:' . $dimesion;
122
+ }
123
+ $parameters['dimensions'] = substr($dimensions_string,1);
124
+ }
125
+ else
126
+ {
127
+ $parameters['dimensions'] = 'ga:'.$dimensions;
128
+ }
129
+
130
+ if(is_array($metrics))
131
+ {
132
+ $metrics_string = '';
133
+ foreach($metrics as $metric)
134
+ {
135
+ $metrics_string .= ',ga:' . $metric;
136
+ }
137
+ $parameters['metrics'] = substr($metrics_string,1);
138
+ }
139
+ else
140
+ {
141
+ $parameters['metrics'] = 'ga:'.$metrics;
142
+ }
143
+
144
+ if($sort_metric==null&&isset($parameters['metrics']))
145
+ {
146
+ $parameters['sort'] = $parameters['metrics'];
147
+ }
148
+ elseif(is_array($sort_metric))
149
+ {
150
+ $sort_metric_string = '';
151
+
152
+ foreach($sort_metric as $sort_metric_value)
153
+ {
154
+ //Reverse sort - Thanks Nick Sullivan
155
+ if (substr($sort_metric_value, 0, 1) == "-")
156
+ {
157
+ $sort_metric_string .= ',-ga:' . substr($sort_metric_value, 1); // Descending
158
+ }
159
+ else
160
+ {
161
+ $sort_metric_string .= ',ga:' . $sort_metric_value; // Ascending
162
+ }
163
+ }
164
+
165
+ $parameters['sort'] = substr($sort_metric_string, 1);
166
+ }
167
+ else
168
+ {
169
+ if (substr($sort_metric, 0, 1) == "-")
170
+ {
171
+ $parameters['sort'] = '-ga:' . substr($sort_metric, 1);
172
+ }
173
+ else
174
+ {
175
+ $parameters['sort'] = 'ga:' . $sort_metric;
176
+ }
177
+ }
178
+
179
+ if($filter!=null)
180
+ {
181
+ $filter = $this->processFilter($filter);
182
+ if($filter!==false)
183
+ {
184
+ $parameters['filters'] = $filter;
185
+ }
186
+ }
187
+
188
+ if($start_date==null)
189
+ {
190
+ $start_date=date('Y-m-d',strtotime('1 month ago'));
191
+ }
192
+
193
+ $parameters['start-date'] = $start_date;
194
+
195
+ if($end_date==null)
196
+ {
197
+ $end_date=date('Y-m-d');
198
+ }
199
+
200
+ $parameters['end-date'] = $end_date;
201
+
202
+
203
+ $parameters['start-index'] = $start_index;
204
+ $parameters['max-results'] = $max_results;
205
+
206
+ $parameters['prettyprint'] = self::dev_mode ? 'true' : 'false';
207
+
208
+ $response = $this->httpRequest(self::report_data_url, $parameters, null, $this->generateAuthHeader());
209
+
210
+ //HTTP 2xx
211
+ if(substr($response['code'],0,1) == '2')
212
+ {
213
+ return $this->reportObjectMapper($response['body']);
214
+ }
215
+ else
216
+ {
217
+ throw new Exception('GAPI: Failed to request report data. Error: "' . strip_tags($response['body']) . '"');
218
+ }
219
+ }
220
+
221
+ /**
222
+ * Process filter string, clean parameters and convert to Google Analytics
223
+ * compatible format
224
+ *
225
+ * @param String $filter
226
+ * @return String Compatible filter string
227
+ */
228
+ protected function processFilter($filter)
229
+ {
230
+ $valid_operators = '(!~|=~|==|!=|>|<|>=|<=|=@|!@)';
231
+
232
+ $filter = preg_replace('/\s\s+/',' ',trim($filter)); //Clean duplicate whitespace
233
+ $filter = str_replace(array(',',';'),array('\,','\;'),$filter); //Escape Google Analytics reserved characters
234
+ $filter = preg_replace('/(&&\s*|\|\|\s*|^)([a-z]+)(\s*' . $valid_operators . ')/i','$1ga:$2$3',$filter); //Prefix ga: to metrics and dimensions
235
+ $filter = preg_replace('/[\'\"]/i','',$filter); //Clear invalid quote characters
236
+ $filter = preg_replace(array('/\s*&&\s*/','/\s*\|\|\s*/','/\s*' . $valid_operators . '\s*/'),array(';',',','$1'),$filter); //Clean up operators
237
+
238
+ if(strlen($filter)>0)
239
+ {
240
+ return urlencode($filter);
241
+ }
242
+ else
243
+ {
244
+ return false;
245
+ }
246
+ }
247
+
248
+ /**
249
+ * Report Account Mapper to convert the XML to array of useful PHP objects
250
+ *
251
+ * @param String $xml_string
252
+ * @return Array of gapiAccountEntry objects
253
+ */
254
+ protected function accountObjectMapper($xml_string)
255
+ {
256
+ $xml = simplexml_load_string($xml_string);
257
+
258
+ $this->results = null;
259
+
260
+ $results = array();
261
+ $account_root_parameters = array();
262
+
263
+ //Load root parameters
264
+
265
+ $account_root_parameters['updated'] = strval($xml->updated);
266
+ $account_root_parameters['generator'] = strval($xml->generator);
267
+ $account_root_parameters['generatorVersion'] = strval($xml->generator->attributes());
268
+
269
+ $open_search_results = $xml->children('http://a9.com/-/spec/opensearchrss/1.0/');
270
+
271
+ foreach($open_search_results as $key => $open_search_result)
272
+ {
273
+ $report_root_parameters[$key] = intval($open_search_result);
274
+ }
275
+
276
+ $account_root_parameters['startDate'] = strval($google_results->startDate);
277
+ $account_root_parameters['endDate'] = strval($google_results->endDate);
278
+
279
+ //Load result entries
280
+
281
+ foreach($xml->entry as $entry)
282
+ {
283
+ $properties = array();
284
+ foreach($entry->children('http://schemas.google.com/analytics/2009')->property as $property)
285
+ {
286
+ $properties[str_replace('ga:','',$property->attributes()->name)] = strval($property->attributes()->value);
287
+ }
288
+
289
+ $properties['title'] = strval($entry->title);
290
+ $properties['updated'] = strval($entry->updated);
291
+
292
+ $results[] = new gapiAccountEntry($properties);
293
+ }
294
+
295
+ $this->account_root_parameters = $account_root_parameters;
296
+ $this->results = $results;
297
+
298
+ return $results;
299
+ }
300
+
301
+
302
+ /**
303
+ * Report Object Mapper to convert the XML to array of useful PHP objects
304
+ *
305
+ * @param String $xml_string
306
+ * @return Array of gapiReportEntry objects
307
+ */
308
+ protected function reportObjectMapper($xml_string)
309
+ {
310
+ $xml = simplexml_load_string($xml_string);
311
+
312
+ $this->results = null;
313
+ $results = array();
314
+
315
+ $report_root_parameters = array();
316
+ $report_aggregate_metrics = array();
317
+
318
+ //Load root parameters
319
+
320
+ $report_root_parameters['updated'] = strval($xml->updated);
321
+ $report_root_parameters['generator'] = strval($xml->generator);
322
+ $report_root_parameters['generatorVersion'] = strval($xml->generator->attributes());
323
+
324
+ $open_search_results = $xml->children('http://a9.com/-/spec/opensearchrss/1.0/');
325
+
326
+ foreach($open_search_results as $key => $open_search_result)
327
+ {
328
+ $report_root_parameters[$key] = intval($open_search_result);
329
+ }
330
+
331
+ $google_results = $xml->children('http://schemas.google.com/analytics/2009');
332
+
333
+ foreach($google_results->dataSource->property as $property_attributes)
334
+ {
335
+ $report_root_parameters[str_replace('ga:','',$property_attributes->attributes()->name)] = strval($property_attributes->attributes()->value);
336
+ }
337
+
338
+ $report_root_parameters['startDate'] = strval($google_results->startDate);
339
+ $report_root_parameters['endDate'] = strval($google_results->endDate);
340
+
341
+ //Load result aggregate metrics
342
+
343
+ foreach($google_results->aggregates->metric as $aggregate_metric)
344
+ {
345
+ $metric_value = strval($aggregate_metric->attributes()->value);
346
+
347
+ //Check for float, or value with scientific notation
348
+ if(preg_match('/^(\d+\.\d+)|(\d+E\d+)|(\d+.\d+E\d+)$/',$metric_value))
349
+ {
350
+ $report_aggregate_metrics[str_replace('ga:','',$aggregate_metric->attributes()->name)] = floatval($metric_value);
351
+ }
352
+ else
353
+ {
354
+ $report_aggregate_metrics[str_replace('ga:','',$aggregate_metric->attributes()->name)] = intval($metric_value);
355
+ }
356
+ }
357
+
358
+ //Load result entries
359
+
360
+ foreach($xml->entry as $entry)
361
+ {
362
+ $metrics = array();
363
+ foreach($entry->children('http://schemas.google.com/analytics/2009')->metric as $metric)
364
+ {
365
+ $metric_value = strval($metric->attributes()->value);
366
+
367
+ //Check for float, or value with scientific notation
368
+ if(preg_match('/^(\d+\.\d+)|(\d+E\d+)|(\d+.\d+E\d+)$/',$metric_value))
369
+ {
370
+ $metrics[str_replace('ga:','',$metric->attributes()->name)] = floatval($metric_value);
371
+ }
372
+ else
373
+ {
374
+ $metrics[str_replace('ga:','',$metric->attributes()->name)] = intval($metric_value);
375
+ }
376
+ }
377
+
378
+ $dimensions = array();
379
+ foreach($entry->children('http://schemas.google.com/analytics/2009')->dimension as $dimension)
380
+ {
381
+ $dimensions[str_replace('ga:','',$dimension->attributes()->name)] = strval($dimension->attributes()->value);
382
+ }
383
+
384
+ $results[] = new gapiReportEntry($metrics,$dimensions);
385
+ }
386
+
387
+ $this->report_root_parameters = $report_root_parameters;
388
+ $this->report_aggregate_metrics = $report_aggregate_metrics;
389
+ $this->results = $results;
390
+
391
+ return $results;
392
+ }
393
+
394
+ /**
395
+ * Authenticate Google Account with Google
396
+ *
397
+ * @param String $email
398
+ * @param String $password
399
+ */
400
+ public function authenticateUser($email, $password)
401
+ {
402
+ $post_variables = array(
403
+ 'accountType' => 'GOOGLE',
404
+ 'Email' => $email,
405
+ 'Passwd' => $password,
406
+ 'source' => self::interface_name,
407
+ 'service' => 'analytics'
408
+ );
409
+
410
+ $response = $this->httpRequest(self::client_login_url,null,$post_variables);
411
+
412
+ //Convert newline delimited variables into url format then import to array
413
+ parse_str(str_replace(array("\n","\r\n"),'&',$response['body']),$auth_token);
414
+
415
+ if(substr($response['code'],0,1) != '2' || !is_array($auth_token) || empty($auth_token['Auth']))
416
+ {
417
+ throw new Exception('GAPI: Failed to authenticate user. Error: "' . strip_tags($response['body']) . '"');
418
+ }
419
+
420
+ $this->auth_token = $auth_token['Auth'];
421
+ return $this;
422
+ }
423
+
424
+ /**
425
+ * Generate authentication token header for all requests
426
+ *
427
+ * @return Array
428
+ */
429
+ protected function generateAuthHeader()
430
+ {
431
+ return array('Authorization: GoogleLogin auth=' . $this->auth_token);
432
+ }
433
+
434
+ /**
435
+ * Perform http request
436
+ *
437
+ *
438
+ * @param Array $get_variables
439
+ * @param Array $post_variables
440
+ * @param Array $headers
441
+ */
442
+ protected function httpRequest($url, $get_variables=null, $post_variables=null, $headers=null)
443
+ {
444
+ $interface = self::http_interface;
445
+
446
+ if(self::http_interface =='auto')
447
+ {
448
+ if(function_exists('curl_exec'))
449
+ {
450
+ $interface = 'curl';
451
+ }
452
+ else
453
+ {
454
+ $interface = 'fopen';
455
+ }
456
+ }
457
+
458
+ if($interface == 'curl')
459
+ {
460
+ return $this->curlRequest($url, $get_variables, $post_variables, $headers);
461
+ }
462
+ elseif($interface == 'fopen')
463
+ {
464
+ return $this->fopenRequest($url, $get_variables, $post_variables, $headers);
465
+ }
466
+ else
467
+ {
468
+ throw new Exception('Invalid http interface defined. No such interface "' . self::http_interface . '"');
469
+ }
470
+ }
471
+
472
+ /**
473
+ * HTTP request using PHP CURL functions
474
+ * Requires curl library installed and configured for PHP
475
+ *
476
+ * @param Array $get_variables
477
+ * @param Array $post_variables
478
+ * @param Array $headers
479
+ */
480
+ private function curlRequest($url, $get_variables=null, $post_variables=null, $headers=null)
481
+ {
482
+ $ch = curl_init();
483
+
484
+ if(is_array($get_variables))
485
+ {
486
+ $get_variables = '?' . str_replace('&amp;','&',urldecode(http_build_query($get_variables)));
487
+ }
488
+ else
489
+ {
490
+ $get_variables = null;
491
+ }
492
+
493
+ curl_setopt($ch, CURLOPT_URL, $url . $get_variables);
494
+ curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
495
+ curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); //CURL doesn't like google's cert
496
+
497
+ if(is_array($post_variables))
498
+ {
499
+ curl_setopt($ch, CURLOPT_POST, true);
500
+ curl_setopt($ch, CURLOPT_POSTFIELDS, $post_variables);
501
+ }
502
+
503
+ if(is_array($headers))
504
+ {
505
+ curl_setopt($ch, CURLOPT_HTTPHEADER,$headers);
506
+ }
507
+
508
+ $response = curl_exec($ch);
509
+ $code = curl_getinfo($ch,CURLINFO_HTTP_CODE);
510
+
511
+ curl_close($ch);
512
+
513
+ return array('body'=>$response,'code'=>$code);
514
+ }
515
+
516
+ /**
517
+ * HTTP request using native PHP fopen function
518
+ * Requires PHP openSSL
519
+ *
520
+ * @param Array $get_variables
521
+ * @param Array $post_variables
522
+ * @param Array $headers
523
+ */
524
+ private function fopenRequest($url, $get_variables=null, $post_variables=null, $headers=null)
525
+ {
526
+ $http_options = array('method'=>'GET','timeout'=>3);
527
+
528
+ if(is_array($headers))
529
+ {
530
+ $headers = implode("\r\n",$headers) . "\r\n";
531
+ }
532
+ else
533
+ {
534
+ $headers = '';
535
+ }
536
+
537
+ if(is_array($get_variables))
538
+ {
539
+ $get_variables = '?' . str_replace('&amp;','&',urldecode(http_build_query($get_variables)));
540
+ }
541
+ else
542
+ {
543
+ $get_variables = null;
544
+ }
545
+
546
+ if(is_array($post_variables))
547
+ {
548
+ $post_variables = str_replace('&amp;','&',urldecode(http_build_query($post_variables)));
549
+ $http_options['method'] = 'POST';
550
+ $headers = "Content-type: application/x-www-form-urlencoded\r\n" . "Content-Length: " . strlen($post_variables) . "\r\n" . $headers;
551
+ $http_options['header'] = $headers;
552
+ $http_options['content'] = $post_variables;
553
+ }
554
+ else
555
+ {
556
+ $post_variables = '';
557
+ $http_options['header'] = $headers;
558
+ }
559
+
560
+ $context = stream_context_create(array('http'=>$http_options));
561
+ $response = @file_get_contents($url . $get_variables, null, $context);
562
+
563
+ return array('body'=>$response!==false?$response:'Request failed, fopen provides no further information','code'=>$response!==false?'200':'400');
564
+ }
565
+
566
+ /**
567
+ * Case insensitive array_key_exists function, also returns
568
+ * matching key.
569
+ *
570
+ * @param String $key
571
+ * @param Array $search
572
+ * @return String Matching array key
573
+ */
574
+ public static function array_key_exists_nc($key, $search)
575
+ {
576
+ if (array_key_exists($key, $search))
577
+ {
578
+ return $key;
579
+ }
580
+ if (!(is_string($key) && is_array($search)))
581
+ {
582
+ return false;
583
+ }
584
+ $key = strtolower($key);
585
+ foreach ($search as $k => $v)
586
+ {
587
+ if (strtolower($k) == $key)
588
+ {
589
+ return $k;
590
+ }
591
+ }
592
+ return false;
593
+ }
594
+
595
+ /**
596
+ * Get Results
597
+ *
598
+ * @return Array
599
+ */
600
+ public function getResults()
601
+ {
602
+ if(is_array($this->results))
603
+ {
604
+ return $this->results;
605
+ }
606
+ else
607
+ {
608
+ return;
609
+ }
610
+ }
611
+
612
+
613
+ /**
614
+ * Get an array of the metrics and the matchning
615
+ * aggregate values for the current result
616
+ *
617
+ * @return Array
618
+ */
619
+ public function getMetrics()
620
+ {
621
+ return $this->report_aggregate_metrics;
622
+ }
623
+
624
+ /**
625
+ * Call method to find a matching root parameter or
626
+ * aggregate metric to return
627
+ *
628
+ * @param $name String name of function called
629
+ * @return String
630
+ * @throws Exception if not a valid parameter or aggregate
631
+ * metric, or not a 'get' function
632
+ */
633
+ public function __call($name,$parameters)
634
+ {
635
+ if(!preg_match('/^get/',$name))
636
+ {
637
+ throw new Exception('No such function "' . $name . '"');
638
+ }
639
+
640
+ $name = preg_replace('/^get/','',$name);
641
+
642
+ $parameter_key = self::array_key_exists_nc($name,$this->report_root_parameters);
643
+
644
+ if($parameter_key)
645
+ {
646
+ return $this->report_root_parameters[$parameter_key];
647
+ }
648
+
649
+ $aggregate_metric_key = self::array_key_exists_nc($name,$this->report_aggregate_metrics);
650
+
651
+ if($aggregate_metric_key)
652
+ {
653
+ return $this->report_aggregate_metrics[$aggregate_metric_key];
654
+ }
655
+
656
+ throw new Exception('No valid root parameter or aggregate metric called "' . $name . '"');
657
+ }
658
+ }
659
+
660
+ /**
661
+ * Class gapiAccountEntry
662
+ *
663
+ * Storage for individual gapi account entries
664
+ *
665
+ */
666
+ class gapiAccountEntry
667
+ {
668
+ private $properties = array();
669
+
670
+ public function __construct($properties)
671
+ {
672
+ $this->properties = $properties;
673
+ }
674
+
675
+ /**
676
+ * toString function to return the name of the account
677
+ *
678
+ * @return String
679
+ */
680
+ public function __toString()
681
+ {
682
+ if(isset($this->properties['title']))
683
+ {
684
+ return $this->properties['title'];
685
+ }
686
+ else
687
+ {
688
+ return;
689
+ }
690
+ }
691
+
692
+ /**
693
+ * Get an associative array of the properties
694
+ * and the matching values for the current result
695
+ *
696
+ * @return Array
697
+ */
698
+ public function getProperties()
699
+ {
700
+ return $this->properties;
701
+ }
702
+
703
+ /**
704
+ * Call method to find a matching parameter to return
705
+ *
706
+ * @param $name String name of function called
707
+ * @return String
708
+ * @throws Exception if not a valid parameter, or not a 'get' function
709
+ */
710
+ public function __call($name,$parameters)
711
+ {
712
+ if(!preg_match('/^get/',$name))
713
+ {
714
+ throw new Exception('No such function "' . $name . '"');
715
+ }
716
+
717
+ $name = preg_replace('/^get/','',$name);
718
+
719
+ $property_key = Cinasstore_Googleanalytics_Model_Gapi::array_key_exists_nc($name,$this->properties);
720
+
721
+ if($property_key)
722
+ {
723
+ return $this->properties[$property_key];
724
+ }
725
+
726
+ throw new Exception('No valid property called "' . $name . '"');
727
+ }
728
+ }
729
+
730
+ /**
731
+ * Class gapiReportEntry
732
+ *
733
+ * Storage for individual gapi report entries
734
+ *
735
+ */
736
+ class gapiReportEntry
737
+ {
738
+ private $metrics = array();
739
+ private $dimensions = array();
740
+
741
+ public function __construct($metrics,$dimesions)
742
+ {
743
+ $this->metrics = $metrics;
744
+ $this->dimensions = $dimesions;
745
+ }
746
+
747
+ /**
748
+ * toString function to return the name of the result
749
+ * this is a concatented string of the dimesions chosen
750
+ *
751
+ * For example:
752
+ * 'Firefox 3.0.10' from browser and browserVersion
753
+ *
754
+ * @return String
755
+ */
756
+ public function __toString()
757
+ {
758
+ if(is_array($this->dimensions))
759
+ {
760
+ return implode(' ',$this->dimensions);
761
+ }
762
+ else
763
+ {
764
+ return '';
765
+ }
766
+ }
767
+
768
+ /**
769
+ * Get an associative array of the dimesions
770
+ * and the matching values for the current result
771
+ *
772
+ * @return Array
773
+ */
774
+ public function getDimesions()
775
+ {
776
+ return $this->dimensions;
777
+ }
778
+
779
+ /**
780
+ * Get an array of the metrics and the matchning
781
+ * values for the current result
782
+ *
783
+ * @return Array
784
+ */
785
+ public function getMetrics()
786
+ {
787
+ return $this->metrics;
788
+ }
789
+
790
+ /**
791
+ * Call method to find a matching metric or dimension to return
792
+ *
793
+ * @param $name String name of function called
794
+ * @return String
795
+ * @throws Exception if not a valid metric or dimensions, or not a 'get' function
796
+ */
797
+ public function __call($name,$parameters)
798
+ {
799
+ if(!preg_match('/^get/',$name))
800
+ {
801
+ throw new Exception('No such function "' . $name . '"');
802
+ }
803
+
804
+ $name = preg_replace('/^get/','',$name);
805
+
806
+ $metric_key = Cinasstore_Googleanalytics_Model_Gapi::array_key_exists_nc($name,$this->metrics);
807
+
808
+ if($metric_key)
809
+ {
810
+ return $this->metrics[$metric_key];
811
+ }
812
+
813
+ $dimension_key = Cinasstore_Googleanalytics_Model_Gapi::array_key_exists_nc($name,$this->dimensions);
814
+
815
+ if($dimension_key)
816
+ {
817
+ return $this->dimensions[$dimension_key];
818
+ }
819
+
820
+ throw new Exception('No valid metric or dimesion called "' . $name . '"');
821
+ }
822
+ }
app/code/local/Cinasstore/Googleanalytics/Model/Googleanalytics.php ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Cinasstore_Googleanalytics_Model_Googleanalytics extends Mage_Core_Model_Abstract
4
+ {
5
+ public function _construct()
6
+ {
7
+ parent::_construct();
8
+ $this->_init('googleanalytics/googleanalytics');
9
+ }
10
+ }
app/code/local/Cinasstore/Googleanalytics/Model/Mysql4/Googleanalytics.php ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Cinasstore_Googleanalytics_Model_Mysql4_Googleanalytics extends Mage_Core_Model_Mysql4_Abstract
4
+ {
5
+ public function _construct()
6
+ {
7
+ // Note that the googleanalytics_id refers to the key field in your database table.
8
+ $this->_init('googleanalytics/googleanalytics', 'googleanalytics_id');
9
+ }
10
+ }
app/code/local/Cinasstore/Googleanalytics/Model/Mysql4/Googleanalytics/Collection.php ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Cinasstore_Googleanalytics_Model_Mysql4_Googleanalytics_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract
4
+ {
5
+ public function _construct()
6
+ {
7
+ parent::_construct();
8
+ $this->_init('googleanalytics/googleanalytics');
9
+ }
10
+ }
app/code/local/Cinasstore/Googleanalytics/Model/Observer.php ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Cinasstore_Googleanalytics_Model_Observer {
4
+
5
+ public function saveGoogleanalyticsConfig($observer)
6
+ {
7
+ $googleanalytics = Mage::getModel('googleanalytics/googleanalytics');
8
+ $googleanalytics->setEditTime(now());
9
+ try{
10
+ $googleanalytics->save();
11
+ }catch(Exception $e){
12
+ Mage::getSingleton('core/session')->addError($e);
13
+ }
14
+ }
15
+
16
+ public function controller_action_predispatch_adminhtml($observer)
17
+ {
18
+ $controller = $observer->getControllerAction();
19
+ if($controller->getRequest()->getControllerName() != 'system_config'
20
+ || $controller->getRequest()->getActionName() != 'edit')
21
+ return;
22
+ $section = $controller->getRequest()->getParam('section');
23
+ if($section != 'googleanalytics')
24
+ return;
25
+ }
26
+ }
app/code/local/Cinasstore/Googleanalytics/Model/Status.php ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Cinasstore_Googleanalytics_Model_Status extends Varien_Object
4
+ {
5
+ const STATUS_ENABLED = 1;
6
+ const STATUS_DISABLED = 2;
7
+
8
+ static public function getOptionArray()
9
+ {
10
+ return array(
11
+ self::STATUS_ENABLED => Mage::helper('googleanalytics')->__('Enabled'),
12
+ self::STATUS_DISABLED => Mage::helper('googleanalytics')->__('Disabled')
13
+ );
14
+ }
15
+ }
app/code/local/Cinasstore/Googleanalytics/Model/System/Config/Language.php ADDED
@@ -0,0 +1,118 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Cinasstore_Googleanalytics_Model_System_Config_Language
4
+ {
5
+ public function toOptionArray()
6
+ {
7
+ $options = array(
8
+ array('value'=>'ca_ES','label'=> Mage::helper('googleanalytics')->__('Catalan')),
9
+ array('value'=>'cs_CZ','label'=> Mage::helper('googleanalytics')->__('Czech')),
10
+ array('value'=>'cy_GB','label'=> Mage::helper('googleanalytics')->__('Welsh')),
11
+ array('value'=>'da_DK','label'=> Mage::helper('googleanalytics')->__('Danish')),
12
+ array('value'=>'de_DE','label'=> Mage::helper('googleanalytics')->__('German')),
13
+ array('value'=>'eu_ES','label'=> Mage::helper('googleanalytics')->__('Basque')),
14
+ array('value'=>'en_PI','label'=> Mage::helper('googleanalytics')->__('English (Pirate)')),
15
+ array('value'=>'en_UD','label'=> Mage::helper('googleanalytics')->__('English (Upside Down)')),
16
+ array('value'=>'ck_US','label'=> Mage::helper('googleanalytics')->__('Cherokee')),
17
+ array('value'=>'en_US','label'=> Mage::helper('googleanalytics')->__('English (US)')),
18
+ array('value'=>'es_LA','label'=> Mage::helper('googleanalytics')->__('Spanish')),
19
+ array('value'=>'es_CL','label'=> Mage::helper('googleanalytics')->__('Spanish (Chile)')),
20
+ array('value'=>'es_CO','label'=> Mage::helper('googleanalytics')->__('Spanish (Colombia)')),
21
+ array('value'=>'es_ES','label'=> Mage::helper('googleanalytics')->__('Spanish (Spain)')),
22
+ array('value'=>'es_MX','label'=> Mage::helper('googleanalytics')->__('Spanish (Mexico)')),
23
+ array('value'=>'es_VE','label'=> Mage::helper('googleanalytics')->__('Spanish (Venezuela)')),
24
+ array('value'=>'fb_FI','label'=> Mage::helper('googleanalytics')->__('Finnish (test)')),
25
+ array('value'=>'fi_FI','label'=> Mage::helper('googleanalytics')->__('Finnish')),
26
+ array('value'=>'fr_FR','label'=> Mage::helper('googleanalytics')->__('French (France)')),
27
+ array('value'=>'gl_ES','label'=> Mage::helper('googleanalytics')->__('Galician')),
28
+ array('value'=>'hu_HU','label'=> Mage::helper('googleanalytics')->__('Hungarian')),
29
+ array('value'=>'it_IT','label'=> Mage::helper('googleanalytics')->__('Italian')),
30
+ array('value'=>'ja_JP','label'=> Mage::helper('googleanalytics')->__('Japanese')),
31
+ array('value'=>'ko_KR','label'=> Mage::helper('googleanalytics')->__('Korean')),
32
+ array('value'=>'nb_NO','label'=> Mage::helper('googleanalytics')->__('Norwegian (bokmal)')),
33
+ array('value'=>'nn_NO','label'=> Mage::helper('googleanalytics')->__('Norwegian (nynorsk)')),
34
+ array('value'=>'nl_NL','label'=> Mage::helper('googleanalytics')->__('Dutch')),
35
+ array('value'=>'pl_PL','label'=> Mage::helper('googleanalytics')->__('Polish')),
36
+ array('value'=>'pt_BR','label'=> Mage::helper('googleanalytics')->__('Portuguese (Brazil)')),
37
+ array('value'=>'pt_PT','label'=> Mage::helper('googleanalytics')->__('Portuguese (Portugal)')),
38
+ array('value'=>'ro_RO','label'=> Mage::helper('googleanalytics')->__('Romanian')),
39
+ array('value'=>'ru_RU','label'=> Mage::helper('googleanalytics')->__('Russian')),
40
+ array('value'=>'sk_SK','label'=> Mage::helper('googleanalytics')->__('Slovak')),
41
+ array('value'=>'sl_SI','label'=> Mage::helper('googleanalytics')->__('Slovenian')),
42
+ array('value'=>'sv_SE','label'=> Mage::helper('googleanalytics')->__('Swedish')),
43
+ array('value'=>'th_TH','label'=> Mage::helper('googleanalytics')->__('Thai')),
44
+ array('value'=>'ku_TR','label'=> Mage::helper('googleanalytics')->__('Kurdish')),
45
+ array('value'=>'zh_CN','label'=> Mage::helper('googleanalytics')->__('Simplified Chinese (China)')),
46
+ array('value'=>'zh_HK','label'=> Mage::helper('googleanalytics')->__('Traditional Chinese (Hong Kong)')),
47
+ array('value'=>'zh_TW','label'=> Mage::helper('googleanalytics')->__('Traditional Chinese (Taiwan)')),
48
+ array('value'=>'fb_LT','label'=> Mage::helper('googleanalytics')->__('Leet Speak')),
49
+ array('value'=>'af_ZA','label'=> Mage::helper('googleanalytics')->__('Afrikaans')),
50
+ array('value'=>'sq_AL','label'=> Mage::helper('googleanalytics')->__('Albanian')),
51
+ array('value'=>'hy_AM','label'=> Mage::helper('googleanalytics')->__('Armenian')),
52
+ array('value'=>'az_AZ','label'=> Mage::helper('googleanalytics')->__('Azeri')),
53
+ array('value'=>'be_BY','label'=> Mage::helper('googleanalytics')->__('Belarusian')),
54
+ array('value'=>'bn_IN','label'=> Mage::helper('googleanalytics')->__('Bengali')),
55
+ array('value'=>'bs_BA','label'=> Mage::helper('googleanalytics')->__('Bosnian')),
56
+ array('value'=>'bg_BG','label'=> Mage::helper('googleanalytics')->__('Bulgarian')),
57
+ array('value'=>'hr_HR','label'=> Mage::helper('googleanalytics')->__('Croatian')),
58
+ array('value'=>'nl_BE','label'=> Mage::helper('googleanalytics')->__('Dutch (Belgie)')),
59
+ array('value'=>'en_GB','label'=> Mage::helper('googleanalytics')->__('English (UK)')),
60
+ array('value'=>'eo_EO','label'=> Mage::helper('googleanalytics')->__('Esperanto')),
61
+ array('value'=>'et_EE','label'=> Mage::helper('googleanalytics')->__('Estonian')),
62
+ array('value'=>'fo_FO','label'=> Mage::helper('googleanalytics')->__('Faroese')),
63
+ array('value'=>'fr_CA','label'=> Mage::helper('googleanalytics')->__('French (Canada)')),
64
+ array('value'=>'ka_GE','label'=> Mage::helper('googleanalytics')->__('Georgian')),
65
+ array('value'=>'el_GR','label'=> Mage::helper('googleanalytics')->__('Greek')),
66
+ array('value'=>'gu_IN','label'=> Mage::helper('googleanalytics')->__('Gujarati')),
67
+ array('value'=>'hi_IN','label'=> Mage::helper('googleanalytics')->__('Hindi')),
68
+ array('value'=>'is_IS','label'=> Mage::helper('googleanalytics')->__('Icelandic')),
69
+ array('value'=>'id_ID','label'=> Mage::helper('googleanalytics')->__('Indonesian')),
70
+ array('value'=>'ga_IE','label'=> Mage::helper('googleanalytics')->__('Irish')),
71
+ array('value'=>'jv_ID','label'=> Mage::helper('googleanalytics')->__('Javanese')),
72
+ array('value'=>'kn_IN','label'=> Mage::helper('googleanalytics')->__('Kannada')),
73
+ array('value'=>'kk_KZ','label'=> Mage::helper('googleanalytics')->__('Kazakh')),
74
+ array('value'=>'la_VA','label'=> Mage::helper('googleanalytics')->__('Latin')),
75
+ array('value'=>'lv_LV','label'=> Mage::helper('googleanalytics')->__('Latvian')),
76
+ array('value'=>'li_NL','label'=> Mage::helper('googleanalytics')->__('Limburgish')),
77
+ array('value'=>'lt_LT','label'=> Mage::helper('googleanalytics')->__('Lithuanian')),
78
+ array('value'=>'mk_MK','label'=> Mage::helper('googleanalytics')->__('Macedonian')),
79
+ array('value'=>'mg_MG','label'=> Mage::helper('googleanalytics')->__('Malagasy')),
80
+ array('value'=>'ms_MY','label'=> Mage::helper('googleanalytics')->__('Malay')),
81
+ array('value'=>'mt_MT','label'=> Mage::helper('googleanalytics')->__('Maltese')),
82
+ array('value'=>'mr_IN','label'=> Mage::helper('googleanalytics')->__('Marathi')),
83
+ array('value'=>'mn_MN','label'=> Mage::helper('googleanalytics')->__('Mongolian')),
84
+ array('value'=>'ne_NP','label'=> Mage::helper('googleanalytics')->__('Nepali')),
85
+ array('value'=>'pa_IN','label'=> Mage::helper('googleanalytics')->__('Punjabi')),
86
+ array('value'=>'rm_CH','label'=> Mage::helper('googleanalytics')->__('Romansh')),
87
+ array('value'=>'sa_IN','label'=> Mage::helper('googleanalytics')->__('Sanskrit')),
88
+ array('value'=>'sr_RS','label'=> Mage::helper('googleanalytics')->__('Serbian')),
89
+ array('value'=>'so_SO','label'=> Mage::helper('googleanalytics')->__('Somali')),
90
+ array('value'=>'sw_KE','label'=> Mage::helper('googleanalytics')->__('Swahili')),
91
+ array('value'=>'tl_PH','label'=> Mage::helper('googleanalytics')->__('Filipino')),
92
+ array('value'=>'ta_IN','label'=> Mage::helper('googleanalytics')->__('Tamil')),
93
+ array('value'=>'tt_RU','label'=> Mage::helper('googleanalytics')->__('Tatar')),
94
+ array('value'=>'te_IN','label'=> Mage::helper('googleanalytics')->__('Telugu')),
95
+ array('value'=>'ml_IN','label'=> Mage::helper('googleanalytics')->__('Malayalam')),
96
+ array('value'=>'uk_UA','label'=> Mage::helper('googleanalytics')->__('Ukrainian')),
97
+ array('value'=>'uz_UZ','label'=> Mage::helper('googleanalytics')->__('Uzbek')),
98
+ array('value'=>'vi_VN','label'=> Mage::helper('googleanalytics')->__('Vietnamese')),
99
+ array('value'=>'xh_ZA','label'=> Mage::helper('googleanalytics')->__('Xhosa')),
100
+ array('value'=>'zu_ZA','label'=> Mage::helper('googleanalytics')->__('Zulu')),
101
+ array('value'=>'km_KH','label'=> Mage::helper('googleanalytics')->__('Khmer')),
102
+ array('value'=>'tg_TJ','label'=> Mage::helper('googleanalytics')->__('Tajik')),
103
+ array('value'=>'ar_AR','label'=> Mage::helper('googleanalytics')->__('Arabic')),
104
+ array('value'=>'he_IL','label'=> Mage::helper('googleanalytics')->__('Hebrew')),
105
+ array('value'=>'ur_PK','label'=> Mage::helper('googleanalytics')->__('Urdu')),
106
+ array('value'=>'fa_IR','label'=> Mage::helper('googleanalytics')->__('Persian')),
107
+ array('value'=>'sy_SY','label'=> Mage::helper('googleanalytics')->__('Syriac')),
108
+ array('value'=>'yi_DE','label'=> Mage::helper('googleanalytics')->__('Yiddish')),
109
+ array('value'=>'gn_PY','label'=> Mage::helper('googleanalytics')->__('Guarani')),
110
+ array('value'=>'qu_PE','label'=> Mage::helper('googleanalytics')->__('Quechua')),
111
+ array('value'=>'ay_BO','label'=> Mage::helper('googleanalytics')->__('Aymara')),
112
+ array('value'=>'se_NO','label'=> Mage::helper('googleanalytics')->__('Northern Sami')),
113
+ array('value'=>'ps_AF','label'=> Mage::helper('googleanalytics')->__('Pashto')),
114
+ array('value'=>'tl_ST','label'=> Mage::helper('googleanalytics')->__('Klingon')),
115
+ );
116
+ return $options;
117
+ }
118
+ }
app/code/local/Cinasstore/Googleanalytics/controllers/Adminhtml/DashboardController.php ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Cinasstore_Googleanalytics_Adminhtml_DashboardController extends Mage_Adminhtml_Controller_action
3
+ {
4
+
5
+ protected function _initAction()
6
+ {
7
+ $this->loadLayout()
8
+ ->_setActiveMenu('googleanalytics/dashboard')
9
+ ->_addBreadcrumb(Mage::helper('adminhtml')->__('Settings'), Mage::helper('adminhtml')->__('Settings'));
10
+ return $this;
11
+ }
12
+
13
+ public function indexAction() {
14
+ $this->_initAction()
15
+ ->renderLayout();
16
+ }
17
+
18
+ }
app/code/local/Cinasstore/Googleanalytics/controllers/Adminhtml/GoogleanalyticsController.php ADDED
@@ -0,0 +1,186 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Cinasstore_Googleanalytics_Adminhtml_GoogleanalyticsController extends Mage_Adminhtml_Controller_action
4
+ {
5
+
6
+ protected function _initAction() {
7
+ $this->loadLayout()
8
+ ->_setActiveMenu('googleanalytics/items')
9
+ ->_addBreadcrumb(Mage::helper('adminhtml')->__('Items Manager'), Mage::helper('adminhtml')->__('Item Manager'));
10
+
11
+ return $this;
12
+ }
13
+
14
+ public function indexAction() {
15
+ $this->_initAction()
16
+ ->renderLayout();
17
+ }
18
+
19
+ public function editAction() {
20
+ $id = $this->getRequest()->getParam('id');
21
+ $model = Mage::getModel('googleanalytics/googleanalytics')->load($id);
22
+
23
+ if ($model->getId() || $id == 0) {
24
+ $data = Mage::getSingleton('adminhtml/session')->getFormData(true);
25
+ if (!empty($data)) {
26
+ $model->setData($data);
27
+ }
28
+
29
+ Mage::register('googleanalytics_data', $model);
30
+
31
+ $this->loadLayout();
32
+ $this->_setActiveMenu('googleanalytics/items');
33
+
34
+ $this->_addBreadcrumb(Mage::helper('adminhtml')->__('Item Manager'), Mage::helper('adminhtml')->__('Item Manager'));
35
+ $this->_addBreadcrumb(Mage::helper('adminhtml')->__('Item News'), Mage::helper('adminhtml')->__('Item News'));
36
+
37
+ $this->getLayout()->getBlock('head')->setCanLoadExtJs(true);
38
+
39
+ $this->_addContent($this->getLayout()->createBlock('googleanalytics/adminhtml_googleanalytics_edit'))
40
+ ->_addLeft($this->getLayout()->createBlock('googleanalytics/adminhtml_googleanalytics_edit_tabs'));
41
+
42
+ $this->renderLayout();
43
+ } else {
44
+ Mage::getSingleton('adminhtml/session')->addError(Mage::helper('googleanalytics')->__('Item does not exist'));
45
+ $this->_redirect('*/*/');
46
+ }
47
+ }
48
+
49
+ public function newAction() {
50
+ $this->_forward('edit');
51
+ }
52
+
53
+ public function saveAction() {
54
+ if ($data = $this->getRequest()->getPost()) {
55
+
56
+ $model = Mage::getModel('googleanalytics/googleanalytics');
57
+ $model->setData($data)
58
+ ->setId($this->getRequest()->getParam('id'));
59
+
60
+ try {
61
+ if ($model->getCreatedTime == NULL || $model->getUpdateTime() == NULL) {
62
+ $model->setCreatedTime(now())
63
+ ->setUpdateTime(now());
64
+ } else {
65
+ $model->setUpdateTime(now());
66
+ }
67
+
68
+ $model->save();
69
+ Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('googleanalytics')->__('Item was successfully saved'));
70
+ Mage::getSingleton('adminhtml/session')->setFormData(false);
71
+
72
+ if ($this->getRequest()->getParam('back')) {
73
+ $this->_redirect('*/*/edit', array('id' => $model->getId()));
74
+ return;
75
+ }
76
+ $this->_redirect('*/*/');
77
+ return;
78
+ } catch (Exception $e) {
79
+ Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
80
+ Mage::getSingleton('adminhtml/session')->setFormData($data);
81
+ $this->_redirect('*/*/edit', array('id' => $this->getRequest()->getParam('id')));
82
+ return;
83
+ }
84
+ }
85
+ Mage::getSingleton('adminhtml/session')->addError(Mage::helper('googleanalytics')->__('Unable to find item to save'));
86
+ $this->_redirect('*/*/');
87
+ }
88
+
89
+ public function deleteAction() {
90
+ if( $this->getRequest()->getParam('id') > 0 ) {
91
+ try {
92
+ $model = Mage::getModel('googleanalytics/googleanalytics');
93
+
94
+ $model->setId($this->getRequest()->getParam('id'))
95
+ ->delete();
96
+
97
+ Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('adminhtml')->__('Item was successfully deleted'));
98
+ $this->_redirect('*/*/');
99
+ } catch (Exception $e) {
100
+ Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
101
+ $this->_redirect('*/*/edit', array('id' => $this->getRequest()->getParam('id')));
102
+ }
103
+ }
104
+ $this->_redirect('*/*/');
105
+ }
106
+
107
+ public function massDeleteAction() {
108
+ $googleanalyticsIds = $this->getRequest()->getParam('googleanalytics');
109
+ if(!is_array($googleanalyticsIds)) {
110
+ Mage::getSingleton('adminhtml/session')->addError(Mage::helper('adminhtml')->__('Please select item(s)'));
111
+ } else {
112
+ try {
113
+ foreach ($googleanalyticsIds as $googleanalyticsId) {
114
+ $googleanalytics = Mage::getModel('googleanalytics/googleanalytics')->load($googleanalyticsId);
115
+ $googleanalytics->delete();
116
+ }
117
+ Mage::getSingleton('adminhtml/session')->addSuccess(
118
+ Mage::helper('adminhtml')->__(
119
+ 'Total of %d record(s) were successfully deleted', count($googleanalyticsIds)
120
+ )
121
+ );
122
+ } catch (Exception $e) {
123
+ Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
124
+ }
125
+ }
126
+ $this->_redirect('*/*/index');
127
+ }
128
+
129
+ public function massStatusAction()
130
+ {
131
+ $googleanalyticsIds = $this->getRequest()->getParam('googleanalytics');
132
+ if(!is_array($googleanalyticsIds)) {
133
+ Mage::getSingleton('adminhtml/session')->addError($this->__('Please select item(s)'));
134
+ } else {
135
+ try {
136
+ foreach ($googleanalyticsIds as $googleanalyticsId) {
137
+ $googleanalytics = Mage::getSingleton('googleanalytics/googleanalytics')
138
+ ->load($googleanalyticsId)
139
+ ->setStatus($this->getRequest()->getParam('status'))
140
+ ->setIsMassupdate(true)
141
+ ->save();
142
+ }
143
+ $this->_getSession()->addSuccess(
144
+ $this->__('Total of %d record(s) were successfully updated', count($googleanalyticsIds))
145
+ );
146
+ } catch (Exception $e) {
147
+ $this->_getSession()->addError($e->getMessage());
148
+ }
149
+ }
150
+ $this->_redirect('*/*/index');
151
+ }
152
+
153
+ public function exportCsvAction()
154
+ {
155
+ $fileName = 'googleanalytics.csv';
156
+ $content = $this->getLayout()->createBlock('googleanalytics/adminhtml_googleanalytics_grid')
157
+ ->getCsv();
158
+
159
+ $this->_sendUploadResponse($fileName, $content);
160
+ }
161
+
162
+ public function exportXmlAction()
163
+ {
164
+ $fileName = 'googleanalytics.xml';
165
+ $content = $this->getLayout()->createBlock('googleanalytics/adminhtml_googleanalytics_grid')
166
+ ->getXml();
167
+
168
+ $this->_sendUploadResponse($fileName, $content);
169
+ }
170
+
171
+ protected function _sendUploadResponse($fileName, $content, $contentType='application/octet-stream')
172
+ {
173
+ $response = $this->getResponse();
174
+ $response->setHeader('HTTP/1.1 200 OK','');
175
+ $response->setHeader('Pragma', 'public', true);
176
+ $response->setHeader('Cache-Control', 'must-revalidate, post-check=0, pre-check=0', true);
177
+ $response->setHeader('Content-Disposition', 'attachment; filename='.$fileName);
178
+ $response->setHeader('Last-Modified', date('r'));
179
+ $response->setHeader('Accept-Ranges', 'bytes');
180
+ $response->setHeader('Content-Length', strlen($content));
181
+ $response->setHeader('Content-type', $contentType);
182
+ $response->setBody($content);
183
+ $response->sendResponse();
184
+ die;
185
+ }
186
+ }
app/code/local/Cinasstore/Googleanalytics/controllers/IndexController.php ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Cinasstore_Googleanalytics_IndexController extends Mage_Core_Controller_Front_Action
3
+ {
4
+
5
+ public function getCssAction()
6
+ {
7
+ $helper = Mage::helper('googleanalytics');
8
+ if($helper->isHiddenComment())
9
+ $css .= 'div.comment_body, div.comment_body div {display:none;}';
10
+ elseif($helper->isCustomComment())
11
+ $css .= $helper->getCommentCssStyle();
12
+
13
+ if($helper->isHiddenLike())
14
+ $css .= 'div.like, div.like div {display:none;}';
15
+ elseif($helper->isCustomLike())
16
+ $css .= $helper->getLikeCssStyle();
17
+
18
+ echo $css;
19
+ return;
20
+ }
21
+
22
+ public function testAction(){
23
+ echo Mage::getStoreConfig('googleanalytics/general/custom_style');
24
+ return;
25
+ }
26
+ }
app/code/local/Cinasstore/Googleanalytics/etc/adminhtml.xml ADDED
@@ -0,0 +1,39 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <menu>
4
+ <googleanalytics translate="title" module="googleanalytics">
5
+ <title>Google Analytics</title>
6
+ <sort_order>100</sort_order>
7
+ <children>
8
+ <dashboard translate="title" module="googleanalytics">
9
+ <title>Dashboard</title>
10
+ <action>googleanalytics/adminhtml_dashboard</action>
11
+ <sort_order>500</sort_order>
12
+ </dashboard>
13
+ </children>
14
+ </googleanalytics>
15
+ </menu>
16
+ <acl>
17
+ <resources>
18
+ <all>
19
+ <title>Allow Everything</title>
20
+ </all>
21
+ <admin>
22
+ <children>
23
+ <system>
24
+ <children>
25
+ <config>
26
+ <children>
27
+ <googleanalytics translate="title">
28
+ <title>Google Analytics</title>
29
+ <sort_order>50</sort_order>
30
+ </googleanalytics>
31
+ </children>
32
+ </config>
33
+ </children>
34
+ </system>
35
+ </children>
36
+ </admin>
37
+ </resources>
38
+ </acl>
39
+ </config>
app/code/local/Cinasstore/Googleanalytics/etc/config.xml ADDED
@@ -0,0 +1,147 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <modules>
4
+ <Cinasstore_Googleanalytics>
5
+ <version>0.1.0</version>
6
+ </Cinasstore_Googleanalytics>
7
+ </modules>
8
+ <frontend>
9
+ <routers>
10
+ <googleanalytics>
11
+ <use>standard</use>
12
+ <args>
13
+ <module>Cinasstore_Googleanalytics</module>
14
+ <frontName>googleanalytics</frontName>
15
+ </args>
16
+ </googleanalytics>
17
+ </routers>
18
+ <layout>
19
+ <updates>
20
+ <googleanalytics>
21
+ <file>googleanalytics.xml</file>
22
+ </googleanalytics>
23
+ </updates>
24
+ </layout>
25
+ </frontend>
26
+ <admin>
27
+ <routers>
28
+ <googleanalytics>
29
+ <use>admin</use>
30
+ <args>
31
+ <module>Cinasstore_Googleanalytics</module>
32
+ <frontName>googleanalytics</frontName>
33
+ </args>
34
+ </googleanalytics>
35
+ </routers>
36
+ </admin>
37
+ <adminhtml>
38
+ <acl>
39
+ <resources>
40
+ <all>
41
+ <title>Allow Everything</title>
42
+ </all>
43
+ <admin>
44
+ <children>
45
+ <system>
46
+ <children>
47
+ <config>
48
+ <children>
49
+ <googleanalytics translate="title">
50
+ <title>Google Analytics</title>
51
+ <sort_order>50</sort_order>
52
+ </googleanalytics>
53
+ </children>
54
+ </config>
55
+ </children>
56
+ </system>
57
+ </children>
58
+ </admin>
59
+ </resources>
60
+ </acl>
61
+ <layout>
62
+ <updates>
63
+ <googleanalytics>
64
+ <file>googleanalytics.xml</file>
65
+ </googleanalytics>
66
+ </updates>
67
+ </layout>
68
+ <events>
69
+ <controller_action_predispatch_adminhtml>
70
+ <observers>
71
+ <cinasstore_googleanalytics_observer>
72
+ <type>singleton</type>
73
+ <class>googleanalytics/observer</class>
74
+ <method>controller_action_predispatch_adminhtml</method>
75
+ </cinasstore_googleanalytics_observer>
76
+ </observers>
77
+ </controller_action_predispatch_adminhtml>
78
+ </events>
79
+ </adminhtml>
80
+ <global>
81
+ <events>
82
+ <admin_system_config_changed_section_googleanalytics>
83
+ <observers>
84
+ <cinasstore_googleanalytics_observer>
85
+ <type>singleton</type>
86
+ <class>googleanalytics/observer</class>
87
+ <method>saveGoogleanalyticsConfig</method>
88
+ </cinasstore_googleanalytics_observer>
89
+ </observers>
90
+ </admin_system_config_changed_section_googleanalytics>
91
+ </events>
92
+ <models>
93
+ <googleanalytics>
94
+ <class>Cinasstore_Googleanalytics_Model</class>
95
+ <resourceModel>googleanalytics_mysql4</resourceModel>
96
+ </googleanalytics>
97
+ <googleanalytics_mysql4>
98
+ <class>Cinasstore_Googleanalytics_Model_Mysql4</class>
99
+ <entities>
100
+ <googleanalytics>
101
+ <table>googleanalytics</table>
102
+ </googleanalytics>
103
+ </entities>
104
+ </googleanalytics_mysql4>
105
+ </models>
106
+ <resources>
107
+ <googleanalytics_setup>
108
+ <setup>
109
+ <module>Cinasstore_Googleanalytics</module>
110
+ </setup>
111
+ <connection>
112
+ <use>core_setup</use>
113
+ </connection>
114
+ </googleanalytics_setup>
115
+ <googleanalytics_write>
116
+ <connection>
117
+ <use>core_write</use>
118
+ </connection>
119
+ </googleanalytics_write>
120
+ <googleanalytics_read>
121
+ <connection>
122
+ <use>core_read</use>
123
+ </connection>
124
+ </googleanalytics_read>
125
+ </resources>
126
+ <blocks>
127
+ <googleanalytics>
128
+ <class>Cinasstore_Googleanalytics_Block</class>
129
+ </googleanalytics>
130
+ </blocks>
131
+ <helpers>
132
+ <googleanalytics>
133
+ <class>Cinasstore_Googleanalytics_Helper</class>
134
+ </googleanalytics>
135
+ </helpers>
136
+ </global>
137
+ <default>
138
+ <googleanalytics>
139
+ <general>
140
+ <show_number_of_comment>10</show_number_of_comment>
141
+ <width_of_comment_box>642</width_of_comment_box>
142
+ <language>en_US</language>
143
+
144
+ </general>
145
+ </googleanalytics>
146
+ </default>
147
+ </config>
app/code/local/Cinasstore/Googleanalytics/etc/system.xml ADDED
@@ -0,0 +1,63 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <tabs>
4
+ <cinasstore translate="label">
5
+ <label>Cinasstore Extension</label>
6
+ <sort_order>400</sort_order>
7
+ </cinasstore>
8
+ </tabs>
9
+
10
+ <sections>
11
+ <googleanalytics translate="label" module="googleanalytics">
12
+ <class>separator-top</class>
13
+ <label>Google Analytics</label>
14
+ <tab>cinasstore</tab>
15
+ <frontend_type>text</frontend_type>
16
+ <sort_order>300</sort_order>
17
+ <show_in_default>1</show_in_default>
18
+ <show_in_website>1</show_in_website>
19
+ <show_in_store>1</show_in_store>
20
+ <groups>
21
+ <general translate="label">
22
+ <label>Google Analytics Configuration</label>
23
+ <frontend_type>text</frontend_type>
24
+ <sort_order>0</sort_order>
25
+ <show_in_default>1</show_in_default>
26
+ <show_in_website>1</show_in_website>
27
+ <show_in_store>0</show_in_store>
28
+ <fields>
29
+ <analytic_profile_id translate="label">
30
+ <label>Google Analytic Profile ID</label>
31
+ <frontend_type>text</frontend_type>
32
+ <sort_order>0</sort_order>
33
+ <show_in_default>1</show_in_default>
34
+ <show_in_website>1</show_in_website>
35
+ <show_in_store>1</show_in_store>
36
+ <comment></comment>
37
+ </analytic_profile_id>
38
+ <analytic_email_id translate="label">
39
+ <label>Analytic Account Email ID</label>
40
+ <frontend_type>text</frontend_type>
41
+ <sort_order>15</sort_order>
42
+ <show_in_default>1</show_in_default>
43
+ <show_in_website>1</show_in_website>
44
+ <show_in_store>1</show_in_store>
45
+ <comment></comment>
46
+ </analytic_email_id>
47
+ <analytic_password translate="label">
48
+ <label>Analytic Account Password</label>
49
+ <frontend_type>password</frontend_type>
50
+ <sort_order>20</sort_order>
51
+ <show_in_default>1</show_in_default>
52
+ <show_in_website>1</show_in_website>
53
+ <show_in_store>1</show_in_store>
54
+ <comment></comment>
55
+ </analytic_password>
56
+
57
+ </fields>
58
+ </general>
59
+
60
+ </groups>
61
+ </googleanalytics>
62
+ </sections>
63
+ </config>
app/code/local/Cinasstore/Googleanalytics/sql/Googleanalytics_setup/mysql4-install-0.1.0.php ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ $installer = $this;
4
+
5
+ $installer->startSetup();
6
+
7
+ $installer->run("
8
+
9
+ DROP TABLE IF EXISTS {$this->getTable('googleanalytics')};
10
+ CREATE TABLE {$this->getTable('googleanalytics')} (
11
+ `googleanalytics_id` int(11) unsigned NOT NULL auto_increment,
12
+ `edit_time` datetime NULL,
13
+ PRIMARY KEY (`googleanalytics_id`)
14
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
15
+
16
+ ");
17
+
18
+ $installer->endSetup();
app/code/local/Cinasstore/Googleanalytics/sql/Googleanalytics_setup/mysql4-upgrade-0.1.0-0.1.1.php ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ $installer = $this;
4
+
5
+ $installer->startSetup();
6
+
7
+ $installer->endSetup();
app/design/adminhtml/default/default/layout/googleanalytics.xml ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <layout version="0.1.0">
3
+ <googleanalytics_adminhtml_dashboard_index>
4
+ <reference name="content">
5
+ <block type="googleanalytics/adminhtml_dashboard" name="googleanalytic" template="googleanalytics/report.phtml"/>
6
+ </reference>
7
+ </googleanalytics_adminhtml_dashboard_index>
8
+
9
+ <googleanalytics_adminhtml_googleanalytics_index>
10
+ <reference name="content">
11
+ <block type="googleanalytics/adminhtml_googleanalytics" name="googleanalytics" />
12
+ </reference>
13
+ </googleanalytics_adminhtml_googleanalytics_index>
14
+ </layout>
app/design/adminhtml/default/default/template/googleanalytics/report.phtml ADDED
@@ -0,0 +1,65 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <div class="content-header">
2
+ <table cellspacing="0">
3
+ <tbody><tr>
4
+ <td><h3 class="icon-head head-cms-page"><?php echo $this->__('Google Analytics Report') ?></h3></td>
5
+
6
+ </tr>
7
+ </tbody></table>
8
+ </div>
9
+ <table width="100%" border="0" cellspacing="5">
10
+ <tr>
11
+ <td width="50%">
12
+ <div class="entry-edit">
13
+ <div class="entry-edit-head"><h4>Page Visits</h4></div>
14
+ <fieldset>
15
+ <div id="chart"></div>
16
+ </fieldset>
17
+ </div>
18
+ </td>
19
+ <td width="50%">
20
+ <div class="entry-edit">
21
+ <div class="entry-edit-head"><h4>Top Referrals</h4></div>
22
+ <fieldset>
23
+ <div id="ga_dash_rdata"></div>
24
+ </fieldset>
25
+ </div>
26
+ </td>
27
+ </tr>
28
+
29
+
30
+ <tr>
31
+ <td width="50%">
32
+ <div class="entry-edit">
33
+ <div class="entry-edit-head"><h4>Views Track</h4></div>
34
+ <fieldset>
35
+ <div id="ga_dash_historydata"></div>
36
+ </td>
37
+ <td width="50%">
38
+ <div class="entry-edit">
39
+ <div class="entry-edit-head"><h4>Top Pages</h4></div>
40
+ <fieldset>
41
+ <div id="ga_dash_pgddata"></div>
42
+ </fieldset>
43
+ </div>
44
+ </td>
45
+ </tr>
46
+
47
+ <!--<tr>
48
+ <td colspan="2">
49
+ <div id="ga_dash_mapdata"></div>
50
+ </td>
51
+ </tr>-->
52
+
53
+ </table>
54
+
55
+
56
+ <script type="text/javascript" src="https://www.google.com/jsapi"></script>
57
+ <script type="text/javascript">
58
+ <?php
59
+ echo $this->topReffer;
60
+ echo $this->PageViews;
61
+ echo $this->PageVisitHistory;
62
+ echo $this->TopPages;
63
+ echo $this->CountryVisits;
64
+ ?>
65
+ </script>
app/etc/modules/Cinasstore_GoogleAnalytics.xml ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <modules>
4
+ <Cinasstore_Googleanalytics>
5
+ <active>true</active>
6
+ <codePool>local</codePool>
7
+ </Cinasstore_Googleanalytics>
8
+ </modules>
9
+ </config>
package.xml ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <package>
3
+ <name>cinasstore_googleanalytics</name>
4
+ <version>0.1.0</version>
5
+ <stability>stable</stability>
6
+ <license>GPL</license>
7
+ <channel>community</channel>
8
+ <extends/>
9
+ <summary>Show Google Analytics Dashboard in Magento Store</summary>
10
+ <description>Show Google Analytics Dashboard in Magento Store.</description>
11
+ <notes>No License Key. &#xD;
12
+ Only one time Charge (No Charge after Purchase)&#xD;
13
+ Fully Customizable and Non-Encrypted Code. Free Support Supporting Magento Versions 1.7 + &#xD;
14
+ &#xD;
15
+ Note- Before Installing the extension, please take the backup of the website</notes>
16
+ <authors><author><name>Cinas Technologies</name><user>Cinas</user><email>sales@cinastechnologies.com</email></author></authors>
17
+ <date>2013-12-30</date>
18
+ <time>19:34:40</time>
19
+ <contents><target name="mageetc"><dir name="modules"><file name="Cinasstore_GoogleAnalytics.xml" hash="36f2a205669e60a81a745ea279707c45"/></dir></target><target name="magelocal"><dir name="Cinasstore"><dir name="Googleanalytics"><dir name="Block"><dir name="Adminhtml"><file name="Dashboard.php" hash="c5d2bd03e58c93f8c75b1d13e0fe9242"/><dir name="Googleanalytics"><dir name="Edit"><file name="Form.php" hash="4fc3ee2c057426570d0ba5cd202d117e"/><dir name="Tab"><file name="Form.php" hash="1edd301e42af180be589cb0952abca29"/></dir><file name="Tabs.php" hash="4a02b3eae128c653ea3c90b4908525f9"/></dir><file name="Edit.php" hash="20596c13dbc4c849604656a08d65b56c"/><file name="Grid.php" hash="256c71e00a2c7f4c4f15452e78b4f441"/></dir><file name="Googleanalytics.php" hash="a450b2c377b9d3b0c012d4ac3a68c8c0"/></dir><file name="Googleanalytics.php" hash="0c550f4f87833acc048fe6e62bf1e6da"/></dir><dir name="Helper"><file name="Dashboard.php" hash="945a525471a730f6be94a9a2c73315c3"/><file name="Data.php" hash="981a95aa6d0c3bc98d84f4249e6f9821"/></dir><dir name="Model"><file name="Gapi.php" hash="4503d4eaba7704ca425292fb0b650b1e"/><file name="Googleanalytics.php" hash="fbafb51feba61a4f75d425b9c82a27ff"/><dir name="Mysql4"><dir name="Googleanalytics"><file name="Collection.php" hash="7f4fa8e1631036fea33d195b7b5ec57d"/></dir><file name="Googleanalytics.php" hash="60c1a38819063aea14cf31db066e4c4b"/></dir><file name="Observer.php" hash="528d6351049b2aa4a73f898bf638c28b"/><file name="Status.php" hash="7c39b641f5a091ad67a30c784db7d3e2"/><dir name="System"><dir name="Config"><file name="Language.php" hash="a57563bf23ef1d12591f9001e15fc723"/></dir></dir></dir><dir name="controllers"><dir name="Adminhtml"><file name="DashboardController.php" hash="df6a79802706a4f4e6aea18809e41585"/><file name="GoogleanalyticsController.php" hash="5641fa0e0cd5475b1aebf448bf0f60e8"/></dir><file name="IndexController.php" hash="f7535853602c2e1f5e319b08f7434993"/></dir><dir name="etc"><file name="adminhtml.xml" hash="a187720a4e0940cf4f5127f45058459c"/><file name="config.xml" hash="11e3322f8a1019ad070f5303761ff75d"/><file name="system.xml" hash="cc4af2cf3634cb44503df7a0ce184d86"/></dir><dir name="sql"><dir name="Googleanalytics_setup"><file name="mysql4-install-0.1.0.php" hash="3cdbd040bd4a2b88e52654a42692fa6f"/><file name="mysql4-upgrade-0.1.0-0.1.1.php" hash="8c8ea981a81cf84c52b864438a10db1a"/></dir></dir></dir></dir></target><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="layout"><file name="googleanalytics.xml" hash="25fd348f746f3bf6eb640c9740f86463"/></dir><dir name="template"><dir name="googleanalytics"><file name="report.phtml" hash="6027e1d82bc578d6002797e42428e442"/></dir></dir></dir></dir></dir></target></contents>
20
+ <compatible/>
21
+ <dependencies><required><php><min>5.1.0</min><max>6.0.0</max></php></required></dependencies>
22
+ </package>