Projet

Général

Profil

Paste
Télécharger (6,4 ko) Statistiques
| Branche: | Révision:

root / drupal7 / sites / all / modules / views / modules / statistics.views.inc @ 5d12d676

1
<?php
2

    
3
/**
4
 * @file
5
 * Provide views data and handlers for statistics.module.
6
 *
7
 * @ingroup views_module_handlers
8
 */
9

    
10
/**
11
 * Implements hook_views_data().
12
 */
13
function statistics_views_data() {
14
  // Basic table information.
15
  // ----------------------------------------------------------------
16
  // 'node_counter' table.
17
  $data['node_counter']['table']['group']  = t('Content statistics');
18

    
19
  // Joins to the node table.
20
  $data['node_counter']['table']['join'] = array(
21
    'node' => array(
22
      'left_field' => 'nid',
23
      'field' => 'nid',
24
    ),
25
  );
26

    
27
  // Total count.
28
  $data['node_counter']['totalcount'] = array(
29
    'title' => t('Total views'),
30
    'help' => t('The total number of times the node has been viewed.'),
31

    
32
    'field' => array(
33
      'handler' => 'views_handler_field_statistics_numeric',
34
      'click sortable' => TRUE,
35
    ),
36
    'filter' => array(
37
      'handler' => 'views_handler_filter_numeric',
38
    ),
39
    'sort' => array(
40
      'handler' => 'views_handler_sort',
41
    ),
42
  );
43

    
44
  // Day count.
45
  $data['node_counter']['daycount'] = array(
46
    'title' => t('Views today'),
47
    'help' => t('The total number of times the node has been viewed today.'),
48

    
49
    'field' => array(
50
      'handler' => 'views_handler_field_statistics_numeric',
51
      'click sortable' => TRUE,
52
    ),
53
    'filter' => array(
54
      'handler' => 'views_handler_filter_numeric',
55
    ),
56
    'sort' => array(
57
      'handler' => 'views_handler_sort',
58
    ),
59
  );
60

    
61
  // Timestamp.
62
  $data['node_counter']['timestamp'] = array(
63
    'title' => t('Most recent view'),
64
    'help' => t('The most recent time the node has been viewed.'),
65

    
66
    'field' => array(
67
      'handler' => 'views_handler_field_node_counter_timestamp',
68
      'click sortable' => TRUE,
69
    ),
70
    'filter' => array(
71
      'handler' => 'views_handler_filter_date',
72
    ),
73
    'sort' => array(
74
      'handler' => 'views_handler_sort',
75
    ),
76
  );
77

    
78
  // ----------------------------------------------------------------
79
  // 'accesslog' table.
80
  $data['accesslog']['table']['group']  = t('Access log');
81

    
82
  // Advertise this table as a possible base table.
83
  $data['accesslog']['table']['base'] = array(
84
    'field' => 'aid',
85
    'title' => t('Access log'),
86
    'help' => t('Stores site access information.'),
87
    'weight' => 10,
88
  );
89

    
90
  // For other base tables, explain how we join.
91
  $data['accesslog']['table']['join'] = array(
92
    'users' => array(
93
      'field' => 'uid',
94
      'left_field' => 'uid',
95
    ),
96
  );
97

    
98
  // Access event ID / 'aid'.
99
  $data['accesslog']['aid'] = array(
100
    'title' => t('Aid'),
101
    'help' => t('Unique access event ID.'),
102
    'field' => array(
103
      'handler' => 'views_handler_field_numeric',
104
      'click sortable' => TRUE,
105
    ),
106
    'argument' => array(
107
      'handler' => 'views_handler_argument_numeric',
108
      'name field' => 'wid',
109
      'numeric' => TRUE,
110
    ),
111
    'filter' => array(
112
      'handler' => 'views_handler_filter_numeric',
113
    ),
114
    'sort' => array(
115
      'handler' => 'views_handler_sort',
116
    ),
117
  );
118

    
119
  // Session ID.
120
  $data['accesslog']['sid'] = array(
121
    'title' => t('Session ID'),
122
    'help' => t('Browser session ID of user that visited page.'),
123

    
124
    'field' => array(
125
      'handler' => 'views_handler_field',
126
      'click sortable' => TRUE,
127
    ),
128
    'filter' => array(
129
      'handler' => 'views_handler_filter_string',
130
    ),
131
    'argument' => array(
132
      'handler' => 'views_handler_argument_string',
133
    ),
134
    'sort' => array(
135
      'handler' => 'views_handler_sort',
136
    ),
137
  );
138

    
139
  // Title.
140
  $data['accesslog']['title'] = array(
141
    'title' => t('Page title'),
142
    'help' => t('Title of page visited.'),
143

    
144
    'field' => array(
145
      'handler' => 'views_handler_field_accesslog_path',
146
      'click sortable' => TRUE,
147
    ),
148
    'filter' => array(
149
      'handler' => 'views_handler_filter_string',
150
    ),
151
    'sort' => array(
152
      'handler' => 'views_handler_sort',
153
    ),
154
    'argument' => array(
155
      'handler' => 'views_handler_argument_string',
156
    ),
157
  );
158

    
159
  // Path.
160
  $data['accesslog']['path'] = array(
161
    'title' => t('Path'),
162
    'help' => t('Internal path to page visited (relative to Drupal root.)'),
163

    
164
    'field' => array(
165
      'handler' => 'views_handler_field_accesslog_path',
166
      'click sortable' => TRUE,
167
    ),
168
    'filter' => array(
169
      'handler' => 'views_handler_filter_string',
170
    ),
171
    'sort' => array(
172
      'handler' => 'views_handler_sort',
173
    ),
174
     // No argument here. Can't send forward slashes as arguments. Can be
175
     // worked around by node ID. (but what about aliases?)
176
  );
177

    
178
  // Referrer.
179
  $data['accesslog']['url'] = array(
180
    'title' => t('Referrer'),
181
    'help' => t('Referrer URI.'),
182
    'field' => array(
183
      'handler' => 'views_handler_field_url',
184
      'click sortable' => TRUE,
185
    ),
186
    'filter' => array(
187
      'handler' => 'views_handler_filter_string',
188
    ),
189
    'sort' => array(
190
      'handler' => 'views_handler_sort',
191
    ),
192
  );
193

    
194
  // Hostname.
195
  $data['accesslog']['hostname'] = array(
196
    'title' => t('Hostname'),
197
    'help' => t('Hostname of user that visited the page.'),
198
    'field' => array(
199
      'handler' => 'views_handler_field',
200
      'click sortable' => TRUE,
201
    ),
202
    'filter' => array(
203
      'handler' => 'views_handler_filter_string',
204
    ),
205
    'sort' => array(
206
      'handler' => 'views_handler_sort',
207
    ),
208
    'argument' => array(
209
      'handler' => 'views_handler_argument_string',
210
    ),
211
  );
212

    
213
  // User ID / 'uid'.
214
  $data['accesslog']['uid'] = array(
215
    'title' => t('User'),
216
    'help' => t('The user who visited the site.'),
217
    'relationship' => array(
218
      'handler' => 'views_handler_relationship',
219
      'base' => 'users',
220
      'base field' => 'uid',
221
    ),
222
  );
223

    
224
  // Timer.
225
  $data['accesslog']['timer'] = array(
226
    'title' => t('Timer'),
227
    'help' => t('Time in milliseconds that the page took to load.'),
228
    'field' => array(
229
      'handler' => 'views_handler_field_numeric',
230
      'click sortable' => TRUE,
231
    ),
232
    'filter' => array(
233
      'handler' => 'views_handler_filter_numeric',
234
    ),
235
    'sort' => array(
236
      'handler' => 'views_handler_sort',
237
    ),
238
  );
239

    
240
  // Timestamp.
241
  $data['accesslog']['timestamp'] = array(
242
    'title' => t('Timestamp'),
243
    'help' => t('Timestamp of when the page was visited.'),
244
    'field' => array(
245
      'handler' => 'views_handler_field_date',
246
      'click sortable' => TRUE,
247
    ),
248
    'sort' => array(
249
      'handler' => 'views_handler_sort',
250
    ),
251
    'filter' => array(
252
      'handler' => 'views_handler_filter_date',
253
    ),
254
  );
255

    
256
  return $data;
257
}