Projet

Général

Profil

Paste
Télécharger (14,2 ko) Statistiques
| Branche: | Révision:

root / drupal7 / sites / all / modules / votingapi / views / votingapi.views_default.inc @ 13755f8d

1
<?php
2

    
3
/**
4
 * @file
5
 * Provide default views data for votingapi.module.
6
 */
7

    
8
function votingapi_views_default_views() {
9
  $views = array();
10

    
11
  $view = new view;
12
  $view->name = 'top_content';
13
  $view->description = 'Top rated content';
14
  $view->tag = 'votingapi';
15
  $view->view_php = '';
16
  $view->base_table = 'node';
17
  $view->is_cacheable = FALSE;
18
  $view->api_version = 2;
19
  $view->disabled = TRUE; /* Edit this to true to make a default view disabled initially */
20
  $handler = $view->new_display('default', 'Defaults', 'default');
21
  $handler->override_option('fields', array(
22
    'name' => array(
23
      'label' => 'Author',
24
      'link_to_user' => 1,
25
      'exclude' => 0,
26
      'id' => 'name',
27
      'table' => 'users',
28
      'field' => 'name',
29
      'relationship' => 'none',
30
    ),
31
    'title' => array(
32
      'label' => 'Title',
33
      'link_to_node' => 1,
34
      'exclude' => 0,
35
      'id' => 'title',
36
      'table' => 'node',
37
      'field' => 'title',
38
      'relationship' => 'none',
39
    ),
40
    'created' => array(
41
      'label' => 'Posted',
42
      'date_format' => 'time ago',
43
      'custom_date_format' => '1',
44
      'exclude' => 0,
45
      'id' => 'created',
46
      'table' => 'node',
47
      'field' => 'created',
48
      'relationship' => 'none',
49
    ),
50
  ));
51
  $handler->override_option('filters', array(
52
    'status' => array(
53
      'operator' => '=',
54
      'value' => 1,
55
      'group' => '0',
56
      'exposed' => FALSE,
57
      'expose' => array(
58
        'operator' => FALSE,
59
        'label' => '',
60
      ),
61
      'id' => 'status',
62
      'table' => 'node',
63
      'field' => 'status',
64
      'relationship' => 'none',
65
    ),
66
  ));
67
  $handler->override_option('access', array(
68
    'type' => 'none',
69
  ));
70
  $handler->override_option('title', 'Top rated content');
71
  $handler->override_option('use_pager', '1');
72
  $handler->override_option('style_plugin', 'table');
73
  $handler->override_option('style_options', array(
74
    'grouping' => '',
75
    'override' => 1,
76
    'sticky' => 1,
77
    'order' => 'desc',
78
    'columns' => array(
79
      'name' => 'name',
80
      'title' => 'title',
81
      'created' => 'created',
82
    ),
83
    'info' => array(
84
      'name' => array(
85
        'sortable' => 1,
86
        'separator' => '',
87
      ),
88
      'title' => array(
89
        'sortable' => 1,
90
        'separator' => '',
91
      ),
92
      'created' => array(
93
        'sortable' => 1,
94
        'separator' => '',
95
      ),
96
    ),
97
    'default' => 'title',
98
  ));
99
  $handler = $view->new_display('page', 'Fivestar', 'page_1');
100
  $handler->override_option('relationships', array(
101
    'votingapi_cache' => array(
102
      'label' => 'Voting results',
103
      'required' => 0,
104
      'votingapi' => array(
105
        'value_type' => 'percent',
106
        'tag' => 'vote',
107
        'function' => 'average',
108
      ),
109
      'id' => 'votingapi_cache',
110
      'table' => 'node',
111
      'field' => 'votingapi_cache',
112
      'override' => array(
113
        'button' => 'Use default',
114
      ),
115
      'relationship' => 'none',
116
    ),
117
  ));
118
  $handler->override_option('fields', array(
119
    'name' => array(
120
      'label' => 'Author',
121
      'link_to_user' => 1,
122
      'exclude' => 0,
123
      'id' => 'name',
124
      'table' => 'users',
125
      'field' => 'name',
126
      'relationship' => 'none',
127
    ),
128
    'title' => array(
129
      'label' => 'Title',
130
      'link_to_node' => 1,
131
      'exclude' => 0,
132
      'id' => 'title',
133
      'table' => 'node',
134
      'field' => 'title',
135
      'relationship' => 'none',
136
    ),
137
    'created' => array(
138
      'label' => 'Posted',
139
      'date_format' => 'time ago',
140
      'custom_date_format' => '1',
141
      'exclude' => 0,
142
      'id' => 'created',
143
      'table' => 'node',
144
      'field' => 'created',
145
      'relationship' => 'none',
146
    ),
147
    'value' => array(
148
      'label' => 'Rating',
149
      'set_precision' => FALSE,
150
      'precision' => 0,
151
      'decimal' => '.',
152
      'separator' => ',',
153
      'prefix' => '',
154
      'suffix' => '',
155
      'appearance' => 'fivestar_views_value_display_handler',
156
      'exclude' => 0,
157
      'id' => 'value',
158
      'table' => 'votingapi_cache',
159
      'field' => 'value',
160
      'override' => array(
161
        'button' => 'Use default',
162
      ),
163
      'relationship' => 'votingapi_cache',
164
    ),
165
  ));
166
  $handler->override_option('sorts', array(
167
    'value' => array(
168
      'order' => 'DESC',
169
      'id' => 'value',
170
      'table' => 'votingapi_cache',
171
      'field' => 'value',
172
      'relationship' => 'votingapi_cache',
173
      'override' => array(
174
        'button' => 'Use default',
175
      ),
176
    ),
177
  ));
178
  $handler->override_option('header', 'This page is a demonstration of VotingAPI\'s integration with the Views module. It\'s set up to display nodes sorted by percentage ratings, the style used by Fivestar module.');
179
  $handler->override_option('header_format', '1');
180
  $handler->override_option('header_empty', 0);
181
  $handler->override_option('style_options', array(
182
    'grouping' => '',
183
    'override' => 1,
184
    'sticky' => 1,
185
    'order' => 'desc',
186
    'columns' => array(
187
      'name' => 'name',
188
      'title' => 'title',
189
      'created' => 'created',
190
      'value' => 'value',
191
    ),
192
    'info' => array(
193
      'name' => array(
194
        'sortable' => 1,
195
        'separator' => '',
196
      ),
197
      'title' => array(
198
        'sortable' => 1,
199
        'separator' => '',
200
      ),
201
      'created' => array(
202
        'sortable' => 1,
203
        'separator' => '',
204
      ),
205
      'value' => array(
206
        'sortable' => 1,
207
        'separator' => '',
208
      ),
209
    ),
210
    'default' => 'value',
211
  ));
212
  $handler->override_option('path', 'top-rated-percent');
213
  $handler->override_option('menu', array(
214
    'type' => 'normal',
215
    'title' => 'Top content (Fivestar)',
216
    'weight' => '0',
217
    'name' => 'navigation',
218
  ));
219
  $handler->override_option('tab_options', array(
220
    'type' => 'none',
221
    'title' => '',
222
    'weight' => 0,
223
  ));
224
  $handler = $view->new_display('page', 'Plus1', 'page_2');
225
  $handler->override_option('relationships', array(
226
    'votingapi_cache' => array(
227
      'label' => 'Voting results',
228
      'required' => 0,
229
      'votingapi' => array(
230
        'value_type' => 'points',
231
        'tag' => 'vote',
232
        'function' => 'sum',
233
      ),
234
      'id' => 'votingapi_cache',
235
      'table' => 'node',
236
      'field' => 'votingapi_cache',
237
      'override' => array(
238
        'button' => 'Use default',
239
      ),
240
      'relationship' => 'none',
241
    ),
242
  ));
243
  $handler->override_option('fields', array(
244
    'name' => array(
245
      'label' => 'Author',
246
      'link_to_user' => 1,
247
      'exclude' => 0,
248
      'id' => 'name',
249
      'table' => 'users',
250
      'field' => 'name',
251
      'relationship' => 'none',
252
    ),
253
    'title' => array(
254
      'label' => 'Title',
255
      'link_to_node' => 1,
256
      'exclude' => 0,
257
      'id' => 'title',
258
      'table' => 'node',
259
      'field' => 'title',
260
      'relationship' => 'none',
261
    ),
262
    'created' => array(
263
      'label' => 'Posted',
264
      'date_format' => 'time ago',
265
      'custom_date_format' => '1',
266
      'exclude' => 0,
267
      'id' => 'created',
268
      'table' => 'node',
269
      'field' => 'created',
270
      'relationship' => 'none',
271
    ),
272
    'value' => array(
273
      'label' => 'Rating',
274
      'set_precision' => FALSE,
275
      'precision' => 0,
276
      'decimal' => '.',
277
      'separator' => ',',
278
      'prefix' => '',
279
      'suffix' => ' points',
280
      'appearance' => '',
281
      'exclude' => 0,
282
      'id' => 'value',
283
      'table' => 'votingapi_cache',
284
      'field' => 'value',
285
      'override' => array(
286
        'button' => 'Use default',
287
      ),
288
      'relationship' => 'votingapi_cache',
289
    ),
290
  ));
291
  $handler->override_option('sorts', array(
292
    'value' => array(
293
      'order' => 'DESC',
294
      'id' => 'value',
295
      'table' => 'votingapi_cache',
296
      'field' => 'value',
297
      'override' => array(
298
        'button' => 'Use default',
299
      ),
300
      'relationship' => 'votingapi_cache',
301
    ),
302
  ));
303
  $handler->override_option('header', 'This page is a demonstration of VotingAPI\'s integration with the Views module. It\'s set up to display nodes sorted by point ratings, the style used by the Plus1 and VoteUpDown modules.');
304
  $handler->override_option('header_format', '1');
305
  $handler->override_option('header_empty', 0);
306
  $handler->override_option('style_options', array(
307
    'grouping' => '',
308
    'override' => 1,
309
    'sticky' => 1,
310
    'order' => 'desc',
311
    'columns' => array(
312
      'name' => 'name',
313
      'title' => 'title',
314
      'created' => 'created',
315
      'value' => 'value',
316
    ),
317
    'info' => array(
318
      'name' => array(
319
        'sortable' => 1,
320
        'separator' => '',
321
      ),
322
      'title' => array(
323
        'sortable' => 1,
324
        'separator' => '',
325
      ),
326
      'created' => array(
327
        'sortable' => 1,
328
        'separator' => '',
329
      ),
330
      'value' => array(
331
        'sortable' => 1,
332
        'separator' => '',
333
      ),
334
    ),
335
    'default' => 'value',
336
  ));
337
  $handler->override_option('path', 'top-rated-points');
338
  $handler->override_option('menu', array(
339
    'type' => 'normal',
340
    'title' => 'Top content (Plus1)',
341
    'weight' => '0',
342
    'name' => 'navigation',
343
  ));
344
  $handler->override_option('tab_options', array(
345
    'type' => 'none',
346
    'title' => '',
347
    'weight' => 0,
348
  ));
349
  $handler = $view->new_display('page', 'Current user', 'page_3');
350
  $handler->override_option('relationships', array(
351
    'votingapi_vote' => array(
352
      'label' => 'Individual votes',
353
      'required' => 1,
354
      'votingapi' => array(
355
        'value_type' => '',
356
        'tag' => '',
357
      ),
358
      'current_user' => 0,
359
      'id' => 'votingapi_vote',
360
      'table' => 'node',
361
      'field' => 'votingapi_vote',
362
      'override' => array(
363
        'button' => 'Use default',
364
      ),
365
      'relationship' => 'none',
366
    ),
367
  ));
368
  $handler->override_option('fields', array(
369
    'title' => array(
370
      'label' => 'Title',
371
      'link_to_node' => 1,
372
      'exclude' => 0,
373
      'id' => 'title',
374
      'table' => 'node',
375
      'field' => 'title',
376
      'relationship' => 'none',
377
    ),
378
    'value_type' => array(
379
      'label' => 'Vote type',
380
      'exclude' => 0,
381
      'id' => 'value_type',
382
      'table' => 'votingapi_vote',
383
      'field' => 'value_type',
384
      'override' => array(
385
        'button' => 'Override',
386
      ),
387
      'relationship' => 'votingapi_vote',
388
    ),
389
    'value' => array(
390
      'label' => 'Value',
391
      'set_precision' => FALSE,
392
      'precision' => 0,
393
      'decimal' => '.',
394
      'separator' => ',',
395
      'prefix' => '',
396
      'suffix' => '',
397
      'appearance' => '',
398
      'exclude' => 0,
399
      'id' => 'value',
400
      'table' => 'votingapi_vote',
401
      'field' => 'value',
402
      'override' => array(
403
        'button' => 'Override',
404
      ),
405
      'relationship' => 'votingapi_vote',
406
    ),
407
    'timestamp' => array(
408
      'label' => 'Timestamp',
409
      'date_format' => 'time ago',
410
      'custom_date_format' => '1',
411
      'exclude' => 0,
412
      'id' => 'timestamp',
413
      'table' => 'votingapi_vote',
414
      'field' => 'timestamp',
415
      'override' => array(
416
        'button' => 'Use default',
417
      ),
418
      'relationship' => 'votingapi_vote',
419
    ),
420
  ));
421
  $handler->override_option('sorts', array(
422
    'timestamp' => array(
423
      'order' => 'DESC',
424
      'id' => 'timestamp',
425
      'table' => 'votingapi_vote',
426
      'field' => 'timestamp',
427
      'override' => array(
428
        'button' => 'Use default',
429
      ),
430
      'relationship' => 'votingapi_vote',
431
    ),
432
  ));
433
  $handler->override_option('arguments', array(
434
    'uid' => array(
435
      'default_action' => 'default',
436
      'style_plugin' => 'default_summary',
437
      'style_options' => array(),
438
      'wildcard' => 'all',
439
      'wildcard_substitution' => 'Everyone',
440
      'title' => '%1\'s votes',
441
      'default_argument_type' => 'current_user',
442
      'default_argument' => '',
443
      'validate_type' => 'none',
444
      'validate_fail' => 'not found',
445
      'break_phrase' => 0,
446
      'not' => 0,
447
      'id' => 'uid',
448
      'table' => 'votingapi_vote',
449
      'field' => 'uid',
450
      'relationship' => 'votingapi_vote',
451
      'override' => array(
452
        'button' => 'Use default',
453
      ),
454
      'default_options_div_prefix' => '',
455
      'default_argument_user' => 0,
456
      'default_argument_fixed' => '',
457
      'default_argument_php' => '',
458
      'validate_argument_node_type' => array(
459
        'page' => 0,
460
        'story' => 0,
461
      ),
462
      'validate_argument_node_access' => 0,
463
      'validate_argument_nid_type' => 'nid',
464
      'validate_argument_vocabulary' => array(),
465
      'validate_argument_type' => 'tid',
466
      'validate_argument_php' => '',
467
    ),
468
  ));
469
  $handler->override_option('filters', array(
470
    'status' => array(
471
      'operator' => '=',
472
      'value' => 1,
473
      'group' => '0',
474
      'exposed' => FALSE,
475
      'expose' => array(
476
        'operator' => FALSE,
477
        'label' => '',
478
      ),
479
      'id' => 'status',
480
      'table' => 'node',
481
      'field' => 'status',
482
      'relationship' => 'none',
483
    ),
484
    'value' => array(
485
      'operator' => 'not empty',
486
      'value' => array(
487
        'value' => '',
488
        'min' => '',
489
        'max' => '',
490
      ),
491
      'group' => '0',
492
      'exposed' => FALSE,
493
      'expose' => array(
494
        'operator' => FALSE,
495
        'label' => '',
496
      ),
497
      'id' => 'value',
498
      'table' => 'votingapi_vote',
499
      'field' => 'value',
500
      'override' => array(
501
        'button' => 'Use default',
502
      ),
503
      'relationship' => 'votingapi_vote',
504
    ),
505
  ));
506
  $handler->override_option('title', 'Your votes');
507
  $handler->override_option('style_options', array(
508
    'grouping' => '',
509
    'override' => 1,
510
    'sticky' => 1,
511
    'order' => 'desc',
512
    'columns' => array(
513
      'title' => 'title',
514
      'value_type' => 'value_type',
515
      'value' => 'value',
516
      'timestamp' => 'timestamp',
517
    ),
518
    'info' => array(
519
      'title' => array(
520
        'sortable' => 1,
521
        'separator' => '',
522
      ),
523
      'value_type' => array(
524
        'sortable' => 1,
525
        'separator' => '',
526
      ),
527
      'value' => array(
528
        'sortable' => 1,
529
        'separator' => '',
530
      ),
531
      'timestamp' => array(
532
        'sortable' => 1,
533
        'separator' => '',
534
      ),
535
    ),
536
    'default' => 'timestamp',
537
  ));
538
  $handler->override_option('path', 'your-votes');
539
  $handler->override_option('menu', array(
540
    'type' => 'normal',
541
    'title' => 'Your votes',
542
    'weight' => '0',
543
    'name' => 'navigation',
544
  ));
545
  $handler->override_option('tab_options', array(
546
    'type' => 'none',
547
    'title' => '',
548
    'weight' => 0,
549
  ));
550

    
551

    
552
  $views[$view->name] = $view;
553
  return $views;
554
}