You are here

function translation_node_autocomplete in Internationalization 5.2

Same name and namespace in other branches
  1. 5.3 translation/translation.module \translation_node_autocomplete()
  2. 5 translation/translation.module \translation_node_autocomplete()

Menu callback: autocomplete for selecting node translations

1 string reference to 'translation_node_autocomplete'
translation_menu in translation/translation.module
Implementation of hook_menu().

File

translation/translation.module, line 495

Code

function translation_node_autocomplete($lang = NULL, $string = NULL) {
  $languages = i18n_supported_languages();
  if ($lang && $string && in_array($lang, array_keys($languages))) {
    $matches = array();
    $result = db_query(db_rewrite_sql("SELECT n.nid, n.title FROM {node} n INNER JOIN {i18n_node} i ON n.nid = i.nid WHERE (LOWER(n.title) LIKE LOWER('%s%%') OR n.nid = %d) AND i.language = '%s'"), $string, $string, $lang);
    while ($nodelist = db_fetch_object($result)) {
      $title = check_plain($nodelist->title);
      $matches["{$nodelist->nid} - {$title}"] = "{$title} [nid={$nodelist->nid}]";
    }
    print drupal_to_js($matches);
  }
  exit;
}