You are here

function apachesolr_vocab_name in Apache Solr Search 6.2

Same name and namespace in other branches
  1. 8 apachesolr.index.inc \apachesolr_vocab_name()
  2. 5.2 apachesolr.index.inc \apachesolr_vocab_name()
  3. 6.3 apachesolr.index.inc \apachesolr_vocab_name()
  4. 6 apachesolr.index.inc \apachesolr_vocab_name()
  5. 7 apachesolr.index.inc \apachesolr_vocab_name()

Helper function - return a safe (PHP identifier) vocabulary name.

1 call to apachesolr_vocab_name()
apachesolr_add_taxonomy_to_document in ./apachesolr.index.inc
Extract taxonomy from $node and add to dynamic fields.

File

./apachesolr.index.inc, line 262
Functions used when indexing content to Apache Solr.

Code

function apachesolr_vocab_name($vid) {
  static $names = array();
  if (!isset($names[$vid])) {
    $vocab_name = db_result(db_query('SELECT v.name FROM {vocabulary} v WHERE v.vid = %d', $vid));
    $names[$vid] = preg_replace('/[^a-zA-Z0-9_\\x7f-\\xff]/', '_', $vocab_name);

    // Fallback for names ending up all as '_'.
    $check = rtrim($names[$vid], '_');
    if (!$check) {
      $names[$vid] = '_' . $vid . '_';
    }
  }
  return $names[$vid];
}