You are here

function _get_zip_from_github in Bibliography Module 6.2

Same name and namespace in other branches
  1. 7 modules/CiteProc/biblio_citeproc.admin.inc \_get_zip_from_github()
  2. 7.2 modules/CiteProc/biblio_citeproc.admin.inc \_get_zip_from_github()
2 calls to _get_zip_from_github()
biblio_citeproc_style_manager_form in modules/CiteProc/biblio_citeproc.admin.inc
biblio_citeproc_style_manager_form_submit in modules/CiteProc/biblio_citeproc.admin.inc
1 string reference to '_get_zip_from_github'
biblio_citeproc_style_manager_form_submit in modules/CiteProc/biblio_citeproc.admin.inc

File

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

Code

function _get_zip_from_github(&$context = NULL) {
  $zip_url = 'https://github.com/citation-style-language/styles/zipball/master';
  $dest_dir = file_directory_path();
  $parsed_url = parse_url($zip_url);
  $destination = realpath($dest_dir) . '/' . 'Biblio-CiteProc-Styles.zip';
  $zip_file = drupal_http_request($zip_url);
  if ($zip_file->code != 200 && $zip_file->code != 302) {
    drupal_set_message(t('HTTP error @errorcode occurred when trying to fetch @remote.', array(
      '@errorcode' => $zip_file->code,
      '@remote' => $zip_url,
    )), 'error');
    return FALSE;
  }
  $filename = file_save_data($zip_file->data, $destination);
  if (!empty($filename)) {
    variable_set('biblio_citeproc_styles_zip_file', $destination);
    cache_clear_all('biblio_citeproc_styles');
  }
  return $destination;
}