public function recordAction()
 {
     $library = $this->request->getParam("library");
     $id = $this->request->getParam("id");
     $solr = new Engine();
     $results = $solr->getRecord($id);
     if ($results == null) {
         throw new \Exception('Could not fetch record');
     }
     $title = urlencode($results->getRecord(0)->getXerxesRecord()->getTitle());
     $url = 'http://' . $this->server . "/search/z?9{$library}+{$id}&title={$title}";
     return $this->redirectTo($url);
 }
Exemplo n.º 2
0
 /**
  * Return an individual record
  * 
  * @param string	record identifier
  * @return ResultSet
  */
 protected function doGetRecord($id)
 {
     $results = new Search\ResultSet($this->config);
     // get the record from the database
     $record = $this->datamap->getRecordByID($id);
     // no record found?
     if ($record == null) {
         $results->total = 0;
         return $results;
     }
     // got one
     $results->total = 1;
     $result = $this->createSearchResult($record);
     // corrupted record, look out
     if ($result->corrupted == true) {
         $fixed = false;
         $data = $record->marc;
         // go back to the original search engine and fetch it again
         $class_name = 'Application\\Model\\' . ucfirst($result->source) . '\\Engine';
         if (class_exists($class_name)) {
             try {
                 $engine = new $class_name();
                 $new_results = $engine->getRecord($result->original_id);
                 if ($new_results->total > 0) {
                     $result = $new_results->getRecord(0);
                     $fixed = true;
                 }
             } catch (NotFoundException $e) {
                 if (strstr($data, 'Xerxes_TransRecord')) {
                     $data = '<?xml version="1.0"?>' . Parser::removeLeft($data, '<?xml version="1.0"?>');
                     $data = Parser::removeRight($data, '</xerxes_record>') . '</xerxes_record>';
                     $xerxes_record = new Xerxes\Record();
                     $xerxes_record->loadXML($data);
                     $record->xerxes_record = $xerxes_record;
                     // recreate the result, since we need the openurl and such
                     $result = $this->createSearchResult($record);
                     $fixed = true;
                 }
             }
         } elseif (strstr($data, 'Xerxes_MetalibRecord')) {
             $data = '<?xml' . Parser::removeLeft($data, '<?xml');
             $data = Parser::removeRight($data, '</x_server_response>') . '</x_server_response>';
             $xerxes_record = new \Xerxes_MetalibRecord();
             $xerxes_record->loadXML($data);
             $record->xerxes_record = $xerxes_record;
             // recreate the result, since we need the openurl and such
             $result = $this->createSearchResult($record);
             $fixed = true;
         }
         if ($fixed == false) {
             throw new \Exception('Sorry, this record has been corrupted');
         }
     }
     // if a catalog record, fetch holdings
     if ($record->xerxes_record instanceof Solr\Record) {
         try {
             $engine = new Solr\Engine();
             $solr_results = $engine->getRecord($result->original_id);
             $holdings = $solr_results->getRecord(0)->getHoldings();
             $result->setHoldings($holdings);
         } catch (\Exception $e) {
             trigger_error('saved records holdings lookup: ' . $e->getMessage(), E_USER_WARNING);
         }
     }
     $results->addResult($result);
     return $results;
 }