You are here

function biblio_citeproc_load_csl in Bibliography Module 7

1 call to biblio_citeproc_load_csl()
theme_biblio_citeproc_style in modules/CiteProc/biblio_citeproc.module

File

modules/CiteProc/biblio_citeproc.module, line 96

Code

function biblio_citeproc_load_csl($csl_id) {
  $csl_file_contents = '';

  // Try to convert old style names to csl...
  if (strpos($csl_id, '.csl') === FALSE) {
    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_query('SELECT parent,csl FROM {biblio_citeproc_styles} WHERE filename = :id', array(
      ':id' => $csl_id,
    ))
      ->fetchObject();
    if (!isset($csl->csl)) {
      drupal_set_message(t('Biblio-CiteProc could not fetch the style file: @csl_id from the database. Check your CiteProc settings.', array(
        '@csl_id' => $csl_id,
      )), 'error');
      return;
    }
    if (!empty($csl->parent)) {
      $csl_file_contents = db_query("SELECT csl FROM {biblio_citeproc_styles} WHERE id = :id", array(
        ':id' => $csl->parent,
      ))
        ->fetchField();
    }
    else {
      $csl_file_contents = $csl->csl;
    }
  }
  return $csl_file_contents;
}