You are here

function references_dialog_get_applicable_views in References dialog 7

1 call to references_dialog_get_applicable_views()
references_dialog_get_search_views in ./references_dialog.module
Get all search views that are available for a particular attachable.

File

./references_dialog.module, line 153
This the main module file.

Code

function references_dialog_get_applicable_views() {
  $references_dialog_views =& drupal_static(__FUNCTION__, FALSE);
  if (!$references_dialog_views) {
    $references_dialog_views = cache_get('references_dialog_views');
    $references_dialog_views = !empty($references_dialog_views) ? $references_dialog_views->data : FALSE;
  }
  if (!empty($references_dialog_views)) {
    return $references_dialog_views;
  }
  $references_dialog_views = array();

  // Get all references_dialog_views that has a references_dialog display.
  $results = views_get_applicable_views('references_dialog display');
  foreach ($results as $result) {
    list($view, $display) = $result;
    if (is_object($view)) {
      $references_dialog_views[$view->name][$display] = array(
        'display' => $display,
        'title' => isset($view->display[$view->current_display]->display_options['title']) ? $view->display[$view->current_display]->display_options['title'] : t('Search'),
        'attachables' => $view->display_handler
          ->get_option('attach'),
      );
    }
  }
  cache_set('references_dialog_views', $references_dialog_views);
  return $references_dialog_views;
}