Projet

Général

Profil

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

root / drupal7 / sites / all / modules / views / modules / statistics.views.inc @ 7547bb19

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
  // ----------------------------------------------------------------
17
  // node_counter table
18

    
19
  $data['node_counter']['table']['group']  = t('Content statistics');
20

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

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

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

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

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

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

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

    
80

    
81
  // ----------------------------------------------------------------
82
  // accesslog table
83

    
84
  $data['accesslog']['table']['group']  = t('Access log');
85

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

    
94
  // For other base tables, explain how we join
95
  $data['accesslog']['table']['join'] = array(
96
    'users' => array(
97
      'field' => 'uid',
98
      'left_field' => 'uid',
99
     ),
100
  );
101

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

    
123
  // session id
124
  $data['accesslog']['sid'] = array(
125
    'title' => t('Session ID'),
126
    'help' => t('Browser session ID of user that visited page.'),
127

    
128
    'field' => array(
129
      'handler' => 'views_handler_field',
130
      'click sortable' => TRUE,
131
     ),
132
     'filter' => array(
133
      'handler' => 'views_handler_filter_string',
134
     ),
135
     'argument' => array(
136
       'handler' => 'views_handler_argument_string',
137
     ),
138
     'sort' => array(
139
      'handler' => 'views_handler_sort',
140
     ),
141
  );
142

    
143
  // title
144
  $data['accesslog']['title'] = array(
145
    'title' => t('Page title'),
146
    'help' => t('Title of page visited.'),
147

    
148
    'field' => array(
149
      'handler' => 'views_handler_field_accesslog_path',
150
      'click sortable' => TRUE,
151
     ),
152
     'filter' => array(
153
      'handler' => 'views_handler_filter_string',
154
     ),
155
     'sort' => array(
156
      'handler' => 'views_handler_sort',
157
     ),
158
     'argument' => array(
159
      'handler' => 'views_handler_argument_string',
160
     ),
161
  );
162

    
163
  // path
164
  $data['accesslog']['path'] = array(
165
    'title' => t('Path'),
166
    'help' => t('Internal path to page visited (relative to Drupal root.)'),
167

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

    
183
  // referrer
184
  $data['accesslog']['url'] = array(
185
    'title' => t('Referrer'),
186
    'help' => t('Referrer URI.'),
187
    'field' => array(
188
      'handler' => 'views_handler_field_url',
189
      'click sortable' => TRUE,
190
     ),
191
    'filter' => array(
192
      'handler' => 'views_handler_filter_string',
193
    ),
194
    'sort' => array(
195
      'handler' => 'views_handler_sort',
196
    ),
197
  );
198

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

    
218
  // user
219
  $data['accesslog']['uid'] = array(
220
    'title' => t('User'),
221
    'help' => t('The user who visited the site.'),
222
    'relationship' => array(
223
      'handler' => 'views_handler_relationship',
224
      'base' => 'users',
225
      'base field' => 'uid',
226
     ),
227
  );
228

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

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

    
261

    
262
  return $data;
263
}