You are here

function biblio_citeproc_style_manager_form_submit in Bibliography Module 7.2

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

File

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

Code

function biblio_citeproc_style_manager_form_submit($form, &$form_state) {
  if ($form_state['clicked_button']['#value'] == '<--' && count($form_state['values']['avialable_styles'])) {
    module_load_include('php', 'biblio_citeproc', '/Github/Autoloader');
    Github_Autoloader::register();
    $github = new Github_Client();
    foreach ($form_state['values']['avialable_styles'] as $sha) {
      $csl = $github
        ->getObjectApi()
        ->getRawData('citation-style-language', 'styles', $sha);
      _install_csl($form_state['values']['remote_names'][$sha], $csl, $sha);
    }
  }
  if ($form_state['clicked_button']['#value'] == '-->' && count($form_state['values']['installed_styles'])) {
    foreach ($form_state['values']['installed_styles'] as $id) {
      db_delete('biblio_citeproc_styles')
        ->condition('filename', $id)
        ->execute();
    }
  }
  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/config/content/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/config/content/biblio/styles');
  }
  if ($form_state['clicked_button']['#value'] == t('Import')) {
  }
}