You are here

function theme_biblio_citeproc_style in Bibliography Module 6.2

Same name and namespace in other branches
  1. 7 modules/CiteProc/biblio_citeproc.module \theme_biblio_citeproc_style()
  2. 7.2 modules/CiteProc/biblio_citeproc.module \theme_biblio_citeproc_style()
1 call to theme_biblio_citeproc_style()
biblio_citeproc_example_citation in modules/CiteProc/biblio_citeproc.admin.inc
1 string reference to 'theme_biblio_citeproc_style'
biblio_citeproc_theme in modules/CiteProc/biblio_citeproc.module

File

modules/CiteProc/biblio_citeproc.module, line 64

Code

function theme_biblio_citeproc_style($node, $base = 'biblio', $style_name = NULL, $inline = false) {
  static $citeproc;
  global $language;
  $cached = NULL;
  module_load_include('inc', 'biblio_citeproc', 'CSL');
  if (!$citeproc) {
    $csl_id = $style_name ? $style_name : biblio_get_style();
    if (strpos($csl_id, '.csl') === FALSE) {

      // try to convert old style names to csl...
      if (in_array($csl_id, array(
        'ama',
        'apa',
        'cse',
        'ieee',
        'mla',
        'vancouver',
      ))) {
        $csl_id .= '.csl';
      }
      elseif ($csl_id == 'chicago') {
        $csl_id = 'chicago-fullnote-bibliography.csl';
      }
      else {
        $csl_id = '';
        $message = t('An invalid style "@style" was selected, please check your "CiteProc" style settings.', array(
          '@style' => $csl_id,
        ));
        drupal_set_message($message, 'error');
      }
    }
    if (!empty($csl_id)) {
      $csl = db_fetch_object(db_query("SELECT parent,csl FROM {biblio_citeproc_styles} WHERE filename = '%s'", $csl_id));
      if (!isset($csl->csl)) {
        drupal_set_message(t('Biblio-CiteProc could not fetch the style file: @csl_id from the database.', array(
          '@csl_id' => $csl_id,
        )), 'error');
        return;
      }
      if (!empty($csl->parent)) {
        $csl_file_contents = db_result(db_query("SELECT csl FROM {biblio_citeproc_styles} WHERE id = '%s'", $csl->parent));
        if (!$csl_file_contents) {
          drupal_set_message(t('Biblio-CiteProc could not fetch the parent style file: @csl_id from the database.', array(
            '@csl_id' => $csl->parent,
          )), 'error');
          return;
        }
      }
      else {
        $csl_file_contents = $csl->csl;
      }

      //    $cslid = $csl_file_name . '-' . $language->language;
      //    $cached = cache_get($cslid, 'cache_biblio_csl_object');
      if (!$cached) {
        $citeproc = new citeproc($csl_file_contents, $language->language);

        //      cache_set($cslid, $citeproc, 'cache_biblio_csl_object');
      }
      else {
        $citeproc = $cached->data;
      }
    }
  }
  $styled_node = $citeproc
    ->render($node);
  return $styled_node . filter_xss($node->biblio_coins, array(
    'span',
  ));
}