You are here

function _context_contrib_get_views in Context 6.2

Same name and namespace in other branches
  1. 6 context_contrib/context_contrib.module \_context_contrib_get_views()

Helper function to generate a list of database and module provided views.

1 call to _context_contrib_get_views()
context_contrib_context_conditions in context_contrib/context_contrib.module
Implementation of hook_context_conditions().

File

context_contrib/context_contrib.module, line 150

Code

function _context_contrib_get_views() {
  $enabled_views = array();
  $views = views_get_all_views();

  // Sort the views so our list is nice and alphabetical:
  ksort($views);
  foreach ($views as $view) {
    if (!isset($views[$view->name]->disabled) || !$views[$view->name]->disabled) {
      $enabled_views[$view->name] = $view->name;

      // Provide more granular options for each page display
      $displays = array();
      foreach ($view->display as $id => $display) {
        if ($display->display_plugin == 'page') {
          $displays[$view->name . ":" . $id] = "-- {$display->display_title}";
        }
      }
      if (count($displays) > 1) {
        $enabled_views += $displays;
      }
    }
  }
  return $enabled_views;
}