You are here

function calendar_add_items in Calendar 5

Call hooks in other modules to add other items to a calendar view.

Parameters

object $view:

string $type - display type, 'table', 'teasers', 'nodes', 'list', 'calendar':

Return value

array of additional items to add.

4 calls to calendar_add_items()
theme_calendar_view_calendar in ./calendar.theme
Calendar Views plugin theme, overrides default views theme to create a calendar view.
theme_calendar_view_list in ./calendar.theme
Display the nodes of a view as a list.
theme_calendar_view_nodes in ./calendar.theme
Display the nodes of a view as plain nodes.
theme_calendar_view_table in ./calendar.theme
Display the nodes of a view as a table.

File

./calendar.module, line 90
Adds calendar filtering and displays to Views.

Code

function calendar_add_items($view, $type) {
  $new_items = array();
  foreach (module_implements('calendar_add_items') as $module) {
    $function = $module . '_calendar_add_items';
    if (function_exists($function)) {
      $feeds = $function($view);

      // Calendar items are just added as objects, themeing will be done by the calendar api.
      // For other types, theme the items and add them.
      foreach ($feeds as $feed) {
        if ($type == 'calendar') {
          $new_items[] = $feed;
        }
        else {
          switch ($type) {
            case 'table':
              $output = array(
                'data' => array(
                  theme('calendar_node_month', $feed),
                ),
              );
              break;
            case 'nodes':
            case 'teasers':
            case 'list':
              $output = theme('calendar_node_day', $feed);
              break;
          }
          if (!empty($output)) {
            $new_items[] = $output;
          }
        }
      }
    }
  }
  return $new_items;
}