You are here

function _get_csl_list_from_zip in Bibliography Module 6.2

Same name and namespace in other branches
  1. 7 modules/CiteProc/biblio_citeproc.admin.inc \_get_csl_list_from_zip()
1 call to _get_csl_list_from_zip()
biblio_citeproc_style_manager_form in modules/CiteProc/biblio_citeproc.admin.inc

File

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

Code

function _get_csl_list_from_zip($filename) {
  $options = array();
  $za = new ZipArchive();
  if ($za
    ->open($filename) !== TRUE) {
    $message = t('Could not open zip file containing styles: @file', array(
      '@file' => realpath($filename),
    ));
    $message = check_plain($message);
    drupal_set_message($message, 'error');
    return $options;
  }
  $num_files = $za->numFiles;
  for ($i = 0; $i < $num_files; $i++) {
    $name = $za
      ->getNameIndex($i);
    $name = basename($name);
    if (strstr($name, '.csl')) {
      $csl = $za
        ->getFromIndex($i);
      $xml = simplexml_load_string($csl);
      if ($xml) {
        $options[$i] = trim((string) $xml->info->title);
      }
    }
  }
  $za
    ->close();
  asort($options);
  return $options;
}