public function getIsbnsForWork($permanentId = null) { if ($permanentId == null) { $permanentId = $_REQUEST['id']; } $isbns = array(); require_once ROOT_DIR . '/sys/Grouping/GroupedWork.php'; require_once ROOT_DIR . '/sys/Grouping/GroupedWorkIdentifier.php'; require_once ROOT_DIR . '/sys/Grouping/GroupedWorkIdentifierRef.php'; $groupedWork = new GroupedWork(); $groupedWork->permanent_id = $permanentId; if ($groupedWork->find(true)) { $groupedWorkIdentifier = new GroupedWorkIdentifier(); $groupedWorkIdentifierRef = new GroupedWorkIdentifierRef(); $groupedWorkIdentifierRef->grouped_work_id = $groupedWork->id; $groupedWorkIdentifier->type = 'isbn'; $groupedWorkIdentifierRef->joinAdd($groupedWorkIdentifier); $groupedWorkIdentifierRef->find(); if ($groupedWorkIdentifierRef->N > 0) { while ($groupedWorkIdentifierRef->fetch()) { $isbns[] = $groupedWorkIdentifierRef->identifier; } } } return $isbns; }
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; }