コード例 #1
0
ファイル: IndexRecord.php プロジェクト: bharatm/NDL-VuFind
 /**
  * Assign necessary Smarty variables and return a template name to
  * load in order to display similar items of the record view page.
  *
  * @return string Name of Smarty template file to display.
  * @access public
  */
 public function getSimilarItems()
 {
     global $interface;
     $this->db = ConnectionManager::connectToIndex();
     // Get similar records
     $similar = $this->db->getMoreLikeThis($this->fields['id'], array('fq' => SearchObject_Solr::getDefaultHiddenFilters()));
     if (!$similar || !array_key_exists('response', $similar) || !array_key_exists('docs', $similar['response'])) {
         PEAR::raiseError(new PEAR_Error('Cannot Load similar items'));
     }
     // Send the similar items to the template; if there is only one, we need
     // to force it to be an array or things will not display correctly.
     if (count($similar['response']['docs']) > 0) {
         $interface->assign('similarRecords', $similar['response']['docs']);
     }
     // Find Other Editions
     $editions = $this->getEditions();
     if (!PEAR::isError($editions)) {
         $interface->assign('editions', $editions);
     }
     return 'Record/similar-items.tpl';
 }
コード例 #2
0
ファイル: Solr.php プロジェクト: bharatm/NDL-VuFind
 /**
  * Obtain information from an alphabetic browse index.
  *
  * @param string $source          Name of index to search
  * @param string $from            Starting point for browse results
  * @param string $rowid           Starting point rowid when known
  * @param int    $page            If page is 0 browse forward, if page is -1 browse backwards
  * @param int    $page_size       The numer of results to return
  * @param string $extras          Also return these Solr db fields in the results
  * @param bool   $returnSolrError Should we fail outright on syntax error
  * (false) or treat it as an empty result set with an error key set (true)?
  *
  * @return array
  * @access public
  */
 public function alphabeticBrowse($source, $from, $rowid, $page, $page_size = 20, $extras = null, $returnSolrError = false)
 {
     $this->client->setMethod('GET');
     $this->client->setURL($this->host . "/browse");
     $this->client->addQueryString('source', $source);
     $this->client->addQueryString('from', $from);
     $this->client->addQueryString('rowid', $rowid);
     $this->client->addQueryString('offset', $page);
     $this->client->addQueryString('rows', $page_size);
     $this->client->addQueryString('extras', $extras);
     $this->client->addQueryString('json.nl', 'arrarr');
     $this->client->addQueryString('wt', 'json');
     $filters = SearchObject_Solr::getDefaultHiddenFilters();
     if ($this->_mergedRecords) {
         // Filter out merged children by default
         $filters[] = '-merged_child_boolean:TRUE';
     } elseif ($this->_mergedRecords !== null) {
         // Filter out merged records by default
         if (!isset($filter)) {
             $filter = array();
         }
         $filters[] = '-merged_boolean:TRUE';
     }
     if (!empty($filters)) {
         $this->client->addQueryString('filters', implode(' AND ', $filters));
     }
     if ($this->debug) {
         echo '<pre>Browse: ' . $this->client->getUrl() . "\n";
         echo "</pre>\n";
     }
     $result = $this->client->sendRequest();
     if (!PEAR::isError($result)) {
         return $this->_process($this->client->getResponseBody(), $returnSolrError);
     } else {
         return $result;
     }
 }