You are here

function _calendar_info in Calendar 5

Same name and namespace in other branches
  1. 5.2 calendar_admin.inc \_calendar_info()

Function to get information about all views that have calendar components.

Return value

array with views that use calendar plugins or have calendar arguments.

1 call to _calendar_info()
calendar_info in ./calendar.module
Function to get information about all views that have calendar components.

File

./calendar_admin.inc, line 32
This file contains administrative functions used only when setting up the calendar and views_hooks() that are called infrequently and cached. No need to parse all this code the rest of the time.

Code

function _calendar_info() {
  $cid = 'calendar_views';
  cache_clear_all($cid, 'cache_views');
  $calendar_views = array();
  $calendar_types = calendar_view_types();
  $result = db_query("SELECT vid, name FROM {view_view} ORDER BY name");
  while ($v = db_fetch_object($result)) {
    $view = views_get_view($v->vid);
    $additions = array();
    $additions['vid'] = $view->vid;
    $additions['name'] = $view->name;
    $additions['url'] = $view->url;
    $additions['args'] = array();
    $additions['page'] = array_key_exists($view->page_type, $calendar_types);
    $additions['block'] = array_key_exists($view->block_type, $calendar_types);
    foreach ((array) $view->argument as $delta => $argument) {
      if (in_array($argument['type'], calendar_args())) {
        $additions['args'][$delta] = $argument['id'];
      }
    }
    if (!empty($additions['args']) || $additions['page'] || $additions['block']) {
      $calendar_views[$view->name] = $additions;
    }
  }
  views_load_cache();
  foreach (_views_get_default_views() as $view) {
    if (empty($view->disabled)) {
      $additions = array();
      $additions['vid'] = $view->vid;
      $additions['name'] = $view->name;
      $additions['url'] = $view->url;
      $additions['args'] = array();
      $additions['page'] = array_key_exists($view->page_type, $calendar_types);
      $additions['block'] = array_key_exists($view->block_type, $calendar_types);
      foreach ((array) $view->argument as $delta => $argument) {
        if (in_array($argument['type'], calendar_args())) {
          $additions['args'][$delta] = $argument['id'];
        }
      }
      if (!empty($additions['args']) || $additions['page'] || $additions['block']) {
        $calendar_views[$view->name] = $additions;
      }
    }
  }
  cache_set($cid, 'cache_views', serialize($calendar_views));
  return $calendar_views;
}