You are here

function views_content_views_panes_content_type_content_types in Chaos Tool Suite (ctools) 6

Same name and namespace in other branches
  1. 7 views_content/plugins/content_types/views_panes.inc \views_content_views_panes_content_type_content_types()

Return all content types available.

File

views_content/plugins/content_types/views_panes.inc, line 23
Content type plugin to allow Views to be exposed as a display type, leaving most of the configuration on the view.

Code

function views_content_views_panes_content_type_content_types($plugin) {
  $types = array();

  // It can be fairly intensive to calculate this, so let's cache this in the
  // cache_views table. The nice thing there is that if views ever change, that
  // table will always be cleared. Except for the occasional default view, so
  // we must use the Views caching functions in order to respect Views caching
  // settings.
  views_include('cache');
  $data = views_cache_get('views_content_panes', TRUE);
  if (!empty($data->data)) {
    $types = $data->data;
  }
  if (empty($types)) {
    $types = array();
    $views = views_get_all_views();
    foreach ($views as $view) {
      if (!empty($view->disabled)) {
        continue;
      }
      $view
        ->init_display();
      foreach ($view->display as $id => $display) {
        if (empty($display->handler->panel_pane_display)) {
          continue;
        }
        $info = _views_content_panes_content_type($view, $display);
        if ($info) {
          $types[$view->name . '-' . $id] = $info;
        }
      }
      $view
        ->destroy();
    }
    views_cache_set('views_content_panes', $types, TRUE);
  }
  return $types;
}