You are here

function _install_csl_from_github in Bibliography Module 7

Same name and namespace in other branches
  1. 6.2 modules/CiteProc/biblio_citeproc.admin.inc \_install_csl_from_github()
1 call to _install_csl_from_github()
_install_csl in modules/CiteProc/biblio_citeproc.admin.inc

File

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

Code

function _install_csl_from_github($path, $update = FALSE) {
  $csl = '';
  $github_url = 'https://api.github.com/repos/citation-style-language/styles-distribution/contents/';
  $URL = $github_url . $path;
  $result = drupal_http_request($URL);
  if ($result->code == 200) {
    $file = json_decode($result->data);
    switch ($file->encoding) {
      case 'base64':
        $csl = base64_decode($file->content);
        break;
    }
    _install_csl($file->name, $csl, $file->sha, FALSE, $update);
  }
  else {
    $message = t('Attempt to get style: %name from GitHub resulted in an HTTP error: !code.', array(
      '%name' => $path,
      '!code' => $result->code,
    ));
    $mess_type = 'error';
    drupal_set_message(check_plain($message), $mess_type);
  }
}