You are here

function _fetch_possible_keywords in Glossify 6

Same name and namespace in other branches
  1. 6.3 glossify.module \_fetch_possible_keywords()

Helper function the possible keywords for a given configuration and nid.

2 calls to _fetch_possible_keywords()
glossify_filter in ./glossify.module
Implementation of hook_filter().
glossify_nodeapi in ./glossify.module
Implementation of hook_nodeapi().

File

./glossify.module, line 550

Code

function _fetch_possible_keywords($configuration, $nid) {
  $glossify_dict = array();
  $methods = array(
    "'title'",
  );
  if ($configuration['methods']['use_internal']) {
    $methods[] = "'internal'";
  }
  if ($configuration['methods']['use_cck']) {
    $methods[] = "'cck'";
  }
  if ($configuration['methods']['use_taxonomy']) {
    $methods[] = "'taxonomy'";
  }
  if ($configuration['language']) {
    $q = db_query("SELECT g.term, g.nid, g.alternate, g.language FROM {node} n INNER JOIN {glossify} g ON g.nid = n.nid WHERE g.language = n.language AND n.type IN (" . db_placeholders($configuration['to'], 'varchar') . ") AND g.nid != %d AND g.method IN (" . implode(', ', $methods) . ")", $configuration['to'], $nid);
  }
  else {
    $q = db_query("SELECT g.term, g.nid, g.alternate, g.language FROM {node} n INNER JOIN {glossify} g ON g.nid = n.nid WHERE n.type IN (" . db_placeholders($configuration['to'], 'varchar') . ") AND g.nid != %d AND g.method IN (" . implode(', ', $methods) . ")", $configuration['to'], $nid);
  }
  while ($r = db_fetch_array($q)) {
    if (!empty($r['alternate'])) {
      if (is_numeric($r['alternate'])) {
        $glossify_dict[$r['term']] = drupal_lookup_path('alias', 'node/' . $r['alternate'], $r['language']);
      }
      elseif ($path = drupal_lookup_path('alias', $r['alternate'], $r['language'])) {
        $glossify_dict[$r['term']] = $path;
      }
      else {
        $glossify_dict[$r['term']] = $r['alternate'];
      }
    }
    else {
      $glossify_dict[$r['term']] = drupal_lookup_path('alias', 'node/' . $r['nid'], $r['language']);
    }
  }
  return $glossify_dict;
}