You are here

function finder_ui_views in Finder 7.2

Get an array of views.

Parameters

$append_id: Whether to append the id to the returned display names.

$filter: A list of IDs in the format view_name:display_key to restrict results by.

$full: If TRUE will return all the data, rather than just the title.

$string: String to match against the title to filter results by.

$exact_string: If TRUE the $string parameter must match exactly.

$long_key: If TRUE will key array by the title and ID, not just the ID.

Return value

The array of views.

1 call to finder_ui_views()
finder_ui_form in modules/finder_ui/includes/finder.inc
Form handler callback for finder_ui plugin.

File

modules/finder_ui/includes/common.inc, line 50
common.inc

Code

function finder_ui_views($append_id = FALSE, $filter = NULL, $full = FALSE, $string = '', $exact_string = FALSE, $long_key = FALSE) {
  $views = array();
  $loaded_views = views_get_all_views();
  $filter = $filter ? array_filter($filter) : NULL;
  $finder_views = array(
    'finder_node',
    'finder_user',
  );
  $finder_group = t('Finder Views');
  foreach ((array) $loaded_views as $view_name => $view) {
    foreach ((array) $view->display as $display_key => $display) {

      // Skip this one if it's a 'default' view.
      if ($display_key != 'default') {
        $id = $view_name . ':' . $display_key;

        // Skip this one if it's not 'allowed'.
        if (empty($filter) || in_array($id, $filter)) {

          // Get display title.
          $display_title = finder_ui_views_title($view, $view_name, $display_key, $append_id);

          // Determine whether and what to return.
          $key = $long_key ? $display_title . ($append_id ? '' : ' [' . $id . ']') : $id;
          $type = in_array($view_name, $finder_views) ? $finder_group : ($view->type == 'default' ? t('default Views') : t('Custom Views'));
          if ($string) {
            if (!$exact_string && (stripos($display_title, $string) !== FALSE || stripos($key, $string) !== FALSE)) {
              $views[$type][$key] = $full ? $display : $display_title;
            }
            elseif ($display_title == $string) {
              $views[$type][$key] = $full ? $display : $display_title;
            }
          }
          else {
            $views[$type][$key] = $full ? $display : $display_title;
          }
        }
      }
    }
  }
  if (isset($views[$finder_group])) {
    $finder_views = array(
      $finder_group => $views[$finder_group],
    );
    unset($views[$finder_group]);
    $views = $finder_views + $views;
  }
  asort($views['Custom Views']);
  return $views;
}