You are here

function biblio_citeproc_csl_editor in Bibliography Module 7

Same name and namespace in other branches
  1. 6.2 modules/CiteProc/biblio_citeproc.admin.inc \biblio_citeproc_csl_editor()
  2. 7.2 modules/CiteProc/biblio_citeproc.admin.inc \biblio_citeproc_csl_editor()
1 string reference to 'biblio_citeproc_csl_editor'
biblio_citeproc_menu in modules/CiteProc/biblio_citeproc.module

File

modules/CiteProc/biblio_citeproc.admin.inc, line 627

Code

function biblio_citeproc_csl_editor($form, &$form_state, $style) {
  $csl = db_query('SELECT id,parent,csl FROM {biblio_citeproc_styles} WHERE filename = :id', array(
    ':id' => $style,
  ))
    ->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' => $style,
    )), 'error');
    return;
  }
  if (!empty($csl->parent)) {
    $csl = db_query("SELECT id,csl FROM {biblio_citeproc_styles} WHERE id = :id", array(
      ':id' => $csl->parent,
    ))
      ->fetchObject();
  }
  if (isset($csl->csl)) {
    $csl_file_contents = $csl->csl;
  }
  $form['editor'] = array(
    '#title' => t('Editing %style', array(
      '%style' => $style,
    )),
    '#type' => 'text_format',
    '#rows' => 40,
    '#format' => 'csl',
    '#default_value' => $csl_file_contents,
  );
  $form['save'] = array(
    '#value' => t('Save'),
    '#type' => 'submit',
  );
  $form['cancel'] = array(
    '#value' => t('Cancel'),
    '#type' => 'submit',
  );
  $form['style'] = array(
    '#value' => $style,
    '#type' => 'hidden',
  );
  $form['id'] = array(
    '#value' => $csl->id,
    '#type' => 'hidden',
  );
  return $form;
}