Beispiel #1
0
 /**
  * Load a record image.
  *
  * @param \Vufind\RecordDriver\SolrDefault $driver Record
  * @param int                              $index  Image index
  *
  * @return void
  */
 public function loadRecordImage(\VuFind\RecordDriver\SolrDefault $driver, $index = 0)
 {
     $this->index = $index;
     $params = $driver->getRecordImage($this->fullRes ? 'large' : 'medium', $index);
     if (isset($params['url'])) {
         $this->id = $params['id'];
         $this->url = $params['url'];
         return parent::fetchFromAPI();
     }
 }
Beispiel #2
0
 /**
  * Return an XML representation of the record using the specified format.
  * Return false if the format is unsupported.
  *
  * @param string     $format     Name of format to use (corresponds with OAI-PMH
  * metadataPrefix parameter).
  * @param string     $baseUrl    Base URL of host containing VuFind (optional;
  * may be used to inject record URLs into XML when appropriate).
  * @param RecordLink $recordLink Record link helper (optional; may be used to
  * inject record URLs into XML when appropriate).
  *
  * @return mixed         XML, or false if format unsupported.
  */
 public function getXML($format, $baseUrl = null, $recordLink = null)
 {
     // Special case for MARC:
     if ($format == 'marc21') {
         $xml = $this->getMarcRecord()->toXML();
         $xml = str_replace([chr(27), chr(28), chr(29), chr(30), chr(31)], ' ', $xml);
         $xml = simplexml_load_string($xml);
         if (!$xml || !isset($xml->record)) {
             return false;
         }
         // Set up proper namespacing and extract just the <record> tag:
         $xml->record->addAttribute('xmlns', "http://www.loc.gov/MARC21/slim");
         $xml->record->addAttribute('xsi:schemaLocation', 'http://www.loc.gov/MARC21/slim ' . 'http://www.loc.gov/standards/marcxml/schema/MARC21slim.xsd', 'http://www.w3.org/2001/XMLSchema-instance');
         $xml->record->addAttribute('type', 'Bibliographic');
         return $xml->record->asXML();
     }
     // Try the parent method:
     return parent::getXML($format, $baseUrl, $recordLink);
 }
 /**
  * Get online URLs for a record as an array
  *
  * @param \VuFind\RecordDriver\SolrDefault $record Record driver
  *
  * @return array|null
  */
 protected function getRecordOnlineURLs($record)
 {
     $urls = $record->getOnlineURLs();
     if ($urls) {
         $translate = $this->getViewRenderer()->plugin('translate');
         foreach ($urls as &$url) {
             if (isset($url['source'])) {
                 $url['source'] = ['value' => $url['source'], 'translated' => $translate->translate('source_' . $url['source'])];
             }
         }
     }
     return $urls;
 }
Beispiel #4
0
 /**
  * Set raw data to initialize the object.
  *
  * @param mixed $data Raw data representing the record; Record Model
  * objects are normally constructed by Record Driver objects using data
  * passed in from a Search Results object.  The exact nature of the data may
  * vary depending on the data source -- the important thing is that the
  * Record Driver + Search Results objects work together correctly.
  *
  * @return void
  */
 public function setRawData($data)
 {
     parent::setRawData($data);
     $this->simpleXML = null;
 }
 /**
  * Get online URLs for a record as an array
  *
  * @param \VuFind\RecordDriver\SolrDefault $record Record driver
  *
  * @return array|null
  */
 protected function getRecordOnlineURLs($record)
 {
     $urls = $record->getOnlineURLs();
     if ($urls) {
         $translate = $this->getViewRenderer()->plugin('translate');
         foreach ($urls as &$url) {
             if (isset($url['source'])) {
                 if (is_array($url['source'])) {
                     $translated = [];
                     foreach ($url['source'] as $source) {
                         $translated[] = $translate->translate("source_{$source}", null, $source);
                     }
                 } else {
                     $translated = $translate->translate('source_' . $url['source']);
                 }
                 $url['source'] = ['value' => $url['source'], 'translated' => $translated];
             }
         }
     }
     return $urls;
 }
Beispiel #6
0
 /**
  * Factory for SolrDefault record driver.
  *
  * @param ServiceManager $sm Service manager.
  *
  * @return SolrDefault
  */
 public static function getSolrDefault(ServiceManager $sm)
 {
     $driver = new SolrDefault($sm->getServiceLocator()->get('VuFind\\Config')->get('config'), null, $sm->getServiceLocator()->get('VuFind\\Config')->get('searches'));
     $driver->attachSearchService($sm->getServiceLocator()->get('VuFind\\Search'));
     return $driver;
 }
 /**
  * Get a record driver with fake data.
  *
  * @param array $overrides Fixture fields to override.
  *
  * @return SolrDefault
  */
 protected function getDriver($overrides = [])
 {
     $fixture = json_decode(file_get_contents(realpath(VUFIND_PHPUNIT_MODULE_PATH . '/fixtures/misc/testbug2.json')), true);
     $record = new SolrDefault();
     $record->setRawData($overrides + $fixture['response']['docs'][0]);
     return $record;
 }
Beispiel #8
0
 /**
  * Returns an associative array (action => description) of record tabs supported
  * by the data.
  *
  * @return array
  */
 public function getTabs()
 {
     // No Holdings tab in Summon module:
     $tabs = parent::getTabs();
     unset($tabs['Holdings']);
     return $tabs;
 }
Beispiel #9
0
 /**
  * GetResponsible
  *
  * @param String                           $titleStatement TitleStatement
  * @param \VuFind\RecordDriver\SolrDefault $record         RecordDriver
  *
  * @return string
  */
 public function getResponsible($titleStatement, $record)
 {
     if ($record instanceof \VuFind\RecordDriver\Summon) {
         if ($record->getAuthor()) {
             return $record->getAuthor();
         }
     } else {
         if (isset($titleStatement['statement_responsibility'])) {
             return $titleStatement['statement_responsibility'];
         } elseif ($record->getPrimaryAuthor(true)) {
             return $record->getPrimaryAuthor();
         } elseif ($record->getSecondaryAuthors(true)) {
             return implode('; ', $record->getSecondaryAuthors());
         } elseif ($record->getCorporationNames(true)) {
             return implode('; ', $record->getCorporationNames());
         } else {
             return '';
         }
     }
 }
Beispiel #10
0
 /**
  * Returns an associative array (action => description) of record tabs supported
  * by the data.
  *
  * @return array
  */
 public function getTabs()
 {
     $tabs = parent::getTabs();
     // Check if we need to disable the holdings tab:
     if (isset($tabs['Holdings'])) {
         $config = ConfigReader::getConfig();
         if (isset($config->Site->hideHoldingsTabWhenEmpty) && $config->Site->hideHoldingsTabWhenEmpty) {
             $catalog = $this->getILS();
             if (!$catalog->hasHoldings($this->getUniqueID())) {
                 unset($tabs['Holdings']);
             }
         }
     }
     return $tabs;
 }
Beispiel #11
0
 /**
  * Set raw data to initialize the object.
  *
  * @param mixed $data Raw data representing the record; Record Model
  * objects are normally constructed by Record Driver objects using data
  * passed in from a Search Results object.  The exact nature of the data may
  * vary depending on the data source -- the important thing is that the
  * Record Driver + Search Results objects work together correctly.
  *
  * @return void
  */
 public function setRawData($data)
 {
     parent::setRawData($data);
     $this->lazyRecordXML = null;
 }