コード例 #1
0
ファイル: Result.php プロジェクト: navtis/xerxes-pazpar2
 /**
  * Constructor
  * 
  * @param Xerxes_Record $record		record
  * @param Config $config			local config
  */
 public function __construct(Record $record, Config $config)
 {
     $this->xerxes_record = $record;
     $this->registry = Registry::getInstance();
     $this->config = $config;
     // link resolver stuff
     $this->link_resolver = $this->config->getConfig("LINK_RESOLVER_ADDRESS", false, $this->registry->getConfig("LINK_RESOLVER_ADDRESS", false));
     $this->sid = $this->config->getConfig("APPLICATION_SID", false, $this->registry->getConfig("APPLICATION_SID", false, "calstate.edu:xerxes"));
     if ($this->link_resolver != null) {
         $this->url_open = $record->getOpenURL($this->link_resolver, $this->sid);
     }
     $this->openurl_kev_co = $record->getOpenURL(null, $this->sid);
     // holdings
     $this->holdings = new Holdings();
     if ($record->hasPhysicalHoldings() == false) {
         $this->holdings->checked = true;
     }
     // proxy links?
     $proxy_server = $this->registry->getConfig('PROXY_SERVER', false);
     $should_proxy_links = $this->config->getConfig('SHOULD_PROXY', false, false);
     if ($should_proxy_links) {
         foreach ($this->xerxes_record->getLinks() as $link) {
             $link->addProxyPrefix($proxy_server);
         }
     }
 }
コード例 #2
0
ファイル: Record.php プロジェクト: navtis/xerxes-pazpar2
 /**
  * Get an OpenURL 1.0 formatted URL
  *
  * @param string $strResolver	base url of the link resolver
  * @param string $strReferer	referrer (unique identifier)
  * @return string
  */
 public function getOpenURL($resolver, $referer = null, $para_delimiter = '&')
 {
     if ($this->config()->getConfig('direct_linking', false, false)) {
         return $this->direct_link;
     } else {
         return parent::getOpenURL($resolver, $referer, $para_delimiter);
     }
 }
コード例 #3
0
ファイル: Result.php プロジェクト: navtis/xerxes
 /**
  * Constructor
  * 
  * @param Xerxes_Record $record		record
  * @param Config $config			local config
  */
 public function __construct(Record $record, Config $config)
 {
     $this->xerxes_record = $record;
     $this->registry = Registry::getInstance();
     $this->config = $config;
     // link resolver stuff
     $this->link_resolver = $this->config->getConfig("LINK_RESOLVER_ADDRESS", false, $this->registry->getConfig("LINK_RESOLVER_ADDRESS", false));
     $this->sid = $this->registry->getConfig("APPLICATION_SID", false, "calstate.edu:xerxes");
     if ($this->link_resolver != null) {
         $this->url_open = $record->getOpenURL($this->link_resolver, $this->sid);
     }
     $this->openurl_kev_co = $record->getOpenURL(null, $this->sid);
     // holdings
     $this->holdings = new Holdings();
     if ($record->hasPhysicalHoldings() == false) {
         $this->holdings->checked = true;
     }
 }
コード例 #4
0
ファイル: Engine.php プロジェクト: navtis/xerxes
 public function getRecommendations(Xerxes\Record $xerxes_record, $min_relevance = 0, $max_records = 10)
 {
     $bx_records = array();
     // now get the open url
     $open_url = $xerxes_record->getOpenURL(null, $this->sid);
     $open_url = str_replace('genre=unknown', 'genre=article', $open_url);
     // send it to bx service
     $url = $this->url . "/recommender/openurl?token=" . $this->token . "&{$open_url}" . "&res_dat=source=global&threshold={$min_relevance}&maxRecords={$max_records}";
     try {
         $client = Factory::getHttpClient();
         $client->setUri($url);
         $client->setConfig(array('timeout' => 4));
         $xml = $client->send()->getBody();
         if ($xml == "") {
             throw new \Exception("No response from bx service");
         }
     } catch (\Exception $e) {
         // just issue the exception as a warning
         trigger_error("Could not get result from bX service: " . $e->getTraceAsString(), E_USER_WARNING);
         return $bx_records;
     }
     // header("Content-type: text/xml"); echo $xml; exit;
     $doc = new \DOMDocument();
     $doc->recover = true;
     $doc->loadXML($xml);
     $xpath = new \DOMXPath($doc);
     $xpath->registerNamespace("ctx", "info:ofi/fmt:xml:xsd:ctx");
     $records = $xpath->query("//ctx:context-object");
     foreach ($records as $record) {
         $bx_record = new Record();
         $bx_record->loadXML($record);
         array_push($bx_records, $bx_record);
     }
     if (count($bx_records) > 0) {
         // first one is the record we want to find recommendations for
         // so skip it; any others are actual recommendations
         array_shift($bx_records);
     }
     return $bx_records;
 }