function launch() { global $interface; global $configArray; if (isset($_REQUEST['rating'])) { $rating = $_REQUEST['rating']; $interface->assign('rating', $rating); } $id = $_REQUEST['id']; // Check if user is logged in if (!$this->user) { // Needed for "back to record" link in view-alt.tpl: $interface->assign('id', $id); //Display the login form $login = $interface->fetch('EContentRecord/ajax-rate-login.tpl'); header('Content-type: text/plain'); header('Cache-Control: no-cache, must-revalidate'); // HTTP/1.1 header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); echo json_encode(array('result' => 'true', 'loginForm' => $login)); exit; } if (isset($_GET['submit'])) { //Save the rating require_once ROOT_DIR . '/sys/eContent/EContentRating.php'; $eContentRating = new EContentRating(); $eContentRating->rating = $rating; $eContentRating->recordId = $id; $eContentRating->userId = $this->user->id; $eContentRating->dateRated = time(); $eContentRating->insert(); return json_encode(array('result' => 'true', 'rating' => $rating)); } }
function getRatingData($user, $showGraph = false) { require_once ROOT_DIR . '/Drivers/marmot_inc/UserRating.php'; //Set default rating data $ratingData = array('average' => 0, 'count' => 0, 'user' => 0); //Get rating data for the resource $sql = "SELECT AVG(rating) average, count(rating) count from econtent_rating where recordId = '{$this->recordId}'"; $rating = new EContentRating(); $rating->query($sql); if ($rating->N > 0) { $rating->fetch(); $ratingData['average'] = number_format($rating->average, 2); $ratingData['count'] = $rating->count; } //Get user rating if (isset($user) && $user != false) { $rating = new EContentRating(); $rating->userId = $user->id; $rating->recordId = $this->recordId; $rating->find(); if ($rating->N) { $rating->fetch(); $ratingData['user'] = $rating->rating; } } return $ratingData; }
public function launch() { global $interface; global $user; //Load user ratings require_once ROOT_DIR . '/Drivers/marmot_inc/UserRating.php'; $rating = new UserRating(); $resource = new Resource(); $rating->joinAdd($resource); $rating->userid = $user->id; $rating->find(); $ratings = array(); while ($rating->fetch()) { if ($rating->deleted == 0) { $ratings[] = array('id' => $rating->id, 'title' => $rating->title, 'author' => $rating->author, 'format' => $rating->format, 'rating' => $rating->rating, 'resourceId' => $rating->resourceid, 'fullId' => $rating->record_id, 'shortId' => $rating->shortId, 'link' => '/Record/' . $rating->record_id . '/Home', 'dateRated' => $rating->dateRated, 'ratingData' => array('user' => $rating->rating), 'source' => 'VuFind'); } } //Load econtent ratings require_once ROOT_DIR . '/sys/eContent/EContentRating.php'; $eContentRating = new EContentRating(); $econtentRecord = new EContentRecord(); $eContentRating->joinAdd($econtentRecord); $eContentRating->userId = $user->id; $eContentRating->find(); while ($eContentRating->fetch()) { if ($eContentRating->status == 'active') { $resource = new Resource(); $resource->record_id = $eContentRating->id; $resource->source = 'eContent'; $resource->find(true); $ratings[] = array('id' => $eContentRating->id, 'title' => $eContentRating->title, 'author' => $eContentRating->author, 'format' => $resource->format_category, 'rating' => $eContentRating->rating, 'fullId' => $eContentRating->id, 'shortId' => $eContentRating->id, 'link' => '/EcontentRecord/' . $eContentRating->id . '/Home', 'dateRated' => $eContentRating->dateRated, 'ratingData' => array('user' => $eContentRating->rating), 'source' => 'eContent'); } } asort($ratings); //Load titles the user is not interested in $notInterested = array(); $notInterestedObj = new NotInterested(); $resource = new Resource(); $notInterestedObj->joinAdd($resource); $notInterestedObj->userId = $user->id; $notInterestedObj->deleted = 0; $notInterestedObj->selectAdd('user_not_interested.id as user_not_interested_id'); $notInterestedObj->find(); while ($notInterestedObj->fetch()) { if ($notInterestedObj->source == 'VuFind') { $link = '/Record/' . $notInterestedObj->record_id; } else { $link = '/EcontentRecord/' . $notInterestedObj->record_id; } if ($notInterestedObj->deleted == 0) { $notInterested[] = array('id' => $notInterestedObj->user_not_interested_id, 'title' => $notInterestedObj->title, 'author' => $notInterestedObj->author, 'dateMarked' => $notInterestedObj->dateMarked, 'link' => $link); } } $interface->assign('ratings', $ratings); $interface->assign('notInterested', $notInterested); $interface->setPageTitle('My Ratings'); $interface->setTemplate('myRatings.tpl'); $interface->display('layout.tpl'); }
/** * Get ratings as a tab separated file * * First column : ItemId * Second Column : Rating Average (should be between 0 and 5, decimals are accepted) * Third column : Total votes * It is VERY important that the frist column represents the "itemId" * has the same id that the one you are sending us with your catalog, * because that is what we use to link your products with its ratings */ function getRatingInfo() { require_once ROOT_DIR . '/Drivers/marmot_inc/UserRating.php'; $ratings = new UserRating(); $ratings->query("SELECT record_id, AVG(rating) as averageRating, count(resource.id) as numRatings from user_rating INNER JOIN resource on resourceid = resource.id GROUP BY record_id"); $tabbedData = ''; while ($ratings->fetch()) { $tabbedData .= "{$ratings->record_id}\t{$ratings->averageRating}\t{$ratings->numRatings}\r\n"; } //Get eContent Ratings as well require_once ROOT_DIR . '/sys/eContent/EContentRating.php'; $eContentRatings = new EContentRating(); $eContentRatings->query("SELECT recordId, AVG(rating)as averageRating, count(id) as numRatings FROM `econtent_rating` GROUP BY recordId"); while ($eContentRatings->fetch()) { $tabbedData .= "econtentRecord{$eContentRatings->recordId}\t{$eContentRatings->averageRating}\t{$eContentRatings->numRatings}\r\n"; } return $tabbedData; }
function rating() { require_once ROOT_DIR . '/sys/eContent/EContentRating.php'; $econtentRating = new EContentRating(); $query = "SELECT AVG(rating) as avgRating from econtent_rating where recordId = {$this->id}"; $econtentRating->query($query); if ($econtentRating->N > 0) { $econtentRating->fetch(); if ($econtentRating->avgRating == 0) { return -2.5; } else { return $econtentRating->avgRating; } } else { return -2.5; } }
static function getSuggestions($userId = -1) { global $configArray; if ($userId == -1) { global $user; $userId = $user->id; } //Load all titles the user is not interested in $notInterestedTitles = array(); $notInterested = new NotInterested(); $resource = new Resource(); $notInterested->joinAdd($resource); $notInterested->userId = $userId; $notInterested->find(); while ($notInterested->fetch()) { if ($notInterested->source == 'VuFind') { $fullId = $notInterested->record_id; } else { $fullId = 'econtentRecord' . $notInterested->record_id; } $notInterestedTitles[$fullId] = $fullId; } //Load all titles the user has rated (print) $allRatedTitles = array(); $allLikedRatedTitles = array(); $ratings = new UserRating(); $ratings->userid = $userId; $resource = new Resource(); $notInterested->joinAdd($resource); $ratings->joinAdd($resource); $ratings->find(); while ($ratings->fetch()) { $allRatedTitles[$ratings->record_id] = $ratings->record_id; if ($ratings->rating >= 4) { $allLikedRatedTitles[] = $ratings->record_id; } } //Load all titles the user has rated (eContent) $econtentRatings = new EContentRating(); $econtentRatings->userId = $userId; $econtentRatings->find(); while ($econtentRatings->fetch()) { $allRatedTitles['econtentRecord' . $econtentRatings->recordId] = 'econtentRecord' . $econtentRatings->recordId; if ($econtentRatings->rating >= 4) { $allLikedRatedTitles[] = 'econtentRecord' . $econtentRatings->recordId; } } // Setup Search Engine Connection $class = $configArray['Index']['engine']; $url = $configArray['Index']['url']; $db = new $class($url); if ($configArray['System']['debugSolr']) { $db->debug = true; } //Get a list of all titles the user has rated (3 star and above) $ratings = new UserRating(); $ratings->whereAdd("userId = {$userId}", 'AND'); $ratings->whereAdd('rating >= 3', 'AND'); $ratings->orderBy('rating DESC, dateRated DESC, id DESC'); //Use the 20 highest ratings to make real-time recommendations faster $ratings->limit(0, 5); $ratings->find(); $suggestions = array(); //echo("User has rated {$ratings->N} titles<br/>"); if ($ratings->N > 0) { while ($ratings->fetch()) { $resourceId = $ratings->resourceid; //Load the resource $resource = new Resource(); $resource->id = $resourceId; $resource->find(); if ($resource->N != 1) { //echo("Did not find resource for $resourceId<br/>"); } else { $resource->fetch(); //echo("Found resource for $resourceId - {$resource->title}<br/>"); $ratedTitles[$resource->record_id] = clone $ratings; $numRecommendations = 0; if ($resource->isbn) { //If there is an isbn for the title, we can load similar titles based on Novelist. $isbn = $resource->isbn; $numRecommendations = Suggestions::getNovelistRecommendations($ratings, $isbn, $resource, $allRatedTitles, $suggestions, $notInterestedTitles); //echo(" - Found $numRecommendations for $isbn from Novelist<br/>"); } if ($numRecommendations == 0) { Suggestions::getSimilarlyRatedTitles($db, $ratings, $userId, $allRatedTitles, $suggestions, $notInterestedTitles); //echo(" - Found $numRecommendations based on ratings from other users<br/>"); } } } } //Also get eContent the user has rated highly $econtentRatings = new EContentRating(); $econtentRatings->userId = $userId; $econtentRatings->whereAdd('rating >= 3'); $econtentRatings->orderBy('rating DESC, dateRated DESC'); $econtentRatings->limit(0, 5); $econtentRatings->find(); //echo("User has rated {$econtentRatings->N} econtent titles<br/>"); if ($econtentRatings->N > 0) { while ($econtentRatings->fetch()) { //echo("Processing eContent Rating {$econtentRatings->recordId}<br/>"); //Load the resource $resource = new Resource(); $resource->record_id = $econtentRatings->recordId; $resource->source = 'eContent'; $resource->find(); if ($resource->N != 1) { //echo("Did not find resource for $resourceId<br/>"); } else { $resource->fetch(); //echo("Found resource for $resourceId - {$resource->title}<br/>"); $ratedTitles[$resource->record_id] = clone $econtentRatings; $numRecommendations = 0; if ($resource->isbn) { //If there is an isbn for the title, we can load similar titles based on Novelist. $isbn = $resource->isbn; $numRecommendations = Suggestions::getNovelistRecommendations($ratings, $isbn, $resource, $allRatedTitles, $suggestions, $notInterestedTitles); //echo(" - Found $numRecommendations for $isbn from Novelist<br/>"); } if ($numRecommendations == 0) { Suggestions::getSimilarlyRatedTitles($db, $ratings, $userId, $allRatedTitles, $suggestions, $notInterestedTitles); //echo(" - Found $numRecommendations based on ratings from other users<br/>"); } } } } $groupedTitles = array(); foreach ($suggestions as $suggestion) { $groupingTerm = $suggestion['titleInfo']['grouping_term']; $groupedTitles[] = $groupingTerm; } //If the user has not rated anything, return nothing. if (count($allLikedRatedTitles) == 0) { return array(); } //Get recommendations based on everything I've rated using more like this functionality $class = $configArray['Index']['engine']; $url = $configArray['Index']['url']; /** @var Solr $db */ $db = new $class($url); //$db->debug = true; $moreLikeTheseSuggestions = $db->getMoreLikeThese($allLikedRatedTitles); //print_r($moreLikeTheseSuggestions); if (count($suggestions) < 30) { foreach ($moreLikeTheseSuggestions['response']['docs'] as $suggestion) { $groupingTerm = $suggestion['grouping_term']; if (array_key_exists($groupingTerm, $groupedTitles)) { //echo ($suggestion['grouping_term'] . " is already in the suggestions"); continue; } $groupedTitles[$groupingTerm] = $groupingTerm; //print_r($suggestion); if (!array_key_exists($suggestion['id'], $allRatedTitles) && !array_key_exists($suggestion['id'], $notInterestedTitles)) { $suggestions[$suggestion['id']] = array('rating' => $suggestion['rating'] - 2.5, 'titleInfo' => $suggestion, 'basedOn' => 'MetaData for all titles rated'); } if (count($suggestions) == 30) { break; } } } //print_r($groupedTitles); //sort suggestions based on score from ascending to descending uasort($suggestions, 'Suggestions::compareSuggestions'); //Only return up to 50 suggestions to make the page size reasonable $suggestions = array_slice($suggestions, 0, 30, true); //Return suggestions for use in the user interface. return $suggestions; }
function clearUserRating() { global $user; $source = $_REQUEST['source']; $recordId = $_REQUEST['recordId']; $result = array('result' => false); if ($source == 'VuFind') { require_once ROOT_DIR . '/Drivers/marmot_inc/UserRating.php'; $resource = new Resource(); $resource->record_id = $recordId; $resource->source = 'VuFind'; if ($resource->find(true)) { $rating = new UserRating(); $rating->userid = $user->id; $rating->resourceid = $resource->id; if ($rating->find(true)) { if ($rating->delete()) { $result = array('result' => true, 'message' => 'deleted user rating for resource ' . $rating->resourceid); } } } } else { require_once ROOT_DIR . '/sys/eContent/EContentRating.php'; $econtentRating = new EContentRating(); $econtentRating->userId = $user->id; $econtentRating->recordId = $recordId; if ($econtentRating->find(true)) { if ($econtentRating->delete()) { $result = array('result' => true); } } } return json_encode($result); }
public function getSupplementalSearchResult() { global $configArray; global $interface; global $user; $id = $this->getUniqueID(); $interface->assign('summId', $id); if (substr($id, 0, 1) == '.') { $interface->assign('summShortId', substr($id, 1)); } else { $interface->assign('summShortId', $id); } $formats = $this->getFormats(); $interface->assign('summFormats', $formats); $formatCategories = $this->getFormatCategory(); $interface->assign('summFormatCategory', $formatCategories); $interface->assign('summTitle', $this->getTitle()); $interface->assign('summSubTitle', $this->getSubtitle()); $interface->assign('summTitleStatement', $this->getTitleSection()); $interface->assign('summAuthor', $this->getPrimaryAuthor()); $publishers = $this->getPublishers(); $pubDates = $this->getPublicationDates(); $pubPlaces = $this->getPlacesOfPublication(); $interface->assign('summPublicationDates', $pubDates); $interface->assign('summPublishers', $publishers); $interface->assign('summPublicationPlaces', $pubPlaces); $interface->assign('summDate', $this->getPublicationDates()); $interface->assign('summISBN', $this->getCleanISBN()); $issn = $this->getCleanISSN(); $interface->assign('summISSN', $issn); $upc = $this->getCleanUPC(); $interface->assign('summUPC', $upc); if ($configArray['System']['debugSolr'] == 1) { $interface->assign('summScore', $this->getScore()); $interface->assign('summExplain', $this->getExplain()); } $interface->assign('summPhysical', $this->getPhysicalDescriptions()); $interface->assign('summEditions', $this->getEdition()); // Obtain and assign snippet information: $snippet = $this->getHighlightedSnippet(); $interface->assign('summSnippetCaption', $snippet ? $snippet['caption'] : false); $interface->assign('summSnippet', $snippet ? $snippet['snippet'] : false); //Get Rating require_once ROOT_DIR . '/sys/eContent/EContentRating.php'; $econtentRating = new EContentRating(); $econtentRating->recordId = $id; //$logger->log("Loading ratings for econtent record $id", PEAR_LOG_DEBUG); $interface->assign('summRating', $econtentRating->getRatingData($user, false)); //Determine the cover to use $isbn = $this->getCleanISBN(); $formatCategory = isset($formatCategories[0]) ? $formatCategories[0] : ''; $format = isset($formats[0]) ? $formats[0] : ''; $interface->assign('bookCoverUrl', $this->getBookcoverUrl($id, $isbn, $upc, $formatCategory, $format)); // By default, do not display AJAX status; we won't assume that all // records exist in the ILS. Child classes can override this setting // to turn on AJAX as needed: $interface->assign('summAjaxStatus', false); return 'RecordDrivers/Econtent/supplementalResult.tpl'; }
/** * Returns information about the titles within a list including: * - Title, Author, Bookcover URL, description, record id */ function getListTitles($listId = NULL, Pagination $pagination = NULL) { global $configArray; if (!$listId) { if (!isset($_REQUEST['id'])) { return array('success' => false, 'message' => 'The id of the list to load must be provided as the id parameter.'); } $listId = $_REQUEST['id']; } if (isset($_REQUEST['username']) && isset($_REQUEST['password'])) { $username = $_REQUEST['username']; $password = $_REQUEST['password']; global $user; $user = UserAccount::validateAccount($username, $password); } else { global $user; } if ($user) { $userId = $user->id; } if (is_numeric($listId) || preg_match('/list[-:](.*)/', $listId, $listInfo)) { if (isset($listInfo)) { $listId = $listInfo[1]; } return $this->_getUserListTitles($listId); } elseif (preg_match('/search:(.*)/', $listId, $searchInfo)) { if (is_numeric($searchInfo[1])) { $titles = $this->getSavedSearchTitles($searchInfo[1]); if ($titles && count($titles) > 0) { return array('success' => true, 'listTitle' => $listId, 'listDescription' => "Search Results", 'titles' => $titles, 'cacheLength' => 4); } else { return array('success' => false, 'message' => 'The specified search could not be found.'); } } else { //Do a default search $titles = $this->getSystemListTitles($listId); if (count($titles) > 0) { return array('success' => true, 'listTitle' => $listId, 'listDescription' => "System Generated List", 'titles' => $titles, 'cacheLength' => 4); } else { return array('success' => false, 'message' => 'The specified list could not be found.'); } } } else { $systemList = null; $systemLists = $this->getSystemLists(); foreach ($systemLists['lists'] as $curSystemList) { if ($curSystemList['id'] == $listId) { $systemList = $curSystemList; break; } } //The list is a system generated list if ($listId == 'newEpub' || $listId == 'newebooks') { require_once ROOT_DIR . 'sys/eContent/EContentRecord.php'; $eContentRecord = new EContentRecord(); $eContentRecord->orderBy('date_added DESC'); $eContentRecord->limit(0, 30); $eContentRecord->find(); $titles = array(); while ($eContentRecord->fetch()) { $titles[] = $this->setEcontentRecordInfoForList($eContentRecord); } return array('success' => true, 'listTitle' => $systemList['title'], 'listDescription' => $systemList['description'], 'titles' => $titles, 'cacheLength' => 1); } elseif ($listId == 'freeEbooks') { if (!$pagination) { $pagination = new Pagination(); } require_once ROOT_DIR . 'sys/eContent/EContentRecord.php'; $eContentRecord = new EContentRecord(); $eContentRecord->orderBy('date_added DESC'); $eContentRecord->whereAdd('accessType = \'free\''); $eContentRecord->limit($pagination->getOffset(), $pagination->getNumItemsPerPage()); $eContentRecord->find(); $titles = array(); while ($eContentRecord->fetch()) { $titles[] = $this->setEcontentRecordInfoForList($eContentRecord); } return array('success' => true, 'listTitle' => $systemList['title'], 'listDescription' => $systemList['description'], 'titles' => $titles, 'cacheLength' => 1); } elseif ($listId == 'highestRated') { $query = "SELECT record_id, AVG(rating) FROM `user_rating` inner join resource on resourceid = resource.id GROUP BY resourceId order by AVG(rating) DESC LIMIT 30"; $result = mysql_query($query); $ids = array(); while ($epubInfo = mysql_fetch_assoc($result)) { $ids[] = $epubInfo['record_id']; } $titles = $this->loadTitleInformationForIds($ids); return array('success' => true, 'listTitle' => $systemList['title'], 'listDescription' => $systemList['description'], 'titles' => $titles, 'cacheLength' => 1); } elseif ($listId == 'highestRatedEContent') { require_once ROOT_DIR . '/sys/eContent/EContentRating.php'; $econtentRating = new EContentRating(); $records = $econtentRating->getRecordsListAvgRating("DESC", 30); $titles = array(); if (!empty($records)) { foreach ($records as $eContentRecord) { $titles[] = $this->setEcontentRecordInfoForList($eContentRecord); } } return array('success' => true, 'listTitle' => $systemList['title'], 'listDescription' => $systemList['description'], 'titles' => $titles, 'cacheLength' => 1); } elseif ($listId == 'recentlyReviewed') { $query = "SELECT record_id, MAX(created) FROM `comments` inner join resource on resource_id = resource.id group by resource_id order by max(created) DESC LIMIT 30"; $result = mysql_query($query); $ids = array(); while ($epubInfo = mysql_fetch_assoc($result)) { $ids[] = $epubInfo['record_id']; } $titles = $this->loadTitleInformationForIds($ids); return array('success' => true, 'listTitle' => $systemList['title'], 'listDescription' => $systemList['description'], 'titles' => $titles, 'cacheLength' => 1); } elseif ($listId == 'mostPopular') { $query = "SELECT record_id, count(userId) from user_reading_history inner join resource on resourceId = resource.id GROUP BY resourceId order by count(userId) DESC LIMIT 30"; $result = mysql_query($query); $ids = array(); while ($epubInfo = mysql_fetch_assoc($result)) { $ids[] = $epubInfo['record_id']; } $titles = $this->loadTitleInformationForIds($ids); return array('success' => true, 'listTitle' => $systemList['title'], 'listDescription' => $systemList['description'], 'titles' => $titles, 'cacheLength' => 1); } elseif ($listId == 'recommendations') { if (!$user) { return array('success' => false, 'message' => 'A valid user must be provided to load recommendations.'); } else { $userId = $user->id; require_once ROOT_DIR . '/services/MyResearch/lib/Suggestions.php'; $suggestions = Suggestions::getSuggestions($userId); $titles = array(); foreach ($suggestions as $id => $suggestion) { $imageUrl = $configArray['Site']['coverUrl'] . "/bookcover.php?id=" . $id; if (isset($suggestion['titleInfo']['issn'])) { $imageUrl .= "&issn=" . $suggestion['titleInfo']['issn']; } if (isset($suggestion['titleInfo']['isbn10'])) { $imageUrl .= "&isn=" . $suggestion['titleInfo']['isbn10']; } if (isset($suggestion['titleInfo']['upc'])) { $imageUrl .= "&upc=" . $suggestion['titleInfo']['upc']; } if (isset($suggestion['titleInfo']['format_category'])) { $imageUrl .= "&category=" . $suggestion['titleInfo']['format_category']; } $smallImageUrl = $imageUrl . "&size=small"; $imageUrl .= "&size=medium"; $titles[] = array('id' => $id, 'image' => $imageUrl, 'small_image' => $smallImageUrl, 'title' => $suggestion['titleInfo']['title'], 'author' => $suggestion['titleInfo']['author']); } return array('success' => true, 'listTitle' => $systemList['title'], 'listDescription' => $systemList['description'], 'titles' => $titles, 'cacheLength' => 0); } } else { return array('success' => false, 'message' => 'The specified list could not be found.'); } } }
private function _parseOverDriveHolds($holdsSection) { global $user; $holds = array(); $holds['available'] = array(); $holds['unavailable'] = array(); //Match holds //Get the individual holds by splitting the section based on each <li class="mobile-four"> //Trim to the first li //$firstTitlePos = preg_match($holdsSection, '/<li .*?class="mobile-four">/'); //$holdsSection = substr($holdsSection, $firstTitlePos); $heldTitles = preg_split('/<li[^>]*?class="mobile-four"[^>]*?>/', $holdsSection); foreach ($heldTitles as $titleHtml) { //echo("\r\nSection " . $i++ . "\r\n$titleHtml"); if (preg_match('/<div class="coverID">.*?<a href="ContentDetails\\.htm\\?id=(.*?)">.*?<img class="lrgImg" src="(.*?)".*?<div class="trunc-title-line".*?title="(.*?)".*?<div class="trunc-author-line".*?title="(.*?)".*?<div class="(?:holds-info)?".*?>(.*)/si', $titleHtml, $holdInfo)) { $hold = array(); $grpCtr = 1; $hold['overDriveId'] = $holdInfo[$grpCtr++]; $hold['imageUrl'] = $holdInfo[$grpCtr++]; $eContentRecord = new EContentRecord(); $eContentRecord->externalId = $hold['overDriveId']; $eContentRecord->source = 'OverDrive'; $eContentRecord->status = 'active'; if ($eContentRecord->find(true)) { $hold['recordId'] = $eContentRecord->id; //Get Rating require_once ROOT_DIR . '/sys/eContent/EContentRating.php'; $econtentRating = new EContentRating(); $econtentRating->recordId = $eContentRecord->id; $hold['ratingData'] = $econtentRating->getRatingData($user, false); } else { $hold['recordId'] = -1; } $hold['title'] = $holdInfo[$grpCtr++]; $hold['author'] = $holdInfo[$grpCtr++]; $holdDetails = $holdInfo[$grpCtr++]; if (preg_match('/<h6[^>]*?class="holds-wait-position"[^>]*?>(.*?)<\\/h6>.*?<h6[^>]*?class="holds-wait-email"[^>]*?>(.*?)<\\/h6>/si', $holdDetails, $holdDetailInfo)) { $notificationInformation = $holdDetailInfo[1]; if (preg_match('/You are (?:patron|user) <b>(\\d+)<\\/b> out of <b>(\\d+)<\\/b> on the waiting list/si', $notificationInformation, $notifyInfo)) { $hold['holdQueuePosition'] = $notifyInfo[1]; $hold['holdQueueLength'] = $notifyInfo[2]; } else { echo $notificationInformation; } $hold['notifyEmail'] = $holdDetailInfo[2]; $hold['available'] = false; } if (preg_match('/This title can be borrowed(.*?)<\\/div>.*?new Date \\("(.*?)"\\)/si', $holdDetails, $holdDetailInfo)) { ///print_r($holdDetails); $hold['emailSent'] = $holdDetailInfo[2]; $hold['notificationDate'] = strtotime($hold['emailSent']); $hold['expirationDate'] = $hold['notificationDate'] + 3 * 24 * 60 * 60; $hold['available'] = true; } if ($hold['available']) { $holds['available'][] = $hold; } else { $holds['unavailable'][] = $hold; } } } return $holds; }
public function getMyTransactions($user) { $return = array(); $eContentCheckout = new EContentCheckout(); $eContentCheckout->userId = $user->id; $eContentCheckout->status = 'out'; $eContentCheckout->find(); $return['transactions'] = array(); $return['numTransactions'] = $eContentCheckout->find(); while ($eContentCheckout->fetch()) { $eContentRecord = new EContentRecord(); $eContentRecord->id = $eContentCheckout->recordId; if ($eContentRecord->find(true)) { $daysUntilDue = ceil(($eContentCheckout->dateDue - time()) / (24 * 60 * 60)); $overdue = $daysUntilDue < 0; $waitList = $this->getWaitList($eContentRecord->id); $links = $this->_getCheckedOutEContentLinks($eContentRecord, null, $eContentCheckout); //Get Ratings require_once ROOT_DIR . '/sys/eContent/EContentRating.php'; $econtentRating = new EContentRating(); $econtentRating->recordId = $eContentRecord->id; $ratingData = $econtentRating->getRatingData($user, false); $return['transactions'][] = array('id' => $eContentRecord->id, 'recordId' => 'econtentRecord' . $eContentRecord->id, 'source' => $eContentRecord->source, 'title' => $eContentRecord->title, 'author' => $eContentRecord->author, 'duedate' => $eContentCheckout->dateDue, 'checkoutdate' => $eContentCheckout->dateCheckedOut, 'daysUntilDue' => $daysUntilDue, 'holdQueueLength' => $waitList, 'links' => $links, 'ratingData' => $ratingData); } } return $return; }
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 launch() { global $interface; global $timer; global $configArray; global $user; //Enable and disable functionality based on library settings global $library; global $locationSingleton; // Setup Search Engine Connection $class = $configArray['Index']['engine']; $url = $configArray['Index']['url']; $this->db = new $class($url); if (isset($_REQUEST['searchId'])) { $_SESSION['searchId'] = $_REQUEST['searchId']; $interface->assign('searchId', $_SESSION['searchId']); } else { if (isset($_SESSION['searchId'])) { $interface->assign('searchId', $_SESSION['searchId']); } } $location = $locationSingleton->getActiveLocation(); $showCopiesLineInHoldingsSummary = true; if ($library && $library->showCopiesLineInHoldingsSummary == 0) { $showCopiesLineInHoldingsSummary = false; } $interface->assign('showCopiesLineInHoldingsSummary', $showCopiesLineInHoldingsSummary); $timer->logTime('Configure UI for library and location'); $interface->assign('overDriveVersion', isset($configArray['OverDrive']['interfaceVersion']) ? $configArray['OverDrive']['interfaceVersion'] : 1); $timer->logTime('Loaded Comments'); $eContentRecord = new EContentRecord(); $this->id = strip_tags($_REQUEST['id']); $eContentRecord->id = $this->id; if (!$eContentRecord->find(true)) { //TODO: display record not found error } else { $this->recordDriver = new EcontentRecordDriver(); $this->recordDriver->setDataObject($eContentRecord); if ($configArray['Catalog']['ils'] == 'Millennium' || $configArray['Catalog']['ils'] == 'Sierra') { if (isset($eContentRecord->ilsId) && strlen($eContentRecord->ilsId) > 0) { $interface->assign('classicId', substr($eContentRecord->ilsId, 1, strlen($eContentRecord->ilsId) - 2)); $interface->assign('classicUrl', $configArray['Catalog']['linking_url']); } } $this->isbn = $eContentRecord->getIsbn(); if (is_array($this->isbn)) { if (count($this->isbn) > 0) { $this->isbn = $this->isbn[0]; } else { $this->isbn = ""; } } $this->issn = $eContentRecord->getPropertyArray('issn'); if (is_array($this->issn)) { if (count($this->issn) > 0) { $this->issn = $this->issn[0]; } else { $this->issn = ""; } } $interface->assign('additionalAuthorsList', $eContentRecord->getPropertyArray('author2')); $interface->assign('lccnList', $eContentRecord->getPropertyArray('lccn')); $interface->assign('isbnList', $eContentRecord->getPropertyArray('isbn')); $interface->assign('isbn', $eContentRecord->getIsbn()); $interface->assign('isbn10', $eContentRecord->getIsbn10()); $interface->assign('issnList', $eContentRecord->getPropertyArray('issn')); $interface->assign('upcList', $eContentRecord->getPropertyArray('upc')); $interface->assign('seriesList', $eContentRecord->getPropertyArray('series')); $interface->assign('topicList', $eContentRecord->getPropertyArray('topic')); $interface->assign('genreList', $eContentRecord->getPropertyArray('genre')); $interface->assign('regionList', $eContentRecord->getPropertyArray('region')); $interface->assign('eraList', $eContentRecord->getPropertyArray('era')); $interface->assign('eContentRecord', $eContentRecord); $interface->assign('cleanDescription', strip_tags($eContentRecord->description, '<p><br><b><i><em><strong>')); $interface->assign('id', $eContentRecord->id); require_once ROOT_DIR . '/sys/eContent/EContentRating.php'; $eContentRating = new EContentRating(); $eContentRating->recordId = $eContentRecord->id; $interface->assign('ratingData', $eContentRating->getRatingData($user, false)); //Determine the cover to use $bookCoverUrl = $configArray['Site']['coverUrl'] . "/bookcover.php?id={$eContentRecord->id}&econtent=true&issn={$eContentRecord->getIssn()}&isn={$eContentRecord->getIsbn()}&size=large&upc={$eContentRecord->getUpc()}&category=" . urlencode($eContentRecord->format_category()) . "&format=" . urlencode($eContentRecord->getFirstFormat()); $interface->assign('bookCoverUrl', $bookCoverUrl); if (isset($_REQUEST['detail'])) { $detail = strip_tags($_REQUEST['detail']); $interface->assign('defaultDetailsTab', $detail); } // Find Similar Records $similar = $this->db->getMoreLikeThis('econtentRecord' . $eContentRecord->id); $timer->logTime('Got More Like This'); //Load the citations $this->loadCitation($eContentRecord); // Retrieve User Search History $interface->assign('lastsearch', isset($_SESSION['lastSearchURL']) ? $_SESSION['lastSearchURL'] : false); //Get Next/Previous Links $searchSource = isset($_REQUEST['searchSource']) ? $_REQUEST['searchSource'] : 'local'; $searchObject = SearchObjectFactory::initSearchObject(); $searchObject->init($searchSource); $searchObject->getNextPrevLinks(); //Load notes if any $marcRecord = MarcLoader::loadEContentMarcRecord($eContentRecord); if ($marcRecord) { $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('520' => 'Description', '500' => 'General Note', '504' => 'Bibliography', '511' => 'Participants/Performers', '518' => 'Date/Time and Place of Event', '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', '513' => 'Type of Report an Period Covered', '515' => 'Numbering Peculiarities', '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) { $noteText[] = $subfield->getData(); } $note = implode(',', $noteText); if (strlen($note) > 0) { $notes[] = "<dt>{$label}</dt><dd>" . $note . '</dd>'; } } } if (count($notes) > 0) { $interface->assign('notes', $notes); } } //Load subjects if ($marcRecord) { if (isset($configArray['Content']['subjectFieldsToShow'])) { $subjectFieldsToShow = $configArray['Content']['subjectFieldsToShow']; $subjectFields = explode(',', $subjectFieldsToShow); $subjects = array(); $standardSubjects = array(); $bisacSubjects = array(); $oclcFastSubjects = array(); foreach ($subjectFields as $subjectField) { /** @var File_MARC_Data_Field[] $marcFields */ $marcFields = $marcRecord->getFields($subjectField); if ($marcFields) { foreach ($marcFields as $marcField) { $searchSubject = ""; $subject = array(); //Determine the type of the subject $type = 'standard'; $subjectSource = $marcField->getSubfield('2'); if ($subjectSource != null) { if (preg_match('/bisac/i', $subjectSource->getData())) { $type = 'bisac'; } elseif (preg_match('/fast/i', $subjectSource->getData())) { $type = 'fast'; } } foreach ($marcField->getSubFields() as $subField) { /** @var File_MARC_Subfield $subField */ if ($subField->getCode() != '2' && $subField->getCode() != '0') { $subFieldData = $subField->getData(); if ($type == 'bisac' && $subField->getCode() == 'a') { $subFieldData = ucwords(strtolower($subFieldData)); } $searchSubject .= " " . $subFieldData; $subject[] = array('search' => trim($searchSubject), 'title' => $subFieldData); } } if ($type == 'bisac') { $bisacSubjects[] = $subject; $subjects[] = $subject; } elseif ($type == 'fast') { //Suppress fast subjects by default $oclcFastSubjects[] = $subject; } else { $subjects[] = $subject; $standardSubjects[] = $subject; } } } $interface->assign('subjects', $subjects); $interface->assign('standardSubjects', $standardSubjects); $interface->assign('bisacSubjects', $bisacSubjects); $interface->assign('oclcFastSubjects', $oclcFastSubjects); } } } else { $rawSubjects = $eContentRecord->getPropertyArray('subject'); $subjects = array(); foreach ($rawSubjects as $subject) { $explodedSubjects = explode(' -- ', $subject); $searchSubject = ""; $subject = array(); foreach ($explodedSubjects as $tmpSubject) { $searchSubject .= $tmpSubject . ' '; $subject[] = array('search' => trim($searchSubject), 'title' => $tmpSubject); } $subjects[] = $subject; } $interface->assign('subjects', $subjects); } $this->loadReviews($eContentRecord); if (isset($_REQUEST['subsection'])) { $subsection = $_REQUEST['subsection']; if ($subsection == 'Description') { $interface->assign('extendedMetadata', $this->recordDriver->getExtendedMetadata()); $interface->assign('subTemplate', 'view-description.tpl'); } elseif ($subsection == 'Reviews') { $interface->assign('subTemplate', 'view-reviews.tpl'); } } //Build the actual view $interface->setTemplate('view.tpl'); $interface->setPageTitle($eContentRecord->title); //Load Staff Details $interface->assign('staffDetails', $this->recordDriver->getStaffView($eContentRecord)); // Display Page $interface->display('layout.tpl'); } }
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 RateTitle() { require_once ROOT_DIR . '/sys/eContent/EContentRating.php'; global $user; if (!isset($user) || $user == false) { header('HTTP/1.0 500 Internal server error'); return 'Please login to rate this title.'; } $ratingValue = $_REQUEST['rating']; //Save the rating $rating = new EContentRating(); $rating->recordId = $_REQUEST['id']; $rating->userId = $user->id; $existingRating = false; if ($rating->find(true) >= 1) { $existingRating = true; } $rating->rating = $ratingValue; $rating->dateRated = time(); if ($existingRating) { $rating->update(); } else { $rating->insert(); } return $ratingValue; }
function launch() { global $interface; global $timer; global $configArray; global $user; //Enable and disable functionality based on library settings global $library; global $locationSingleton; // 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; } if (isset($_REQUEST['searchId'])) { $_SESSION['searchId'] = $_REQUEST['searchId']; $interface->assign('searchId', $_SESSION['searchId']); } else { if (isset($_SESSION['searchId'])) { $interface->assign('searchId', $_SESSION['searchId']); } } $location = $locationSingleton->getActiveLocation(); if (isset($library)) { $interface->assign('showTextThis', $library->showTextThis); $interface->assign('showEmailThis', $library->showEmailThis); $interface->assign('showFavorites', $library->showFavorites); $interface->assign('linkToAmazon', $library->linkToAmazon); $interface->assign('enablePurchaseLinks', $library->linkToAmazon); $interface->assign('enablePospectorIntegration', $library->enablePospectorIntegration); if ($location != null) { $interface->assign('showAmazonReviews', $location->showAmazonReviews == 1 && $library->showAmazonReviews == 1 ? 1 : 0); $interface->assign('showStandardReviews', $location->showStandardReviews == 1 && $library->showStandardReviews == 1 ? 1 : 0); $interface->assign('showHoldButton', $location->showHoldButton == 1 && $library->showHoldButton == 1 ? 1 : 0); } else { $interface->assign('showAmazonReviews', $library->showAmazonReviews); $interface->assign('showStandardReviews', $library->showStandardReviews); $interface->assign('showHoldButton', $library->showHoldButton); } $interface->assign('showTagging', $library->showTagging); $interface->assign('showRatings', $library->showRatings); $interface->assign('showComments', $library->showComments); $interface->assign('tabbedDetails', $library->tabbedDetails); $interface->assign('showOtherEditionsPopup', $library->showOtherEditionsPopup == 1 ? true : false); $interface->assign('showProspectorTitlesAsTab', $library->showProspectorTitlesAsTab); } else { $interface->assign('showTextThis', 1); $interface->assign('showEmailThis', 1); $interface->assign('showFavorites', 1); $interface->assign('linkToAmazon', 1); $interface->assign('enablePurchaseLinks', 1); $interface->assign('enablePospectorIntegration', 0); if ($location != null) { $interface->assign('showAmazonReviews', $location->showAmazonReviews); $interface->assign('showStandardReviews', $location->showStandardReviews); $interface->assign('showHoldButton', $location->showHoldButton); } else { $interface->assign('showAmazonReviews', 1); $interface->assign('showStandardReviews', 1); $interface->assign('showHoldButton', 1); } $interface->assign('showTagging', 1); $interface->assign('showRatings', 1); $interface->assign('showComments', 1); $interface->assign('tabbedDetails', 1); $interface->assign('showProspectorTitlesAsTab', 0); } $interface->assign('showOtherEditionsPopup', $configArray['Content']['showOtherEditionsPopup']); $interface->assign('chiliFreshAccount', $configArray['Content']['chiliFreshAccount']); $showCopiesLineInHoldingsSummary = true; if ($library && $library->showCopiesLineInHoldingsSummary == 0) { $showCopiesLineInHoldingsSummary = false; } $interface->assign('showCopiesLineInHoldingsSummary', $showCopiesLineInHoldingsSummary); $timer->logTime('Configure UI for library and location'); $interface->assign('overDriveVersion', isset($configArray['OverDrive']['interfaceVersion']) ? $configArray['OverDrive']['interfaceVersion'] : 1); Record_UserComments::loadEContentComments(); $timer->logTime('Loaded Comments'); $eContentRecord = new EContentRecord(); $this->id = strip_tags($_REQUEST['id']); $eContentRecord->id = $this->id; if (!$eContentRecord->find(true)) { //TODO: display record not found error } else { $this->recordDriver = new EcontentRecordDriver(); $this->recordDriver->setDataObject($eContentRecord); if ($configArray['Catalog']['ils'] == 'Millennium') { if (isset($eContentRecord->ilsId) && strlen($eContentRecord->ilsId) > 0) { $interface->assign('classicId', substr($eContentRecord->ilsId, 1, strlen($eContentRecord->ilsId) - 2)); $interface->assign('classicUrl', $configArray['Catalog']['linking_url']); } } $this->isbn = $eContentRecord->getIsbn(); if (is_array($this->isbn)) { if (count($this->isbn) > 0) { $this->isbn = $this->isbn[0]; } else { $this->isbn = ""; } } elseif ($this->isbn == null || strlen($this->isbn) == 0) { $interface->assign('showOtherEditionsPopup', false); } $this->issn = $eContentRecord->getPropertyArray('issn'); if (is_array($this->issn)) { if (count($this->issn) > 0) { $this->issn = $this->issn[0]; } else { $this->issn = ""; } } $interface->assign('additionalAuthorsList', $eContentRecord->getPropertyArray('author2')); $rawSubjects = $eContentRecord->getPropertyArray('subject'); $subjects = array(); foreach ($rawSubjects as $subject) { $explodedSubjects = explode(' -- ', $subject); $searchSubject = ""; $subject = array(); foreach ($explodedSubjects as $tmpSubject) { $searchSubject .= $tmpSubject . ' '; $subject[] = array('search' => trim($searchSubject), 'title' => $tmpSubject); } $subjects[] = $subject; } $interface->assign('subjects', $subjects); $interface->assign('lccnList', $eContentRecord->getPropertyArray('lccn')); $interface->assign('isbnList', $eContentRecord->getPropertyArray('isbn')); $interface->assign('isbn', $eContentRecord->getIsbn()); $interface->assign('isbn10', $eContentRecord->getIsbn10()); $interface->assign('issnList', $eContentRecord->getPropertyArray('issn')); $interface->assign('upcList', $eContentRecord->getPropertyArray('upc')); $interface->assign('seriesList', $eContentRecord->getPropertyArray('series')); $interface->assign('topicList', $eContentRecord->getPropertyArray('topic')); $interface->assign('genreList', $eContentRecord->getPropertyArray('genre')); $interface->assign('regionList', $eContentRecord->getPropertyArray('region')); $interface->assign('eraList', $eContentRecord->getPropertyArray('era')); $interface->assign('eContentRecord', $eContentRecord); $interface->assign('cleanDescription', strip_tags($eContentRecord->description, '<p><br><b><i><em><strong>')); $interface->assign('id', $eContentRecord->id); require_once ROOT_DIR . '/sys/eContent/EContentRating.php'; $eContentRating = new EContentRating(); $eContentRating->recordId = $eContentRecord->id; $interface->assign('ratingData', $eContentRating->getRatingData($user, false)); //Determine the cover to use $bookCoverUrl = $configArray['Site']['coverUrl'] . "/bookcover.php?id={$eContentRecord->id}&econtent=true&issn={$eContentRecord->getIssn()}&isn={$eContentRecord->getIsbn()}&size=large&upc={$eContentRecord->getUpc()}&category=" . urlencode($eContentRecord->format_category()) . "&format=" . urlencode($eContentRecord->getFirstFormat()); $interface->assign('bookCoverUrl', $bookCoverUrl); if (isset($_REQUEST['detail'])) { $detail = strip_tags($_REQUEST['detail']); $interface->assign('defaultDetailsTab', $detail); } // Find Similar Records $similar = $this->db->getMoreLikeThis('econtentRecord' . $eContentRecord->id); $timer->logTime('Got More Like This'); // Find Other Editions if ($configArray['Content']['showOtherEditionsPopup'] == false) { $editions = OtherEditionHandler::getEditions($eContentRecord->solrId(), $eContentRecord->getIsbn(), null); if (!PEAR_Singleton::isError($editions)) { $interface->assign('editions', $editions); } $timer->logTime('Got Other editions'); } //Load the citations $this->loadCitation($eContentRecord); // Retrieve User Search History $interface->assign('lastsearch', isset($_SESSION['lastSearchURL']) ? $_SESSION['lastSearchURL'] : false); //Get Next/Previous Links $searchSource = isset($_REQUEST['searchSource']) ? $_REQUEST['searchSource'] : 'local'; $searchObject = SearchObjectFactory::initSearchObject(); $searchObject->init($searchSource); $searchObject->getNextPrevLinks(); // Retrieve tags associated with the record $limit = 5; $resource = new Resource(); $resource->record_id = $_GET['id']; $resource->source = 'eContent'; $resource->find(true); $tags = $resource->getTags($limit); $interface->assign('tagList', $tags); $timer->logTime('Got tag list'); //Load notes if any $marcRecord = MarcLoader::loadEContentMarcRecord($eContentRecord); if ($marcRecord) { $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) { $noteText[] = $subfield->getData(); } $note = implode(',', $noteText); if (strlen($note) > 0) { $notes[] = "<b>{$label}</b>: " . $note; } } } if (count($notes) > 0) { $interface->assign('notes', $notes); } } $this->loadReviews($eContentRecord); if (isset($_REQUEST['subsection'])) { $subsection = $_REQUEST['subsection']; if ($subsection == 'Description') { $interface->assign('extendedMetadata', $this->recordDriver->getExtendedMetadata()); $interface->assign('subTemplate', 'view-description.tpl'); } elseif ($subsection == 'Reviews') { $interface->assign('subTemplate', 'view-reviews.tpl'); } } //Build the actual view $interface->setTemplate('view.tpl'); $interface->setPageTitle($eContentRecord->title); //Var for the IDCLREADER TEMPLATE $interface->assign('ButtonBack', true); $interface->assign('ButtonHome', true); $interface->assign('MobileTitle', ' '); //Load Staff Details $interface->assign('staffDetails', $this->getStaffView($eContentRecord)); // Display Page $interface->display('layout.tpl'); } }