vid; } $query = db_select('taxonomy_term_data', 't'); $query->addTag('translatable'); $query->addTag('term_access'); // Select rows that match by term name. $tags_return = $query ->fields('t', array('tid', 'name')) ->condition('t.vid', $vids) ->condition('t.name', '%' . db_like($typed) . '%', 'LIKE') ->range(0, 10) ->execute() ->fetchAllKeyed(); $term_matches = array(); foreach ($tags_return as $tid => $name) { $n = $name; // Term names containing commas or quotes must be wrapped in quotes. // if (strpos($name, ',') !== FALSE || strpos($name, '"') !== FALSE) { // $n = '"' . str_replace('"', '""', $name) . '"'; // } $term_matches[$n] = check_plain($name); } } drupal_json_output($term_matches); } function materiobase_search_autocomplete_searchapi($typed = ''){ // If the request has a '/' in the search text, then the menu system will have // split it into multiple arguments, recover the intended $tags_typed. $args = func_get_args(); $typed = implode('/', $args); /* TODO riche serach engine + \\ etc gmail like */ if ($typed != '') { $query = search_api_query('referencement'); $query_filter = $query->createFilter(); $query_filter->condition('name', $typed); // $query_filter->condition('type', 'article'); $query->filter($query_filter); $tags_return = $query->execute(); dsm($tags_return, '$tags_return'); $term_matches = array(); $index = search_api_index_load('referencement'); foreach ($index->loadItems(array_keys($tags_return['results'])) as $item) { dsm($item, '$item'); } // // foreach ($tags_return as $tid => $name) { // $n = $name; // // Term names containing commas or quotes must be wrapped in quotes. // // if (strpos($name, ',') !== FALSE || strpos($name, '"') !== FALSE) { // // $n = '"' . str_replace('"', '""', $name) . '"'; // // } // $term_matches[$n] = check_plain($name); // } } drupal_json_output($term_matches); }