You are here

function views_ui_autocomplete_tag in Views (for Drupal 7) 6.3

Same name and namespace in other branches
  1. 8.3 views_ui/admin.inc \views_ui_autocomplete_tag()
  2. 6.2 includes/admin.inc \views_ui_autocomplete_tag()
  3. 7.3 includes/admin.inc \views_ui_autocomplete_tag()

Page callback for views tag autocomplete

1 string reference to 'views_ui_autocomplete_tag'
views_ui_menu in ./views_ui.module

File

includes/admin.inc, line 3818
admin.inc Provides the Views' administrative interface.

Code

function views_ui_autocomplete_tag($string = '') {
  $matches = array();

  // get matches from default views:
  views_include('view');
  $views = views_discover_default_views();
  foreach ($views as $view) {
    if (!empty($view->tag) && strpos($view->tag, $string) === 0) {
      $matches[$view->tag] = $view->tag;
    }
  }
  if ($string) {
    $result = db_query_range("SELECT DISTINCT tag FROM {views_view} WHERE LOWER(tag) LIKE LOWER('%s%%')", $string, 0, 10 - count($matches));
    while ($view = db_fetch_object($result)) {
      $matches[$view->tag] = check_plain($view->tag);
    }
  }
  drupal_json($matches);
}