Ejemplo n.º 1
0
 public function getCitation($format)
 {
     require_once ROOT_DIR . '/sys/CitationBuilder.php';
     // Build author list:
     $authors = array();
     $primary = $this->eContentRecord->author;
     if (!empty($primary)) {
         $authors[] = $primary;
     }
     $authors = array_unique(array_merge($authors, $this->eContentRecord->getPropertyArray('author2')));
     // Collect all details for citation builder:
     $publishers = array($this->eContentRecord->publisher);
     $pubDates = $this->eContentRecord->getPropertyArray('publishDate');
     $pubPlaces = array();
     $details = array('authors' => $authors, 'title' => $this->eContentRecord->title, 'subtitle' => $this->eContentRecord->subTitle, 'pubPlace' => count($pubPlaces) > 0 ? $pubPlaces[0] : null, 'pubName' => count($publishers) > 0 ? $publishers[0] : null, 'pubDate' => count($pubDates) > 0 ? $pubDates[0] : null, 'edition' => $this->eContentRecord->getPropertyArray('edition'), 'source' => $this->eContentRecord->source, 'format' => $this->eContentRecord->format());
     // Build the citation:
     $citation = new CitationBuilder($details);
     switch ($format) {
         case 'APA':
             return $citation->getAPA();
         case 'MLA':
             return $citation->getMLA();
         case 'AMA':
             return $citation->getAMA();
         case 'ChicagoAuthDate':
             return $citation->getChicagoAuthDate();
         case 'ChicagoHumanities':
             return $citation->getChicagoHumanities();
     }
     return '';
 }
Ejemplo n.º 2
0
 function getBasicItemInfo()
 {
     global $timer;
     global $configArray;
     $itemData = array();
     //Load basic information
     $this->id = $_GET['id'];
     $itemData['id'] = $this->id;
     // Setup Search Engine Connection
     $class = $configArray['Index']['engine'];
     $url = $configArray['Index']['url'];
     $this->db = new $class($url);
     if ($configArray['System']['debugSolr']) {
         $this->db->debug = true;
     }
     // Retrieve Full Marc Record
     if (!($record = $this->db->getRecord($this->id))) {
         PEAR_Singleton::raiseError(new PEAR_Error('Record Does Not Exist'));
     }
     $this->record = $record;
     $this->recordDriver = RecordDriverFactory::initRecordDriver($record);
     $timer->logTime('Initialized the Record Driver');
     // Process MARC Data
     if ($record['recordtype'] == 'econtentRecord') {
         require_once ROOT_DIR . '/sys/eContent/EContentRecord.php';
         $eContentRecord = new EContentRecord();
         $eContentRecord->id = substr($record['id'], strlen('econtentRecord'));
         if (!$eContentRecord->find(true)) {
             $itemData['error'] = 'Cannot load eContent Record for id ' . $record['id'];
         } else {
             $itemData['isbn'] = $eContentRecord->getIsbn();
             $itemData['issn'] = $eContentRecord->getissn();
             $itemData['upc'] = $eContentRecord->getUpc();
             $itemData['issn'] = '';
             $itemData['title'] = $record['title'];
             $itemData['author'] = $eContentRecord->author;
             $itemData['publisher'] = $eContentRecord->publisher;
             $itemData['allIsbn'] = $eContentRecord->getPropertyArray('isbn');
             $itemData['allUpc'] = $eContentRecord->getPropertyArray('upc');
             $itemData['allIssn'] = $eContentRecord->getPropertyArray('issn');
             $itemData['format'] = $eContentRecord->format();
             $itemData['formatCategory'] = $eContentRecord->format_category();
             $itemData['language'] = $eContentRecord->language;
             $itemData['cover'] = $configArray['Site']['coverUrl'] . "/bookcover.php?id={$itemData['id']}&isbn={$itemData['isbn']}&issn={$itemData['issn']}&upc={$itemData['upc']}&category={$itemData['formatCategory']}&format={$itemData['format'][0]}&size=medium";
             $itemData['description'] = $eContentRecord->description;
             require_once ROOT_DIR . '/sys/eContent/EContentRating.php';
             $eContentRating = new EContentRating();
             $eContentRating->recordId = $eContentRecord->id;
             global $user;
             $itemData['ratingData'] = $eContentRating->getRatingData($user, false);
         }
     } else {
         require_once ROOT_DIR . '/sys/MarcLoader.php';
         $marcRecord = MarcLoader::loadMarcRecordFromRecord($record);
         if ($marcRecord) {
             $this->marcRecord = $marcRecord;
         } else {
             $itemData['error'] = 'Cannot Process MARC Record';
         }
         $timer->logTime('Processed the marc record');
         // Get ISBN for cover and review use
         if ($isbnFields = $this->marcRecord->getFields('020')) {
             //Use the first good ISBN we find.
             /** @var File_MARC_Data_Field $isbnField */
             foreach ($isbnFields as $isbnField) {
                 if ($isbnSubfield = $isbnField->getSubfield('a')) {
                     $this->isbn = trim($isbnSubfield->getData());
                     if ($pos = strpos($this->isbn, ' ')) {
                         $this->isbn = substr($this->isbn, 0, $pos);
                     }
                     if (strlen($this->isbn) < 10) {
                         $this->isbn = str_pad($this->isbn, 10, "0", STR_PAD_LEFT);
                     }
                     $itemData['isbn'] = $this->isbn;
                     break;
                 }
             }
         }
         /** @var File_MARC_Data_Field $upcField */
         if ($upcField = $this->marcRecord->getField('024')) {
             if ($upcSubField = $upcField->getSubfield('a')) {
                 $this->upc = trim($upcSubField->getData());
                 $itemData['upc'] = $this->upc;
             }
         }
         /** @var File_MARC_Data_Field $issnField */
         if ($issnField = $this->marcRecord->getField('022')) {
             if ($issnSubfield = $issnField->getSubfield('a')) {
                 $this->issn = trim($issnSubfield->getData());
                 if ($pos = strpos($this->issn, ' ')) {
                     $this->issn = substr($this->issn, 0, $pos);
                 }
                 $itemData['issn'] = $this->issn;
             }
         }
         $timer->logTime('Got UPC, ISBN, and ISSN');
         //Generate basic information from the marc file to make display easier.
         $itemData['title'] = $record['title'];
         $itemData['author'] = isset($record['author']) ? $record['author'] : (isset($record['author2']) ? $record['author2'][0] : '');
         $itemData['publisher'] = $record['publisher'];
         $itemData['allIsbn'] = $record['isbn'];
         $itemData['allUpc'] = $record['upc'];
         $itemData['allIssn'] = $record['issn'];
         $itemData['issn'] = $record['issn'];
         $itemData['format'] = isset($record['format']) ? $record['format'][0] : '';
         $itemData['formatCategory'] = $record['format_category'][0];
         $itemData['language'] = $record['language'];
         $itemData['cover'] = $configArray['Site']['path'] . "/bookcover.php?id={$itemData['id']}&issn={$itemData['issn']}&isbn={$itemData['isbn']}&upc={$itemData['upc']}&category={$itemData['formatCategory']}&format={$itemData['format'][0]}";
         //Retrieve description from MARC file
         $description = '';
         /** @var File_MARC_Data_Field $descriptionField */
         if ($descriptionField = $this->marcRecord->getField('520')) {
             if ($descriptionSubfield = $descriptionField->getSubfield('a')) {
                 $description = trim($descriptionSubfield->getData());
             }
         }
         $itemData['description'] = $description;
         //setup 5 star ratings
         global $user;
         $resource = new Resource();
         $resource->record_id = $this->id;
         $resource->source = 'VuFind';
         $ratingData = $resource->getRatingData($user);
         $itemData['ratingData'] = $ratingData;
         $timer->logTime('Got 5 star data');
     }
     return $itemData;
 }