calendar.views_template.inc 32 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614
  1. <?php
  2. /**
  3. * @file
  4. * View templates for the Calendar module.
  5. *
  6. * Create calendar templates for every date field in the system.
  7. */
  8. /**
  9. * Implements hook_views_templates().
  10. *
  11. */
  12. function calendar_views_templates() {
  13. $views = array();
  14. // Map the base tables to entity types.
  15. $entity_info = entity_get_info();
  16. $base_tables = date_views_base_tables();
  17. // Find all the date fields we know about.
  18. $processed = array();
  19. foreach ($entity_info as $entity_type => $info) {
  20. if (!$info['fieldable']) {
  21. continue;
  22. }
  23. $items = field_info_instances($entity_type);
  24. $views_fields = date_views_fields($info['base table']);
  25. foreach ($views_fields['name'] as $name => $data) {
  26. // For each of the Field date fields, we need to find the bundle and entities this field is used on.
  27. if ($data['is_field']) {
  28. foreach ($items as $bundle => $widgets) {
  29. foreach ($widgets as $field_name => $widget) {
  30. $field = field_info_field($field_name);
  31. // See if this is a date field. Since fields might be shared
  32. // across bundles, make sure we haven't already processed this field.
  33. $alias = 'field_data_' . $field_name . '.' . $field_name . '_value';
  34. if ($alias == $name && !in_array($alias, $processed)) {
  35. $base_table = $base_tables[$entity_type];
  36. $calendar_option = array(
  37. 'name' => 'calendar_' . $field_name,
  38. '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)),
  39. 'path' => 'calendar-' . str_replace('_', '-', $field_name),
  40. 'base_table' => $base_table,
  41. 'field_name' => $field_name,
  42. );
  43. $view = calendar_views_template_construct($calendar_option);
  44. $views[$view->name] = $view;
  45. $processed[] = $alias;
  46. }
  47. }
  48. }
  49. }
  50. // For other date fields, we infer the entity type from the base table.
  51. else {
  52. $parts = explode('.', $name);
  53. $base_table = $parts[0];
  54. $field_name = $parts[1];
  55. $calendar_option = array(
  56. 'name' => 'calendar_' . $entity_type . '_' . $field_name,
  57. '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)),
  58. 'path' => 'calendar-' . str_replace('_', '-', $field_name),
  59. 'base_table' => $base_table,
  60. 'field_name' => $field_name,
  61. );
  62. $view = calendar_views_template_construct($calendar_option);
  63. $views[$view->name] = $view;
  64. }
  65. }
  66. }
  67. return $views;
  68. }
  69. /**
  70. * Helper function to construct a calendar template from an array of values.
  71. *
  72. * @param $options:
  73. * An array of options to create calendar templates.
  74. *
  75. * Possible options include:
  76. * @param string $base_table:
  77. * The base table for the view.
  78. * @param string $name:
  79. * The view name.
  80. * @param string $description:
  81. * The view description.
  82. * @param string $path:
  83. * The view url, if empty, defaults to 'calendar'.
  84. * @param string $bundle:
  85. * The bundle for this calendar.
  86. * @param string $field_name:
  87. * Date field used to filter the calendar.
  88. *
  89. * @return the default template array.
  90. */
  91. function calendar_views_template_construct($options = NULL) {
  92. $name = $options['name'];
  93. $description = $options['description'];
  94. $path = $options['path'];
  95. $base_table = $options['base_table'];
  96. $field_name = $options['field_name'];
  97. $colors = array();
  98. if (substr($field_name, 0, 6) == 'field_') {
  99. $table = 'field_data_' . $field_name;
  100. $alias = $table . '.' . $field_name . '_value';
  101. $is_field = TRUE;
  102. }
  103. else {
  104. $table = $base_table;
  105. $alias = $table . '.' . $field_name;
  106. $is_field = FALSE;
  107. }
  108. $aliases = array($alias => $alias);
  109. $view = new view;
  110. $view->name = $name;
  111. $view->description = $description;
  112. $view->tag = 'Calendar';
  113. $view->base_table = $base_table;
  114. $view->human_name = t("Calendar");
  115. $view->core = 7;
  116. $view->api_version = '3.0';
  117. $view->disabled = FALSE; /* Edit this to true to make a default view disabled initially */
  118. /* Display: Master */
  119. $handler = $view->new_display('default', 'Master', 'default');
  120. $handler->display->display_options['title'] = '';
  121. $handler->display->display_options['link_display'] = 'page_1';
  122. $handler->display->display_options['access']['type'] = 'perm';
  123. $handler->display->display_options['cache']['type'] = 'none';
  124. $handler->display->display_options['query']['type'] = 'views_query';
  125. $handler->display->display_options['query']['options']['query_comment'] = FALSE;
  126. $handler->display->display_options['exposed_form']['type'] = 'basic';
  127. $handler->display->display_options['pager']['type'] = 'date_views_pager';
  128. $handler->display->display_options['pager']['options']['date_id'] = 'month';
  129. $handler->display->display_options['pager']['options']['pager_position'] = 'top';
  130. $handler->display->display_options['style_plugin'] = 'calendar_style';
  131. $handler->display->display_options['style_options']['name_size'] = '3';
  132. $handler->display->display_options['style_options']['with_weekno'] = '0';
  133. $handler->display->display_options['style_options']['multiday_theme'] = '1';
  134. $handler->display->display_options['style_options']['theme_style'] = '1';
  135. $handler->display->display_options['style_options']['max_items'] = '0';
  136. $handler->display->display_options['row_plugin'] = 'calendar_entity';
  137. /* Field: Title */
  138. switch ($base_table) {
  139. case 'node':
  140. case 'node_revision':
  141. $handler->display->display_options['fields']['title']['id'] = 'title';
  142. $handler->display->display_options['fields']['title']['table'] = $base_table;
  143. $handler->display->display_options['fields']['title']['field'] = 'title';
  144. $handler->display->display_options['fields']['title']['label'] = '';
  145. $handler->display->display_options['fields']['title']['alter']['alter_text'] = 0;
  146. $handler->display->display_options['fields']['title']['alter']['make_link'] = 0;
  147. $handler->display->display_options['fields']['title']['alter']['absolute'] = 0;
  148. $handler->display->display_options['fields']['title']['alter']['external'] = 0;
  149. $handler->display->display_options['fields']['title']['alter']['replace_spaces'] = 0;
  150. $handler->display->display_options['fields']['title']['alter']['trim_whitespace'] = 0;
  151. $handler->display->display_options['fields']['title']['alter']['nl2br'] = 0;
  152. $handler->display->display_options['fields']['title']['alter']['word_boundary'] = 0;
  153. $handler->display->display_options['fields']['title']['alter']['ellipsis'] = 0;
  154. $handler->display->display_options['fields']['title']['alter']['strip_tags'] = 0;
  155. $handler->display->display_options['fields']['title']['alter']['trim'] = 0;
  156. $handler->display->display_options['fields']['title']['alter']['html'] = 0;
  157. $handler->display->display_options['fields']['title']['element_label_colon'] = FALSE;
  158. $handler->display->display_options['fields']['title']['element_default_classes'] = 1;
  159. $handler->display->display_options['fields']['title']['hide_empty'] = 0;
  160. $handler->display->display_options['fields']['title']['empty_zero'] = 0;
  161. $handler->display->display_options['fields']['title']['hide_alter_empty'] = 0;
  162. $handler->display->display_options['fields']['title']['link_to_node'] = 1;
  163. break;
  164. case 'users':
  165. $handler->display->display_options['fields']['name']['id'] = 'name';
  166. $handler->display->display_options['fields']['name']['table'] = 'users';
  167. $handler->display->display_options['fields']['name']['field'] = 'name';
  168. $handler->display->display_options['fields']['name']['label'] = '';
  169. $handler->display->display_options['fields']['name']['alter']['alter_text'] = 0;
  170. $handler->display->display_options['fields']['name']['alter']['make_link'] = 0;
  171. $handler->display->display_options['fields']['name']['alter']['absolute'] = 0;
  172. $handler->display->display_options['fields']['name']['alter']['word_boundary'] = 0;
  173. $handler->display->display_options['fields']['name']['alter']['ellipsis'] = 0;
  174. $handler->display->display_options['fields']['name']['alter']['strip_tags'] = 0;
  175. $handler->display->display_options['fields']['name']['alter']['trim'] = 0;
  176. $handler->display->display_options['fields']['name']['alter']['html'] = 0;
  177. $handler->display->display_options['fields']['name']['hide_empty'] = 0;
  178. $handler->display->display_options['fields']['name']['empty_zero'] = 0;
  179. $handler->display->display_options['fields']['name']['link_to_user'] = 1;
  180. $handler->display->display_options['fields']['name']['overwrite_anonymous'] = 0;
  181. break;
  182. }
  183. /* Date Field */
  184. $handler->display->display_options['fields'][$field_name]['id'] = $field_name;
  185. $handler->display->display_options['fields'][$field_name]['table'] = $table;
  186. $handler->display->display_options['fields'][$field_name]['field'] = $field_name;
  187. $handler->display->display_options['fields'][$field_name]['label'] = '';
  188. $handler->display->display_options['fields'][$field_name]['alter']['alter_text'] = 0;
  189. $handler->display->display_options['fields'][$field_name]['alter']['make_link'] = 0;
  190. $handler->display->display_options['fields'][$field_name]['alter']['absolute'] = 0;
  191. $handler->display->display_options['fields'][$field_name]['alter']['external'] = 0;
  192. $handler->display->display_options['fields'][$field_name]['alter']['replace_spaces'] = 0;
  193. $handler->display->display_options['fields'][$field_name]['alter']['trim_whitespace'] = 0;
  194. $handler->display->display_options['fields'][$field_name]['alter']['nl2br'] = 0;
  195. $handler->display->display_options['fields'][$field_name]['alter']['word_boundary'] = 1;
  196. $handler->display->display_options['fields'][$field_name]['alter']['ellipsis'] = 1;
  197. $handler->display->display_options['fields'][$field_name]['alter']['strip_tags'] = 0;
  198. $handler->display->display_options['fields'][$field_name]['alter']['trim'] = 0;
  199. $handler->display->display_options['fields'][$field_name]['alter']['html'] = 0;
  200. $handler->display->display_options['fields'][$field_name]['element_label_colon'] = FALSE;
  201. $handler->display->display_options['fields'][$field_name]['element_default_classes'] = 1;
  202. $handler->display->display_options['fields'][$field_name]['hide_empty'] = 0;
  203. $handler->display->display_options['fields'][$field_name]['empty_zero'] = 0;
  204. $handler->display->display_options['fields'][$field_name]['hide_alter_empty'] = 0;
  205. if ($is_field) {
  206. $handler->display->display_options['fields'][$field_name]['settings'] = array(
  207. 'format_type' => 'short',
  208. 'fromto' => 'both',
  209. 'multiple_number' => '',
  210. 'multiple_from' => '',
  211. 'multiple_to' => '',
  212. 'show_repeat_rule' => '',
  213. );
  214. $handler->display->display_options['fields'][$field_name]['group_rows'] = 0;
  215. $handler->display->display_options['fields'][$field_name]['delta_offset'] = '0';
  216. $handler->display->display_options['fields'][$field_name]['delta_reversed'] = 0;
  217. $handler->display->display_options['fields'][$field_name]['field_api_classes'] = 0;
  218. /* Sort criterion */
  219. $handler->display->display_options['sorts'][$field_name . '_value']['id'] = $field_name . '_value';
  220. $handler->display->display_options['sorts'][$field_name . '_value']['table'] = $table;
  221. $handler->display->display_options['sorts'][$field_name . '_value']['field'] = $field_name . '_value';
  222. }
  223. else {
  224. /* Sort criterion */
  225. $handler->display->display_options['sorts'][$field_name]['id'] = $field_name;
  226. $handler->display->display_options['sorts'][$field_name]['table'] = $table;
  227. $handler->display->display_options['sorts'][$field_name]['field'] = $field_name;
  228. }
  229. /* Filter criterion: Content: Published */
  230. switch ($base_table) {
  231. case 'node':
  232. $handler->display->display_options['filters']['status']['id'] = 'status';
  233. $handler->display->display_options['filters']['status']['table'] = $base_table;
  234. $handler->display->display_options['filters']['status']['field'] = 'status';
  235. $handler->display->display_options['filters']['status']['value'] = 1;
  236. $handler->display->display_options['filters']['status']['group'] = 0;
  237. $handler->display->display_options['filters']['status']['expose']['operator'] = FALSE;
  238. break;
  239. }
  240. /* Display: Month */
  241. $handler = $view->new_display('page', 'Month', 'page_1');
  242. $handler->display->display_options['defaults']['pager'] = FALSE;
  243. $handler->display->display_options['pager']['type'] = 'date_views_pager';
  244. $handler->display->display_options['pager']['options']['date_id'] = 'month';
  245. $handler->display->display_options['pager']['options']['pager_position'] = 'top';
  246. $handler->display->display_options['pager']['options']['link_format'] = 'clean';
  247. $handler->display->display_options['defaults']['style_plugin'] = FALSE;
  248. $handler->display->display_options['style_plugin'] = 'calendar_style';
  249. $handler->display->display_options['style_options']['calendar_type'] = 'month';
  250. $handler->display->display_options['style_options']['name_size'] = '3';
  251. $handler->display->display_options['style_options']['mini'] = '0';
  252. $handler->display->display_options['style_options']['with_weekno'] = '0';
  253. $handler->display->display_options['style_options']['multiday_theme'] = '1';
  254. $handler->display->display_options['style_options']['theme_style'] = '1';
  255. $handler->display->display_options['style_options']['max_items'] = '0';
  256. $handler->display->display_options['defaults']['style_options'] = FALSE;
  257. $handler->display->display_options['defaults']['row_plugin'] = FALSE;
  258. $handler->display->display_options['row_plugin'] = 'calendar_entity';
  259. $handler->display->display_options['row_options']['calendar_date_link'] = '';
  260. $handler->display->display_options['row_options']['colors']['legend'] = 'type';
  261. $handler->display->display_options['row_options']['colors']['calendar_colors_type'] = array();
  262. $handler->display->display_options['row_options']['colors']['calendar_colors_vocabulary'] = array();
  263. $handler->display->display_options['defaults']['row_options'] = FALSE;
  264. $handler->display->display_options['defaults']['arguments'] = FALSE;
  265. /* Contextual filter: Date */
  266. $handler->display->display_options['arguments']['date_argument']['id'] = 'date_argument';
  267. $handler->display->display_options['arguments']['date_argument']['table'] = $base_table;
  268. $handler->display->display_options['arguments']['date_argument']['field'] = 'date_argument';
  269. $handler->display->display_options['arguments']['date_argument']['default_action'] = 'default';
  270. $handler->display->display_options['arguments']['date_argument']['default_argument_type'] = 'date';
  271. $handler->display->display_options['arguments']['date_argument']['default_argument_skip_url'] = 0;
  272. $handler->display->display_options['arguments']['date_argument']['summary']['format'] = 'default_summary';
  273. $handler->display->display_options['arguments']['date_argument']['year_range'] = '-3:+3';
  274. $handler->display->display_options['arguments']['date_argument']['granularity'] = 'month';
  275. $handler->display->display_options['arguments']['date_argument']['add_delta'] = 'yes';
  276. $handler->display->display_options['arguments']['date_argument']['date_fields'] = $aliases;
  277. $handler->display->display_options['arguments']['date_argument']['date_method'] = 'OR';
  278. $handler->display->display_options['arguments']['date_argument']['date_group'] = 'date';
  279. $handler->display->display_options['path'] = $path . '/month';
  280. $handler->display->display_options['menu']['title'] = 'Month';
  281. $handler->display->display_options['menu']['weight'] = '0';
  282. $handler->display->display_options['tab_options']['type'] = 'normal';
  283. $handler->display->display_options['tab_options']['title'] = 'Month';
  284. $handler->display->display_options['tab_options']['weight'] = '0';
  285. /* Display: Week */
  286. $handler = $view->new_display('page', 'Week', 'page_2');
  287. $handler->display->display_options['defaults']['pager'] = FALSE;
  288. $handler->display->display_options['pager']['type'] = 'date_views_pager';
  289. $handler->display->display_options['pager']['options']['date_id'] = 'week';
  290. $handler->display->display_options['pager']['options']['pager_position'] = 'top';
  291. $handler->display->display_options['pager']['options']['link_format'] = 'clean';
  292. $handler->display->display_options['defaults']['style_plugin'] = FALSE;
  293. $handler->display->display_options['style_plugin'] = 'calendar_style';
  294. $handler->display->display_options['style_options']['calendar_type'] = 'week';
  295. $handler->display->display_options['style_options']['name_size'] = '3';
  296. $handler->display->display_options['style_options']['mini'] = '0';
  297. $handler->display->display_options['style_options']['with_weekno'] = '0';
  298. $handler->display->display_options['style_options']['multiday_theme'] = '1';
  299. $handler->display->display_options['style_options']['groupby_times'] = 'hour';
  300. $handler->display->display_options['style_options']['theme_style'] = '1';
  301. $handler->display->display_options['style_options']['max_items'] = '0';
  302. $handler->display->display_options['defaults']['style_options'] = FALSE;
  303. $handler->display->display_options['defaults']['row_plugin'] = FALSE;
  304. $handler->display->display_options['row_plugin'] = 'calendar_entity';
  305. $handler->display->display_options['defaults']['row_options'] = FALSE;
  306. $handler->display->display_options['defaults']['arguments'] = FALSE;
  307. /* Contextual filter: Date */
  308. $handler->display->display_options['arguments']['date_argument']['id'] = 'date_argument';
  309. $handler->display->display_options['arguments']['date_argument']['table'] = $base_table;
  310. $handler->display->display_options['arguments']['date_argument']['field'] = 'date_argument';
  311. $handler->display->display_options['arguments']['date_argument']['default_action'] = 'default';
  312. $handler->display->display_options['arguments']['date_argument']['default_argument_type'] = 'date';
  313. $handler->display->display_options['arguments']['date_argument']['default_argument_skip_url'] = 0;
  314. $handler->display->display_options['arguments']['date_argument']['summary']['format'] = 'default_summary';
  315. $handler->display->display_options['arguments']['date_argument']['year_range'] = '-3:+3';
  316. $handler->display->display_options['arguments']['date_argument']['granularity'] = 'week';
  317. $handler->display->display_options['arguments']['date_argument']['add_delta'] = 'yes';
  318. $handler->display->display_options['arguments']['date_argument']['date_fields'] = $aliases;
  319. $handler->display->display_options['arguments']['date_argument']['date_method'] = 'OR';
  320. $handler->display->display_options['arguments']['date_argument']['date_group'] = 'date';
  321. $handler->display->display_options['path'] = $path . '/week';
  322. $handler->display->display_options['menu']['title'] = 'Week';
  323. $handler->display->display_options['menu']['weight'] = '2';
  324. /* Display: Day */
  325. $handler = $view->new_display('page', 'Day', 'page_3');
  326. $handler->display->display_options['defaults']['pager'] = FALSE;
  327. $handler->display->display_options['pager']['type'] = 'date_views_pager';
  328. $handler->display->display_options['pager']['options']['date_id'] = 'day';
  329. $handler->display->display_options['pager']['options']['pager_position'] = 'top';
  330. $handler->display->display_options['pager']['options']['link_format'] = 'clean';
  331. $handler->display->display_options['defaults']['style_plugin'] = FALSE;
  332. $handler->display->display_options['style_plugin'] = 'calendar_style';
  333. $handler->display->display_options['style_options']['calendar_type'] = 'day';
  334. $handler->display->display_options['style_options']['name_size'] = '3';
  335. $handler->display->display_options['style_options']['mini'] = '0';
  336. $handler->display->display_options['style_options']['with_weekno'] = '0';
  337. $handler->display->display_options['style_options']['multiday_theme'] = '1';
  338. $handler->display->display_options['style_options']['theme_style'] = '1';
  339. $handler->display->display_options['style_options']['max_items'] = '0';
  340. $handler->display->display_options['style_options']['groupby_times'] = 'hour';
  341. $handler->display->display_options['defaults']['style_options'] = FALSE;
  342. $handler->display->display_options['defaults']['row_plugin'] = FALSE;
  343. $handler->display->display_options['row_plugin'] = 'calendar_entity';
  344. $handler->display->display_options['defaults']['row_options'] = FALSE;
  345. $handler->display->display_options['defaults']['arguments'] = FALSE;
  346. /* Contextual filter: Date */
  347. $handler->display->display_options['arguments']['date_argument']['id'] = 'date_argument';
  348. $handler->display->display_options['arguments']['date_argument']['table'] = $base_table;
  349. $handler->display->display_options['arguments']['date_argument']['field'] = 'date_argument';
  350. $handler->display->display_options['arguments']['date_argument']['default_action'] = 'default';
  351. $handler->display->display_options['arguments']['date_argument']['default_argument_type'] = 'date';
  352. $handler->display->display_options['arguments']['date_argument']['default_argument_skip_url'] = 0;
  353. $handler->display->display_options['arguments']['date_argument']['summary']['format'] = 'default_summary';
  354. $handler->display->display_options['arguments']['date_argument']['year_range'] = '-3:+3';
  355. $handler->display->display_options['arguments']['date_argument']['granularity'] = 'day';
  356. $handler->display->display_options['arguments']['date_argument']['add_delta'] = '';
  357. $handler->display->display_options['arguments']['date_argument']['date_fields'] = $aliases;
  358. $handler->display->display_options['arguments']['date_argument']['date_method'] = 'OR';
  359. $handler->display->display_options['arguments']['date_argument']['date_group'] = 'date';
  360. $handler->display->display_options['path'] = $path . '/day';
  361. $handler->display->display_options['menu']['title'] = 'Day';
  362. $handler->display->display_options['menu']['weight'] = '3';
  363. /* Display: Year */
  364. $handler = $view->new_display('page', 'Year', 'page');
  365. $handler->display->display_options['defaults']['pager'] = FALSE;
  366. $handler->display->display_options['pager']['type'] = 'date_views_pager';
  367. $handler->display->display_options['pager']['options']['date_id'] = 'year';
  368. $handler->display->display_options['pager']['options']['pager_position'] = 'top';
  369. $handler->display->display_options['pager']['options']['link_format'] = 'clean';
  370. $handler->display->display_options['defaults']['style_plugin'] = FALSE;
  371. $handler->display->display_options['style_plugin'] = 'calendar_style';
  372. $handler->display->display_options['style_options']['calendar_type'] = 'year';
  373. $handler->display->display_options['style_options']['name_size'] = '1';
  374. $handler->display->display_options['style_options']['mini'] = '0';
  375. $handler->display->display_options['style_options']['with_weekno'] = '0';
  376. $handler->display->display_options['style_options']['multiday_theme'] = '1';
  377. $handler->display->display_options['style_options']['theme_style'] = '1';
  378. $handler->display->display_options['style_options']['max_items'] = '0';
  379. $handler->display->display_options['defaults']['style_options'] = FALSE;
  380. $handler->display->display_options['defaults']['row_plugin'] = FALSE;
  381. $handler->display->display_options['row_plugin'] = 'calendar_entity';
  382. $handler->display->display_options['defaults']['row_options'] = FALSE;
  383. $handler->display->display_options['defaults']['arguments'] = FALSE;
  384. /* Contextual filter: Date */
  385. $handler->display->display_options['arguments']['date_argument']['id'] = 'date_argument';
  386. $handler->display->display_options['arguments']['date_argument']['table'] = $base_table;
  387. $handler->display->display_options['arguments']['date_argument']['field'] = 'date_argument';
  388. $handler->display->display_options['arguments']['date_argument']['default_action'] = 'default';
  389. $handler->display->display_options['arguments']['date_argument']['default_argument_type'] = 'date';
  390. $handler->display->display_options['arguments']['date_argument']['default_argument_skip_url'] = 0;
  391. $handler->display->display_options['arguments']['date_argument']['summary']['format'] = 'default_summary';
  392. $handler->display->display_options['arguments']['date_argument']['year_range'] = '-3:+3';
  393. $handler->display->display_options['arguments']['date_argument']['granularity'] = 'year';
  394. $handler->display->display_options['arguments']['date_argument']['add_delta'] = 'yes';
  395. $handler->display->display_options['arguments']['date_argument']['date_fields'] = $aliases;
  396. $handler->display->display_options['arguments']['date_argument']['date_method'] = 'OR';
  397. $handler->display->display_options['arguments']['date_argument']['date_group'] = 'date';
  398. $handler->display->display_options['path'] = $path . '/year';
  399. $handler->display->display_options['menu']['title'] = 'Year';
  400. $handler->display->display_options['menu']['weight'] = '4';
  401. /* Display: Block */
  402. $handler = $view->new_display('block', 'Block', 'block_1');
  403. $handler->display->display_options['defaults']['pager'] = FALSE;
  404. $handler->display->display_options['pager']['type'] = 'date_views_pager';
  405. $handler->display->display_options['pager']['options']['date_id'] = 'mini';
  406. $handler->display->display_options['pager']['options']['pager_position'] = 'top';
  407. $handler->display->display_options['pager']['options']['link_format'] = 'clean';
  408. $handler->display->display_options['defaults']['style_plugin'] = FALSE;
  409. $handler->display->display_options['style_plugin'] = 'calendar_style';
  410. $handler->display->display_options['style_options']['calendar_type'] = 'month';
  411. $handler->display->display_options['style_options']['name_size'] = '1';
  412. $handler->display->display_options['style_options']['mini'] = '1';
  413. $handler->display->display_options['style_options']['with_weekno'] = '0';
  414. $handler->display->display_options['style_options']['multiday_theme'] = '1';
  415. $handler->display->display_options['style_options']['theme_style'] = '1';
  416. $handler->display->display_options['style_options']['max_items'] = '0';
  417. $handler->display->display_options['defaults']['style_options'] = FALSE;
  418. $handler->display->display_options['defaults']['row_plugin'] = FALSE;
  419. $handler->display->display_options['row_plugin'] = 'calendar_entity';
  420. $handler->display->display_options['defaults']['row_options'] = FALSE;
  421. $handler->display->display_options['defaults']['arguments'] = FALSE;
  422. /* Contextual filter: Date */
  423. $handler->display->display_options['arguments']['date_argument']['id'] = 'date_argument';
  424. $handler->display->display_options['arguments']['date_argument']['table'] = $base_table;
  425. $handler->display->display_options['arguments']['date_argument']['field'] = 'date_argument';
  426. $handler->display->display_options['arguments']['date_argument']['default_action'] = 'default';
  427. $handler->display->display_options['arguments']['date_argument']['default_argument_type'] = 'date';
  428. $handler->display->display_options['arguments']['date_argument']['default_argument_skip_url'] = 0;
  429. $handler->display->display_options['arguments']['date_argument']['summary']['format'] = 'default_summary';
  430. $handler->display->display_options['arguments']['date_argument']['year_range'] = '-3:+3';
  431. $handler->display->display_options['arguments']['date_argument']['granularity'] = 'month';
  432. $handler->display->display_options['arguments']['date_argument']['add_delta'] = 'yes';
  433. $handler->display->display_options['arguments']['date_argument']['date_fields'] = $aliases;
  434. $handler->display->display_options['arguments']['date_argument']['date_method'] = 'OR';
  435. $handler->display->display_options['arguments']['date_argument']['date_group'] = 'date';
  436. if (module_exists('date_ical')) {
  437. /* Display: iCal */
  438. $handler = $view->new_display('feed', 'iCal', 'feed_1');
  439. $handler->display->display_options['pager']['type'] = 'some';
  440. $handler->display->display_options['style_plugin'] = 'date_ical';
  441. $handler->display->display_options['row_plugin'] = 'date_ical';
  442. $handler->display->display_options['row_options']['date_field'] = $alias;
  443. $handler->display->display_options['defaults']['filters'] = FALSE;
  444. /* Filter criterion: Content: Published */
  445. switch ($base_table) {
  446. case 'node':
  447. $handler->display->display_options['filters']['status']['id'] = 'status';
  448. $handler->display->display_options['filters']['status']['table'] = $base_table;
  449. $handler->display->display_options['filters']['status']['field'] = 'status';
  450. $handler->display->display_options['filters']['status']['value'] = 1;
  451. $handler->display->display_options['filters']['status']['group'] = 0;
  452. $handler->display->display_options['filters']['status']['expose']['operator'] = FALSE;
  453. break;
  454. }
  455. /* Filter criterion: Date */
  456. $handler->display->display_options['filters']['date_filter']['id'] = 'date_filter';
  457. $handler->display->display_options['filters']['date_filter']['table'] = $base_table;
  458. $handler->display->display_options['filters']['date_filter']['field'] = 'date_filter';
  459. $handler->display->display_options['filters']['date_filter']['operator'] = '>=';
  460. $handler->display->display_options['filters']['date_filter']['granularity'] = 'day';
  461. $handler->display->display_options['filters']['date_filter']['form_type'] = 'date_select';
  462. $handler->display->display_options['filters']['date_filter']['default_date'] = 'now';
  463. $handler->display->display_options['filters']['date_filter']['default_to_date'] = '';
  464. $handler->display->display_options['filters']['date_filter']['year_range'] = '-3:+3';
  465. $handler->display->display_options['filters']['date_filter']['add_delta'] = 'yes';
  466. $handler->display->display_options['filters']['date_filter']['date_fields'] = $aliases;
  467. $handler->display->display_options['filters']['date_filter']['date_method'] = 'OR';
  468. $handler->display->display_options['filters']['date_filter']['date_group'] = 'date';
  469. $handler->display->display_options['path'] = $path . '/ical/%/calendar.ics';
  470. $handler->display->display_options['displays'] = array(
  471. 'page' => 'page',
  472. 'page_1' => 'page_1',
  473. 'page_2' => 'page_2',
  474. 'page_3' => 'page_3',
  475. 'block_1' => 'block_1',
  476. 'default' => 0,
  477. );
  478. } // End if module_exists()
  479. /* Display: Upcoming */
  480. $handler = $view->new_display('block', 'Upcoming', 'block_2');
  481. $handler->display->display_options['display_description'] = 'Upcoming events block';
  482. $handler->display->display_options['defaults']['pager'] = FALSE;
  483. $handler->display->display_options['pager']['type'] = 'some';
  484. $handler->display->display_options['pager']['options']['items_per_page'] = '5';
  485. $handler->display->display_options['pager']['options']['offset'] = '0';
  486. $handler->display->display_options['defaults']['style_plugin'] = FALSE;
  487. $handler->display->display_options['style_plugin'] = 'list';
  488. $handler->display->display_options['defaults']['style_options'] = FALSE;
  489. $handler->display->display_options['defaults']['row_plugin'] = FALSE;
  490. $handler->display->display_options['row_plugin'] = 'fields';
  491. $handler->display->display_options['row_options']['links'] = 1;
  492. $handler->display->display_options['row_options']['comments'] = 0;
  493. $handler->display->display_options['defaults']['row_options'] = FALSE;
  494. $handler->display->display_options['defaults']['filters'] = FALSE;
  495. /* Filter criterion: Content: Published */
  496. switch ($base_table) {
  497. case 'node':
  498. $handler->display->display_options['filters']['status']['id'] = 'status';
  499. $handler->display->display_options['filters']['status']['table'] = $base_table;
  500. $handler->display->display_options['filters']['status']['field'] = 'status';
  501. $handler->display->display_options['filters']['status']['value'] = 1;
  502. $handler->display->display_options['filters']['status']['group'] = 0;
  503. $handler->display->display_options['filters']['status']['expose']['operator'] = FALSE;
  504. break;
  505. }
  506. /* Filter criterion: Date */
  507. $handler->display->display_options['filters']['date_filter']['id'] = 'date_filter';
  508. $handler->display->display_options['filters']['date_filter']['table'] = $base_table;
  509. $handler->display->display_options['filters']['date_filter']['field'] = 'date_filter';
  510. $handler->display->display_options['filters']['date_filter']['operator'] = '>=';
  511. $handler->display->display_options['filters']['date_filter']['granularity'] = 'day';
  512. $handler->display->display_options['filters']['date_filter']['form_type'] = 'date_select';
  513. $handler->display->display_options['filters']['date_filter']['default_date'] = 'now';
  514. $handler->display->display_options['filters']['date_filter']['default_to_date'] = '';
  515. $handler->display->display_options['filters']['date_filter']['year_range'] = '-3:+3';
  516. $handler->display->display_options['filters']['date_filter']['add_delta'] = 'yes';
  517. $handler->display->display_options['filters']['date_filter']['date_fields'] = $aliases;
  518. $handler->display->display_options['filters']['date_filter']['date_method'] = 'OR';
  519. $handler->display->display_options['filters']['date_filter']['date_group'] = 'date';
  520. $translatables[$name] = array(
  521. t('Master'),
  522. t($name),
  523. t('more'),
  524. t('Apply'),
  525. t('Reset'),
  526. t('Sort by'),
  527. t('Asc'),
  528. t('Desc'),
  529. t('Year'),
  530. t('All'),
  531. t('Month'),
  532. t('Week'),
  533. t('Day'),
  534. t('Block'),
  535. t('iCal'),
  536. t('Upcoming'),
  537. t('Upcoming events block'),
  538. );
  539. return $view;
  540. }