You are here

function biblio_citeproc_install_default_styles in Bibliography Module 6.2

Same name and namespace in other branches
  1. 7 modules/CiteProc/biblio_citeproc.install \biblio_citeproc_install_default_styles()
  2. 7.2 modules/CiteProc/biblio_citeproc.install \biblio_citeproc_install_default_styles()
1 call to biblio_citeproc_install_default_styles()
biblio_citeproc_install in modules/CiteProc/biblio_citeproc.install

File

modules/CiteProc/biblio_citeproc.install, line 95

Code

function biblio_citeproc_install_default_styles() {
  $record = array();
  $dir = drupal_get_path('module', 'biblio_citeproc') . '/style';
  $files = file_scan_directory($dir, '..*.csl$');
  foreach ($files as $file) {
    $csl = file_get_contents($file->filename);
    $xml = simplexml_load_string($csl);
    $parent = '';
    foreach ($xml->info->link as $link) {
      $attrs = $link
        ->attributes();
      if (isset($attrs['rel']) && $attrs['rel'] == 'independent-parent') {
        $parent = (string) $attrs['href'];
      }
    }
    $record = array(
      'filename' => basename($file->filename),
      'parent' => $parent,
      'title' => (string) $xml->info->title,
      'summary' => (string) $xml->info->summary,
      'csl' => $csl,
      'sha1' => sha1($csl),
      'id' => (string) $xml->info->id,
    );
    db_query("INSERT INTO {biblio_citeproc_styles} (filename, parent, title, summary, csl, sha1, id) VALUES ('%s', '%s', '%s', '%s', '%s', %b, '%s')", $record);
  }
}