Project

General

Profile

Paste
Download (44.3 KB) Statistics
| Branch: | Revision:

root / drupal7 / sites / all / modules / calendar / includes / calendar.views_template.inc @ 62e0cc08

1
<?php
2

    
3
/**
4
 * @file
5
 * View templates for the Calendar module.
6
 *
7
 * Create calendar templates for every date field in the system.
8
 */
9

    
10
/**
11
 * Implements hook_views_templates().
12
 *
13
*/
14
function calendar_views_templates() {
15

    
16
  $views = array();
17

    
18
  if (!variable_get('calendar_provide_views_templates', 1)) {
19
    return $views;
20
  }
21

    
22
  // Map the base tables to entity types.
23
  $entity_info = entity_get_info();
24
  $base_tables = date_views_base_tables();
25

    
26
  $with_ical = module_exists('date_ical');
27

    
28
  // Find all the date fields we know about.
29

    
30
  $processed = array();
31

    
32
  foreach ($entity_info as $entity_type => $info) {
33
    if (!$info['fieldable']) {
34
      continue;
35
    }
36
    $items = field_info_instances($entity_type);
37
    $views_fields = date_views_fields($info['base table']);
38
    $with_colorbox = $entity_type == 'node' && module_exists('colorbox') && variable_get('calendar_add_colorbox', 0);
39

    
40
    foreach ($views_fields['name'] as $name => $data) {
41

    
42
      // For each of the Field date fields, we need to find the bundle and entities this field is used on.
43
      if ($data['is_field']) {
44
        foreach ($items as $bundle => $widgets) {
45
          foreach ($widgets as $field_name => $widget) {
46
            $field = field_info_field($field_name);
47

    
48
            // See if this is a date field. Since fields might be shared
49
            // across bundles, make sure we haven't already processed this field.
50
            // $alias = 'field_data_' . $field_name . '.' . $field_name . '_value';
51
            // $alias will not work because $alias can be from multiple base_tables
52
            // and we would not want to exclude a field from other base tables because
53
            // it was used in one.
54

    
55
            // Limiting the fields to date fields will make this loop more efficient
56
            if ($field['module'] == 'date') {
57
              $base_table = $info['base table'];
58
              $calendar_option = array(
59
                'name' => 'calendar_' . $base_table . '_' . $field_name,
60
                'description' => t("A calendar view of the '@field_name' field in the '@base_table' base table.", array('@base_table' => $base_table, '@field_name' => $field_name)),
61
                'path' => str_replace('_', '-', 'calendar-' . $base_table . '-' . $field_name),
62
                'base_table' => $base_table,
63
                'field_name' => $field_name,
64
                'with_colorbox' => $with_colorbox,
65
                'with_ical' => $with_ical,
66
              );
67
              $view = calendar_views_template_construct($calendar_option);
68
              $views[$view->name] = $view;
69
            }
70
          }
71
        }
72
      }
73

    
74
      // For other date fields, we infer the entity type from the base table.
75
      else {
76
        $parts = explode('.', $name);
77
        $base_table = $parts[0];
78
        $field_name = $parts[1];
79
        $calendar_option = array(
80
          'name' => 'calendar_' . $entity_type . '_' . $field_name,
81
          'description' => t("A calendar view of the '@field_name' field in the '@base_table' base table.", array('@base_table' => $base_table, '@field_name' => $field_name)),
82
          'path' => 'calendar-' . str_replace('_', '-', $field_name),
83
          'base_table' => $base_table,
84
          'field_name' => $field_name,
85
          'with_colorbox' => $with_colorbox,
86
          'with_ical' => $with_ical,
87
        );
88
        $view = calendar_views_template_construct($calendar_option);
89
        $views[$view->name] = $view;
90
      }
91
    }
92
  }
93
 return $views;
94
}
95

    
96
/**
97
 * Helper function to construct a calendar template from an array of values.
98
 *
99
 * @param $options:
100
 *   An array of options to create calendar templates.
101
 *
102
 * Possible options include:
103
 * @param string $base_table:
104
 *   The base table for the view.
105
 * @param string $name:
106
 *   The view name.
107
 * @param string $description:
108
 *   The view description.
109
 * @param string $path:
110
 *   The view url, if empty, defaults to 'calendar'.
111
 * @param string  $bundle:
112
 *   The bundle for this calendar.
113
 * @param string  $field_name:
114
 *   Date field used to filter the calendar.
115
 *
116
 * @return the default template array.
117
 */
118
function calendar_views_template_construct($options = NULL) {
119

    
120
$name        = $options['name'];
121
$description = $options['description'];
122
$path        = $options['path'];
123
$base_table  = $options['base_table'];
124
$field_name  = $options['field_name'];
125
$with_colorbox = !empty($options['with_colorbox']);
126
$with_ical   = !empty($options['with_ical']);
127

    
128
$colors      = array();
129
$field_info = field_info_field($field_name);
130

    
131
if (!empty($field_info)) {
132
  $table = 'field_data_' . $field_name;
133
  $alias = $table . '.' . $field_name . '_value';
134
  $is_field = TRUE;
135
}
136
else {
137
  $table = $base_table;
138
  $alias = $table . '.' . $field_name;
139
  $is_field = FALSE;
140
}
141
$aliases     = array($alias => $alias);
142

    
143
$view = new view;
144
$view->name = $name;
145
$view->description = $description;
146
$view->tag = 'Calendar';
147
$view->base_table = $base_table;
148
$view->human_name = t("Calendar");
149
$view->core = 7;
150
$view->api_version = '3.0';
151
$view->disabled = FALSE; /* Edit this to true to make a default view disabled initially */
152

    
153
/* Display: Master */
154

    
155
$handler = $view->new_display('default', 'Master', 'default');
156
$handler->display->display_options['title'] = '';
157
$handler->display->display_options['link_display'] = 'page_1';
158
$handler->display->display_options['access']['type'] = 'perm';
159
$handler->display->display_options['query']['type'] = 'views_query';
160
$handler->display->display_options['query']['options']['query_comment'] = FALSE;
161
$handler->display->display_options['exposed_form']['type'] = 'basic';
162
$handler->display->display_options['pager']['type'] = 'date_views_pager';
163
$handler->display->display_options['pager']['options']['date_id'] = 'month';
164
$handler->display->display_options['pager']['options']['pager_position'] = 'top';
165
$handler->display->display_options['style_plugin'] = 'calendar_style';
166
$handler->display->display_options['style_options']['name_size'] = '3';
167
$handler->display->display_options['style_options']['with_weekno'] = '0';
168
$handler->display->display_options['style_options']['multiday_theme'] = '1';
169
$handler->display->display_options['style_options']['theme_style'] = '1';
170
$handler->display->display_options['style_options']['max_items'] = '0';
171
$handler->display->display_options['row_plugin'] = 'calendar_entity';
172

    
173
/* Field: Title */
174

    
175
switch ($base_table) {
176

    
177
  case 'node':
178
  case 'node_revision':
179
    $handler->display->display_options['fields']['title']['id'] = 'title';
180
    $handler->display->display_options['fields']['title']['table'] = $base_table;
181
    $handler->display->display_options['fields']['title']['field'] = 'title';
182
    $handler->display->display_options['fields']['title']['label'] = '';
183
    $handler->display->display_options['fields']['title']['exclude'] = $with_colorbox ? 1 : 0;
184
    $handler->display->display_options['fields']['title']['alter']['alter_text'] = 0;
185
    $handler->display->display_options['fields']['title']['alter']['make_link'] = 0;
186
    $handler->display->display_options['fields']['title']['alter']['absolute'] = 0;
187
    $handler->display->display_options['fields']['title']['alter']['external'] = 0;
188
    $handler->display->display_options['fields']['title']['alter']['replace_spaces'] = 0;
189
    $handler->display->display_options['fields']['title']['alter']['trim_whitespace'] = 0;
190
    $handler->display->display_options['fields']['title']['alter']['nl2br'] = 0;
191
    $handler->display->display_options['fields']['title']['alter']['word_boundary'] = 0;
192
    $handler->display->display_options['fields']['title']['alter']['ellipsis'] = 0;
193
    $handler->display->display_options['fields']['title']['alter']['strip_tags'] = 0;
194
    $handler->display->display_options['fields']['title']['alter']['trim'] = 0;
195
    $handler->display->display_options['fields']['title']['alter']['html'] = 0;
196
    $handler->display->display_options['fields']['title']['element_label_colon'] = FALSE;
197
    $handler->display->display_options['fields']['title']['element_default_classes'] = 1;
198
    $handler->display->display_options['fields']['title']['hide_empty'] = 0;
199
    $handler->display->display_options['fields']['title']['empty_zero'] = 0;
200
    $handler->display->display_options['fields']['title']['hide_alter_empty'] = 0;
201
    $handler->display->display_options['fields']['title']['link_to_node'] = $with_colorbox ? 0 : 1;
202
    break;
203

    
204
  case 'users':
205
    $handler->display->display_options['fields']['name']['id'] = 'name';
206
    $handler->display->display_options['fields']['name']['table'] = 'users';
207
    $handler->display->display_options['fields']['name']['field'] = 'name';
208
    $handler->display->display_options['fields']['name']['label'] = '';
209
    $handler->display->display_options['fields']['name']['alter']['alter_text'] = 0;
210
    $handler->display->display_options['fields']['name']['alter']['make_link'] = 0;
211
    $handler->display->display_options['fields']['name']['alter']['absolute'] = 0;
212
    $handler->display->display_options['fields']['name']['alter']['word_boundary'] = 0;
213
    $handler->display->display_options['fields']['name']['alter']['ellipsis'] = 0;
214
    $handler->display->display_options['fields']['name']['alter']['strip_tags'] = 0;
215
    $handler->display->display_options['fields']['name']['alter']['trim'] = 0;
216
    $handler->display->display_options['fields']['name']['alter']['html'] = 0;
217
    $handler->display->display_options['fields']['name']['hide_empty'] = 0;
218
    $handler->display->display_options['fields']['name']['empty_zero'] = 0;
219
    $handler->display->display_options['fields']['name']['link_to_user'] = 1;
220
    $handler->display->display_options['fields']['name']['overwrite_anonymous'] = 0;
221
  break;
222

    
223
}
224

    
225
if ($with_colorbox) {
226

    
227
/* Field: Content: Rendered Node */
228
$handler->display->display_options['fields']['rendered_entity']['id'] = 'rendered_entity';
229
$handler->display->display_options['fields']['rendered_entity']['table'] = 'views_entity_node';
230
$handler->display->display_options['fields']['rendered_entity']['field'] = 'rendered_entity';
231
$handler->display->display_options['fields']['rendered_entity']['label'] = '';
232
$handler->display->display_options['fields']['rendered_entity']['exclude'] = TRUE;
233
$handler->display->display_options['fields']['rendered_entity']['alter']['alter_text'] = 0;
234
$handler->display->display_options['fields']['rendered_entity']['alter']['make_link'] = 0;
235
$handler->display->display_options['fields']['rendered_entity']['alter']['absolute'] = 0;
236
$handler->display->display_options['fields']['rendered_entity']['alter']['external'] = 0;
237
$handler->display->display_options['fields']['rendered_entity']['alter']['replace_spaces'] = 0;
238
$handler->display->display_options['fields']['rendered_entity']['alter']['trim_whitespace'] = 0;
239
$handler->display->display_options['fields']['rendered_entity']['alter']['nl2br'] = 0;
240
$handler->display->display_options['fields']['rendered_entity']['alter']['word_boundary'] = 1;
241
$handler->display->display_options['fields']['rendered_entity']['alter']['ellipsis'] = 1;
242
$handler->display->display_options['fields']['rendered_entity']['alter']['more_link'] = 0;
243
$handler->display->display_options['fields']['rendered_entity']['alter']['strip_tags'] = 0;
244
$handler->display->display_options['fields']['rendered_entity']['alter']['trim'] = 0;
245
$handler->display->display_options['fields']['rendered_entity']['alter']['html'] = 0;
246
$handler->display->display_options['fields']['rendered_entity']['element_label_colon'] = FALSE;
247
$handler->display->display_options['fields']['rendered_entity']['element_default_classes'] = 1;
248
$handler->display->display_options['fields']['rendered_entity']['hide_empty'] = 0;
249
$handler->display->display_options['fields']['rendered_entity']['empty_zero'] = 0;
250
$handler->display->display_options['fields']['rendered_entity']['hide_alter_empty'] = 1;
251
$handler->display->display_options['fields']['rendered_entity']['link_to_entity'] = 1;
252
$handler->display->display_options['fields']['rendered_entity']['display'] = 'view';
253
$handler->display->display_options['fields']['rendered_entity']['view_mode'] = 'full';
254
/* Field: Colorbox: Colorbox trigger */
255
$handler->display->display_options['fields']['colorbox']['id'] = 'colorbox';
256
$handler->display->display_options['fields']['colorbox']['table'] = 'colorbox';
257
$handler->display->display_options['fields']['colorbox']['field'] = 'colorbox';
258
$handler->display->display_options['fields']['colorbox']['label'] = '';
259
$handler->display->display_options['fields']['colorbox']['alter']['alter_text'] = 1;
260
$handler->display->display_options['fields']['colorbox']['alter']['make_link'] = 0;
261
$handler->display->display_options['fields']['colorbox']['alter']['absolute'] = 0;
262
$handler->display->display_options['fields']['colorbox']['alter']['external'] = 0;
263
$handler->display->display_options['fields']['colorbox']['alter']['replace_spaces'] = 0;
264
$handler->display->display_options['fields']['colorbox']['alter']['trim_whitespace'] = 0;
265
$handler->display->display_options['fields']['colorbox']['alter']['nl2br'] = 0;
266
$handler->display->display_options['fields']['colorbox']['alter']['word_boundary'] = 1;
267
$handler->display->display_options['fields']['colorbox']['alter']['ellipsis'] = 1;
268
$handler->display->display_options['fields']['colorbox']['alter']['more_link'] = 0;
269
$handler->display->display_options['fields']['colorbox']['alter']['strip_tags'] = 0;
270
$handler->display->display_options['fields']['colorbox']['alter']['trim'] = 0;
271
$handler->display->display_options['fields']['colorbox']['alter']['html'] = 0;
272
$handler->display->display_options['fields']['colorbox']['element_label_colon'] = FALSE;
273
$handler->display->display_options['fields']['colorbox']['element_default_classes'] = 1;
274
$handler->display->display_options['fields']['colorbox']['hide_empty'] = 0;
275
$handler->display->display_options['fields']['colorbox']['empty_zero'] = 0;
276
$handler->display->display_options['fields']['colorbox']['hide_alter_empty'] = 1;
277
$handler->display->display_options['fields']['colorbox']['trigger_field'] = 'title';
278
$handler->display->display_options['fields']['colorbox']['popup'] = '[rendered_entity]';
279
$handler->display->display_options['fields']['colorbox']['gid'] = 1;
280

    
281
} // End if($with_colorbox);
282

    
283
/* Date Field */
284

    
285
$handler->display->display_options['fields'][$field_name]['id'] = $field_name;
286
$handler->display->display_options['fields'][$field_name]['table'] = $table;
287
$handler->display->display_options['fields'][$field_name]['field'] = $field_name;
288
$handler->display->display_options['fields'][$field_name]['label'] = '';
289
$handler->display->display_options['fields'][$field_name]['alter']['alter_text'] = 0;
290
$handler->display->display_options['fields'][$field_name]['alter']['make_link'] = 0;
291
$handler->display->display_options['fields'][$field_name]['alter']['absolute'] = 0;
292
$handler->display->display_options['fields'][$field_name]['alter']['external'] = 0;
293
$handler->display->display_options['fields'][$field_name]['alter']['replace_spaces'] = 0;
294
$handler->display->display_options['fields'][$field_name]['alter']['trim_whitespace'] = 0;
295
$handler->display->display_options['fields'][$field_name]['alter']['nl2br'] = 0;
296
$handler->display->display_options['fields'][$field_name]['alter']['word_boundary'] = 1;
297
$handler->display->display_options['fields'][$field_name]['alter']['ellipsis'] = 1;
298
$handler->display->display_options['fields'][$field_name]['alter']['strip_tags'] = 0;
299
$handler->display->display_options['fields'][$field_name]['alter']['trim'] = 0;
300
$handler->display->display_options['fields'][$field_name]['alter']['html'] = 0;
301
$handler->display->display_options['fields'][$field_name]['element_label_colon'] = FALSE;
302
$handler->display->display_options['fields'][$field_name]['element_default_classes'] = 1;
303
$handler->display->display_options['fields'][$field_name]['hide_empty'] = 0;
304
$handler->display->display_options['fields'][$field_name]['empty_zero'] = 0;
305
$handler->display->display_options['fields'][$field_name]['hide_alter_empty'] = 0;
306

    
307
if ($is_field) {
308
  $handler->display->display_options['fields'][$field_name]['settings'] = array(
309
    'format_type' => 'short',
310
    'fromto' => 'both',
311
    'multiple_number' => '',
312
    'multiple_from' => '',
313
    'multiple_to' => '',
314
    'show_repeat_rule' => '',
315
  );
316
  $handler->display->display_options['fields'][$field_name]['group_rows'] = 0;
317
  $handler->display->display_options['fields'][$field_name]['delta_offset'] = '0';
318
  $handler->display->display_options['fields'][$field_name]['delta_reversed'] = 0;
319
  $handler->display->display_options['fields'][$field_name]['field_api_classes'] = 0;
320

    
321
  /* Sort criterion */
322
  $handler->display->display_options['sorts'][$field_name . '_value']['id'] = $field_name . '_value';
323
  $handler->display->display_options['sorts'][$field_name . '_value']['table'] = $table;
324
  $handler->display->display_options['sorts'][$field_name . '_value']['field'] = $field_name . '_value';
325

    
326
}
327
else {
328

    
329
  /* Sort criterion */
330
  $handler->display->display_options['sorts'][$field_name]['id'] = $field_name;
331
  $handler->display->display_options['sorts'][$field_name]['table'] = $table;
332
  $handler->display->display_options['sorts'][$field_name]['field'] = $field_name;
333

    
334
}
335

    
336
/* Filter criterion: Content: Published */
337

    
338
switch ($base_table) {
339

    
340
  case 'node':
341

    
342
    $handler->display->display_options['filters']['status']['id'] = 'status';
343
    $handler->display->display_options['filters']['status']['table'] = $base_table;
344
    $handler->display->display_options['filters']['status']['field'] = 'status';
345
    $handler->display->display_options['filters']['status']['value'] = 1;
346
    $handler->display->display_options['filters']['status']['group'] = 0;
347
    $handler->display->display_options['filters']['status']['expose']['operator'] = FALSE;
348
    break;
349
}
350

    
351
/* Display: Month */
352

    
353
$handler = $view->new_display('page', 'Month', 'page_1');
354
$handler->display->display_options['defaults']['pager'] = FALSE;
355
$handler->display->display_options['pager']['type'] = 'date_views_pager';
356
$handler->display->display_options['pager']['options']['date_id'] = 'month';
357
$handler->display->display_options['pager']['options']['pager_position'] = 'top';
358
$handler->display->display_options['pager']['options']['link_format'] = 'clean';
359
$handler->display->display_options['defaults']['style_plugin'] = FALSE;
360
$handler->display->display_options['style_plugin'] = 'calendar_style';
361
$handler->display->display_options['style_options']['calendar_type'] = 'month';
362
$handler->display->display_options['style_options']['name_size'] = '3';
363
$handler->display->display_options['style_options']['mini'] = '0';
364
$handler->display->display_options['style_options']['with_weekno'] = '0';
365
$handler->display->display_options['style_options']['multiday_theme'] = '1';
366
$handler->display->display_options['style_options']['theme_style'] = '1';
367
$handler->display->display_options['style_options']['max_items'] = '0';
368

    
369
if ($with_colorbox) {
370
$handler->display->display_options['style_options']['multiday_hidden'] = array(
371
  'title' => 'title',
372
  'rendered_entity' => 'rendered_entity',
373
  $field_name => $field_name,
374
);
375
} // End if ($with_colorbox);
376

    
377
$handler->display->display_options['defaults']['style_options'] = FALSE;
378
$handler->display->display_options['defaults']['row_plugin'] = FALSE;
379
$handler->display->display_options['row_plugin'] = 'calendar_entity';
380
$handler->display->display_options['row_options']['calendar_date_link'] = '';
381
$handler->display->display_options['row_options']['colors']['legend'] = 'type';
382
$handler->display->display_options['row_options']['colors']['calendar_colors_type'] = array();
383
$handler->display->display_options['row_options']['colors']['calendar_colors_vocabulary'] = array();
384
$handler->display->display_options['defaults']['row_options'] = FALSE;
385
$handler->display->display_options['defaults']['arguments'] = FALSE;
386

    
387

    
388
/* Contextual filter: Date */
389

    
390
$handler->display->display_options['arguments']['date_argument']['id'] = 'date_argument';
391
$handler->display->display_options['arguments']['date_argument']['table'] = $base_table;
392
$handler->display->display_options['arguments']['date_argument']['field'] = 'date_argument';
393
$handler->display->display_options['arguments']['date_argument']['default_action'] = 'default';
394
$handler->display->display_options['arguments']['date_argument']['default_argument_type'] = 'date';
395
$handler->display->display_options['arguments']['date_argument']['default_argument_skip_url'] = 0;
396
$handler->display->display_options['arguments']['date_argument']['summary']['format'] = 'default_summary';
397
$handler->display->display_options['arguments']['date_argument']['year_range'] = '-3:+3';
398
$handler->display->display_options['arguments']['date_argument']['granularity'] = 'month';
399
$handler->display->display_options['arguments']['date_argument']['add_delta'] = 'yes';
400
$handler->display->display_options['arguments']['date_argument']['date_fields'] = $aliases;
401
$handler->display->display_options['arguments']['date_argument']['date_method'] = 'OR';
402
$handler->display->display_options['arguments']['date_argument']['date_group'] = 'date';
403

    
404
$handler->display->display_options['path'] = $path . '/month';
405
$handler->display->display_options['menu']['type'] = 'default tab';
406
$handler->display->display_options['menu']['title'] = 'Month';
407
$handler->display->display_options['menu']['weight'] = '0';
408
$handler->display->display_options['menu']['context'] = 0;
409
$handler->display->display_options['tab_options']['type'] = 'normal';
410
$handler->display->display_options['tab_options']['title'] = 'Calendar';
411
$handler->display->display_options['tab_options']['weight'] = '0';
412

    
413

    
414
/* Display: Week */
415

    
416
$handler = $view->new_display('page', 'Week', 'page_2');
417
$handler->display->display_options['defaults']['pager'] = FALSE;
418
$handler->display->display_options['pager']['type'] = 'date_views_pager';
419
$handler->display->display_options['pager']['options']['date_id'] = 'week';
420
$handler->display->display_options['pager']['options']['pager_position'] = 'top';
421
$handler->display->display_options['pager']['options']['link_format'] = 'clean';
422
$handler->display->display_options['defaults']['style_plugin'] = FALSE;
423
$handler->display->display_options['style_plugin'] = 'calendar_style';
424
$handler->display->display_options['style_options']['calendar_type'] = 'week';
425
$handler->display->display_options['style_options']['name_size'] = '3';
426
$handler->display->display_options['style_options']['mini'] = '0';
427
$handler->display->display_options['style_options']['with_weekno'] = '0';
428
$handler->display->display_options['style_options']['multiday_theme'] = '1';
429
$handler->display->display_options['style_options']['groupby_times'] = 'hour';
430
$handler->display->display_options['style_options']['theme_style'] = '1';
431
$handler->display->display_options['style_options']['max_items'] = '0';
432

    
433
if ($with_colorbox) {
434
$handler->display->display_options['style_options']['multiday_hidden'] = array(
435
  'title' => 'title',
436
  'rendered_entity' => 'rendered_entity',
437
  $field_name => $field_name,
438
);
439
} // End if ($with_colorbox);
440

    
441
$handler->display->display_options['defaults']['style_options'] = FALSE;
442
$handler->display->display_options['defaults']['row_plugin'] = FALSE;
443
$handler->display->display_options['row_plugin'] = 'calendar_entity';
444
$handler->display->display_options['defaults']['row_options'] = FALSE;
445
$handler->display->display_options['defaults']['arguments'] = FALSE;
446

    
447
/* Contextual filter: Date */
448

    
449
$handler->display->display_options['arguments']['date_argument']['id'] = 'date_argument';
450
$handler->display->display_options['arguments']['date_argument']['table'] = $base_table;
451
$handler->display->display_options['arguments']['date_argument']['field'] = 'date_argument';
452
$handler->display->display_options['arguments']['date_argument']['default_action'] = 'default';
453
$handler->display->display_options['arguments']['date_argument']['default_argument_type'] = 'date';
454
$handler->display->display_options['arguments']['date_argument']['default_argument_skip_url'] = 0;
455
$handler->display->display_options['arguments']['date_argument']['summary']['format'] = 'default_summary';
456
$handler->display->display_options['arguments']['date_argument']['year_range'] = '-3:+3';
457
$handler->display->display_options['arguments']['date_argument']['granularity'] = 'week';
458
$handler->display->display_options['arguments']['date_argument']['add_delta'] = 'yes';
459
$handler->display->display_options['arguments']['date_argument']['date_fields'] = $aliases;
460
$handler->display->display_options['arguments']['date_argument']['date_method'] = 'OR';
461
$handler->display->display_options['arguments']['date_argument']['date_group'] = 'date';
462

    
463
$handler->display->display_options['path'] = $path . '/week';
464
$handler->display->display_options['menu']['type'] = 'tab';
465
$handler->display->display_options['menu']['title'] = 'Week';
466
$handler->display->display_options['menu']['weight'] = '2';
467
$handler->display->display_options['menu']['context'] = 0;
468

    
469
/* Display: Day */
470

    
471
$handler = $view->new_display('page', 'Day', 'page_3');
472
$handler->display->display_options['defaults']['pager'] = FALSE;
473
$handler->display->display_options['pager']['type'] = 'date_views_pager';
474
$handler->display->display_options['pager']['options']['date_id'] = 'day';
475
$handler->display->display_options['pager']['options']['pager_position'] = 'top';
476
$handler->display->display_options['pager']['options']['link_format'] = 'clean';
477
$handler->display->display_options['defaults']['style_plugin'] = FALSE;
478
$handler->display->display_options['style_plugin'] = 'calendar_style';
479
$handler->display->display_options['style_options']['calendar_type'] = 'day';
480
$handler->display->display_options['style_options']['name_size'] = '3';
481
$handler->display->display_options['style_options']['mini'] = '0';
482
$handler->display->display_options['style_options']['with_weekno'] = '0';
483
$handler->display->display_options['style_options']['multiday_theme'] = '1';
484
$handler->display->display_options['style_options']['theme_style'] = '1';
485
$handler->display->display_options['style_options']['max_items'] = '0';
486
$handler->display->display_options['style_options']['groupby_times'] = 'hour';
487

    
488
if ($with_colorbox) {
489
$handler->display->display_options['style_options']['multiday_hidden'] = array(
490
  'title' => 'title',
491
  'rendered_entity' => 'rendered_entity',
492
  $field_name => $field_name,
493
);
494
} // End if ($with_colorbox);
495

    
496
$handler->display->display_options['defaults']['style_options'] = FALSE;
497
$handler->display->display_options['defaults']['row_plugin'] = FALSE;
498
$handler->display->display_options['row_plugin'] = 'calendar_entity';
499
$handler->display->display_options['defaults']['row_options'] = FALSE;
500
$handler->display->display_options['defaults']['arguments'] = FALSE;
501

    
502
/* Contextual filter: Date */
503

    
504
$handler->display->display_options['arguments']['date_argument']['id'] = 'date_argument';
505
$handler->display->display_options['arguments']['date_argument']['table'] = $base_table;
506
$handler->display->display_options['arguments']['date_argument']['field'] = 'date_argument';
507
$handler->display->display_options['arguments']['date_argument']['default_action'] = 'default';
508
$handler->display->display_options['arguments']['date_argument']['default_argument_type'] = 'date';
509
$handler->display->display_options['arguments']['date_argument']['default_argument_skip_url'] = 0;
510
$handler->display->display_options['arguments']['date_argument']['summary']['format'] = 'default_summary';
511
$handler->display->display_options['arguments']['date_argument']['year_range'] = '-3:+3';
512
$handler->display->display_options['arguments']['date_argument']['granularity'] = 'day';
513
$handler->display->display_options['arguments']['date_argument']['add_delta'] = '';
514
$handler->display->display_options['arguments']['date_argument']['date_fields'] = $aliases;
515
$handler->display->display_options['arguments']['date_argument']['date_method'] = 'OR';
516
$handler->display->display_options['arguments']['date_argument']['date_group'] = 'date';
517

    
518
$handler->display->display_options['path'] = $path . '/day';
519
$handler->display->display_options['menu']['type'] = 'tab';
520
$handler->display->display_options['menu']['title'] = 'Day';
521
$handler->display->display_options['menu']['weight'] = '3';
522
$handler->display->display_options['menu']['context'] = 0;
523

    
524
/* Display: Year */
525

    
526
$handler = $view->new_display('page', 'Year', 'page');
527
$handler->display->display_options['defaults']['pager'] = FALSE;
528
$handler->display->display_options['pager']['type'] = 'date_views_pager';
529
$handler->display->display_options['pager']['options']['date_id'] = 'year';
530
$handler->display->display_options['pager']['options']['pager_position'] = 'top';
531
$handler->display->display_options['pager']['options']['link_format'] = 'clean';
532
$handler->display->display_options['defaults']['style_plugin'] = FALSE;
533
$handler->display->display_options['style_plugin'] = 'calendar_style';
534
$handler->display->display_options['style_options']['calendar_type'] = 'year';
535
$handler->display->display_options['style_options']['name_size'] = '1';
536
$handler->display->display_options['style_options']['mini'] = '0';
537
$handler->display->display_options['style_options']['with_weekno'] = '0';
538
$handler->display->display_options['style_options']['multiday_theme'] = '1';
539
$handler->display->display_options['style_options']['theme_style'] = '1';
540
$handler->display->display_options['style_options']['max_items'] = '0';
541
$handler->display->display_options['defaults']['style_options'] = FALSE;
542
$handler->display->display_options['defaults']['row_plugin'] = FALSE;
543
$handler->display->display_options['row_plugin'] = 'calendar_entity';
544
$handler->display->display_options['defaults']['row_options'] = FALSE;
545
$handler->display->display_options['defaults']['arguments'] = FALSE;
546
$handler->display->display_options['defaults']['fields'] = FALSE;
547

    
548
switch ($base_table) {
549

    
550
  case 'node':
551
  case 'node_revision':
552
    $handler->display->display_options['fields']['title']['id'] = 'title';
553
    $handler->display->display_options['fields']['title']['table'] = $base_table;
554
    $handler->display->display_options['fields']['title']['field'] = 'title';
555
    $handler->display->display_options['fields']['title']['label'] = '';
556
    $handler->display->display_options['fields']['title']['exclude'] = $with_colorbox ? 1 : 0;
557
    $handler->display->display_options['fields']['title']['alter']['alter_text'] = 0;
558
    $handler->display->display_options['fields']['title']['alter']['make_link'] = 0;
559
    $handler->display->display_options['fields']['title']['alter']['absolute'] = 0;
560
    $handler->display->display_options['fields']['title']['alter']['external'] = 0;
561
    $handler->display->display_options['fields']['title']['alter']['replace_spaces'] = 0;
562
    $handler->display->display_options['fields']['title']['alter']['trim_whitespace'] = 0;
563
    $handler->display->display_options['fields']['title']['alter']['nl2br'] = 0;
564
    $handler->display->display_options['fields']['title']['alter']['word_boundary'] = 0;
565
    $handler->display->display_options['fields']['title']['alter']['ellipsis'] = 0;
566
    $handler->display->display_options['fields']['title']['alter']['strip_tags'] = 0;
567
    $handler->display->display_options['fields']['title']['alter']['trim'] = 0;
568
    $handler->display->display_options['fields']['title']['alter']['html'] = 0;
569
    $handler->display->display_options['fields']['title']['element_label_colon'] = FALSE;
570
    $handler->display->display_options['fields']['title']['element_default_classes'] = 1;
571
    $handler->display->display_options['fields']['title']['hide_empty'] = 0;
572
    $handler->display->display_options['fields']['title']['empty_zero'] = 0;
573
    $handler->display->display_options['fields']['title']['hide_alter_empty'] = 0;
574
    $handler->display->display_options['fields']['title']['link_to_node'] = $with_colorbox ? 0 : 1;
575
    break;
576

    
577
  case 'users':
578
    $handler->display->display_options['fields']['name']['id'] = 'name';
579
    $handler->display->display_options['fields']['name']['table'] = 'users';
580
    $handler->display->display_options['fields']['name']['field'] = 'name';
581
    $handler->display->display_options['fields']['name']['label'] = '';
582
    $handler->display->display_options['fields']['name']['alter']['alter_text'] = 0;
583
    $handler->display->display_options['fields']['name']['alter']['make_link'] = 0;
584
    $handler->display->display_options['fields']['name']['alter']['absolute'] = 0;
585
    $handler->display->display_options['fields']['name']['alter']['word_boundary'] = 0;
586
    $handler->display->display_options['fields']['name']['alter']['ellipsis'] = 0;
587
    $handler->display->display_options['fields']['name']['alter']['strip_tags'] = 0;
588
    $handler->display->display_options['fields']['name']['alter']['trim'] = 0;
589
    $handler->display->display_options['fields']['name']['alter']['html'] = 0;
590
    $handler->display->display_options['fields']['name']['hide_empty'] = 0;
591
    $handler->display->display_options['fields']['name']['empty_zero'] = 0;
592
    $handler->display->display_options['fields']['name']['link_to_user'] = 1;
593
    $handler->display->display_options['fields']['name']['overwrite_anonymous'] = 0;
594
  break;
595

    
596
}
597

    
598
/* Date Field */
599

    
600
$handler->display->display_options['fields'][$field_name]['id'] = $field_name;
601
$handler->display->display_options['fields'][$field_name]['table'] = $table;
602
$handler->display->display_options['fields'][$field_name]['field'] = $field_name;
603
$handler->display->display_options['fields'][$field_name]['label'] = '';
604
$handler->display->display_options['fields'][$field_name]['alter']['alter_text'] = 0;
605
$handler->display->display_options['fields'][$field_name]['alter']['make_link'] = 0;
606
$handler->display->display_options['fields'][$field_name]['alter']['absolute'] = 0;
607
$handler->display->display_options['fields'][$field_name]['alter']['external'] = 0;
608
$handler->display->display_options['fields'][$field_name]['alter']['replace_spaces'] = 0;
609
$handler->display->display_options['fields'][$field_name]['alter']['trim_whitespace'] = 0;
610
$handler->display->display_options['fields'][$field_name]['alter']['nl2br'] = 0;
611
$handler->display->display_options['fields'][$field_name]['alter']['word_boundary'] = 1;
612
$handler->display->display_options['fields'][$field_name]['alter']['ellipsis'] = 1;
613
$handler->display->display_options['fields'][$field_name]['alter']['strip_tags'] = 0;
614
$handler->display->display_options['fields'][$field_name]['alter']['trim'] = 0;
615
$handler->display->display_options['fields'][$field_name]['alter']['html'] = 0;
616
$handler->display->display_options['fields'][$field_name]['element_label_colon'] = FALSE;
617
$handler->display->display_options['fields'][$field_name]['element_default_classes'] = 1;
618
$handler->display->display_options['fields'][$field_name]['hide_empty'] = 0;
619
$handler->display->display_options['fields'][$field_name]['empty_zero'] = 0;
620
$handler->display->display_options['fields'][$field_name]['hide_alter_empty'] = 0;
621

    
622
if ($is_field) {
623
  $handler->display->display_options['fields'][$field_name]['settings'] = array(
624
    'format_type' => 'short',
625
    'fromto' => 'both',
626
    'multiple_number' => '',
627
    'multiple_from' => '',
628
    'multiple_to' => '',
629
    'show_repeat_rule' => '',
630
  );
631
  $handler->display->display_options['fields'][$field_name]['group_rows'] = 0;
632
  $handler->display->display_options['fields'][$field_name]['delta_offset'] = '0';
633
  $handler->display->display_options['fields'][$field_name]['delta_reversed'] = 0;
634
  $handler->display->display_options['fields'][$field_name]['field_api_classes'] = 0;
635
}
636

    
637
/* Contextual filter: Date */
638

    
639
$handler->display->display_options['arguments']['date_argument']['id'] = 'date_argument';
640
$handler->display->display_options['arguments']['date_argument']['table'] = $base_table;
641
$handler->display->display_options['arguments']['date_argument']['field'] = 'date_argument';
642
$handler->display->display_options['arguments']['date_argument']['default_action'] = 'default';
643
$handler->display->display_options['arguments']['date_argument']['default_argument_type'] = 'date';
644
$handler->display->display_options['arguments']['date_argument']['default_argument_skip_url'] = 0;
645
$handler->display->display_options['arguments']['date_argument']['summary']['format'] = 'default_summary';
646
$handler->display->display_options['arguments']['date_argument']['year_range'] = '-3:+3';
647
$handler->display->display_options['arguments']['date_argument']['granularity'] = 'year';
648
$handler->display->display_options['arguments']['date_argument']['add_delta'] = 'yes';
649
$handler->display->display_options['arguments']['date_argument']['date_fields'] = $aliases;
650
$handler->display->display_options['arguments']['date_argument']['date_method'] = 'OR';
651
$handler->display->display_options['arguments']['date_argument']['date_group'] = 'date';
652

    
653
$handler->display->display_options['path'] = $path . '/year';
654
$handler->display->display_options['menu']['type'] = 'tab';
655
$handler->display->display_options['menu']['title'] = 'Year';
656
$handler->display->display_options['menu']['weight'] = '4';
657
$handler->display->display_options['menu']['context'] = 0;
658

    
659
/* Display: Block */
660

    
661
$handler = $view->new_display('block', 'Block', 'block_1');
662
$handler->display->display_options['defaults']['use_ajax'] = FALSE;
663
$handler->display->display_options['use_ajax'] = TRUE;
664
$handler->display->display_options['defaults']['pager'] = FALSE;
665
$handler->display->display_options['pager']['type'] = 'date_views_pager';
666
$handler->display->display_options['pager']['options']['date_id'] = 'mini';
667
$handler->display->display_options['defaults']['style_plugin'] = FALSE;
668
$handler->display->display_options['style_plugin'] = 'calendar_style';
669
$handler->display->display_options['style_options']['calendar_type'] = 'month';
670
$handler->display->display_options['style_options']['name_size'] = '1';
671
$handler->display->display_options['style_options']['mini'] = '1';
672
$handler->display->display_options['style_options']['with_weekno'] = '0';
673
$handler->display->display_options['style_options']['multiday_theme'] = '1';
674
$handler->display->display_options['style_options']['theme_style'] = '1';
675
$handler->display->display_options['style_options']['max_items'] = '0';
676
$handler->display->display_options['defaults']['style_options'] = FALSE;
677
$handler->display->display_options['defaults']['row_plugin'] = FALSE;
678
$handler->display->display_options['row_plugin'] = 'calendar_entity';
679
$handler->display->display_options['defaults']['row_options'] = FALSE;
680
$handler->display->display_options['defaults']['arguments'] = FALSE;
681

    
682
/* Contextual filter: Date */
683

    
684
$handler->display->display_options['arguments']['date_argument']['id'] = 'date_argument';
685
$handler->display->display_options['arguments']['date_argument']['table'] = $base_table;
686
$handler->display->display_options['arguments']['date_argument']['field'] = 'date_argument';
687
$handler->display->display_options['arguments']['date_argument']['default_action'] = 'default';
688
$handler->display->display_options['arguments']['date_argument']['default_argument_type'] = 'date';
689
$handler->display->display_options['arguments']['date_argument']['default_argument_skip_url'] = 0;
690
$handler->display->display_options['arguments']['date_argument']['summary']['format'] = 'default_summary';
691
$handler->display->display_options['arguments']['date_argument']['year_range'] = '-3:+3';
692
$handler->display->display_options['arguments']['date_argument']['granularity'] = 'month';
693
$handler->display->display_options['arguments']['date_argument']['add_delta'] = 'yes';
694
$handler->display->display_options['arguments']['date_argument']['date_fields'] = $aliases;
695
$handler->display->display_options['arguments']['date_argument']['date_method'] = 'OR';
696
$handler->display->display_options['arguments']['date_argument']['date_group'] = 'date';
697

    
698
if ($with_ical) {
699

    
700
/* Display: iCal */
701

    
702
$handler = $view->new_display('feed', 'iCal', 'feed_1');
703
$handler->display->display_options['pager']['type'] = 'some';
704
$handler->display->display_options['style_plugin'] = 'date_ical';
705
$handler->display->display_options['row_plugin'] = 'date_ical';
706
$handler->display->display_options['row_options']['date_field'] = $alias;
707
$handler->display->display_options['defaults']['filters'] = FALSE;
708

    
709
/* Filter criterion: Content: Published */
710

    
711
switch ($base_table) {
712

    
713
  case 'node':
714
    $handler->display->display_options['filters']['status']['id'] = 'status';
715
    $handler->display->display_options['filters']['status']['table'] = $base_table;
716
    $handler->display->display_options['filters']['status']['field'] = 'status';
717
    $handler->display->display_options['filters']['status']['value'] = 1;
718
    $handler->display->display_options['filters']['status']['group'] = 0;
719
    $handler->display->display_options['filters']['status']['expose']['operator'] = FALSE;
720
    break;
721
}
722

    
723
/* Filter criterion: Date */
724

    
725
$handler->display->display_options['filters']['date_filter']['id'] = 'date_filter';
726
$handler->display->display_options['filters']['date_filter']['table'] = $base_table;
727
$handler->display->display_options['filters']['date_filter']['field'] = 'date_filter';
728
$handler->display->display_options['filters']['date_filter']['operator'] = '>=';
729
$handler->display->display_options['filters']['date_filter']['granularity'] = 'day';
730
$handler->display->display_options['filters']['date_filter']['form_type'] = 'date_select';
731
$handler->display->display_options['filters']['date_filter']['default_date'] = 'now';
732
$handler->display->display_options['filters']['date_filter']['default_to_date'] = '';
733
$handler->display->display_options['filters']['date_filter']['year_range'] = '-3:+3';
734
$handler->display->display_options['filters']['date_filter']['add_delta'] = 'yes';
735
$handler->display->display_options['filters']['date_filter']['date_fields'] = $aliases;
736
$handler->display->display_options['filters']['date_filter']['date_method'] = 'OR';
737
$handler->display->display_options['filters']['date_filter']['date_group'] = 'date';
738
$handler->display->display_options['path'] = $path . '/ical/%/calendar.ics';
739
$handler->display->display_options['displays'] = array(
740
  'page' => 'page',
741
  'page_1' => 'page_1',
742
  'page_2' => 'page_2',
743
  'page_3' => 'page_3',
744
  'block_1' => 'block_1',
745
  'block_2' => 'block_2',
746
  'default' => 0,
747
);
748

    
749
} // End if($with_ical);
750

    
751
/* Display: Upcoming */
752

    
753
$handler = $view->new_display('block', 'Upcoming', 'block_2');
754
$handler->display->display_options['display_description'] = 'Upcoming events block';
755
$handler->display->display_options['defaults']['use_more'] = FALSE;
756
$handler->display->display_options['use_more'] = TRUE;
757
$handler->display->display_options['use_more_always'] = TRUE;
758
$handler->display->display_options['defaults']['pager'] = FALSE;
759
$handler->display->display_options['pager']['type'] = 'some';
760
$handler->display->display_options['pager']['options']['items_per_page'] = '5';
761
$handler->display->display_options['pager']['options']['offset'] = '0';
762
$handler->display->display_options['defaults']['style_plugin'] = FALSE;
763
$handler->display->display_options['style_plugin'] = 'list';
764
$handler->display->display_options['defaults']['style_options'] = FALSE;
765
$handler->display->display_options['defaults']['row_plugin'] = FALSE;
766
$handler->display->display_options['row_plugin'] = 'fields';
767
$handler->display->display_options['row_options']['links'] = 1;
768
$handler->display->display_options['row_options']['comments'] = 0;
769
$handler->display->display_options['defaults']['row_options'] = FALSE;
770
$handler->display->display_options['defaults']['filters'] = FALSE;
771

    
772
/* Filter criterion: Content: Published */
773

    
774
switch ($base_table) {
775

    
776
  case 'node':
777

    
778
    $handler->display->display_options['filters']['status']['id'] = 'status';
779
    $handler->display->display_options['filters']['status']['table'] = $base_table;
780
    $handler->display->display_options['filters']['status']['field'] = 'status';
781
    $handler->display->display_options['filters']['status']['value'] = 1;
782
    $handler->display->display_options['filters']['status']['group'] = 0;
783
    $handler->display->display_options['filters']['status']['expose']['operator'] = FALSE;
784
    break;
785
}
786

    
787
/* Filter criterion: Date */
788

    
789
$handler->display->display_options['filters']['date_filter']['id'] = 'date_filter';
790
$handler->display->display_options['filters']['date_filter']['table'] = $base_table;
791
$handler->display->display_options['filters']['date_filter']['field'] = 'date_filter';
792
$handler->display->display_options['filters']['date_filter']['operator'] = '>=';
793
$handler->display->display_options['filters']['date_filter']['granularity'] = 'day';
794
$handler->display->display_options['filters']['date_filter']['form_type'] = 'date_select';
795
$handler->display->display_options['filters']['date_filter']['default_date'] = 'now';
796
$handler->display->display_options['filters']['date_filter']['default_to_date'] = '';
797
$handler->display->display_options['filters']['date_filter']['year_range'] = '-3:+3';
798
$handler->display->display_options['filters']['date_filter']['add_delta'] = 'yes';
799
$handler->display->display_options['filters']['date_filter']['date_fields'] = $aliases;
800
$handler->display->display_options['filters']['date_filter']['date_method'] = 'OR';
801
$handler->display->display_options['filters']['date_filter']['date_group'] = 'date';
802

    
803
$translatables[$name] = array(
804
  t('Master'),
805
  t($name),
806
  t('more'),
807
  t('Apply'),
808
  t('Reset'),
809
  t('Sort by'),
810
  t('Asc'),
811
  t('Desc'),
812
  t('Year'),
813
  t('All'),
814
  t('Month'),
815
  t('Week'),
816
  t('Day'),
817
  t('Block'),
818
  t('iCal'),
819
  t('Upcoming'),
820
  t('Upcoming events block'),
821
);
822

    
823

    
824
return $view;
825

    
826
}