~spreadubuntu/spreadubuntu/devel-drupal6

« back to all changes in this revision

Viewing changes to sites/all/modules/votingapi/views/votingapi.views_default.inc

  • Committer: ruben
  • Date: 2009-06-08 09:38:49 UTC
  • Revision ID: ruben@captive-20090608093849-s1qtsyctv2vwp1x1
SpreadUbuntu moving to Drupal6. Based on ubuntu-drupal theme and adding our modules

Show diffs side-by-side

added added

removed removed

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