Example #1
0
 /**
  * Get the last citation's date
  *
  * @return     boolean False if errors
  */
 public function getLastCitationDate()
 {
     if ($this->_id) {
         return false;
     }
     include_once PATH_CORE . DS . 'components' . DS . 'com_citations' . DS . 'tables' . DS . 'citation.php';
     include_once PATH_CORE . DS . 'components' . DS . 'com_citations' . DS . 'tables' . DS . 'association.php';
     include_once PATH_CORE . DS . 'components' . DS . 'com_citations' . DS . 'tables' . DS . 'author.php';
     include_once PATH_CORE . DS . 'components' . DS . 'com_citations' . DS . 'tables' . DS . 'secondary.php';
     $cc = new \Components\Citations\Tables\Citation($this->_db);
     $this->lastCitationDate = $cc->getLastCitationDate('resource', $this->_id);
 }
Example #2
0
							<th><?php 
    echo Lang::txt('PLG_GROUPS_CITATIONS_IMPORT_REQUIRE_ATTENTION', count($citations_require_attention));
    ?>
</th>
						</tr>
					</thead>
					<tbody>
						<?php 
    $counter = 0;
    ?>
						<?php 
    foreach ($citations_require_attention as $c) {
        ?>
							<?php 
        //load the duplicate citation
        $cc = new \Components\Citations\Tables\Citation($database);
        $cc->load($c['duplicate']);
        //get the type
        $ct = new \Components\Citations\Tables\Type($database);
        $type = $ct->getType($cc->type);
        $type_title = $type[0]['type_title'];
        //get citations tags
        $th = new \Components\Citations\Tables\Tags($cc->id);
        $tags = $th->render('string');
        $badges = $th->render('string', array('label' => 'badges'), true);
        ?>
							<tr>
								<!--<td>&nbsp;&nbsp;&nbsp;&nbsp;</td>-->
								<td>
									<span class="citation-title"><u><?php 
        echo Lang::txt('PLG_GROUPS_CITATIONS_IMPORT_DUPLICATE');
Example #3
0
 /**
  * Return data on a resource view (this will be some form of HTML)
  *
  * @param   object   $publication  Current publication
  * @param   string   $option       Name of the component
  * @param   array    $areas        Active area(s)
  * @param   string   $rtrn         Data to be returned
  * @param   string   $version      Version name
  * @param   boolean  $extended     Whether or not to show panel
  * @return  array
  */
 public function onPublication($publication, $option, $areas, $rtrn = 'all', $version = 'default', $extended = true)
 {
     $arr = array('html' => '', 'metadata' => '');
     // Check if our area is in the array of areas we want to return results for
     if (is_array($areas)) {
         if (!array_intersect($areas, $this->onPublicationAreas($publication)) && !array_intersect($areas, array_keys($this->onPublicationAreas($publication)))) {
             $rtrn = 'metadata';
         }
     }
     if (!$publication->_category->_params->get('plg_citations')) {
         return $arr;
     }
     // Get a needed library
     include_once PATH_CORE . DS . 'components' . DS . 'com_citations' . DS . 'tables' . DS . 'citation.php';
     include_once PATH_CORE . DS . 'components' . DS . 'com_citations' . DS . 'tables' . DS . 'association.php';
     include_once PATH_CORE . DS . 'components' . DS . 'com_citations' . DS . 'tables' . DS . 'author.php';
     include_once PATH_CORE . DS . 'components' . DS . 'com_citations' . DS . 'tables' . DS . 'secondary.php';
     // Get citations for this publication
     $database = App::get('db');
     $c = new \Components\Citations\Tables\Citation($database);
     $citations = $c->getCitations('publication', $publication->id);
     $arr['count'] = $citations ? count($citations) : 0;
     $arr['name'] = 'citations';
     // Are we returning HTML?
     if ($rtrn == 'all' || $rtrn == 'html') {
         $config = Component::params($option);
         // Instantiate a view
         $view = $this->view('default', 'browse')->set('option', $option)->set('publication', $publication)->set('citations', $citations)->set('format', $config->get('citation_format', 'apa'));
         // Return the output
         $arr['html'] = $view->setErrors($this->getErrors())->loadTemplate();
     }
     // Are we returning metadata?
     if ($rtrn == 'all' || $rtrn == 'metadata') {
         $view = $this->view('default', 'metadata')->set('url', Route::url('index.php?option=' . $option . '&' . ($publication->alias ? 'alias=' . $publication->alias : 'id=' . $publication->id) . '&active=citations&v=' . $publication->version_number))->set('citations', $citations);
         $arr['metadata'] = $view->loadTemplate();
     }
     // Return results
     return $arr;
 }
Example #4
0
 /**
  * Get citation fields as an array
  *
  * @return  array
  */
 protected function getCitationVars()
 {
     // get all the vars that a citation can have
     $db = App::get('db');
     $tbl = new \Components\Citations\Tables\Citation($db);
     $keys = $tbl->getProperties();
     // remove any private vars
     foreach ($keys as $k => $v) {
         if (substr($v, 0, 1) == '_') {
             unset($keys[$k]);
         }
     }
     // return keys with keys reset
     return array_values($keys);
 }
Example #5
0
 /**
  * Get last citation date
  *
  * @return     void
  */
 public function getLastCitationDate()
 {
     if (!$this->exists()) {
         return false;
     }
     if (!isset($this->_lastCitationDate)) {
         include_once PATH_CORE . DS . 'components' . DS . 'com_citations' . DS . 'tables' . DS . 'citation.php';
         include_once PATH_CORE . DS . 'components' . DS . 'com_citations' . DS . 'tables' . DS . 'association.php';
         include_once PATH_CORE . DS . 'components' . DS . 'com_citations' . DS . 'tables' . DS . 'author.php';
         include_once PATH_CORE . DS . 'components' . DS . 'com_citations' . DS . 'tables' . DS . 'secondary.php';
         $cc = new \Components\Citations\Tables\Citation($this->_db);
         $this->_lastCitationDate = $cc->getLastCitationDate('publication', $this->get('id'));
     }
     return $this->_lastCitationDate;
 }
Example #6
0
 /**
  * Get citations on a resource
  *   Accepts a numeric array index
  *
  * @param      integer $idx Index value
  * @return     array
  */
 public function citations($idx = null)
 {
     if (!$this->exists()) {
         return array();
     }
     if (!isset($this->citations)) {
         $this->citations = array();
         include_once PATH_CORE . DS . 'components' . DS . 'com_citations' . DS . 'tables' . DS . 'citation.php';
         include_once PATH_CORE . DS . 'components' . DS . 'com_citations' . DS . 'tables' . DS . 'association.php';
         include_once PATH_CORE . DS . 'components' . DS . 'com_citations' . DS . 'tables' . DS . 'author.php';
         include_once PATH_CORE . DS . 'components' . DS . 'com_citations' . DS . 'tables' . DS . 'secondary.php';
         $cc = new \Components\Citations\Tables\Citation($this->_db);
         if ($results = $cc->getCitations('resource', $this->resource->id)) {
             $this->citations = $results;
         }
     }
     if ($idx !== null && is_numeric($idx)) {
         if (isset($this->citations[$idx])) {
             return $this->citations[$idx];
         } else {
             $this->setError(Lang::txt('Index not found: ') . __CLASS__ . '::' . __METHOD__ . '[' . $idx . ']');
             return false;
         }
     }
     return $this->citations;
 }
Example #7
0
 /**
  * Check completion status
  *
  * @return  object
  */
 public function getStatus($pub = NULL, $manifest = NULL, $elementId = NULL)
 {
     $status = new \Components\Publications\Models\Status();
     if (!isset($pub->_citations)) {
         // Get citations for this publication
         $c = new \Components\Citations\Tables\Citation($this->_parent->_db);
         $pub->_citations = $c->getCitations('publication', $pub->id);
     }
     // Required?
     $required = $manifest->params->required;
     $status->status = $required && (!$pub->_citations || count($pub->_citations) == 0) ? 0 : 1;
     $status->status = !$required && (!$pub->_citations || count($pub->_citations) == 0) ? 2 : $status->status;
     return $status;
 }
Example #8
0
 /**
  * Show the results of the import
  *
  * @return  void
  */
 private function savedAction()
 {
     // Check if they're logged in
     if (User::isGuest()) {
         return $this->loginAction();
     }
     if (!$this->params->get('access-manage')) {
         throw new Exception(Lang::txt('PLG_MEMBERS_CITATIONS_NOT_AUTHORIZED'), 403);
     }
     // Get the session object
     $session = App::get('session');
     // Get the citations
     $citations_saved = $session->get('citations_saved');
     $citations_not_saved = $session->get('citations_not_saved');
     $citations_error = $session->get('citations_error');
     // Check to make sure we have citations
     if (!$citations_saved && !$citations_not_saved) {
         App::redirect(Route::url($this->member->getLink() . '&active=' . $this->_name . '&action=import'), Lang::txt('PLG_MEMBERS_CITATIONS_IMPORT_MISSING_FILE_CONTINUE'), 'error');
         return;
     }
     $view = $this->view('saved', 'import');
     $view->member = $this->member;
     $view->option = $this->option;
     $view->isAdmin = $this->params->get('access-manage');
     $view->config = Component::params('com_citations');
     $view->database = $this->database;
     $view->filters = array('start' => 0, 'search' => '');
     $view->citations = array();
     foreach ($citations_saved as $cs) {
         $cc = new \Components\Citations\Tables\Citation($this->database);
         $cc->load($cs);
         $view->citations[] = $cc;
     }
     $view->openurl['link'] = '';
     $view->openurl['text'] = '';
     $view->openurl['icon'] = '';
     //take care fo type
     $ct = new \Components\Citations\Tables\Type($this->database);
     $view->types = $ct->getType();
     $view->messages = Notify::messages('plg_members_citations');
     return $view->loadTemplate();
 }
Example #9
0
 /**
  * Return data on a resource view (this will be some form of HTML)
  *
  * @param      object  $resource Current resource
  * @param      string  $option    Name of the component
  * @param      array   $areas     Active area(s)
  * @param      string  $rtrn      Data to be returned
  * @return     array
  */
 public function onResources($model, $option, $areas, $rtrn = 'all')
 {
     $arr = array('area' => $this->_name, 'html' => '', 'metadata' => '');
     // Check if our area is in the array of areas we want to return results for
     if (is_array($areas)) {
         if (!array_intersect($areas, $this->onResourcesAreas($model)) && !array_intersect($areas, array_keys($this->onResourcesAreas($model)))) {
             $rtrn = 'metadata';
         }
     }
     if (!$model->type->params->get('plg_citations')) {
         return $arr;
     }
     $database = App::get('db');
     // Get a needed library
     include_once PATH_CORE . DS . 'components' . DS . 'com_citations' . DS . 'tables' . DS . 'citation.php';
     include_once PATH_CORE . DS . 'components' . DS . 'com_citations' . DS . 'tables' . DS . 'association.php';
     include_once PATH_CORE . DS . 'components' . DS . 'com_citations' . DS . 'tables' . DS . 'author.php';
     include_once PATH_CORE . DS . 'components' . DS . 'com_citations' . DS . 'tables' . DS . 'secondary.php';
     // Get reviews for this resource
     $c = new \Components\Citations\Tables\Citation($database);
     $citations = $c->getCitations('resource', $model->resource->id);
     // Are we returning HTML?
     if ($rtrn == 'all' || $rtrn == 'html') {
         // Instantiate a view
         $view = new \Hubzero\Plugin\View(array('folder' => $this->_type, 'element' => $this->_name, 'name' => 'browse'));
         // Pass the view some info
         $view->option = $option;
         $view->resource = $model->resource;
         $view->citations = $citations;
         $view->citationFormat = $this->params->get('format', 'APA');
         if ($this->getError()) {
             $view->setError($this->getError());
         }
         // Return the output
         $arr['html'] = $view->loadTemplate();
     }
     // Are we returning metadata?
     if ($rtrn == 'all' || $rtrn == 'metadata') {
         $view = new \Hubzero\Plugin\View(array('folder' => $this->_type, 'element' => $this->_name, 'name' => 'metadata'));
         $view->url = Route::url('index.php?option=' . $option . '&' . ($model->resource->alias ? 'alias=' . $model->resource->alias : 'id=' . $model->resource->id) . '&active=citations');
         $view->citations = $citations;
         $arr['metadata'] = $view->loadTemplate();
     }
     // Return results
     return $arr;
 }
Example #10
0
 /**
  * Attach citation
  *
  * @return   boolean
  */
 public function attachCitation($pid = 0, $doi = NULL, $format = 'apa', $actor = 0, $returnStatus = false)
 {
     include_once PATH_CORE . DS . 'components' . DS . 'com_citations' . DS . 'tables' . DS . 'citation.php';
     include_once PATH_CORE . DS . 'components' . DS . 'com_citations' . DS . 'tables' . DS . 'association.php';
     include_once PATH_CORE . DS . 'components' . DS . 'com_citations' . DS . 'tables' . DS . 'type.php';
     include_once PATH_CORE . DS . 'components' . DS . 'com_citations' . DS . 'helpers' . DS . 'format.php';
     $out = array('error' => NULL, 'success' => NULL);
     if (!$doi || !$pid) {
         $this->setError(Lang::txt('PLG_PROJECTS_LINKS_NO_DOI'));
         if ($returnStatus) {
             $out['error'] = $this->getError();
             return $out;
         }
         return false;
     }
     $database = App::get('db');
     $c = new \Components\Citations\Tables\Citation($database);
     if ($c->loadPubCitation($doi, $pid)) {
         $this->setError(Lang::txt('PLG_PROJECTS_LINKS_CITATION_ALREADY_ATTACHED'));
         if ($returnStatus) {
             $out['error'] = $this->getError();
             return $out;
         }
         return false;
     } else {
         // Get DOI preview
         $output = self::parseUrl($doi, true, true, $format);
         $output = json_decode($output);
         if (isset($output->error) && $output->error) {
             $this->setError($output->error);
             if ($returnStatus) {
                 $out['error'] = $this->getError();
                 return $out;
             }
             return false;
         } elseif (isset($output->preview) && $output->preview) {
             // Load citation record with the same DOI if present
             if (!$c->loadByDoi($doi)) {
                 $c->created = Date::toSql();
                 $c->title = $doi;
                 $c->uid = $actor;
                 $c->affiliated = 1;
             }
             $c->formatted = $output->preview;
             $c->format = $format;
             $c->doi = $doi;
             // Try getting more metadata
             $url = '';
             $data = self::getDoiMetadata($doi, false, $url);
             // Save available data
             if ($data) {
                 foreach ($c as $key => $value) {
                     $column = strtolower($key);
                     if (isset($data->{$column})) {
                         $c->{$column} = $data->{$column};
                     }
                 }
                 // Some extra mapping hacks
                 $c->pages = $data->page;
                 // Get type ID
                 $ct = new \Components\Citations\Tables\Type($database);
                 $types = $ct->getType();
                 $dType = isset($data->type) ? $data->type : 'article';
                 // Hub types don't match library types
                 // Trying to match the best we can
                 $validTypes = array();
                 foreach ($types as $type) {
                     if ($type['type'] == $dType) {
                         $c->type = $type['id'];
                     } elseif ($type['type'] == 'article') {
                         $validTypes['journal-article'] = $type['id'];
                     } elseif ($type['type'] == 'chapter') {
                         $validTypes['book-chapter'] = $type['id'];
                     } elseif ($type['type'] == 'inproceedings') {
                         $validTypes['proceedings'] = $type['id'];
                     }
                 }
                 if (isset($validTypes[$dType])) {
                     $c->type = $validTypes[$dType];
                 } elseif (!intval($c->type)) {
                     // Default to article
                     $c->type = $validTypes['journal-article'];
                 }
             }
             if (!$c->store()) {
                 $this->setError(Lang::txt('PLG_PROJECTS_LINKS_CITATION_ERROR_SAVE'));
                 if ($returnStatus) {
                     $out['error'] = $this->getError();
                     return $out;
                 }
                 return false;
             }
             // Create association
             if ($c->id) {
                 $assoc = new \Components\Citations\Tables\Association($database);
                 $assoc->oid = $pid;
                 $assoc->tbl = 'publication';
                 $assoc->type = 'owner';
                 $assoc->cid = $c->id;
                 // Store new content
                 if (!$assoc->store()) {
                     $this->setError($assoc->getError());
                     if ($returnStatus) {
                         $out['error'] = $this->getError();
                         return $out;
                     }
                     return false;
                 }
             }
         } else {
             $this->setError(Lang::txt('PLG_PROJECTS_LINKS_CITATION_COULD_NOT_LOAD'));
             if ($returnStatus) {
                 $out['error'] = $this->getError();
                 return $out;
             }
             return false;
         }
     }
     if ($returnStatus) {
         $out['success'] = true;
         return $out;
     }
     return true;
 }
Example #11
0
							<th><?php 
    echo Lang::txt('COM_CITATIONS_IMPORT_REQUIRE_ATTENTION', count($citations_require_attention));
    ?>
</th>
						</tr>
					</thead>
					<tbody>
						<?php 
    $counter = 0;
    ?>
						<?php 
    foreach ($citations_require_attention as $c) {
        ?>
							<?php 
        //load the duplicate citation
        $cc = new \Components\Citations\Tables\Citation($database);
        $cc->load($c['duplicate']);
        //get the type
        $ct = new \Components\Citations\Tables\Type($database);
        $type = $ct->getType($cc->type);
        $type_title = $type[0]['type_title'];
        //get citations tags
        $th = new \Components\Citations\Tables\Tags($cc->id);
        $tags = $th->render('string');
        $badges = $th->render('string', array('label' => 'badges'), true);
        ?>
							<tr>
								<!--<td>&nbsp;&nbsp;&nbsp;&nbsp;</td>-->
								<td>
									<span class="citation-title"><u><?php 
        echo Lang::txt('COM_CITATIONS_IMPORT_DUPLICATE');
Example #12
0
 /**
  * Static method for formatting results
  *
  * @param      object $row Database row
  * @return     string HTML
  */
 public static function out($row)
 {
     $row->author = isset($row->alias) ? $row->alias : '';
     $row->booktitle = isset($row->itext) ? $row->itext : '';
     $row->doi = isset($row->ftext) ? $row->ftext : '';
     $row->published = isset($row->state) ? $row->state : '';
     $row->year = isset($row->created_by) ? $row->created_by : '';
     $row->month = isset($row->modified) ? $row->modified : '';
     $row->isbn = isset($row->publish_up) ? $row->publish_up : '';
     $row->journal = isset($row->publish_down) ? $row->publish_down : '';
     $row->url = isset($row->href) ? $row->href : '';
     $row->volume = isset($row->params) ? $row->params : '';
     $row->number = isset($row->rcount) ? $row->rcount : '';
     $row->type = isset($row->data1) ? $row->data1 : '';
     $row->pages = isset($row->data2) ? $row->data2 : '';
     $row->publisher = isset($row->data3) ? $row->data3 : '';
     require_once PATH_CORE . DS . 'components' . DS . 'com_citations' . DS . 'tables' . DS . 'type.php';
     require_once PATH_CORE . DS . 'components' . DS . 'com_citations' . DS . 'tables' . DS . 'association.php';
     require_once PATH_CORE . DS . 'components' . DS . 'com_citations' . DS . 'tables' . DS . 'format.php';
     require_once PATH_CORE . DS . 'components' . DS . 'com_citations' . DS . 'helpers' . DS . 'format.php';
     $config = \Component::params('com_citations');
     switch ($config->get("citation_label", "number")) {
         case 'none':
             $citations_label_class = 'no-label';
             break;
         case 'number':
             $citations_label_class = 'number-label';
             break;
         case 'type':
             $citations_label_class = 'type-label';
             break;
         case 'both':
             $citations_label_class = 'both-label';
             break;
     }
     $database = \App::get('db');
     $citationsFormat = new \Components\Citations\Tables\Format($database);
     $template = $citationsFormat->getDefaultFormat() ? $citationsFormat->getDefaultFormat()->format : null;
     $formatter = new \Components\Citations\Helpers\Format();
     $formatter->setTemplate($template);
     // Start building the HTML
     $html = "\t" . '<li class="citation-entry">' . "\n";
     $html .= "\t\t" . '<p class="title">';
     //are we trying wanting to direct to single citaiton view
     $citationSingleView = $config->get('citation_single_view', 1);
     if ($citationSingleView) {
         $html .= '<a href="' . \Route::url('index.php?option=com_citations&task=view&id=' . $row->id) . '">';
     } else {
         $html .= '<a href="' . \Route::url('index.php?option=com_citations&task=browse&type=' . $row->type . '&year=' . $row->year . '&search=' . \Hubzero\Utility\String::truncate(\Hubzero\Utility\Sanitize::stripAll(stripslashes($row->title)), 50)) . '">';
     }
     $html .= \Hubzero\Utility\String::truncate(\Hubzero\Utility\Sanitize::stripAll(stripslashes($row->title)), 200);
     $html .= '</a></p>' . "\n";
     $html .= '<p class="details ' . $citations_label_class . '">' . \Lang::txt('PLG_TAGS_CITATION');
     if ($config->get('citation_label', 'number') != 'none') {
         $types = self::getTypes();
         $type = '';
         foreach ($types as $t) {
             if ($t['id'] == $row->type) {
                 $type = $t['type_title'];
             }
         }
         $type = $type != '' ? $type : 'Generic';
         $html .= ' <span>|</span> ' . $type;
     }
     $html .= '</p>';
     require_once PATH_CORE . DS . 'components' . DS . 'com_citations' . DS . 'tables' . DS . 'citation.php';
     $db = \App::get('db');
     $cc = new \Components\Citations\Tables\Citation($db);
     $cc->load($row->id);
     $html .= '<p>' . $formatter->formatCitation($cc, null, $config->get("citation_coins", 1), $config) . '</p>';
     $html .= "\t" . '</li>' . "\n";
     // Return output
     return $html;
 }
Example #13
0
 /**
  * Display a list of citations
  *
  * @apiMethod GET
  * @apiUri    /citations/list
  * @apiParameter {
  * 		"name":          "limit",
  * 		"description":   "Number of result to return.",
  * 		"type":          "integer",
  * 		"required":      false,
  * 		"default":       25
  * }
  * @apiParameter {
  * 		"name":          "start",
  * 		"description":   "Number of where to start returning results.",
  * 		"type":          "integer",
  * 		"required":      false,
  * 		"default":       0
  * }
  * @apiParameter {
  * 		"name":          "search",
  * 		"description":   "A word or phrase to search for.",
  * 		"type":          "string",
  * 		"required":      false,
  * 		"default":       ""
  * }
  * @apiParameter {
  * 		"name":          "sort",
  * 		"description":   "Field to sort results by.",
  * 		"type":          "string",
  * 		"required":      false,
  *      "default":       "created",
  * 		"allowedValues": "created, title, id"
  * }
  * @apiParameter {
  * 		"name":          "sort_Dir",
  * 		"description":   "Direction to sort results by.",
  * 		"type":          "string",
  * 		"required":      false,
  * 		"default":       "desc",
  * 		"allowedValues": "asc, desc"
  * }
  * @return  void
  */
 public function listTask()
 {
     $database = \App::get('db');
     $filters = array('limit' => Request::getInt('limit', 25), 'start' => Request::getInt('limitstart', 0), 'search' => Request::getVar('search', ''), 'sort' => Request::getVar('sort', 'created'), 'sort_Dir' => strtoupper(Request::getWord('sortDir', 'DESC')), 'state' => 1);
     //get the earliest year we have citations for
     $query = "SELECT c.year FROM `#__citations` as c WHERE c.published=1 AND c.year <> 0 AND c.year IS NOT NULL ORDER BY c.year ASC LIMIT 1";
     $database->setQuery($query);
     $earliest_year = $database->loadResult();
     $earliest_year = $earliest_year ? $earliest_year : 1990;
     $filters['id'] = Request::getInt('id', 0);
     $filters['tag'] = Request::getVar('tag', '', 'request', 'none', 2);
     $filters['type'] = Request::getVar('type', '');
     $filters['author'] = Request::getVar('author', '');
     $filters['publishedin'] = Request::getVar('publishedin', '');
     $filters['year_start'] = Request::getInt('year_start', $earliest_year);
     $filters['year_end'] = Request::getInt('year_end', date("Y"));
     $filters['filter'] = Request::getVar('filter', '');
     $filters['reftype'] = Request::getVar('reftype', array('research' => 1, 'education' => 1, 'eduresearch' => 1, 'cyberinfrastructure' => 1));
     $filters['geo'] = Request::getVar('geo', array('us' => 1, 'na' => 1, 'eu' => 1, 'as' => 1));
     $filters['aff'] = Request::getVar('aff', array('university' => 1, 'industry' => 1, 'government' => 1));
     $filters['startuploaddate'] = Request::getVar('startuploaddate', '0000-00-00');
     $filters['enduploaddate'] = Request::getVar('enduploaddate', '0000-00-00');
     $filters['sort'] = $filters['sort'] . ' ' . $filters['sort_Dir'];
     if ($collection = Request::getInt('collection', 0)) {
         $filters['collection_id'] = $collection;
     }
     $response = new stdClass();
     $response->citations = array();
     // Instantiate a new citations object
     $obj = new \Components\Citations\Tables\Citation($database);
     // Get a record count
     $response->total = $obj->getCount($filters);
     // Get records
     if ($response->total) {
         $href = 'index.php?option=com_citations&task=view&id=';
         $base = str_replace('/api', '', rtrim(Request::base(), '/'));
         foreach ($obj->getRecords($filters) as $i => $entry) {
             $entry->uri = $base . '/' . ltrim(Route::url($href . $entry->id), '/');
             $response->citations[] = $entry;
         }
     }
     $response->success = true;
     $this->send($response);
 }