You are here

function _uuid_link_autocomplete_node in UUID Link 6

Callback for auto completing node links.

Parameters

string $string: The partial string to auto complete.

Return value

array An associative array of uuid => title.

1 call to _uuid_link_autocomplete_node()
uuid_link_autocomplete in ./uuid_link.module
Autocomplete callback for entities.

File

./uuid_link.module, line 310
Provides a filter and UI for adding links to entities that are not affected by changes in URL alias.

Code

function _uuid_link_autocomplete_node($string) {
  $matches = array();
  $query = "SELECT DISTINCT(uu.uuid), title, language FROM {node} n INNER JOIN {uuid_node} u ON n.nid = u.nid";
  $query .= " WHERE n.title LIKE '%s%%'";

  // Only search for published nodes.
  $query .= " AND n.status = 1";
  $query .= " ORDER BY n.title";
  $result = db_query_range(db_rewrite_sql($query), $string, 0, 15);
  while ($row = db_fetch_object($result)) {

    // If content is language specific show language code.
    if (!empty($row->language)) {
      $matches[$row->uuid] = t('[@language] @label', array(
        '@language' => $row->language,
        '@label' => $row->title,
      ));
    }
    else {
      $matches[$row->uuid] = check_plain($row->title);
    }
  }
  return $matches;
}