#153714 by Magnus: Imported translation to localization server and removed CVS file.
[project/views.git] / modules / statistics.views.inc
CommitLineData
d4403eb0
EM
1<?php
2// $Id$
3/**
4 * @file
5 * Provide views data and handlers for statistics.module
6 */
7
8/**
9 * @defgroup views_statistics_module statistics.module handlers
10 *
11 * Includes the ability to create views of just the statistics table.
12 * @{
13 */
14
15/**
16 * Implementation of hook_views_data()
17 */
18function statistics_views_data() {
19 // Basic table information.
20
d2f30c81
EM
21 // ----------------------------------------------------------------
22 // node_counter table
23
d4403eb0
EM
24 $data['node_counter']['table']['group'] = t('Node statistics');
25
d4403eb0 26 $data['node_counter']['table']['join'] = array(
d2f30c81 27 // ...to the node table
d4403eb0 28 'node' => array(
d2f30c81
EM
29 'left_field' => 'nid',
30 'field' => 'nid',
31 ),
d4403eb0
EM
32 );
33
d4403eb0
EM
34 // totalcount
35 $data['node_counter']['totalcount'] = array(
d2f30c81
EM
36 'title' => t('Total views'),
37 'help' => t('The total number of times the node has been viewed.'),
38
d4403eb0 39 'field' => array(
5edc68d5 40 'handler' => 'views_handler_field_numeric',
d4403eb0
EM
41 'click sortable' => TRUE,
42 ),
43 'filter' => array(
d2f30c81 44 'handler' => 'views_handler_filter_numeric',
d4403eb0
EM
45 ),
46 'sort' => array(
47 'handler' => 'views_handler_sort',
48 ),
49 );
50
51 // daycount
52 $data['node_counter']['daycount'] = array(
d2f30c81
EM
53 'title' => t('Views today'),
54 'help' => t('The total number of times the node has been viewed today.'),
55
d4403eb0 56 'field' => array(
5edc68d5 57 'handler' => 'views_handler_field_numeric',
d4403eb0
EM
58 'click sortable' => TRUE,
59 ),
60 'filter' => array(
d2f30c81 61 'handler' => 'views_handler_filter_numeric',
d4403eb0
EM
62 ),
63 'sort' => array(
64 'handler' => 'views_handler_sort',
65 ),
66 );
67
68 // timestamp
69 $data['node_counter']['timestamp'] = array(
d2f30c81
EM
70 'title' => t('Most recent view'),
71 'help' => t('The most recent time the node has been viewed.'),
72
d4403eb0
EM
73 'field' => array(
74 'handler' => 'views_handler_field_date',
75 'click sortable' => TRUE,
76 ),
e905a151
EM
77 'filter' => array(
78 'handler' => 'views_handler_filter_date',
79 ),
d4403eb0
EM
80 'sort' => array(
81 'handler' => 'views_handler_sort',
82 ),
83 );
84
85
d2f30c81
EM
86 // ----------------------------------------------------------------
87 // accesslog table
88
d4403eb0
EM
89 $data['accesslog']['table']['group'] = t('Access log');
90
91 // Advertise this table as a possible base table
92 $data['accesslog']['table']['base'] = array(
93 'field' => 'aid',
94 'title' => t('Access log'),
95 'help' => t('Stores site access information.'),
96 'weight' => 10,
97 );
98
99 // For other base tables, explain how we join
100 $data['accesslog']['table']['join'] = array(
101 'users' => array(
d2f30c81
EM
102 'field' => 'uid',
103 'left_field' => 'uid',
d4403eb0
EM
104 ),
105 );
d4403eb0
EM
106
107 // session id
108 $data['accesslog']['sid'] = array(
d2f30c81
EM
109 'title' => t('Session ID'),
110 'help' => t('Browser session ID of user that visited page.'),
111
d4403eb0
EM
112 'field' => array(
113 'handler' => 'views_handler_field',
114 'click sortable' => TRUE,
115 ),
d2f30c81
EM
116 'filter' => array(
117 'handler' => 'views_handler_filter_string',
118 ),
119 'argument' => array(
120 'handler' => 'views_handler_argument_string',
121 ),
122 'sort' => array(
123 'handler' => 'views_handler_sort',
124 ),
d4403eb0
EM
125 );
126
127 // title
128 $data['accesslog']['title'] = array(
d2f30c81
EM
129 'title' => t('Page title'),
130 'help' => t('Title of page visited.'),
131
d4403eb0
EM
132 'field' => array(
133 'handler' => 'views_handler_field_accesslog_path',
134 'click sortable' => TRUE,
135 ),
d2f30c81
EM
136 'filter' => array(
137 'handler' => 'views_handler_filter_string',
138 ),
139 'sort' => array(
140 'handler' => 'views_handler_sort',
141 ),
142 'argument' => array(
143 'handler' => 'views_handler_argument_string',
144 ),
d4403eb0
EM
145 );
146
147 // path
148 $data['accesslog']['path'] = array(
d2f30c81
EM
149 'title' => t('Path'),
150 'help' => t('Internal path to page visited (relative to Drupal root.)'),
151
d4403eb0
EM
152 'field' => array(
153 'handler' => 'views_handler_field_accesslog_path',
154 'click sortable' => TRUE,
155 ),
d2f30c81
EM
156 'filter' => array(
157 'handler' => 'views_handler_filter_string',
158 ),
159 'sort' => array(
160 'handler' => 'views_handler_sort',
161 ),
162 //No argument here. Can't send forward slashes as arguments.
163 //Can be worked around by node ID.
164 //(but what about aliases?)
d4403eb0
EM
165 );
166
167 // referrer
168 $data['accesslog']['url'] = array(
d2f30c81
EM
169 'title' => t('Referrer'),
170 'help' => t('Referrer URI.'),
d4403eb0
EM
171 'field' => array(
172 'handler' => 'views_handler_field_url',
173 'click sortable' => TRUE,
174 ),
d2f30c81
EM
175 'filter' => array(
176 'handler' => 'views_handler_filter_string',
177 ),
178 'sort' => array(
179 'handler' => 'views_handler_sort',
180 ),
d4403eb0
EM
181 );
182
183 // hostname
184 $data['accesslog']['hostname'] = array(
d2f30c81
EM
185 'title' => t('Hostname'),
186 'help' => t('Hostname of user that visited the page.'),
d4403eb0
EM
187 'field' => array(
188 'handler' => 'views_handler_field',
189 'click sortable' => TRUE,
190 ),
d2f30c81
EM
191 'filter' => array(
192 'handler' => 'views_handler_filter_string',
193 ),
194 'sort' => array(
195 'handler' => 'views_handler_sort',
196 ),
197 'argument' => array(
198 'handler' => 'views_handler_argument_string',
199 ),
d4403eb0
EM
200 );
201
d2f30c81 202 // user
d4403eb0 203 $data['accesslog']['uid'] = array(
d2f30c81
EM
204 'title' => t('User'),
205 'help' => t('The user who visited the site.'),
206 'relationship' => array(
207 'handler' => 'views_handler_relationship',
208 'base' => 'users',
209 'field' => 'uid',
d4403eb0
EM
210 ),
211 );
212
213 // timer
214 $data['accesslog']['timer'] = array(
d2f30c81
EM
215 'title' => t('Timer'),
216 'help' => t('Time in milliseconds that the page took to load.'),
d4403eb0 217 'field' => array(
5edc68d5 218 'handler' => 'views_handler_field_numeric',
d4403eb0
EM
219 'click sortable' => TRUE,
220 ),
221 'filter' => array(
d2f30c81 222 'handler' => 'views_handler_filter_numeric',
d4403eb0
EM
223 ),
224 'sort' => array(
225 'handler' => 'views_handler_sort',
226 ),
227 );
228
229 // timestamp
230 $data['accesslog']['timestamp'] = array(
d2f30c81
EM
231 'title' => t('Timestamp'),
232 'help' => t('Timestamp of when the page was visited.'),
d4403eb0
EM
233 'field' => array(
234 'handler' => 'views_handler_field_date',
235 'click sortable' => TRUE,
236 ),
237 'sort' => array(
238 'handler' => 'views_handler_sort',
239 ),
d2f30c81
EM
240 'filter' => array(
241 'handler' => 'views_handler_filter_date',
242 ),
d4403eb0
EM
243 );
244
245
246 return $data;
247}
248
249/**
fe44beb7
EM
250 * Implementation of hook_views_handlers() to register all of the basic handlers
251 * views uses.
d4403eb0 252 */
fe44beb7
EM
253function statistics_views_handlers() {
254 return array(
255 'info' => array(
256 'path' => drupal_get_path('module', 'views') . '/modules/statistics',
257 ),
258 'handlers' => array(
259 'views_handler_field_accesslog_path' => array(
260 'parent' => 'views_handler_field',
261 ),
262 ),
263 );
d4403eb0
EM
264}
265
5ad6fb04
EM
266/**
267 * @}
268 */