You are here

function apachesolr_vocab_name in Apache Solr Search 6.3

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 apachesolr.index.inc \apachesolr_vocab_name()
  4. 6.2 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_term_indexing_callback in ./apachesolr.index.inc
Callback that converts term field into an array

File

./apachesolr.index.inc, line 999
Functions related to Apache Solr indexing operations.

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 = '%s'", array(
      $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];
}