Newer
Older
The Great Git Migration
committed
<?php
/**
* @file
* Provide views data and handlers for statistics.module
*/
/**
* @defgroup views_statistics_module statistics.module handlers
*
* Includes the ability to create views of just the statistics table.
* @{
*/
/**
* Implements hook_views_data()
The Great Git Migration
committed
*/
function statistics_views_data() {
// Basic table information.
// ----------------------------------------------------------------
// node_counter table
$data['node_counter']['table']['group'] = t('Content statistics');
The Great Git Migration
committed
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
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
$data['node_counter']['table']['join'] = array(
// ...to the node table
'node' => array(
'left_field' => 'nid',
'field' => 'nid',
),
);
// totalcount
$data['node_counter']['totalcount'] = array(
'title' => t('Total views'),
'help' => t('The total number of times the node has been viewed.'),
'field' => array(
'handler' => 'views_handler_field_numeric',
'click sortable' => TRUE,
),
'filter' => array(
'handler' => 'views_handler_filter_numeric',
),
'sort' => array(
'handler' => 'views_handler_sort',
),
);
// daycount
$data['node_counter']['daycount'] = array(
'title' => t('Views today'),
'help' => t('The total number of times the node has been viewed today.'),
'field' => array(
'handler' => 'views_handler_field_numeric',
'click sortable' => TRUE,
),
'filter' => array(
'handler' => 'views_handler_filter_numeric',
),
'sort' => array(
'handler' => 'views_handler_sort',
),
);
// timestamp
$data['node_counter']['timestamp'] = array(
'title' => t('Most recent view'),
'help' => t('The most recent time the node has been viewed.'),
'field' => array(
'handler' => 'views_handler_field_date',
'click sortable' => TRUE,
),
'filter' => array(
'handler' => 'views_handler_filter_date',
),
'sort' => array(
'handler' => 'views_handler_sort',
),
);
// ----------------------------------------------------------------
// accesslog table
$data['accesslog']['table']['group'] = t('Access log');
// Advertise this table as a possible base table
$data['accesslog']['table']['base'] = array(
'field' => 'aid',
'title' => t('Access log'),
'help' => t('Stores site access information.'),
'weight' => 10,
);
// For other base tables, explain how we join
$data['accesslog']['table']['join'] = array(
'users' => array(
'field' => 'uid',
'left_field' => 'uid',
),
);
// session id
$data['accesslog']['sid'] = array(
'title' => t('Session ID'),
'help' => t('Browser session ID of user that visited page.'),
'field' => array(
'handler' => 'views_handler_field',
'click sortable' => TRUE,
),
'filter' => array(
'handler' => 'views_handler_filter_string',
),
'argument' => array(
'handler' => 'views_handler_argument_string',
),
'sort' => array(
'handler' => 'views_handler_sort',
),
);
// title
$data['accesslog']['title'] = array(
'title' => t('Page title'),
'help' => t('Title of page visited.'),
'field' => array(
'handler' => 'views_handler_field_accesslog_path',
'click sortable' => TRUE,
),
'filter' => array(
'handler' => 'views_handler_filter_string',
),
'sort' => array(
'handler' => 'views_handler_sort',
),
'argument' => array(
'handler' => 'views_handler_argument_string',
),
);
// path
$data['accesslog']['path'] = array(
'title' => t('Path'),
'help' => t('Internal path to page visited (relative to Drupal root.)'),
'field' => array(
'handler' => 'views_handler_field_accesslog_path',
'click sortable' => TRUE,
),
'filter' => array(
'handler' => 'views_handler_filter_string',
),
'sort' => array(
'handler' => 'views_handler_sort',
),
//No argument here. Can't send forward slashes as arguments.
//Can be worked around by node ID.
//(but what about aliases?)
);
// referrer
$data['accesslog']['url'] = array(
'title' => t('Referrer'),
'help' => t('Referrer URI.'),
'field' => array(
'handler' => 'views_handler_field_url',
'click sortable' => TRUE,
),
'filter' => array(
'handler' => 'views_handler_filter_string',
),
'sort' => array(
'handler' => 'views_handler_sort',
),
);
// hostname
$data['accesslog']['hostname'] = array(
'title' => t('Hostname'),
'help' => t('Hostname of user that visited the page.'),
'field' => array(
'handler' => 'views_handler_field',
'click sortable' => TRUE,
),
'filter' => array(
'handler' => 'views_handler_filter_string',
),
'sort' => array(
'handler' => 'views_handler_sort',
),
'argument' => array(
'handler' => 'views_handler_argument_string',
),
);
// user
$data['accesslog']['uid'] = array(
'title' => t('User'),
'help' => t('The user who visited the site.'),
'relationship' => array(
'handler' => 'views_handler_relationship',
'base' => 'users',
'base field' => 'uid',
The Great Git Migration
committed
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
),
);
// timer
$data['accesslog']['timer'] = array(
'title' => t('Timer'),
'help' => t('Time in milliseconds that the page took to load.'),
'field' => array(
'handler' => 'views_handler_field_numeric',
'click sortable' => TRUE,
),
'filter' => array(
'handler' => 'views_handler_filter_numeric',
),
'sort' => array(
'handler' => 'views_handler_sort',
),
);
// timestamp
$data['accesslog']['timestamp'] = array(
'title' => t('Timestamp'),
'help' => t('Timestamp of when the page was visited.'),
'field' => array(
'handler' => 'views_handler_field_date',
'click sortable' => TRUE,
),
'sort' => array(
'handler' => 'views_handler_sort',
),
'filter' => array(
'handler' => 'views_handler_filter_date',
),
);
return $data;
}
/**
* @}
*/