Ejemplo n.º 1
0
 static function loadDescription($eContentRecord, $forSummary = false)
 {
     $descriptionArray = array();
     //Load the description
     if (strlen($eContentRecord->description) > 0) {
         $descriptionArray['description'] = EcontentRecord_Description::trimDescription($eContentRecord->description);
     } else {
         $marc = MarcLoader::loadEContentMarcRecord($eContentRecord);
         require_once ROOT_DIR . '/services/Record/Description.php';
         global $library;
         $allowExternalDescription = true;
         if (isset($library) && $library->preferSyndeticsSummary == 0) {
             $allowExternalDescription = false;
         }
         if ($forSummary) {
             $allowExternalDescription = false;
         }
         $descriptionArray = Record_Description::loadDescriptionFromMarc($marc, $allowExternalDescription);
     }
     //Load publisher
     $descriptionArray['publisher'] = $eContentRecord->publisher;
     return $descriptionArray;
 }
Ejemplo n.º 2
0
 static function loadDescriptionFromMarc($marcRecord, $allowExternalDescription = true)
 {
     global $interface;
     global $configArray;
     global $library;
     global $timer;
     global $memCache;
     // Get ISBN for cover and review use
     $isbn = null;
     if ($isbnFields = $marcRecord->getFields('020')) {
         //Use the first good ISBN we find.
         foreach ($isbnFields as $isbnField) {
             if ($isbnSubfieldA = $isbnField->getSubfield('a')) {
                 $tmpIsbn = trim($isbnSubfieldA->getData());
                 if (strlen($tmpIsbn) > 0) {
                     $pos = strpos($tmpIsbn, ' ');
                     if ($pos > 0) {
                         $tmpIsbn = substr($tmpIsbn, 0, $pos);
                     }
                     $tmpIsbn = trim($tmpIsbn);
                     if (strlen($tmpIsbn) > 0) {
                         if (strlen($tmpIsbn) < 10) {
                             $tmpIsbn = str_pad($tmpIsbn, 10, "0", STR_PAD_LEFT);
                         }
                         $isbn = $tmpIsbn;
                         break;
                     }
                 }
             }
         }
     }
     $upc = null;
     if ($upcField = $marcRecord->getField('024')) {
         if ($upcField = $upcField->getSubfield('a')) {
             $upc = trim($upcField->getData());
         }
     }
     $descriptionArray = $memCache->get("record_description_{$isbn}_{$upc}_{$allowExternalDescription}");
     if (!$descriptionArray) {
         $marcDescription = null;
         $description = '';
         if ($descriptionField = $marcRecord->getField('520')) {
             if ($descriptionSubfield = $descriptionField->getSubfield('a')) {
                 $description = trim($descriptionSubfield->getData());
                 $marcDescription = Record_Description::trimDescription($description);
             }
         }
         //Load the description
         //Check to see if there is a description in Syndetics and use that instead if available
         $useMarcSummary = true;
         if ($allowExternalDescription) {
             if (!is_null($isbn) || !is_null($upc)) {
                 require_once ROOT_DIR . '/Drivers/marmot_inc/GoDeeperData.php';
                 $summaryInfo = GoDeeperData::getSummary($isbn, $upc);
                 if (isset($summaryInfo['summary'])) {
                     $descriptionArray['description'] = Record_Description::trimDescription($summaryInfo['summary']);
                     $useMarcSummary = false;
                 }
             }
         }
         if ($useMarcSummary) {
             if ($marcDescription != null) {
                 $descriptionArray['description'] = $marcDescription;
                 $description = $marcDescription;
             } else {
                 $description = "Description Not Provided";
                 $descriptionArray['description'] = $description;
             }
         }
         $interface->assign('description', $description);
         //Load page count
         if ($length = $marcRecord->getField('300')) {
             if ($length = $length->getSubfield('a')) {
                 $length = trim($length->getData());
                 $length = preg_replace("/[\\/|;:]/", "", $length);
                 $length = preg_replace("/p\\./", "pages", $length);
                 $descriptionArray['length'] = $length;
             }
         }
         //Load publisher
         if ($publisher = $marcRecord->getField('260')) {
             if ($publisher = $publisher->getSubfield('b')) {
                 $publisher = trim($publisher->getData());
                 $descriptionArray['publisher'] = $publisher;
             }
         }
         $memCache->set("record_description_{$isbn}_{$upc}_{$allowExternalDescription}", $descriptionArray, 0, $configArray['Caching']['record_description']);
     }
     return $descriptionArray;
 }
Ejemplo n.º 3
0
 function getDescription()
 {
     /** @var Memcache $memCache */
     global $memCache;
     global $configArray;
     global $interface;
     $id = $_REQUEST['id'];
     //Bypass loading solr, etc if we already have loaded the descriptive info before
     $descriptionArray = $memCache->get("record_description_{$id}");
     if (!$descriptionArray) {
         require_once 'Description.php';
         $searchObject = SearchObjectFactory::initSearchObject();
         $searchObject->init();
         $description = new Record_Description(true, $id);
         $descriptionArray = $description->loadData();
         $memCache->set("record_description_{$id}", $descriptionArray, 0, $configArray['Caching']['record_description']);
     }
     $interface->assign('description', $descriptionArray['description']);
     $interface->assign('length', isset($descriptionArray['length']) ? $descriptionArray['length'] : '');
     $interface->assign('publisher', isset($descriptionArray['publisher']) ? $descriptionArray['publisher'] : '');
     return $interface->fetch('Record/ajax-description-popup.tpl');
 }
Ejemplo n.º 4
0
 function getSystemListTitles($listName)
 {
     /** @var Memcache $memCache */
     global $memCache;
     global $configArray;
     $listTitles = $memCache->get('system_list_titles_' . $listName);
     if ($listTitles == false) {
         require_once ROOT_DIR . '/services/Record/Description.php';
         //return a random selection of 30 titles from the list.
         $scrollerName = strip_tags($_GET['scrollerName']);
         $searchObj = SearchObjectFactory::initSearchObject();
         $searchObj->init();
         $searchObj->setBasicQuery("*:*");
         $searchObj->addFilter("system_list:{$listName}");
         $searchObj->setLimit(50);
         $searchObj->processSearch(false, false);
         $matchingRecords = $searchObj->getResultRecordSet();
         $listTitles = array();
         foreach ($matchingRecords as $record) {
             $isbn = $record['isbn'][0];
             if (strpos($isbn, ' ') > 0) {
                 $isbn = substr($isbn, 0, strpos($isbn, ' '));
             }
             if (isset($record['issn'])) {
                 $issn = $record['issn'][0];
                 if (strpos($issn, ' ') > 0) {
                     $issn = substr($isbn, 0, strpos($issn, ' '));
                 }
             } else {
                 $issn = '';
             }
             // Process MARC Data
             require_once ROOT_DIR . '/sys/MarcLoader.php';
             $marcRecord = MarcLoader::loadMarcRecordFromRecord($record);
             if ($marcRecord) {
                 $descriptiveInfo = Record_Description::loadDescriptionFromMarc($marcRecord);
             }
             $listTitles[] = array('id' => $record['id'], 'image' => $configArray['Site']['coverUrl'] . "/bookcover.php?id=" . $record['id'] . "&issn=" . $issn . "&isn=" . $isbn . "&size=medium&upc=" . $record['upc'][0] . "&category=" . $record['format_category'][0], 'small_image' => $configArray['Site']['coverUrl'] . "/bookcover.php?id=" . $record['id'] . "&issn=" . $issn . "&isn=" . $isbn . "&size=small&upc=" . $record['upc'][0] . "&category=" . $record['format_category'][0], 'title' => $record['title'], 'author' => $record['author'], 'description' => isset($descriptiveInfo) ? $descriptiveInfo['description'] : null, 'length' => isset($descriptiveInfo) ? $descriptiveInfo['length'] : null, 'publisher' => isset($descriptiveInfo) ? $descriptiveInfo['publisher'] : null);
         }
         $memCache->set('system_list_titles_' . $listName, $listTitles, 0, $configArray['Caching']['system_list_titles']);
     }
     return $listTitles;
 }
Ejemplo n.º 5
0
 function getDescription()
 {
     /** @var Memcache $memCache */
     global $memCache;
     global $configArray;
     global $interface;
     global $timer;
     $id = $this->getUniqueID();
     //Bypass loading solr, etc if we already have loaded the descriptive info before
     $descriptionArray = $memCache->get("record_description_{$id}");
     if (!$descriptionArray) {
         require_once ROOT_DIR . '/services/Record/Description.php';
         $searchObject = SearchObjectFactory::initSearchObject();
         $searchObject->init();
         $description = new Record_Description(true, $id);
         $descriptionArray = $description->loadData();
         $memCache->set("record_description_{$id}", $descriptionArray, 0, $configArray['Caching']['record_description']);
         $timer->logTime("Retrieved description for index record");
     }
     $interface->assign('description', $descriptionArray['description']);
     $interface->assign('length', isset($descriptionArray['length']) ? $descriptionArray['length'] : '');
     $interface->assign('publisher', isset($descriptionArray['publisher']) ? $descriptionArray['publisher'] : '');
     return $interface->fetch('Record/ajax-description-popup.tpl');
 }