You are here

function search_autocomplete_views_autocomplete in Search Autocomplete 6.4

Same name and namespace in other branches
  1. 7.4 search_autocomplete.autocomplete.inc \search_autocomplete_views_autocomplete()

Autocomplete the view selection in admin.

The function does not return if the auto-complete feature worked. Otherwise, it returns NULL.

The user string so far

1 string reference to 'search_autocomplete_views_autocomplete'
search_autocomplete_menu in ./search_autocomplete.admin.inc
Implementation of hook_menu(). Create an administration page to access admin form

File

./search_autocomplete.autocomplete.inc, line 17
Function to compute the various autocomplete features.

Code

function search_autocomplete_views_autocomplete($user_input = '') {

  // anything yet?
  if (!$user_input) {
    echo drupal_to_js(array());
    exit;
  }

  // current user has the right to do that?!
  if (!user_access('access content')) {
    drupal_access_denied();
    return;
  }

  // Load all views.
  $views = views_get_all_views();

  // Select views with an according name
  $matches = array();
  foreach ($views as $view_id => $view) {
    if (strpos($view->human_name, $user_input) !== false) {
      $matches[$view_id] = $view->human_name;
    }
  }

  // Return the json inputs.
  echo drupal_to_js($matches);
  exit;
}