You are here

function autocomplete_deluxe_taxonomy_implode_tags in Autocomplete Deluxe 7.2

Same name and namespace in other branches
  1. 7 autocomplete_deluxe.module \autocomplete_deluxe_taxonomy_implode_tags()

Implodes the tags from the taxonomy module.

This function is essentially the same as taxonomy_implode_tags, with the difference, that it uses only a comma instead of a comma and a space to implode the tags. It will help keep problems with delimiters to a minimum.

1 call to autocomplete_deluxe_taxonomy_implode_tags()
autocomplete_deluxe_field_widget_form in ./autocomplete_deluxe.module
Implements hook_field_widget_form().

File

./autocomplete_deluxe.module, line 237
Define enhanced autocomplete wdiget.

Code

function autocomplete_deluxe_taxonomy_implode_tags($tags, $vid = NULL) {
  $typed_tags = array();
  foreach ($tags as $tag) {

    // Extract terms belonging to the vocabulary in question.
    if (!isset($vid) || $tag->vid == $vid) {

      // Make sure we have a completed loaded taxonomy term.
      if (isset($tag->name)) {

        // Commas and quotes in tag names are special cases, so encode 'em.
        if (strpos($tag->name, ',') !== FALSE || strpos($tag->name, '"') !== FALSE) {
          $tag->name = '"' . str_replace('"', '""', $tag->name) . '"';
        }
        $typed_tags[] = $tag->name;
      }
    }
  }
  return implode(',', $typed_tags);
}