コード例 #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);
 }
コード例 #2
0
ファイル: citations.php プロジェクト: kevinwojo/hubzero-cms
 /**
  * Delete one or more entries
  *
  * @return     void
  */
 public function deleteTask()
 {
     // Check if they're logged in
     if (User::isGuest()) {
         $this->loginTask();
         return;
     }
     // Incoming (we're expecting an array)
     $ids = Request::getVar('id', array());
     if (!is_array($ids)) {
         $ids = array();
     }
     // 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
             $isAdmin = User::get("usertype") == "Super Administrator" ? true : false;
             $assocs = $assoc->getRecords(array('cid' => $id), $isAdmin);
             foreach ($assocs as $a) {
                 $assoc->delete($a->id);
             }
             // Fetch and delete all the authors to this citation
             $authors = $author->getRecords(array('cid' => $id), $isAdmin);
             foreach ($authors as $a) {
                 $author->delete($a->id);
             }
             // Delete the citation
             $citation->delete($id);
         }
     }
     // Redirect
     App::redirect(Route::url('index.php?option=' . $this->_option));
 }
コード例 #3
0
ファイル: format.php プロジェクト: kevinwojo/hubzero-cms
 /**
  * Output a citation's associations
  *
  * @param   object  $config    Component config
  * @param   object  $citation  Citation
  * @return  string  HTML
  */
 public function citationAssociation($config, $citation)
 {
     $html = '';
     $internally_cited_image = $config->get('citation_cited', 0);
     $internally_cited_image_single = $config->get('citation_cited_single', '');
     $internally_cited_image_multiple = $config->get('citation_cited_multiple', '');
     //database
     $database = \App::get('db');
     // Get the associations
     $assoc = new Association($database);
     $assocs = $assoc->getRecords(array('cid' => $citation->id));
     if (count($assocs) > 0) {
         if (count($assocs) > 1) {
             $html .= '<span>|</span> <span style="line-height:1.6em;color:#444">' . \Lang::txt('COM_CITATIONS_RESOURCES_CITED') . ':</span> ';
             $k = 0;
             $rrs = array();
             foreach ($assocs as $rid) {
                 if ($rid->tbl == 'resource') {
                     $database->setQuery("SELECT published FROM `#__resources` WHERE id=" . $rid->oid);
                     $state = $database->loadResult();
                     if ($state == 1) {
                         $k++;
                         if ($internally_cited_image) {
                             $rrs[] = '<a class="internally-cited" href="' . \Route::url('index.php?option=com_resources&id=' . $rid->oid) . '">[<img src="' . $internally_cited_image_multiple . '" alt="' . \Lang::txt('COM_CITATIONS_RESOURCES_CITED') . '" />]</a>';
                         } else {
                             $rrs[] = '<a class="internally-cited" href="' . \Route::url('index.php?option=com_resources&id=' . $rid->oid) . '">[' . $k . ']</a>';
                         }
                     }
                 }
             }
             $html .= implode(', ', $rrs);
         } else {
             if ($assocs[0]->tbl == 'resource') {
                 $database->setQuery("SELECT published FROM `#__resources` WHERE id=" . $assocs[0]->oid);
                 $state = $database->loadResult();
                 if ($state == 1) {
                     if ($internally_cited_image) {
                         $html .= ' <span>|</span> <a class="internally-cited" href="' . \Route::url('index.php?option=com_resources&id=' . $assocs[0]->oid) . '"><img src="' . $internally_cited_image_single . '" alt="' . \Lang::txt('COM_CITATIONS_RESOURCES_CITED') . '" /></a>';
                     } else {
                         $html .= ' <span>|</span> <a class="internally-cited" href="' . \Route::url('index.php?option=com_resources&id=' . $assocs[0]->oid) . '">' . \Lang::txt('COM_CITATIONS_RESOURCES_CITED') . '</a>';
                     }
                 }
             }
         }
     }
     if ($citation->eprint) {
         $html .= '<span>|</span>';
         $html .= '<a href="' . String::ampReplace($citation->eprint) . '">' . \Lang::txt('Electronic Paper') . '</a>';
     }
     return $html;
 }