public function getIsbn10() { require_once ROOT_DIR . '/sys/ISBN.php'; $isbn = $this->getIsbn(); if ($isbn == null) { return $isbn; } elseif (strlen($isbn == 10)) { return $isbn; } else { require_once ROOT_DIR . '/Drivers/marmot_inc/ISBNConverter.php'; return ISBNConverter::convertISBN13to10($isbn); } }
private function makeIsbn10And13() { if (!is_null($this->isn) && strlen($this->isn) >= 10) { require_once ROOT_DIR . '/Drivers/marmot_inc/ISBNConverter.php'; if (strlen($this->isn) == 10) { //$this->log("Provided ISBN is 10 digits.", PEAR_LOG_INFO); $this->isbn10 = $this->isn; $this->isbn13 = ISBNConverter::convertISBN10to13($this->isbn10); } elseif (strlen($this->isn) == 13) { //$this->log("Provided ISBN is 13 digits.", PEAR_LOG_INFO); $this->isbn13 = $this->isn; $this->isbn10 = ISBNConverter::convertISBN13to10($this->isbn13); } $this->log("Loaded isbn10 {$this->isbn10} and isbn13 {$this->isbn13}.", PEAR_LOG_INFO); $this->logTime("create isbn 10 and isbn 13"); } }
/** * Load titles that have been rated by other users which are similar to this. * * @param SearchObject_Solr|SearchObject_Base $db * @param UserRating $ratedTitle * @param integer $userId * @param array $ratedTitles * @param array $suggestions * @param integer[] $notInterestedTitles * @return int The number of suggestions for this title */ static function getSimilarlyRatedTitles($db, $ratedTitle, $userId, $ratedTitles, &$suggestions, $notInterestedTitles) { $numRecommendations = 0; //If there is no ISBN, can we come up with an alternative algorithm? //Possibly using common ratings with other patrons? //Get a list of other patrons that have rated this title and that like it as much or more than the active user.. $otherRaters = new UserRating(); //Query the database to get items that other users who rated this liked. $sqlStatement = "SELECT resourceid, record_id, " . " sum(case rating when 5 then 10 when 4 then 6 end) as rating " . " FROM `user_rating` inner join resource on resource.id = user_rating.resourceid WHERE userId in " . " (select userId from user_rating where resourceId = " . $ratedTitle->resourceid . " and rating >= 4 " . " and userid != " . $userId . ") " . " and rating >= 4 " . " and resourceId != " . $ratedTitle->resourceid . " and deleted = 0 " . " group by resourceid order by rating desc limit 10"; //Sort so the highest titles are on top and limit to 10 suggestions. $otherRaters->query($sqlStatement); if ($otherRaters->N > 0) { //Other users have also rated this title. while ($otherRaters->fetch()) { //Process the title disableErrorHandler(); if (!($ownedRecord = $db->getRecord($otherRaters->record_id))) { //Old record which has been removed? Ignore for purposes of suggestions. continue; } enableErrorHandler(); //get the title from the Solr Index if (isset($ownedRecord['isbn'])) { if (strpos($ownedRecord['isbn'][0], ' ') > 0) { $isbnInfo = explode(' ', $ownedRecord['isbn'][0]); $isbn = $isbnInfo[0]; } else { $isbn = $ownedRecord['isbn'][0]; } $isbn13 = strlen($isbn) == 13 ? $isbn : ISBNConverter::convertISBN10to13($isbn); $isbn10 = strlen($isbn) == 10 ? $isbn : ISBNConverter::convertISBN13to10($isbn); } else { $isbn13 = ''; $isbn10 = ''; } //See if we can get the series title from the record if (isset($ownedRecord['series'])) { $series = $ownedRecord['series'][0]; } else { $series = ''; } $similarTitle = array('title' => $ownedRecord['title'], 'title_short' => $ownedRecord['title_short'], 'author' => isset($ownedRecord['author']) ? $ownedRecord['author'] : '', 'publicationDate' => $ownedRecord['publishDate'], 'isbn' => $isbn13, 'isbn10' => $isbn10, 'upc' => isset($ownedRecord['upc']) ? $ownedRecord['upc'][0] : '', 'recordId' => $ownedRecord['id'], 'id' => $ownedRecord['id'], 'libraryOwned' => true, 'isCurrent' => false, 'shortId' => substr($ownedRecord['id'], 1), 'format_category' => isset($ownedRecord['format_category']) ? $ownedRecord['format_category'] : '', 'format' => $ownedRecord['format'], 'recordtype' => $ownedRecord['recordtype'], 'series' => $series, 'grouping_term' => $ownedRecord['grouping_term']); $numRecommendations++; Suggestions::addTitleToSuggestions($ratedTitle, $similarTitle['title'], $similarTitle['recordId'], $similarTitle, $ratedTitles, $suggestions, $notInterestedTitles); } } return $numRecommendations; }
function loadNoveListTitle($originalIsbn, $item, &$titleList, &$titlesOwned, $seriesName = '') { global $user; $isbnList = array(); /** @var SimpleXMLElement $titleItem */ foreach ($item->TitleList->TitleItem as $titleItem) { $tmpIsbn = (string) $titleItem->attributes()->value; if (strlen($tmpIsbn) == 10 || strlen($tmpIsbn) == 13) { $isbnList[] = (string) $titleItem->attributes()->value; } } //If there is no ISBN, don't bother loading the title if (count($isbnList) == 0) { return; } //run a search to get the record id for the isbns. //TODO: cache this info since it can take a really long time to load $searchObj = SearchObjectFactory::initSearchObject(); $searchObj->setBasicQuery(implode(' OR ', $isbnList), 'ISN'); $searchObj->disableScoping(); //Add a filter to only include books and DVDs $searchObj->processSearch(false, false); $matchingRecords = $searchObj->getResultRecordSet(); $isCurrent = in_array($originalIsbn, $isbnList); if (isset($seriesName)) { $series = $seriesName; } else { $series = null; } $volume = ''; if ($item->Volume) { $volume = (string) $item->Volume; } if (count($matchingRecords) > 0) { $ownedRecord = $matchingRecords[0]; if (strpos($ownedRecord['isbn'][0], ' ') > 0) { $isbnInfo = explode(' ', $ownedRecord['isbn'][0]); $isbn = $isbnInfo[0]; } else { $isbn = $ownedRecord['isbn'][0]; } $isbn13 = strlen($isbn) == 13 ? $isbn : ISBNConverter::convertISBN10to13($isbn); $isbn10 = strlen($isbn) == 10 ? $isbn : ISBNConverter::convertISBN13to10($isbn); if (!isset($series)) { if (isset($ownedRecord['series'])) { $series = $ownedRecord['series'][0]; } } //Load rating data if ($ownedRecord['recordtype'] == 'marc') { $resource = new Resource(); $resource->source = 'VuFind'; $resource->record_id = $ownedRecord['id']; $resource->find(true); $ratingData = $resource->getRatingData($user); $fullRecordLink = '/Record/' . $ownedRecord['id'] . '/Home'; } else { require_once ROOT_DIR . '/sys/eContent/EContentRating.php'; $shortId = str_replace('econtentRecord', '', $ownedRecord['id']); $econtentRating = new EContentRating(); $econtentRating->recordId = $shortId; $ratingData = $econtentRating->getRatingData($user, false); $fullRecordLink = '/EcontentRecord/' . $shortId . '/Home'; } //See if we can get the series title from the record $titleList[] = array('title' => $ownedRecord['title'], 'title_short' => isset($ownedRecord['title_short']) ? $ownedRecord['title_short'] : $ownedRecord['title'], 'author' => isset($ownedRecord['author']) ? $ownedRecord['author'] : '', 'publicationDate' => (string) $item->PublicationDate, 'isbn' => $isbn13, 'isbn10' => $isbn10, 'upc' => isset($ownedRecord['upc'][0]) ? $ownedRecord['upc'][0] : '', 'recordId' => $ownedRecord['id'], 'recordtype' => $ownedRecord['recordtype'], 'id' => $ownedRecord['id'], 'libraryOwned' => true, 'isCurrent' => $isCurrent, 'shortId' => substr($ownedRecord['id'], 1), 'format_category' => $ownedRecord['format_category'], 'format' => $ownedRecord['format'], 'series' => $series, 'volume' => $volume, 'ratingData' => $ratingData, 'fullRecordLink' => $fullRecordLink); $titlesOwned++; } else { $isbn = $isbnList[0]; $isbn13 = strlen($isbn) == 13 ? $isbn : ISBNConverter::convertISBN10to13($isbn); $isbn10 = strlen($isbn) == 10 ? $isbn : ISBNConverter::convertISBN13to10($isbn); $titleList[] = array('title' => (string) $item->Name, 'author' => (string) $item->Author, 'publicationDate' => (string) $item->PublicationDate, 'isbn' => $isbn13, 'isbn10' => $isbn10, 'recordId' => -1, 'libraryOwned' => false, 'isCurrent' => $isCurrent, 'series' => $series, 'volume' => $volume); } }
function __construct($subAction = false, $record_id = null) { global $interface; global $configArray; global $library; global $timer; global $logger; $interface->assign('page_body_style', 'sidebar_left'); $interface->assign('libraryThingUrl', $configArray['LibraryThing']['url']); //Determine whether or not materials request functionality should be enabled $interface->assign('enableMaterialsRequest', MaterialsRequest::enableMaterialsRequest()); //Load basic information needed in subclasses if ($record_id == null || !isset($record_id)) { $this->id = $_GET['id']; } else { $this->id = $record_id; } //Check to see if the record exists within the resources table $resource = new Resource(); $resource->record_id = $this->id; $resource->source = 'VuFind'; $resource->deleted = 0; if (!$resource->find()) { //Check to see if the record has been converted to an eContent record require_once ROOT_DIR . '/sys/eContent/EContentRecord.php'; $econtentRecord = new EContentRecord(); $econtentRecord->ilsId = $this->id; $econtentRecord->status = 'active'; if ($econtentRecord->find(true)) { header("Location: /EcontentRecord/{$econtentRecord->id}/Home"); die; } $logger->log("Did not find a record for id {$this->id} in resources table.", PEAR_LOG_DEBUG); $interface->setTemplate('invalidRecord.tpl'); $interface->display('layout.tpl'); die; } if ($configArray['Catalog']['ils'] == 'Millennium') { $interface->assign('classicId', substr($this->id, 1, strlen($this->id) - 2)); $interface->assign('classicUrl', $configArray['Catalog']['linking_url']); } // Setup Search Engine Connection $class = $configArray['Index']['engine']; $url = $configArray['Index']['url']; $this->db = new $class($url); $this->db->disableScoping(); // Retrieve Full Marc Record if (!($record = $this->db->getRecord($this->id))) { $logger->log("Did not find a record for id {$this->id} in solr.", PEAR_LOG_DEBUG); $interface->setTemplate('invalidRecord.tpl'); $interface->display('layout.tpl'); die; } $this->db->enableScoping(); $this->record = $record; $interface->assign('record', $record); $this->recordDriver = RecordDriverFactory::initRecordDriver($record); $timer->logTime('Initialized the Record Driver'); $interface->assign('coreMetadata', $this->recordDriver->getCoreMetadata()); // Process MARC Data require_once ROOT_DIR . '/sys/MarcLoader.php'; $marcRecord = MarcLoader::loadMarcRecordFromRecord($record); if ($marcRecord) { $this->marcRecord = $marcRecord; $interface->assign('marc', $marcRecord); } else { $interface->assign('error', 'Cannot Process MARC Record'); } $timer->logTime('Processed the marc record'); //Load information for display in the template rather than processing specific fields in the template $marcField = $marcRecord->getField('245'); $recordTitle = $this->getSubfieldData($marcField, 'a'); $interface->assign('recordTitle', $recordTitle); $recordTitleSubtitle = trim($this->concatenateSubfieldData($marcField, array('a', 'b', 'h', 'n', 'p'))); $recordTitleSubtitle = preg_replace('~\\s+[\\/:]$~', '', $recordTitleSubtitle); $interface->assign('recordTitleSubtitle', $recordTitleSubtitle); $recordTitleWithAuth = trim($this->concatenateSubfieldData($marcField, array('a', 'b', 'h', 'n', 'p', 'c'))); $interface->assign('recordTitleWithAuth', $recordTitleWithAuth); $marcField = $marcRecord->getField('100'); if ($marcField) { $mainAuthor = $this->concatenateSubfieldData($marcField, array('a', 'b', 'c', 'd')); $interface->assign('mainAuthor', $mainAuthor); } $marcField = $marcRecord->getField('110'); if ($marcField) { $corporateAuthor = $this->getSubfieldData($marcField, 'a'); $interface->assign('corporateAuthor', $corporateAuthor); } $marcFields = $marcRecord->getFields('700'); if ($marcFields) { $contributors = array(); foreach ($marcFields as $marcField) { $contributors[] = $this->concatenateSubfieldData($marcField, array('a', 'b', 'c', 'd')); } $interface->assign('contributors', $contributors); } $published = $this->recordDriver->getPublicationDetails(); $interface->assign('published', $published); $marcFields = $marcRecord->getFields('250'); if ($marcFields) { $editionsThis = array(); foreach ($marcFields as $marcField) { $editionsThis[] = $this->getSubfieldData($marcField, 'a'); } $interface->assign('editionsThis', $editionsThis); } $marcFields = $marcRecord->getFields('300'); if ($marcFields) { $physicalDescriptions = array(); foreach ($marcFields as $marcField) { $description = $this->concatenateSubfieldData($marcField, array('a', 'b', 'c', 'e', 'f', 'g')); if ($description != 'p. cm.') { $description = preg_replace("/[\\/|;:]\$/", '', $description); $description = preg_replace("/p\\./", 'pages', $description); $physicalDescriptions[] = $description; } } $interface->assign('physicalDescriptions', $physicalDescriptions); } // Get ISBN for cover and review use $mainIsbnSet = false; /** @var File_MARC_Data_Field[] $isbnFields */ if ($isbnFields = $this->marcRecord->getFields('020')) { $isbns = array(); //Use the first good ISBN we find. foreach ($isbnFields as $isbnField) { /** @var File_MARC_Subfield $isbnSubfieldA */ if ($isbnSubfieldA = $isbnField->getSubfield('a')) { $tmpIsbn = trim($isbnSubfieldA->getData()); if (strlen($tmpIsbn) > 0) { $isbns[] = $isbnSubfieldA->getData(); $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); } if (!$mainIsbnSet) { $this->isbn = $tmpIsbn; $interface->assign('isbn', $tmpIsbn); $mainIsbnSet = true; } } } } } if (isset($this->isbn)) { if (strlen($this->isbn) == 13) { require_once ROOT_DIR . '/Drivers/marmot_inc/ISBNConverter.php'; $this->isbn10 = ISBNConverter::convertISBN13to10($this->isbn); } else { $this->isbn10 = $this->isbn; } $interface->assign('isbn10', $this->isbn10); } $interface->assign('isbns', $isbns); } if ($upcField = $this->marcRecord->getField('024')) { /** @var File_MARC_Data_Field $upcField */ if ($upcSubField = $upcField->getSubfield('a')) { $this->upc = trim($upcSubField->getData()); $interface->assign('upc', $this->upc); } } if ($issnField = $this->marcRecord->getField('022')) { /** @var File_MARC_Data_Field $issnField */ if ($issnSubField = $issnField->getSubfield('a')) { $this->issn = trim($issnSubField->getData()); if ($pos = strpos($this->issn, ' ')) { $this->issn = substr($this->issn, 0, $pos); } $interface->assign('issn', $this->issn); //Also setup GoldRush link if (isset($library) && strlen($library->goldRushCode) > 0) { $interface->assign('goldRushLink', "http://goldrush.coalliance.org/index.cfm?fuseaction=Search&inst_code={$library->goldRushCode}&search_type=ISSN&search_term={$this->issn}"); } } } $timer->logTime("Got basic data from Marc Record subaction = {$subAction}, record_id = {$record_id}"); //stop if this is not the main action. if ($subAction == true) { return; } //Get street date if ($streetDateField = $this->marcRecord->getField('263')) { $streetDate = $this->getSubfieldData($streetDateField, 'a'); if ($streetDate != '') { $interface->assign('streetDate', $streetDate); } } /** @var File_MARC_Data_Field[] $marcField440 */ $marcField440 = $marcRecord->getFields('440'); /** @var File_MARC_Data_Field[] $marcField490 */ $marcField490 = $marcRecord->getFields('490'); /** @var File_MARC_Data_Field[] $marcField830 */ $marcField830 = $marcRecord->getFields('830'); if ($marcField440 || $marcField490 || $marcField830) { $series = array(); foreach ($marcField440 as $field) { $series[] = $this->getSubfieldData($field, 'a'); } foreach ($marcField490 as $field) { if ($field->getIndicator(1) == 0) { $series[] = $this->getSubfieldData($field, 'a'); } } foreach ($marcField830 as $field) { $series[] = $this->getSubfieldData($field, 'a'); } $interface->assign('series', $series); } //Load description from Syndetics $useMarcSummary = true; if ($this->isbn || $this->upc) { if ($library && $library->preferSyndeticsSummary == 1) { require_once ROOT_DIR . '/Drivers/marmot_inc/GoDeeperData.php'; $summaryInfo = GoDeeperData::getSummary($this->isbn, $this->upc); if (isset($summaryInfo['summary'])) { $interface->assign('summaryTeaser', $summaryInfo['summary']); $interface->assign('summary', $summaryInfo['summary']); $useMarcSummary = false; } } } if ($useMarcSummary) { if ($summaryField = $this->marcRecord->getField('520')) { $interface->assign('summary', $this->getSubfieldData($summaryField, 'a')); $interface->assign('summaryTeaser', $this->getSubfieldData($summaryField, 'a')); } elseif ($library && $library->preferSyndeticsSummary == 0) { require_once ROOT_DIR . '/Drivers/marmot_inc/GoDeeperData.php'; $summaryInfo = GoDeeperData::getSummary($this->isbn, $this->upc); if (isset($summaryInfo['summary'])) { $interface->assign('summaryTeaser', $summaryInfo['summary']); $interface->assign('summary', $summaryInfo['summary']); $useMarcSummary = false; } } } if ($mpaaField = $this->marcRecord->getField('521')) { $interface->assign('mpaaRating', $this->getSubfieldData($mpaaField, 'a')); } if (isset($configArray['Content']['subjectFieldsToShow'])) { $subjectFieldsToShow = $configArray['Content']['subjectFieldsToShow']; $subjectFields = explode(',', $subjectFieldsToShow); $subjects = array(); foreach ($subjectFields as $subjectField) { /** @var File_MARC_Data_Field[] $marcFields */ $marcFields = $marcRecord->getFields($subjectField); if ($marcFields) { foreach ($marcFields as $marcField) { $searchSubject = ""; $subject = array(); foreach ($marcField->getSubFields() as $subField) { /** @var File_MARC_Subfield $subField */ if ($subField->getCode() != 2) { $searchSubject .= " " . $subField->getData(); $subject[] = array('search' => trim($searchSubject), 'title' => $subField->getData()); } } $subjects[] = $subject; } } $interface->assign('subjects', $subjects); } } $format = $record['format']; $interface->assign('recordFormat', $record['format']); $format_category = isset($record['format_category'][0]) ? $record['format_category'][0] : ''; $interface->assign('format_category', $format_category); $interface->assign('recordLanguage', isset($record['language']) ? $record['language'] : null); $timer->logTime('Got detailed data from Marc Record'); $tableOfContents = array(); $marcFields505 = $marcRecord->getFields('505'); if ($marcFields505) { $tableOfContents = $this->processTableOfContentsFields($marcFields505); } $notes = array(); $marcFields500 = $marcRecord->getFields('500'); $marcFields504 = $marcRecord->getFields('504'); $marcFields511 = $marcRecord->getFields('511'); $marcFields518 = $marcRecord->getFields('518'); $marcFields520 = $marcRecord->getFields('520'); if ($marcFields500 || $marcFields504 || $marcFields505 || $marcFields511 || $marcFields518 || $marcFields520) { $allFields = array_merge($marcFields500, $marcFields504, $marcFields511, $marcFields518, $marcFields520); $notes = $this->processNoteFields($allFields); } if (isset($library) && $library->showTableOfContentsTab == 0 || count($tableOfContents) == 0) { $notes = array_merge($notes, $tableOfContents); } else { $interface->assign('tableOfContents', $tableOfContents); } if (isset($library) && strlen($library->notesTabName) > 0) { $interface->assign('notesTabName', $library->notesTabName); } else { $interface->assign('notesTabName', 'Notes'); } $additionalNotesFields = array('310' => 'Current Publication Frequency', '321' => 'Former Publication Frequency', '351' => 'Organization & arrangement of materials', '362' => 'Dates of publication and/or sequential designation', '501' => '"With"', '502' => 'Dissertation', '506' => 'Restrictions on Access', '507' => 'Scale for Graphic Material', '508' => 'Creation/Production Credits', '510' => 'Citation/References', '511' => 'Participant or Performer', '513' => 'Type of Report an Period Covered', '515' => 'Numbering Peculiarities', '518' => 'Date/Time and Place of Event', '521' => 'Target Audience', '522' => 'Geographic Coverage', '525' => 'Supplement', '526' => 'Study Program Information', '530' => 'Additional Physical Form', '533' => 'Reproduction', '534' => 'Original Version', '536' => 'Funding Information', '538' => 'System Details', '545' => 'Biographical or Historical Data', '546' => 'Language', '547' => 'Former Title Complexity', '550' => 'Issuing Body', '555' => 'Cumulative Index/Finding Aids', '556' => 'Information About Documentation', '561' => 'Ownership and Custodial History', '563' => 'Binding Information', '580' => 'Linking Entry Complexity', '581' => 'Publications About Described Materials', '586' => 'Awards', '590' => 'Local note', '599' => 'Differentiable Local note'); foreach ($additionalNotesFields as $tag => $label) { $marcFields = $marcRecord->getFields($tag); foreach ($marcFields as $marcField) { $noteText = array(); foreach ($marcField->getSubFields() as $subfield) { /** @var File_MARC_Subfield $subfield */ $noteText[] = $subfield->getData(); } $note = implode(',', $noteText); if (strlen($note) > 0) { $notes[] = "<b>{$label}</b>: " . $note; } } } if (count($notes) > 0) { $interface->assign('notes', $notes); } /** @var File_MARC_Data_Field[] $linkFields */ $linkFields = $marcRecord->getFields('856'); if ($linkFields) { $internetLinks = array(); $purchaseLinks = array(); $field856Index = 0; foreach ($linkFields as $marcField) { $field856Index++; //Get the link if ($marcField->getSubfield('u')) { $link = $marcField->getSubfield('u')->getData(); if ($marcField->getSubfield('3')) { $linkText = $marcField->getSubfield('3')->getData(); } elseif ($marcField->getSubfield('y')) { $linkText = $marcField->getSubfield('y')->getData(); } elseif ($marcField->getSubfield('z')) { $linkText = $marcField->getSubfield('z')->getData(); } else { $linkText = $link; } $showLink = true; //Process some links differently so we can either hide them //or show them in different areas of the catalog. if (preg_match('/purchase|buy/i', $linkText) || preg_match('/barnesandnoble|tatteredcover|amazon|smashwords\\.com/i', $link)) { $showLink = false; } $isBookLink = preg_match('/acs\\.dcl\\.lan|vufind\\.douglascountylibraries\\.org|catalog\\.douglascountylibraries\\.org/i', $link); if ($isBookLink == 1) { //e-book link, don't show $showLink = false; } if ($showLink) { //Rewrite the link so we can track usage $link = $configArray['Site']['path'] . '/Record/' . $this->id . '/Link?index=' . $field856Index; $internetLinks[] = array('link' => $link, 'linkText' => $linkText); } } } if (count($internetLinks) > 0) { $interface->assign('internetLinks', $internetLinks); } } if (isset($purchaseLinks) && count($purchaseLinks) > 0) { $interface->assign('purchaseLinks', $purchaseLinks); } //Determine the cover to use $bookCoverUrl = $configArray['Site']['coverUrl'] . "/bookcover.php?id={$this->id}&isn={$this->isbn}&issn={$this->issn}&size=large&upc={$this->upc}&category=" . urlencode($format_category) . "&format=" . urlencode(isset($format[0]) ? $format[0] : ''); $interface->assign('bookCoverUrl', $bookCoverUrl); //Load accelerated reader data if (isset($record['accelerated_reader_interest_level'])) { $arData = array('interestLevel' => $record['accelerated_reader_interest_level'], 'pointValue' => $record['accelerated_reader_point_value'], 'readingLevel' => $record['accelerated_reader_reading_level']); $interface->assign('arData', $arData); } if (isset($record['lexile_score']) && $record['lexile_score'] > -1) { $lexileScore = $record['lexile_score']; if (isset($record['lexile_code'])) { $lexileScore = $record['lexile_code'] . $lexileScore; } $interface->assign('lexileScore', $lexileScore . 'L'); } //Do actions needed if this is the main action. //$interface->caching = 1; $interface->assign('id', $this->id); if (substr($this->id, 0, 1) == '.') { $interface->assign('shortId', substr($this->id, 1)); } else { $interface->assign('shortId', $this->id); } $interface->assign('addHeader', '<link rel="alternate" type="application/rdf+xml" title="RDF Representation" href="' . $configArray['Site']['path'] . '/Record/' . urlencode($this->id) . '/RDF" />'); // Define Default Tab $tab = isset($_GET['action']) ? $_GET['action'] : 'Description'; $interface->assign('tab', $tab); if (isset($_REQUEST['detail'])) { $detail = strip_tags($_REQUEST['detail']); $interface->assign('defaultDetailsTab', $detail); } // Define External Content Provider if ($this->marcRecord->getField('020')) { if (isset($configArray['Content']['reviews'])) { $interface->assign('hasReviews', true); } if (isset($configArray['Content']['excerpts'])) { $interface->assign('hasExcerpt', true); } } // Retrieve User Search History $interface->assign('lastsearch', isset($_SESSION['lastSearchURL']) ? $_SESSION['lastSearchURL'] : false); // Retrieve tags associated with the record $limit = 5; $resource = new Resource(); $resource->record_id = $_GET['id']; $resource->source = 'VuFind'; $resource->find(true); $tags = $resource->getTags($limit); $interface->assign('tagList', $tags); $timer->logTime('Got tag list'); $this->cacheId = 'Record|' . $_GET['id'] . '|' . get_class($this); // Find Similar Records /** @var Memcache $memCache */ global $memCache; $similar = $memCache->get('similar_titles_' . $this->id); if ($similar == false) { $similar = $this->db->getMoreLikeThis($this->id); // Send the similar items to the template; if there is only one, we need // to force it to be an array or things will not display correctly. if (isset($similar) && count($similar['response']['docs']) > 0) { $similar = $similar['response']['docs']; } else { $similar = array(); $timer->logTime("Did not find any similar records"); } $memCache->set('similar_titles_' . $this->id, $similar, 0, $configArray['Caching']['similar_titles']); } $this->similarTitles = $similar; $interface->assign('similarRecords', $similar); $timer->logTime('Loaded similar titles'); // Find Other Editions if ($configArray['Content']['showOtherEditionsPopup'] == false) { $editions = OtherEditionHandler::getEditions($this->id, $this->isbn, isset($this->record['issn']) ? $this->record['issn'] : null); if (!PEAR_Singleton::isError($editions)) { $interface->assign('editions', $editions); } else { $timer->logTime("Did not find any other editions"); } $timer->logTime('Got Other editions'); } $interface->assign('showStrands', isset($configArray['Strands']['APID']) && strlen($configArray['Strands']['APID']) > 0); // Send down text for inclusion in breadcrumbs $interface->assign('breadcrumbText', $this->recordDriver->getBreadcrumb()); // Send down OpenURL for COinS use: $interface->assign('openURL', $this->recordDriver->getOpenURL()); // Send down legal export formats (if any): $interface->assign('exportFormats', $this->recordDriver->getExportFormats()); // Set AddThis User $interface->assign('addThis', isset($configArray['AddThis']['key']) ? $configArray['AddThis']['key'] : false); // Set Proxy URL if (isset($configArray['EZproxy']['host'])) { $interface->assign('proxy', $configArray['EZproxy']['host']); } //setup 5 star ratings global $user; $ratingData = $resource->getRatingData($user); $interface->assign('ratingData', $ratingData); $timer->logTime('Got 5 star data'); //Get Next/Previous Links $searchSource = isset($_REQUEST['searchSource']) ? $_REQUEST['searchSource'] : 'local'; $searchObject = SearchObjectFactory::initSearchObject(); $searchObject->init($searchSource); $searchObject->getNextPrevLinks(); //Load Staff Details $interface->assign('staffDetails', $this->recordDriver->getStaffView()); }
function __construct($subAction = false, $record_id = null) { global $interface; global $configArray; global $library; global $timer; $interface->assign('page_body_style', 'sidebar_left'); //Load basic information needed in subclasses if ($record_id == null || !isset($record_id)) { $this->id = $_GET['id']; } else { $this->id = $record_id; } $interface->assign('id', $this->id); if (preg_match('/^[\\da-fA-F-]{36}$/', $this->id)) { header('Location:' . $configArray['Site']['path'] . '/GroupedWork/' . $this->id); die; } //Check to see if the record exists within the resources table $this->recordDriver = new MarcRecord($this->id); if (!$this->recordDriver->isValid()) { $interface->assign('sidebar', 'Record/full-record-sidebar.tpl'); $interface->setTemplate('invalidRecord.tpl'); $interface->display('layout.tpl'); die; } if ($configArray['Catalog']['ils'] == 'Millennium' || $configArray['Catalog']['ils'] == 'Sierra') { $classicId = substr($this->id, 1, strlen($this->id) - 2); $interface->assign('classicId', $classicId); $millenniumScope = $interface->getVariable('millenniumScope'); if (isset($configArray['Catalog']['linking_url'])) { $interface->assign('classicUrl', $configArray['Catalog']['linking_url'] . "/record={$classicId}&searchscope={$millenniumScope}"); } } elseif ($configArray['Catalog']['ils'] == 'Koha') { $interface->assign('classicId', $this->id); $interface->assign('classicUrl', $configArray['Catalog']['url'] . '/cgi-bin/koha/opac-detail.pl?biblionumber=' . $this->id); $interface->assign('staffClientUrl', $configArray['Catalog']['staffClientUrl'] . '/cgi-bin/koha/catalogue/detail.pl?biblionumber=' . $this->id); } // Process MARC Data require_once ROOT_DIR . '/sys/MarcLoader.php'; $marcRecord = MarcLoader::loadMarcRecordByILSId($this->id); if ($marcRecord) { $this->marcRecord = $marcRecord; $interface->assign('marc', $marcRecord); require_once ROOT_DIR . '/RecordDrivers/MarcRecord.php'; $this->recordDriver = new MarcRecord($marcRecord); $interface->assign('recordDriver', $this->recordDriver); } else { $interface->assign('error', 'Cannot Process MARC Record'); } $timer->logTime('Processed the marc record'); //Load information for display in the template rather than processing specific fields in the template $marcField = $marcRecord->getField('245'); $recordTitle = $this->getSubfieldData($marcField, 'a'); $interface->assign('recordTitle', $recordTitle); $recordTitleSubtitle = trim($this->concatenateSubfieldData($marcField, array('a', 'b', 'h', 'n', 'p'))); $recordTitleSubtitle = preg_replace('~\\s+[\\/:]$~', '', $recordTitleSubtitle); $interface->assign('recordTitleSubtitle', $recordTitleSubtitle); $recordTitleWithAuth = trim($this->concatenateSubfieldData($marcField, array('a', 'b', 'h', 'n', 'p', 'c'))); $interface->assign('recordTitleWithAuth', $recordTitleWithAuth); $marcField = $marcRecord->getField('100'); if ($marcField) { $mainAuthor = $this->concatenateSubfieldData($marcField, array('a', 'b', 'c', 'd')); $interface->assign('mainAuthor', $mainAuthor); } $marcFields = $marcRecord->getFields('250'); if ($marcFields) { $editionsThis = array(); foreach ($marcFields as $marcField) { $editionsThis[] = $this->getSubfieldData($marcField, 'a'); } $interface->assign('editionsThis', $editionsThis); } $marcFields = $marcRecord->getFields('300'); if ($marcFields) { $physicalDescriptions = array(); foreach ($marcFields as $marcField) { $description = $this->concatenateSubfieldData($marcField, array('a', 'b', 'c', 'e', 'f', 'g')); if ($description != 'p. cm.') { $description = preg_replace("/[\\/|;:]\$/", '', $description); $description = preg_replace("/p\\./", 'pages', $description); $physicalDescriptions[] = $description; } } $interface->assign('physicalDescriptions', $physicalDescriptions); } // Get ISBN for cover and review use $mainIsbnSet = false; /** @var File_MARC_Data_Field[] $isbnFields */ if ($isbnFields = $this->marcRecord->getFields('020')) { $isbns = array(); //Use the first good ISBN we find. foreach ($isbnFields as $isbnField) { /** @var File_MARC_Subfield $isbnSubfieldA */ if ($isbnSubfieldA = $isbnField->getSubfield('a')) { $tmpIsbn = trim($isbnSubfieldA->getData()); if (strlen($tmpIsbn) > 0) { $isbns[] = $isbnSubfieldA->getData(); $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); } if (!$mainIsbnSet) { $this->isbn = $tmpIsbn; $interface->assign('isbn', $tmpIsbn); $mainIsbnSet = true; } } } } } if (isset($this->isbn)) { if (strlen($this->isbn) == 13) { require_once ROOT_DIR . '/Drivers/marmot_inc/ISBNConverter.php'; $this->isbn10 = ISBNConverter::convertISBN13to10($this->isbn); } else { $this->isbn10 = $this->isbn; } $interface->assign('isbn10', $this->isbn10); } $interface->assign('isbns', $isbns); } if ($upcField = $this->marcRecord->getField('024')) { /** @var File_MARC_Data_Field $upcField */ if ($upcSubField = $upcField->getSubfield('a')) { $this->upc = trim($upcSubField->getData()); $interface->assign('upc', $this->upc); } } if ($issnField = $this->marcRecord->getField('022')) { /** @var File_MARC_Data_Field $issnField */ if ($issnSubField = $issnField->getSubfield('a')) { $this->issn = trim($issnSubField->getData()); if ($pos = strpos($this->issn, ' ')) { $this->issn = substr($this->issn, 0, $pos); } $interface->assign('issn', $this->issn); //Also setup GoldRush link if (isset($library) && strlen($library->goldRushCode) > 0) { $interface->assign('goldRushLink', "http://goldrush.coalliance.org/index.cfm?fuseaction=Search&inst_code={$library->goldRushCode}&search_type=ISSN&search_term={$this->issn}"); } } } $timer->logTime("Got basic data from Marc Record subaction = {$subAction}, record_id = {$record_id}"); //stop if this is not the main action. if ($subAction == true) { return; } //Get street date if ($streetDateField = $this->marcRecord->getField('263')) { $streetDate = $this->getSubfieldData($streetDateField, 'a'); if ($streetDate != '') { $interface->assign('streetDate', $streetDate); } } if ($mpaaField = $this->marcRecord->getField('521')) { $interface->assign('mpaaRating', $this->getSubfieldData($mpaaField, 'a')); } $format = $this->recordDriver->getFormat(); $interface->assign('recordFormat', $format); $format_category = $format = $this->recordDriver->getFormatCategory(); $interface->assign('format_category', $format_category); $interface->assign('recordLanguage', $this->recordDriver->getLanguage()); $timer->logTime('Got detailed data from Marc Record'); $notes = array(); if (isset($library) && strlen($library->notesTabName) > 0) { $interface->assign('notesTabName', $library->notesTabName); } else { $interface->assign('notesTabName', 'Notes'); } $notes = $this->recordDriver->getNotes(); if (count($notes) > 0) { $interface->assign('notes', $notes); } /** @var File_MARC_Data_Field[] $linkFields */ $linkFields = $marcRecord->getFields('856'); if ($linkFields) { $internetLinks = array(); $purchaseLinks = array(); $field856Index = 0; foreach ($linkFields as $marcField) { $field856Index++; //Get the link if ($marcField->getSubfield('u')) { $link = $marcField->getSubfield('u')->getData(); if ($marcField->getSubfield('3')) { $linkText = $marcField->getSubfield('3')->getData(); } elseif ($marcField->getSubfield('y')) { $linkText = $marcField->getSubfield('y')->getData(); } elseif ($marcField->getSubfield('z')) { $linkText = $marcField->getSubfield('z')->getData(); } else { $linkText = $link; } $showLink = true; //Process some links differently so we can either hide them //or show them in different areas of the catalog. if (preg_match('/purchase|buy/i', $linkText) || preg_match('/barnesandnoble|tatteredcover|amazon|smashwords\\.com/i', $link)) { $showLink = false; } $isBookLink = preg_match('/acs\\.dcl\\.lan|vufind\\.douglascountylibraries\\.org|catalog\\.douglascountylibraries\\.org/i', $link); if ($isBookLink == 1) { //e-book link, don't show $showLink = false; } if ($showLink) { //Rewrite the link so we can track usage $link = $configArray['Site']['path'] . '/Record/' . $this->id . '/Link?index=' . $field856Index; $internetLinks[] = array('link' => $link, 'linkText' => $linkText); } } } if (count($internetLinks) > 0) { $interface->assign('internetLinks', $internetLinks); } } if (isset($purchaseLinks) && count($purchaseLinks) > 0) { $interface->assign('purchaseLinks', $purchaseLinks); } //Determine the cover to use $interface->assign('bookCoverUrl', $this->recordDriver->getBookcoverUrl('large')); //Load accelerated reader data if (isset($record['accelerated_reader_interest_level'])) { $arData = array('interestLevel' => $record['accelerated_reader_interest_level'], 'pointValue' => $record['accelerated_reader_point_value'], 'readingLevel' => $record['accelerated_reader_reading_level']); $interface->assign('arData', $arData); } if (isset($record['lexile_score']) && $record['lexile_score'] > -1) { $lexileScore = $record['lexile_score']; if (isset($record['lexile_code'])) { $lexileScore = $record['lexile_code'] . $lexileScore; } $interface->assign('lexileScore', $lexileScore . 'L'); } //Do actions needed if this is the main action. //$interface->caching = 1; $interface->assign('id', $this->id); if (substr($this->id, 0, 1) == '.') { $interface->assign('shortId', substr($this->id, 1)); } else { $interface->assign('shortId', $this->id); } $interface->assign('addHeader', '<link rel="alternate" type="application/rdf+xml" title="RDF Representation" href="' . $configArray['Site']['path'] . '/Record/' . urlencode($this->id) . '/RDF" />'); // Define Default Tab $tab = isset($_GET['action']) ? $_GET['action'] : 'Description'; $interface->assign('tab', $tab); if (isset($_REQUEST['detail'])) { $detail = strip_tags($_REQUEST['detail']); $interface->assign('defaultDetailsTab', $detail); } // Define External Content Provider if ($this->marcRecord->getField('020')) { if (isset($configArray['Content']['reviews'])) { $interface->assign('hasReviews', true); } if (isset($configArray['Content']['excerpts'])) { $interface->assign('hasExcerpt', true); } } // Retrieve User Search History $interface->assign('lastsearch', isset($_SESSION['lastSearchURL']) ? $_SESSION['lastSearchURL'] : false); $this->cacheId = 'Record|' . $_GET['id'] . '|' . get_class($this); // Send down text for inclusion in breadcrumbs $interface->assign('breadcrumbText', $this->recordDriver->getBreadcrumb()); // Send down legal export formats (if any): $interface->assign('exportFormats', $this->recordDriver->getExportFormats()); // Set AddThis User $interface->assign('addThis', isset($configArray['AddThis']['key']) ? $configArray['AddThis']['key'] : false); //Get Next/Previous Links $searchSource = isset($_REQUEST['searchSource']) ? $_REQUEST['searchSource'] : 'local'; $searchObject = SearchObjectFactory::initSearchObject(); $searchObject->init($searchSource); $searchObject->getNextPrevLinks(); //Load Staff Details $interface->assign('staffDetails', $this->recordDriver->getStaffView()); }
private function loadNoveListTitle($currentId, $item, &$titleList, &$titlesOwned, $seriesName = '') { global $user; global $timer; global $configArray; //Find the correct grouped work based on the isbns; require_once ROOT_DIR . '/sys/Grouping/GroupedWork.php'; require_once ROOT_DIR . '/sys/Grouping/GroupedWorkIdentifier.php'; require_once ROOT_DIR . '/sys/Grouping/GroupedWorkIdentifierRef.php'; $timer->logTime("Start loadNoveListTitle"); /** @var SimpleXMLElement $titleItem */ $permanentId = null; $concatenatedIsbns = "'" . implode("','", $item->isbns) . "'"; $groupedWorkIdentifier = new GroupedWorkIdentifier(); $groupedWorkIdentifier->type = "isbn"; $groupedWorkIdentifier->whereAdd("identifier in ({$concatenatedIsbns})"); if ($groupedWorkIdentifier->find()) { while ($groupedWorkIdentifier->fetch()) { $groupedWorkIdentifierRef = new GroupedWorkIdentifierRef(); $groupedWorkIdentifierRef->identifier_id = $groupedWorkIdentifier->id; $groupedWorkIdentifierRef->find(); if ($groupedWorkIdentifierRef->N == 1) { $groupedWorkIdentifierRef->fetch(); $groupedWork = new GroupedWork(); $groupedWork->id = $groupedWorkIdentifierRef->grouped_work_id; if ($groupedWork->find(true)) { $permanentId = $groupedWork->permanent_id; break; } } } } $timer->logTime("Load Novelist Title - Find Grouped Work based on identifier {$permanentId}"); $isCurrent = $currentId == $permanentId; if (isset($seriesName)) { $series = $seriesName; } else { $series = ''; } $volume = ''; if (isset($item->volume)) { $volume = $item->volume; } //We didn't find a match in the database so we don't own it if ($permanentId == null) { $isbn = reset($item->isbns); $isbn13 = strlen($isbn) == 13 ? $isbn : ISBNConverter::convertISBN10to13($isbn); $isbn10 = strlen($isbn) == 10 ? $isbn : ISBNConverter::convertISBN13to10($isbn); $curTitle = array('title' => $item->full_title, 'author' => $item->author, 'isbn' => $isbn13, 'isbn10' => $isbn10, 'recordId' => -1, 'libraryOwned' => false, 'isCurrent' => $isCurrent, 'series' => $series, 'volume' => $volume, 'reason' => isset($item->reason) ? $item->reason : '', 'smallCover' => $cover = $configArray['Site']['coverUrl'] . "/bookcover.php?size=small&isn=" . $isbn13, 'mediumCover' => $cover = $configArray['Site']['coverUrl'] . "/bookcover.php?size=medium&isn=" . $isbn13); } else { //Get more information from Solr /** @var GroupedWorkDriver $recordDriver */ $recordDriver = new GroupedWorkDriver($permanentId); $timer->logTime("Find grouped work in solr"); if ($recordDriver->isValid) { if (!isset($series)) { if (isset($ownedRecord['series'])) { $series = $ownedRecord['series'][0]; } } //Load data about the record $ratingData = $recordDriver->getRatingData($user); $timer->logTime("Get Rating data"); $fullRecordLink = $recordDriver->getLinkUrl(); //See if we can get the series title from the record $curTitle = array('title' => $recordDriver->getTitle(), 'title_short' => $recordDriver->getTitle(), 'author' => $recordDriver->getPrimaryAuthor(), 'isbn' => $recordDriver->getCleanISBN(), 'isbn10' => $recordDriver->getCleanISBN(), 'upc' => $recordDriver->getCleanUPC(), 'recordId' => $recordDriver->getPermanentId(), 'recordtype' => 'grouped_work', 'id' => $recordDriver->getPermanentId(), 'libraryOwned' => true, 'isCurrent' => $isCurrent, 'shortId' => $recordDriver->getPermanentId(), 'format_category' => $recordDriver->getFormatCategory(), 'series' => $series, 'volume' => $volume, 'ratingData' => $ratingData, 'fullRecordLink' => $fullRecordLink, 'reason' => isset($item->reason) ? $item->reason : '', 'recordDriver' => $recordDriver, 'smallCover' => $recordDriver->getBookcoverUrl('small'), 'mediumCover' => $recordDriver->getBookcoverUrl('medium')); $timer->logTime("Load title information"); $titlesOwned++; } else { $isbn = reset($item->isbns); $isbn13 = strlen($isbn) == 13 ? $isbn : ISBNConverter::convertISBN10to13($isbn); $isbn10 = strlen($isbn) == 10 ? $isbn : ISBNConverter::convertISBN13to10($isbn); $curTitle = array('title' => $item->full_title, 'author' => $item->author, 'isbn' => $isbn13, 'isbn10' => $isbn10, 'recordId' => -1, 'libraryOwned' => false, 'isCurrent' => $isCurrent, 'series' => $series, 'volume' => $volume, 'reason' => isset($item->reason) ? $item->reason : '', 'smallCover' => $cover = $configArray['Site']['coverUrl'] . "/bookcover.php?size=small&isn=" . $isbn13, 'mediumCover' => $cover = $configArray['Site']['coverUrl'] . "/bookcover.php?size=medium&isn=" . $isbn13); } } $titleList[] = $curTitle; return $curTitle; }
/** * Amazon Editorial * * This method is responsible for connecting to Amazon AWS and abstracting * editorial reviews for the specific ISBN * * @return array Returns array with review data, otherwise a * PEAR_Error. * @access public * @author Andrew Nagy <*****@*****.**> */ function amazoneditorial($isbn, $id) { global $library; $result = array(); if (isset($library) && $library->showAmazonReviews == 0) { //return an empty review return $result; } if (!isset($isbn)) { return $result; } if (strlen($isbn) == 13) { //convert to a 10 digit ISBN since Amazon likes that best. $isbn = ISBNConverter::convertISBN13to10($isbn); } $params = array('ResponseGroup' => 'EditorialReview', 'ItemId' => $isbn); $request = new AWS_Request($id, 'ItemLookup', $params); $response = $request->sendRequest(); if (!PEAR_Singleton::isError($response)) { $unxml = new XML_Unserializer(); $result = $unxml->unserialize($response); if (!PEAR_Singleton::isError($result)) { $data = $unxml->getUnserializedData(); if (isset($data['Items']['Item'])) { if (isset($data['Items']['Item']['EditorialReviews']['EditorialReview']['Source'])) { $data['Items']['Item']['EditorialReviews']['EditorialReview'] = array($data['Items']['Item']['EditorialReviews']['EditorialReview']); } // Filter out product description for ($i = 0; $i <= count($data['Items']['Item']['EditorialReviews']['EditorialReview']); $i++) { if ($data['Items']['Item']['EditorialReviews']['EditorialReview'][$i]['Source'] == 'Product Description') { unset($data['Items']['Item']['EditorialReviews']['EditorialReview'][$i]); } } return $data['Items']['Item']['EditorialReviews']['EditorialReview']; } else { //An error of some sort occurred. //return $result; return null; } } else { //return $result; return null; } } else { //return $result; return null; } }