Beispiel #1
0
 /**
  * Remove one or more citations
  *
  * @return	void
  */
 public function removeTask()
 {
     // Incoming (we're expecting an array)
     $ids = Request::getVar('id', array());
     if (!is_array($ids)) {
         $ids = array($ids);
     }
     // Make sure we have IDs to work with
     if (count($ids) > 0) {
         // Loop through the IDs and delete the citation
         $citation = new Citation($this->database);
         $assoc = new Association($this->database);
         $author = new Author($this->database);
         foreach ($ids as $id) {
             // Fetch and delete all the associations to this citation
             $assocs = $assoc->getRecords(array('cid' => $id));
             foreach ($assocs as $a) {
                 $assoc->delete($a->id);
             }
             // Fetch and delete all the authors to this citation
             $authors = $author->getRecords(array('cid' => $id));
             foreach ($authors as $a) {
                 $author->delete($a->id);
             }
             // Delete the citation
             $citation->delete($id);
             //citation tags
             $ct = new Tags($id);
             $ct->removeAll();
         }
         $message = Lang::txt('CITATION_REMOVED');
     } else {
         $message = Lang::txt('NO_SELECTION');
     }
     // Redirect
     App::redirect(Route::url('index.php?option=' . $this->_option . '&controller=' . $this->_controller, true), $message);
 }
Beispiel #2
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;
 }
Beispiel #3
0
 /**
  * Add tags to a citation
  *
  * @param   integer  $userid      User ID
  * @param   integer  $objectid    Citation ID
  * @param   string   $tag_string  Comma separated list of tags
  * @param   string   $label       Label
  * @return  void
  */
 protected function tag($userid, $objectid, $tag_string, $label)
 {
     if ($tag_string) {
         $ct = new Tables\Tags($objectid);
         $ct->setTags($tag_string, $userid, 0, 1, $label);
     }
 }