You are here

function biblio_normalize_title in Bibliography Module 7

Same name and namespace in other branches
  1. 6.2 includes/biblio.util.inc \biblio_normalize_title()
  2. 7.2 includes/biblio.util.inc \biblio_normalize_title()
2 calls to biblio_normalize_title()
biblio_update_7009 in ./biblio.install
Populates the new "biblio_sort_title" column, which is used for title sorting.
_biblio_prepare_submit in ./biblio.module
Prepare a node for submit to database. Contains code common to insert and update.

File

includes/biblio.util.inc, line 10

Code

function biblio_normalize_title($title) {
  $stop_words = 'a,an,the,is,on';
  $stop_words = explode(',', variable_get('biblio_stop_words', $stop_words));
  if (!@preg_match('/\\pL/u', 'a')) {

    // Probably a broken PCRE library.
    $title = trim(_strip_punctuation($title));
  }
  else {

    // Unicode safe filter for the value.
    $title = trim(_strip_punctuation_utf8($title));
  }
  $title = trim(_strip_punctuation($title));
  if (function_exists('mb_regex_encoding')) {
    mb_regex_encoding("utf-8");
    $title_words = mb_split(' +', $title);
  }
  else {
    $title_words = explode(' ', $title);
  }
  while (array_search(drupal_strtolower($title_words[0]), $stop_words) !== FALSE) {
    array_shift($title_words);
  }
  return drupal_substr(implode(' ', $title_words), 0, 64);
}