You are here

function biblio_citeproc_style_manager_form_submit in Bibliography Module 6.2

Same name and namespace in other branches
  1. 7 modules/CiteProc/biblio_citeproc.admin.inc \biblio_citeproc_style_manager_form_submit()
  2. 7.2 modules/CiteProc/biblio_citeproc.admin.inc \biblio_citeproc_style_manager_form_submit()

File

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

Code

function biblio_citeproc_style_manager_form_submit($form, &$form_state) {
  if ($form_state['clicked_button']['#value'] == '<--' && count($form_state['values']['available_styles'])) {
    if (!($style_zip_file = variable_get('biblio_citeproc_styles_zip_file', FALSE))) {
      $style_zip_file = _get_zip_from_github();
    }
    if (!$style_zip_file) {
      form_set_error('<--', t('Could not get the style files from GitHub'));
    }
    $selected = $form_state['values']['available_styles'];
    _install_selected_from_zip($style_zip_file, $selected);
  }
  if ($form_state['clicked_button']['#value'] == '-->' && count($form_state['values']['installed_styles'])) {
    foreach ($form_state['values']['installed_styles'] as $id) {
      db_query("DELETE FROM {biblio_citeproc_styles} WHERE filename = '%s'", $id);
    }
  }
  if ($form_state['clicked_button']['#value'] == t('Set as site default') && count($form_state['values']['installed_styles'])) {
    $def = array_shift($form_state['values']['installed_styles']);
    variable_set('biblio_citeproc_style', $def);
  }
  if ($form_state['clicked_button']['#value'] == t('Edit selected') && count($form_state['values']['installed_styles'])) {
    $style = array_shift($form_state['values']['installed_styles']);
    $dest = drupal_get_destination();
    drupal_goto('admin/settings/biblio/citeproc/styles/' . $style . '/edit');
  }
  if ($form_state['clicked_button']['#value'] == t('Install all')) {
    $batch_op = array(
      'title' => t('Importing all styles from GitHub repository'),
      'operations' => array(
        array(
          '_get_zip_from_github',
          array(),
        ),
        array(
          '_install_from_zip',
          array(),
        ),
      ),
      'progressive' => TRUE,
      'finished' => '_csl_import_batch_finished',
      'init_message' => t('Downloading file...'),
      'progress_message' => t('Saving styles...'),
      'file' => './' . drupal_get_path('module', 'biblio_citeproc') . '/biblio_citeproc.admin.inc',
    );
    batch_set($batch_op);
    batch_process('admin/settings/biblio/styles');
  }
}