calendar_ical.module 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. <?php
  2. /**
  3. * Implementation of hook_views_api().
  4. *
  5. * This one is used as the base to reduce errors when updating.
  6. */
  7. function calendar_ical_views_api() {
  8. return array(
  9. 'api' => 2,
  10. 'path' => drupal_get_path('module', 'calendar_ical'),
  11. );
  12. }
  13. /**
  14. * @file
  15. * Adds ical functionality to Calendar.
  16. */
  17. function calendar_ical_theme() {
  18. return array(
  19. 'calendar_ical_icon' => array(
  20. 'variables' => array('url'),
  21. ),
  22. );
  23. }
  24. function theme_calendar_ical_icon($vars) {
  25. $url = $vars['url'];
  26. $variables = array(
  27. 'path' => drupal_get_path('module', 'date_api') . '/images/ical16x16.gif',
  28. 'title' => t('Add to calendar'), t('Add to calendar'),
  29. );
  30. if ($image = theme('image', $variables)) {
  31. return '<div style="text-align:right"><a href="' . check_url($url) . '" class="ical-icon" title="ical">' . $image . '</a></div>';
  32. }
  33. }
  34. /**
  35. * Implements hook_entity_info_alter().
  36. *
  37. * Add an 'iCal' view mode for nodes, similar to RSS view mode.
  38. */
  39. function calendar_ical_entity_info_alter(&$info) {
  40. $info['node']['view modes'] += array(
  41. 'ical' => array(
  42. 'label' => t('iCal'),
  43. 'custom settings' => FALSE,
  44. ),
  45. );
  46. }
  47. /**
  48. * Implementation of hook_views_plugins
  49. */
  50. function calendar_ical_views_plugins() {
  51. $module_path = drupal_get_path('module', 'calendar_ical');
  52. module_load_include('inc', 'calendar_ical', 'theme.inc');
  53. $data = array(
  54. 'module' => 'calendar_ical', // This just tells our themes are elsewhere.
  55. 'style' => array(
  56. 'ical' => array(
  57. 'title' => t('DEPRECATED iCal Feed'),
  58. 'help' => t('Generates an iCal VCALENDAR feed from a view.'),
  59. 'handler' => 'calendar_plugin_style_ical',
  60. 'path' => "$module_path",
  61. 'theme' => 'calendar_style_ical',
  62. 'theme file' => 'theme.inc',
  63. 'theme path' => "$module_path",
  64. 'uses fields' => TRUE,
  65. 'uses grouping' => FALSE,
  66. 'uses row plugin' => TRUE,
  67. 'uses options' => TRUE,
  68. 'type' => 'feed',
  69. 'even empty' => TRUE,
  70. ),
  71. ),
  72. 'row' => array(
  73. 'ical_node' => array(
  74. 'title' => t('DEPRECATED iCal Fields'),
  75. 'help' => t('Display each node as an iCal VEVENT item.'),
  76. 'handler' => 'calendar_plugin_row_ical_node',
  77. 'path' => "$module_path",
  78. 'theme' => 'calendar_row_ical_node',
  79. 'theme file' => 'theme.inc',
  80. 'theme path' => "$module_path",
  81. 'base' => array('node'), // only works with 'node' as base.
  82. 'uses options' => TRUE,
  83. 'uses fields' => FALSE,
  84. 'type' => 'feed',
  85. ),
  86. ),
  87. );
  88. return $data;
  89. }