Beispiel #1
0
 /**
  * Download a batch of entries
  *
  * @return  void
  */
 public function downloadbatchTask()
 {
     // get the submit buttons value
     $download = Request::getVar('download', '');
     $no_html = Request::getVar('no_html', 0);
     // get the citations we want to export
     $citationsString = Request::getVar('idlist', '');
     $citations = explode('-', $citationsString);
     // return to browse mode if we really dont wanna download
     if (strtolower($download) != 'endnote' && strtolower($download) != 'bibtex') {
         if (!$no_html) {
             return $this->displayTask();
         } else {
             return json_encode(array('status' => '1'));
         }
     }
     // var to hold output
     $doc = '';
     // for each citation we want to downlaod
     foreach ($citations as $c) {
         $cc = new Citation($this->database);
         $cc->load($c);
         //get the badges
         $ct = new Tags($cc->id);
         $cc->badges = $ct->render('string', array('label' => 'badge'));
         $cd = new Download();
         $cd->setFormat(strtolower($download));
         $doc .= $cd->formatReference($cc) . "\r\n\r\n";
         $mine = $cd->getMimeType();
     }
     $ext = strtolower($download) == 'bibtex' ? '.bib' : '.enw';
     // filename
     $filename = 'citations_export_' . strtolower($download) . '_' . Date::of('now')->format('Y_m_d') . $ext;
     // output file
     header('Content-Type: application/octet-stream');
     header('Content-Disposition: Attachment; filename=' . $filename);
     header('Pragma: no-cache');
     echo $doc;
     exit;
 }