/** * Process parameters and display the page. * * @return void * @access public */ public function launch() { global $interface; // Retrieve the record from the index if (!($record = $this->db->getRecord($_GET['id']))) { PEAR_Singleton::raiseError(new PEAR_Error('Record Does Not Exist')); } // Send basic information to the template. $interface->setPageTitle(isset($record['heading']) ? $record['heading'] : 'Heading unavailable.'); $interface->assign('record', $record); // Load MARC data require_once ROOT_DIR . '/sys/MarcLoader.php'; $marcRecord = MarcLoader::loadMarcRecordFromRecord($record); if (!$marcRecord) { PEAR_Singleton::raiseError(new PEAR_Error('Cannot Process MARC Record')); } $xml = trim($marcRecord->toXML()); // Transform MARCXML $style = new DOMDocument(); $style->load('services/Record/xsl/record-marc.xsl'); $xsl = new XSLTProcessor(); $xsl->importStyleSheet($style); $doc = new DOMDocument(); if ($doc->loadXML($xml)) { $html = $xsl->transformToXML($doc); $interface->assign('details', $html); } // Assign the ID of the last search so the user can return to it. $interface->assign('lastsearch', isset($_SESSION['lastSearchURL']) ? $_SESSION['lastSearchURL'] : false); // Display Page $interface->setTemplate('record.tpl'); $interface->display('layout.tpl'); }
/** * @param array|File_MARC_Record|string $record */ public function __construct($record) { if ($record instanceof File_MARC_Record) { $this->marcRecord = $record; } elseif (is_string($record)) { require_once ROOT_DIR . '/sys/MarcLoader.php'; $this->id = $record; $this->valid = MarcLoader::marcExistsForILSId($record); } else { // Call the parent's constructor... parent::__construct($record); // Also process the MARC record: require_once ROOT_DIR . '/sys/MarcLoader.php'; $this->marcRecord = MarcLoader::loadMarcRecordFromRecord($record); if (!$this->marcRecord) { $this->valid = false; } } if (!isset($this->id) && $this->valid) { /** @var File_MARC_Data_Field $idField */ global $configArray; $idField = $this->marcRecord->getField($configArray['Reindex']['recordNumberTag']); if ($idField) { $this->id = $idField->getSubfield('a')->getData(); } } parent::loadGroupedWork(); }
public function __construct($record) { // Call the parent's constructor... parent::__construct($record); // Also process the MARC record: require_once ROOT_DIR . '/sys/MarcLoader.php'; $this->marcRecord = MarcLoader::loadMarcRecordFromRecord($record); if (!$this->marcRecord) { PEAR_Singleton::raiseError(new PEAR_Error('Cannot Process MARC Record for record ' . $record['id'])); } }
/** * Constructor. We build the object using data from the Hoopla records stored on disk. * Will be similar to a MarcRecord with slightly different functionality * * @param array|File_MARC_Record|string $record * @access public */ public function __construct($record) { if ($record instanceof File_MARC_Record) { $this->marcRecord = $record; } elseif (is_string($record)) { require_once ROOT_DIR . '/sys/MarcLoader.php'; $this->id = $record; $this->valid = MarcLoader::marcExistsForHooplaId($record); } else { // Call the parent's constructor... parent::__construct($record); // Also process the MARC record: require_once ROOT_DIR . '/sys/MarcLoader.php'; $this->marcRecord = MarcLoader::loadMarcRecordFromRecord($record); if (!$this->marcRecord) { $this->valid = false; } } parent::loadGroupedWork(); }
function launch() { global $configArray; global $interface; //Grab the tracking data $recordId = $_REQUEST['id']; $ipAddress = $_SERVER['REMOTE_ADDR']; $field856Index = isset($_REQUEST['index']) ? $_REQUEST['index'] : null; // 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($recordId))) { PEAR_Singleton::raiseError(new PEAR_Error('Record Does Not Exist')); } $this->record = $record; $interface->assign('record', $record); // Process MARC Data require_once ROOT_DIR . '/sys/MarcLoader.php'; $marcRecord = MarcLoader::loadMarcRecordFromRecord($record); if ($marcRecord) { $this->marcRecord = $marcRecord; } else { PEAR_Singleton::raiseError(new PEAR_Error("Failed to load the MAC record for this title.")); } $linkFields = $marcRecord->getFields('856'); if ($linkFields) { $cur856Index = 0; foreach ($linkFields as $marcField) { $cur856Index++; if ($cur856Index == $field856Index) { //Get the link if ($marcField->getSubfield('u')) { $link = $marcField->getSubfield('u')->getData(); $externalLink = $link; } } } } $linkParts = parse_url($externalLink); //Insert into the purchaseLinkTracking table require_once ROOT_DIR . '/sys/BotChecker.php'; if (!BotChecker::isRequestFromBot()) { require_once ROOT_DIR . '/sys/ExternalLinkTracking.php'; $externalLinkTracking = new ExternalLinkTracking(); $externalLinkTracking->ipAddress = $ipAddress; $externalLinkTracking->recordId = $recordId; $externalLinkTracking->linkUrl = $externalLink; $externalLinkTracking->linkHost = $linkParts['host']; $result = $externalLinkTracking->insert(); } //redirects them to the link they clicked if ($externalLink != "") { header("Location:" . $externalLink); } else { PEAR_Singleton::raiseError(new PEAR_Error("Failed to load link for this record.")); } }
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; }
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 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; }
/** * Process inventory for a particular item in the catalog * * @param string $login Login for the user doing the inventory * @param string $password1 Password for the user doing the inventory * @param string $initials * @param string $password2 * @param string[] $barcodes * @param boolean $updateIncorrectStatuses * * @return array */ function doInventory($login, $password1, $initials, $password2, $barcodes, $updateIncorrectStatuses) { global $configArray; global $logger; $results = array(); if (!isset($configArray['Catalog']['url'])) { return array('success' => false, 'message' => 'There is not a url to millennium set in the config.ini file. Please update the configuration'); } $ils = $configArray['Catalog']['ils']; if ($login == '' || $password1 == '') { return array('success' => false, 'message' => 'Login information not provided correctly. Please fill out all login fields'); } if ($ils != 'Sierra') { if ($initials == '' || $password2 == '') { return array('success' => false, 'message' => 'Login information not provided correctly. Please fill out all login fields'); } } if (is_string($barcodes) && strlen($barcodes) == 0) { return array('success' => false, 'message' => 'Please enter at least one barcode to inventory.'); } else { if (!is_array($barcodes)) { $barcodes = preg_split('/[\\s\\r\\n]+/', $barcodes); } if (count($barcodes) == 0) { return array('success' => false, 'message' => 'Please enter at least one barcode to inventory.'); } } //Setup Solr to be able to get additional information about the title global $configArray; $class = $configArray['Index']['engine']; $url = $configArray['Index']['url']; $this->db = new $class($url); $baseUrl = $configArray['Catalog']['url']; $circaUrl = $configArray['Catalog']['url'] . '/iii/airwkst/airwkstcore'; //Setup curl $curl_url = $circaUrl; $this->curl_connection = curl_init($curl_url); $cookieJar = tempnam("/tmp", "CURLCOOKIE"); curl_setopt($this->curl_connection, CURLOPT_CONNECTTIMEOUT, 30); curl_setopt($this->curl_connection, CURLOPT_USERAGENT, "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)"); curl_setopt($this->curl_connection, CURLOPT_RETURNTRANSFER, true); curl_setopt($this->curl_connection, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($this->curl_connection, CURLOPT_FOLLOWLOCATION, 1); curl_setopt($this->curl_connection, CURLOPT_UNRESTRICTED_AUTH, true); curl_setopt($this->curl_connection, CURLOPT_COOKIEJAR, $cookieJar); curl_setopt($this->curl_connection, CURLOPT_HTTPGET, true); curl_setopt($this->curl_connection, CURLOPT_COOKIESESSION, is_null($cookieJar) ? true : false); //First get the login page curl_exec($this->curl_connection); sleep(1); //Login to circa $post_data = array('action' => 'ValidateAirWkstUserAction', 'login' => $login, 'loginpassword' => $password1, 'nextaction' => 'null', 'purpose' => 'null', 'submit.x' => 41, 'submit.y' => 10, 'subpurpose' => 'null', 'validationstatus' => 'needlogin'); $post_items = array(); foreach ($post_data as $key => $value) { $post_items[] = $key . '=' . urlencode($value); } $post_string = implode('&', $post_items); curl_setopt($this->curl_connection, CURLOPT_POST, true); curl_setopt($this->curl_connection, CURLOPT_POSTFIELDS, $post_string); $sresult = curl_exec($this->curl_connection); $logger->log("Calling {$curl_url}?{$post_string}", PEAR_LOG_DEBUG); //$logger->log("result of circa login $sresult", PEAR_LOG_DEBUG); sleep(1); //Check that we logged in successfully $loginSuccess = false; if (!preg_match('/Invalid login\\/password/i', $sresult)) { if ($ils == 'Sierra') { $loginSuccess = true; } else { $loginSuccess = preg_match('/initials/i', $sresult); } } if ($loginSuccess) { if ($ils != 'Sierra') { //we logged in successfully. //enter initials $post_data = array('action' => 'ValidateAirWkstUserAction', 'initials' => $initials, 'initialspassword' => $password2, 'nextaction' => 'null', 'purpose' => 'null', 'submit.x' => 30, 'submit.y' => 10, 'subpurpose' => 'null', 'validationstatus' => 'needinitials'); $post_items = array(); foreach ($post_data as $key => $value) { $post_items[] = $key . '=' . urlencode($value); } $post_string = implode('&', $post_items); curl_setopt($this->curl_connection, CURLOPT_POSTFIELDS, $post_string); $sresult = curl_exec($this->curl_connection); sleep(1); $logger->log("Calling {$curl_url}?{$post_string}", PEAR_LOG_DEBUG); //$logger->log("result of circa initials $sresult", PEAR_LOG_DEBUG); } if (!preg_match('/You are not authorized to use Circa/i', $sresult) && preg_match('/inventory control/i', $sresult)) { //Logged in and authorized, check in each barcode //Go to the Inventory page curl_setopt($this->curl_connection, CURLOPT_HTTPGET, true); curl_setopt($this->curl_connection, CURLOPT_URL, $baseUrl . '/iii/airwkst/?action=GetAirWkstUserInfoAction&purpose=updinvdt'); curl_exec($this->curl_connection); curl_setopt($this->curl_connection, CURLOPT_POST, true); curl_setopt($this->curl_connection, CURLOPT_URL, $curl_url); $results['barcodes'] = array(); foreach ($barcodes as $barcode) { set_time_limit(60); $post_data = array('action' => 'GetAirWkstItemOneAction', 'prevscreen' => 'AirWkstItemRequestPage', 'purpose' => 'updinvdt', 'searchstring' => $barcode, 'searchtype' => 'b', 'sourcebrowse' => 'airwkstpage'); $post_items = array(); foreach ($post_data as $key => $value) { $post_items[] = $key . '=' . urlencode($value); } $post_string = implode('&', $post_items); curl_setopt($this->curl_connection, CURLOPT_POSTFIELDS, $post_string); $sresult = curl_exec($this->curl_connection); $titleInfo = $this->db->getRecordByBarcode($barcode); $itemInfo = null; if ($titleInfo != null) { $marcInfo = MarcLoader::loadMarcRecordFromRecord($titleInfo); //Get the matching item from the item records $marcItemField = isset($configArray['Reindex']['itemTag']) ? $configArray['Reindex']['itemTag'] : '989'; $itemFields = $marcInfo->getFields($marcItemField); $itemInfo = null; if ($itemFields) { /** @var File_MARC_Data_Field $fieldInfo */ foreach ($itemFields as $fieldInfo) { if ($fieldInfo->getSubfield('b')->getData() == $barcode) { $itemInfo = $fieldInfo; } } } else { $logger->log("Did not find item records {$barcode}", PEAR_LOG_ERR); } } if ($itemInfo == null) { $logger->log("Did not find an item for barcode {$barcode}", PEAR_LOG_ERR); } if (preg_match("/{$barcode} updated successfully/i", $sresult)) { $results['barcodes'][$barcode] = array('inventoryResult' => 'Updated successfully.', 'title' => $titleInfo['title'], 'callNumber' => is_null($itemInfo) ? '' : $itemInfo->getSubfield('a')->getData()); if (preg_match('/Unexpected status; adjust below if appropriate/i', $sresult)) { if ($updateIncorrectStatuses) { //Automatically update the item to checked in //extract the current status and item record preg_match('/<input type="hidden" name="olditemstatuscode" value="(.*?)">/', $sresult, $matches); $lastStatus = $matches[1]; preg_match('/<input type="hidden" name="itemrecordkey" value="(.*?)">/', $sresult, $matches); $itemrecordkey = $matches[1]; $post_data = array('action' => 'UpdateAirWkstItemOneAction', 'itemrecordkey' => $itemrecordkey, 'lastaction' => 'updstatus', 'lastactionstatus' => 'good', 'lastitembarcode' => $barcode, 'newitemstatuscode' => '-', 'olditemstatuscode' => $lastStatus, 'purpose' => 'updstatus', 'submit.x' => 40, 'submit.y' => 10, 'ulang' => 'eng'); $post_items = array(); foreach ($post_data as $key => $value) { $post_items[] = $key . '=' . urlencode($value); } $post_string = implode('&', $post_items); curl_setopt($this->curl_connection, CURLOPT_POSTFIELDS, $post_string); $sresult = curl_exec($this->curl_connection); if (preg_match("/{$barcode} updated successfully/i", $sresult)) { $results['barcodes'][$barcode]['inventoryResult'] = "Automatically changed status from {$lastStatus} to on shelf"; $results['barcodes'][$barcode]['needsAdditionalProcessing'] = false; } else { $logger->log("Could not update status for barcode {$barcode}/r/n{$sresult}", PEAR_LOG_ERR); $results['barcodes'][$barcode]['inventoryResult'] = "Could not automatically fix status, old status is {$lastStatus}"; $results['barcodes'][$barcode]['needsAdditionalProcessing'] = true; } } else { $results['barcodes'][$barcode]['inventoryResult'] = "Unexpected Status, Needs Update"; $results['barcodes'][$barcode]['needsAdditionalProcessing'] = true; } } elseif (preg_match('/Unexpected status; pull this item for correction/i', $sresult)) { $results['barcodes'][$barcode]['inventoryResult'] .= " Pull this item for status correction"; $results['barcodes'][$barcode]['needsAdditionalProcessing'] = true; } else { $results['barcodes'][$barcode]['needsAdditionalProcessing'] = false; } sleep(1); } else { $results['barcodes'][$barcode] = array('inventoryResult' => 'Not updated', 'title' => $titleInfo['title'], 'callNumber' => is_null($itemInfo) ? '' : $itemInfo->getSubfield('a')->getData()); } } $results['success'] = true; } else { //Did not log in correctly. $results['success'] = false; $results['message'] = "The initials or password were incorrect or you are not authorized to use circa."; if (preg_match('/class="error">(.*?)<\\/h2>/i', $sresult, $matches)) { $results['message'] = $matches[1]; } } } else { //Did not log in correctly. $results['success'] = false; $results['message'] = "The login or password were incorrect. Please reenter."; } //Logout of the system curl_setopt($this->curl_connection, CURLOPT_HTTPGET, true); curl_setopt($this->curl_connection, CURLOPT_URL, $circaUrl . '/iii/airwkst/airwkstcore?action=AirWkstReturnToWelcomeAction'); $sresult = curl_exec($this->curl_connection); //Cleanup curl_close($this->curl_connection); unlink($cookieJar); return $results; }
function launch() { global $configArray; global $interface; //Grab the tracking data $store = urldecode(strip_tags($_GET['store'])); $recordId = $_REQUEST['id']; $ipAddress = $_SERVER['REMOTE_ADDR']; $field856Index = isset($_REQUEST['index']) ? $_REQUEST['index'] : null; $libraryName = $configArray['Site']['title']; // 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($recordId))) { PEAR_Singleton::raiseError(new PEAR_Error('Record Does Not Exist')); } $this->record = $record; $interface->assign('record', $record); $titleTerm = $record["title"]; $title = str_replace(":", " ", $titleTerm); $authorTerm = $record["auth_author"]; $author = str_replace("/", "", $authorTerm); if ($field856Index == null) { // Find the store in the database require_once ROOT_DIR . '/Drivers/marmot_inc/BookStore.php'; $storeDbObj = new BookStore(); $storeDbObj->storeName = $store; $storeDbObj->find(); if ($storeDbObj->N > 0) { $storeDbObj->fetch(); $purchaseLinkUrl = self::getPurchaseLinkForTitle($storeDbObj->link, $title, $author, $libraryName); } } else { // Process MARC Data require_once ROOT_DIR . '/sys/MarcLoader.php'; $marcRecord = MarcLoader::loadMarcRecordFromRecord($record); if ($marcRecord) { $this->marcRecord = $marcRecord; } else { PEAR_Singleton::raiseError(new PEAR_Error("Failed to load the MAC record for this title.")); } $linkFields = $marcRecord->getFields('856'); if ($linkFields) { $cur856Index = 0; foreach ($linkFields as $marcField) { $cur856Index++; if ($cur856Index == $field856Index) { //Get the link if ($marcField->getSubfield('u')) { $link = $marcField->getSubfield('u')->getData(); $purchaseLinkUrl = $link; } } } } } //Do not track purchases from Bots require_once ROOT_DIR . '/sys/BotChecker.php'; if (!BotChecker::isRequestFromBot()) { require_once ROOT_DIR . '/sys/PurchaseLinkTracking.php'; $tracking = new PurchaseLinkTracking(); $tracking->ipAddress = $ipAddress; $tracking->recordId = $recordId; $tracking->store = $store; $insertResult = $tracking->insert(); } //redirects them to the link they clicked if ($purchaseLinkUrl != "") { header("Location:" . $purchaseLinkUrl); } else { PEAR_Singleton::raiseError(new PEAR_Error("Failed to load the store information for this title.")); } }