forked from hooduku/Open-Web-Analytics
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathowa_reportController.php
168 lines (133 loc) · 4.41 KB
/
owa_reportController.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
<?php
//
// Open Web Analytics - An Open Source Web Analytics Framework
//
// Copyright 2006 Peter Adams. All rights reserved.
//
// Licensed under GPL v2.0 http://www.gnu.org/copyleft/gpl.html
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// $Id$
//
require_once(OWA_BASE_CLASSES_DIR.'owa_adminController.php');
/**
* Abstract Report Controller Class
*
* @author Peter Adams <peter@openwebanalytics.com>
* @copyright Copyright © 2006 Peter Adams <peter@openwebanalytics.com>
* @license http://www.gnu.org/copyleft/gpl.html GPL v2.0
* @category owa
* @package owa
* @version $Revision$
* @since owa 1.0.0
*/
class owa_reportController extends owa_adminController {
/**
* Constructor
*
* @param array $params
* @return
*/
function __construct($params) {
$this->setControllerType('report');
$this->_setCapability('view_reports');
return parent::__construct($params);
}
/**
* pre action
*
*/
function pre() {
// site lists
$sites = owa_coreAPI::getSitesList();
$this->set('sites', $sites);
// set default siteId if none exists on request
$site_id = $this->getParam('siteId');
if ( ! $site_id ) {
$site_id = $this->getParam('site_id');
}
if ( ! $site_id ) {
$site_id = $sites[0]['site_id'];
}
$this->setParam('siteId', $site_id);
// pass full set of params to view
$this->data['params'] = $this->params;
// set default period if necessary
if ( ! $this->getParam( 'period' ) && ! $this->getParam( 'startDate' ) ) {
$this->set('is_default_period', true);
$period = 'last_seven_days';
$this->params['period'] = $period;
} elseif ( ! $this->getParam( 'period' ) && $this->getParam( 'startDate' ) ) {
$period = 'date_range';
$this->params['period'] = $period;
} else {
$period = $this->getParam('period');
}
$this->setPeriod($period);
$this->setView('base.report');
$this->setViewMethod('delegate');
$this->dom_id = str_replace('.', '-', $this->getParam('do'));
$this->data['dom_id'] = $this->dom_id;
$this->data['do'] = $this->getParam('do');
// setup tabs
$siteId = $this->get('siteId');
$gm = owa_coreAPI::supportClassFactory('base', 'goalManager', $siteId);
$tabs = array();
$site_usage = array(
'tab_label' => 'Site Usage',
'metrics' => 'visits,pagesPerVisit,visitDuration,bounceRate,uniqueVisitors',
'sort' => 'visits-'
);
$tabs['site_usage'] = $site_usage;
// ecommerce tab
if ( owa_coreAPI::getSiteSetting( $this->getParam('siteId'), 'enableEcommerceReporting') ) {
$ecommerce = array(
'tab_label' => 'e-commerce',
'metrics' => 'visits,transactions,transactionRevenue,revenuePerVisit,revenuePerTransaction,ecommerceConversionRate',
'sort' => 'transactionRevenue-'
);
$tabs['ecommerce'] = $ecommerce;
}
$goal_groups = $gm->getActiveGoalGroups();
if ( $goal_groups ) {
foreach ($goal_groups as $group) {
$goal_metrics = 'visits';
$active_goals = $gm->getActiveGoalsByGroup($group);
if ( $active_goals ) {
foreach ($active_goals as $goal) {
$goal_metrics .= sprintf(',goal%sCompletions', $goal);
}
}
$goal_metrics .= ',goalValueAll';
$goal_group = array(
'tab_label' => $gm->getGoalGroupLabel($group),
'metrics' => $goal_metrics,
'sort' => 'goalValueAll-'
);
$name = 'goal_group_'.$group;
$tabs[$name] = $goal_group;
}
}
$this->set('tabs', $tabs);
$this->set('tabs_json', json_encode($tabs));
//$this->body->set('sub_nav', owa_coreAPI::getNavigation($this->get('nav_tab'), 'sub_nav'));
$nav = owa_coreAPI::getGroupNavigation('Reports');
if ( ! owa_coreAPI::getSiteSetting( $this->getParam( 'siteId' ), 'enableEcommerceReporting' ) ) {
unset($nav['Ecommerce']);
}
$this->set('top_level_report_nav', $nav);
}
function post() {
return;
}
function setTitle($title, $suffix = '') {
$this->set('title', $title);
$this->set('titleSuffix', $suffix);
}
}
?>