drupal_explode_tags

Хочешь помочь с переводом? Это очень просто и быстро. Лишь зарегистрируйся, и можешь тут же начать переводить.

includes/common.inc, строка 3602

Версии
6
drupal_explode_tags($tags)

Преобразует строку с тегами в массив.

▾ 5 функции вызывают drupal_explode_tags()

comment_unpublish_by_keyword_action_submit in modules/comment/comment.module
Process comment_unpublish_by_keyword_action_form form submissions.
node_unpublish_by_keyword_action_submit in modules/node/node.module
taxonomy_autocomplete in modules/taxonomy/taxonomy.pages.inc
Вспомогательная функция для автозаполнения формы с терминами таксономии
taxonomy_link in modules/taxonomy/taxonomy.module
Реализация hook_link().
taxonomy_node_save in modules/taxonomy/taxonomy.module
Сохраняет связи термина для заданной ноды.

Код

<?php
function drupal_explode_tags($tags) {
  // This regexp allows the following types of user input:
  // this, "somecompany, llc", "and ""this"" w,o.rks", foo bar
  $regexp = '%(?:^|,\ *)("(?>[^"]*)(?>""[^"]* )*"|(?: [^",]*))%x';
  preg_match_all($regexp, $tags, $matches);
  $typed_tags = array_unique($matches[1]);

  $tags = array();
  foreach ($typed_tags as $tag) {
    // If a user has escaped a term (to demonstrate that it is a group,
    // or includes a comma or quote character), we remove the escape
    // formatting so to save the term into the database as the user intends.
    $tag = trim(str_replace('""', '"', preg_replace('/^"(.*)"$/', '\1', $tag)));
    if ($tag != "") {
      $tags[] = $tag;
    }
  }

  return $tags;
}
?>
Войдите или зарегистрируйтесь, чтобы получить возможность отправлять комментарии

Вход в систему