You are here

function _biblio_filter_reference_process in Bibliography Module 7

Same name and namespace in other branches
  1. 7.2 biblio.module \_biblio_filter_reference_process()
1 string reference to '_biblio_filter_reference_process'
biblio_filter_info in ./biblio.module

File

./biblio.module, line 2175
Bibliography Module for Drupal.

Code

function _biblio_filter_reference_process($text, $filter, $format, $langcode, $cache, $cache_id) {
  $pattern = array(
    '|\\[bib](.*?)\\[/bib]|s',
    '|<bib>(.*?)</bib>|s',
  );

  // This is used with footnote module integration to replace the <bib> tags with <fn> tags.
  if (variable_get('biblio_footnotes_integration', 0) && module_exists('footnotes')) {
    $text = preg_replace_callback($pattern, '_biblio_filter_footnote_callback', $text);
    return $text;
  }
  else {
    $text = preg_replace_callback($pattern, '_biblio_filter_replace_callback', $text);

    // Replace tag <footnotes> with the list of footnotes.
    // If tag is not present, by default add the footnotes at the end.
    // Thanks to acp on drupal.org for this idea. see http://drupal.org/node/87226
    $footer = '';
    $footer = _biblio_filter_replace_callback(NULL, 'output footer');
    if (preg_match('/<bibliography(\\/( )?)?>/', $text) > 0) {
      $text = preg_replace('/<bibliography(\\/( )?)?>/', $footer, $text, 1);
      return $text;
    }
    else {
      return $text . "\n\n" . $footer;
    }
  }
}