function getReviewInfo() { require_once ROOT_DIR . '/RecordDrivers/GroupedWorkDriver.php'; $id = $_REQUEST['id']; $recordDriver = new GroupedWorkDriver($id); $isbn = $recordDriver->getCleanISBN(); //Load external (syndicated reviews) require_once ROOT_DIR . '/sys/Reviews.php'; $externalReviews = new ExternalReviews($isbn); $reviews = $externalReviews->fetch(); global $interface; $interface->assign('id', $id); $numSyndicatedReviews = 0; foreach ($reviews as $providerReviews) { $numSyndicatedReviews += count($providerReviews); } $interface->assign('syndicatedReviews', $reviews); //Load editorial reviews require_once ROOT_DIR . '/sys/LocalEnrichment/EditorialReview.php'; $editorialReviews = new EditorialReview(); $editorialReviews->recordId = $id; $editorialReviews->find(); $allEditorialReviews = array(); while ($editorialReviews->fetch()) { $allEditorialReviews[] = clone $editorialReviews; } $interface->assign('editorialReviews', $allEditorialReviews); $userReviews = $recordDriver->getUserReviews(); $interface->assign('userReviews', $userReviews); $results = array('numSyndicatedReviews' => $numSyndicatedReviews, 'syndicatedReviewsHtml' => $interface->fetch('GroupedWork/view-syndicated-reviews.tpl'), 'numEditorialReviews' => count($allEditorialReviews), 'editorialReviewsHtml' => $interface->fetch('GroupedWork/view-editorial-reviews.tpl'), 'numCustomerReviews' => count($userReviews), 'customerReviewsHtml' => $interface->fetch('GroupedWork/view-user-reviews.tpl')); return json_encode($results); }
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; }