Example #1
0
 /**
  * Load titles that have been rated by other users which are similar to this.
  *
  * @param SearchObject_Solr|SearchObject_Base $db
  * @param UserRating $ratedTitle
  * @param integer $userId
  * @param array $ratedTitles
  * @param array $suggestions
  * @param integer[] $notInterestedTitles
  * @return int The number of suggestions for this title
  */
 static function getSimilarlyRatedTitles($db, $ratedTitle, $userId, $ratedTitles, &$suggestions, $notInterestedTitles)
 {
     $numRecommendations = 0;
     //If there is no ISBN, can we come up with an alternative algorithm?
     //Possibly using common ratings with other patrons?
     //Get a list of other patrons that have rated this title and that like it as much or more than the active user..
     $otherRaters = new UserRating();
     //Query the database to get items that other users who rated this liked.
     $sqlStatement = "SELECT resourceid, record_id, " . " sum(case rating when 5 then 10 when 4 then 6 end) as rating " . " FROM `user_rating` inner join resource on resource.id = user_rating.resourceid WHERE userId in " . " (select userId from user_rating where resourceId = " . $ratedTitle->resourceid . " and rating >= 4 " . " and userid != " . $userId . ") " . " and rating >= 4 " . " and resourceId != " . $ratedTitle->resourceid . " and deleted = 0 " . " group by resourceid order by rating desc limit 10";
     //Sort so the highest titles are on top and limit to 10 suggestions.
     $otherRaters->query($sqlStatement);
     if ($otherRaters->N > 0) {
         //Other users have also rated this title.
         while ($otherRaters->fetch()) {
             //Process the title
             disableErrorHandler();
             if (!($ownedRecord = $db->getRecord($otherRaters->record_id))) {
                 //Old record which has been removed? Ignore for purposes of suggestions.
                 continue;
             }
             enableErrorHandler();
             //get the title from the Solr Index
             if (isset($ownedRecord['isbn'])) {
                 if (strpos($ownedRecord['isbn'][0], ' ') > 0) {
                     $isbnInfo = explode(' ', $ownedRecord['isbn'][0]);
                     $isbn = $isbnInfo[0];
                 } else {
                     $isbn = $ownedRecord['isbn'][0];
                 }
                 $isbn13 = strlen($isbn) == 13 ? $isbn : ISBNConverter::convertISBN10to13($isbn);
                 $isbn10 = strlen($isbn) == 10 ? $isbn : ISBNConverter::convertISBN13to10($isbn);
             } else {
                 $isbn13 = '';
                 $isbn10 = '';
             }
             //See if we can get the series title from the record
             if (isset($ownedRecord['series'])) {
                 $series = $ownedRecord['series'][0];
             } else {
                 $series = '';
             }
             $similarTitle = array('title' => $ownedRecord['title'], 'title_short' => $ownedRecord['title_short'], 'author' => isset($ownedRecord['author']) ? $ownedRecord['author'] : '', 'publicationDate' => $ownedRecord['publishDate'], 'isbn' => $isbn13, 'isbn10' => $isbn10, 'upc' => isset($ownedRecord['upc']) ? $ownedRecord['upc'][0] : '', 'recordId' => $ownedRecord['id'], 'id' => $ownedRecord['id'], 'libraryOwned' => true, 'isCurrent' => false, 'shortId' => substr($ownedRecord['id'], 1), 'format_category' => isset($ownedRecord['format_category']) ? $ownedRecord['format_category'] : '', 'format' => $ownedRecord['format'], 'recordtype' => $ownedRecord['recordtype'], 'series' => $series, 'grouping_term' => $ownedRecord['grouping_term']);
             $numRecommendations++;
             Suggestions::addTitleToSuggestions($ratedTitle, $similarTitle['title'], $similarTitle['recordId'], $similarTitle, $ratedTitles, $suggestions, $notInterestedTitles);
         }
     }
     return $numRecommendations;
 }
 * @package  Utilities
 * @author   Lutz Biedinger <*****@*****.**>
 * @license  http://opensource.org/licenses/gpl-2.0.php GNU General Public License
 * @link     http://vufind.org/wiki Wiki
 */
require_once 'util.inc.php';
require_once 'sys/ConfigArray.php';
require_once 'sys/solr.php';
require_once 'sys/SearchObject/solr.php';
require_once 'sys/SearchObject/Factory.php';
require_once 'RecordDrivers/Factory.php';
require_once 'sys/hierarchy/HierarchyTreeGenerator_JSTree.php';
print "getting config\r\n";
$configArray = readConfig();
print "creating Search Object\r\n";
$solrSearchObject = new SearchObject_Solr();
if (!$solrSearchObject) {
    die("Error: No connection to solr index\n");
}
print "Getting Full Field Facets\r\n";
$hierarchyTopFacets = $solrSearchObject->getFullFieldFacets(array("hierarchy_top_id"));
$db = ConnectionManager::connectToIndex();
print "Iterate through Values\r\n";
foreach ($hierarchyTopFacets["hierarchy_top_id"]["data"] as $hierarchyTopFacet) {
    $topRecord = $db->getRecord($hierarchyTopFacet[0]);
    $RecDriver = RecordDriverFactory::initRecordDriver($topRecord);
    if ($RecDriver->getHierarchyType()) {
        //only do this if the record is actually a hierarchy type record
        $generator = new HierarchyTreeGenerator_JSTree($RecDriver);
        $generator->generateXMLfromSolr($hierarchyTopFacet[0]);
    }
Example #3
0
 /**
  * Assign necessary Smarty variables and return a template name to
  * load in order to display similar items of the record view page.
  *
  * @return string Name of Smarty template file to display.
  * @access public
  */
 public function getSimilarItems()
 {
     global $interface;
     $this->db = ConnectionManager::connectToIndex();
     // Get similar records
     $similar = $this->db->getMoreLikeThis($this->fields['id'], array('fq' => SearchObject_Solr::getDefaultHiddenFilters()));
     if (!$similar || !array_key_exists('response', $similar) || !array_key_exists('docs', $similar['response'])) {
         PEAR::raiseError(new PEAR_Error('Cannot Load similar items'));
     }
     // 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 (count($similar['response']['docs']) > 0) {
         $interface->assign('similarRecords', $similar['response']['docs']);
     }
     // Find Other Editions
     $editions = $this->getEditions();
     if (!PEAR::isError($editions)) {
         $interface->assign('editions', $editions);
     }
     return 'Record/similar-items.tpl';
 }
Example #4
0
 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}&amp;econtent=true&amp;issn={$eContentRecord->getIssn()}&amp;isn={$eContentRecord->getIsbn()}&amp;size=large&amp;upc={$eContentRecord->getUpc()}&amp;category=" . urlencode($eContentRecord->format_category()) . "&amp;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');
     }
 }
Example #5
0
 public function process()
 {
     global $interface;
     //Get Facet settings for processing display
     $interface->assign('checkboxFilters', $this->searchObject->getCheckboxFacets());
     //Get applied facets
     $filterList = $this->searchObject->getFilterList(true);
     foreach ($filterList as $facetKey => $facet) {
         //Remove any top facets since the removal links are displayed above results
         if (strpos($facet[0]['field'], 'availability_toggle') === 0) {
             unset($filterList[$facetKey]);
         }
     }
     $interface->assign('filterList', $filterList);
     //Process the side facet set to handle the Added In Last facet which we only want to be
     //visible if there is not a value selected for the facet (makes it single select
     $sideFacets = $this->searchObject->getFacetList($this->mainFacets);
     $searchLibrary = Library::getSearchLibrary();
     //Do additional processing of facets for non-genealogy searches
     if ($this->searchObject->getSearchType() != 'genealogy') {
         foreach ($sideFacets as $facetKey => $facet) {
             $facetSetting = $this->facetSettings[$facetKey];
             //Do special processing of facets
             if (preg_match('/time_since_added/i', $facetKey)) {
                 $timeSinceAddedFacet = $this->updateTimeSinceAddedFacet($facet);
                 $sideFacets[$facetKey] = $timeSinceAddedFacet;
             } elseif ($facetKey == 'rating_facet') {
                 $userRatingFacet = $this->updateUserRatingsFacet($facet);
                 $sideFacets[$facetKey] = $userRatingFacet;
             } elseif ($facetKey == 'available_at') {
                 //Mangle the availability facets
                 $oldFacetValues = $sideFacets['available_at']['list'];
                 ksort($oldFacetValues);
                 $filters = $this->searchObject->getFilterList();
                 //print_r($filters);
                 $appliedAvailability = array();
                 foreach ($filters as $appliedFilters) {
                     foreach ($appliedFilters as $filter) {
                         if ($filter['field'] == 'available_at') {
                             $appliedAvailability[$filter['value']] = $filter['removalUrl'];
                         }
                     }
                 }
                 $availableAtFacets = array();
                 foreach ($oldFacetValues as $facetKey2 => $facetInfo) {
                     if (strlen($facetKey2) > 1) {
                         $sortIndicator = substr($facetKey2, 0, 1);
                         if ($sortIndicator >= '1' && $sortIndicator <= '4') {
                             $availableAtFacets[$facetKey2] = $facetInfo;
                         }
                     }
                 }
                 $includeAnyLocationFacet = $this->searchObject->getFacetSetting("Availability", "includeAnyLocationFacet");
                 $includeAnyLocationFacet = $includeAnyLocationFacet == '' || $includeAnyLocationFacet == 'true';
                 if ($searchLibrary) {
                     $includeAnyLocationFacet = $searchLibrary->showAvailableAtAnyLocation;
                 }
                 //print_r ("includeAnyLocationFacet = $includeAnyLocationFacet");
                 if ($includeAnyLocationFacet) {
                     $anyLocationLabel = $this->searchObject->getFacetSetting("Availability", "anyLocationLabel");
                     //print_r ("anyLocationLabel = $anyLocationLabel");
                     $availableAtFacets['*'] = array('value' => '*', 'display' => $anyLocationLabel == '' ? "Any Marmot Location" : $anyLocationLabel, 'count' => $this->searchObject->getResultTotal() - (isset($oldFacetValues['']['count']) ? $oldFacetValues['']['count'] : 0), 'url' => $this->searchObject->renderLinkWithFilter('available_at:*'), 'isApplied' => array_key_exists('*', $appliedAvailability), 'removalUrl' => array_key_exists('*', $appliedAvailability) ? $appliedAvailability['*'] : null);
                 }
                 $sideFacets['available_at']['list'] = $availableAtFacets;
             } else {
                 //Do other handling of the display
                 if ($facetSetting->sortMode == 'alphabetically') {
                     asort($sideFacets[$facetKey]['list']);
                 }
                 if ($facetSetting->numEntriesToShowByDefault > 0) {
                     $sideFacets[$facetKey]['valuesToShow'] = $facetSetting->numEntriesToShowByDefault;
                 }
                 if ($facetSetting->showAsDropDown) {
                     $sideFacets[$facetKey]['showAsDropDown'] = $facetSetting->showAsDropDown;
                 }
                 if ($facetSetting->useMoreFacetPopup && count($sideFacets[$facetKey]['list']) > 12) {
                     $sideFacets[$facetKey]['showMoreFacetPopup'] = true;
                     $facetsList = $sideFacets[$facetKey]['list'];
                     $sideFacets[$facetKey]['list'] = array_slice($facetsList, 0, 5);
                     $sortedList = array();
                     foreach ($facetsList as $key => $value) {
                         $sortedList[strtolower($key)] = $value;
                     }
                     ksort($sortedList);
                     $sideFacets[$facetKey]['sortedList'] = $sortedList;
                 } else {
                     $sideFacets[$facetKey]['showMoreFacetPopup'] = false;
                 }
             }
             $sideFacets[$facetKey]['collapseByDefault'] = $facetSetting->collapseByDefault;
         }
     }
     $interface->assign('sideFacetSet', $sideFacets);
 }
Example #6
0
 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}&amp;econtent=true&amp;issn={$eContentRecord->getIssn()}&amp;isn={$eContentRecord->getIsbn()}&amp;size=large&amp;upc={$eContentRecord->getUpc()}&amp;category=" . urlencode($eContentRecord->format_category()) . "&amp;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', '&nbsp;');
         //Load Staff Details
         $interface->assign('staffDetails', $this->getStaffView($eContentRecord));
         // Display Page
         $interface->display('layout.tpl');
     }
 }
Example #7
0
 /**
  * @param SearchObject_Solr $searchObj
  *
  * @return boolean
  */
 public function updateFromSearch($searchObj)
 {
     //Search terms
     $searchTerms = $searchObj->getSearchTerms();
     if (is_array($searchTerms)) {
         if (count($searchTerms) > 1) {
             return false;
         } else {
             if (!isset($searchTerms[0]['index'])) {
                 $this->searchTerm = $searchObj->displayQuery();
             } else {
                 if ($searchTerms[0]['index'] == 'Keyword') {
                     $this->searchTerm = $searchTerms[0]['lookfor'];
                 } else {
                     $this->searchTerm = $searchTerms[0]['index'] . ':' . $searchTerms[0]['lookfor'];
                 }
             }
         }
     } else {
         $this->searchTerm = $searchTerms;
     }
     //Default Filter
     $filters = $searchObj->getFilterList();
     $formattedFilters = '';
     foreach ($filters as $filter) {
         if (strlen($formattedFilters) > 0) {
             $formattedFilters .= "\r\n";
         }
         $formattedFilters .= $filter[0]['field'] . ':' . $filter[0]['value'];
     }
     $this->defaultFilter = $formattedFilters;
     //Default sort
     $solrSort = $searchObj->getSort();
     if ($solrSort == 'relevance') {
         $this->defaultSort = 'relevance';
     } elseif ($solrSort == 'popularity desc') {
         $this->defaultSort = 'popularity';
     } elseif ($solrSort == 'days_since_added asc') {
         $this->defaultSort = 'newest_to_oldest';
     } elseif ($solrSort == 'days_since_added desc') {
         $this->defaultSort = 'oldest_to_newest';
     } elseif ($solrSort == 'author,title') {
         $this->defaultSort = 'author';
     } elseif ($solrSort == 'title,author') {
         $this->defaultSort = 'title';
     } elseif ($solrSort == 'rating desc,title') {
         $this->defaultSort = 'user_rating';
     } else {
         $this->defaultSort = 'relevance';
     }
     return true;
 }
Example #8
0
 /**
  * Obtain information from an alphabetic browse index.
  *
  * @param string $source          Name of index to search
  * @param string $from            Starting point for browse results
  * @param string $rowid           Starting point rowid when known
  * @param int    $page            If page is 0 browse forward, if page is -1 browse backwards
  * @param int    $page_size       The numer of results to return
  * @param string $extras          Also return these Solr db fields in the results
  * @param bool   $returnSolrError Should we fail outright on syntax error
  * (false) or treat it as an empty result set with an error key set (true)?
  *
  * @return array
  * @access public
  */
 public function alphabeticBrowse($source, $from, $rowid, $page, $page_size = 20, $extras = null, $returnSolrError = false)
 {
     $this->client->setMethod('GET');
     $this->client->setURL($this->host . "/browse");
     $this->client->addQueryString('source', $source);
     $this->client->addQueryString('from', $from);
     $this->client->addQueryString('rowid', $rowid);
     $this->client->addQueryString('offset', $page);
     $this->client->addQueryString('rows', $page_size);
     $this->client->addQueryString('extras', $extras);
     $this->client->addQueryString('json.nl', 'arrarr');
     $this->client->addQueryString('wt', 'json');
     $filters = SearchObject_Solr::getDefaultHiddenFilters();
     if ($this->_mergedRecords) {
         // Filter out merged children by default
         $filters[] = '-merged_child_boolean:TRUE';
     } elseif ($this->_mergedRecords !== null) {
         // Filter out merged records by default
         if (!isset($filter)) {
             $filter = array();
         }
         $filters[] = '-merged_boolean:TRUE';
     }
     if (!empty($filters)) {
         $this->client->addQueryString('filters', implode(' AND ', $filters));
     }
     if ($this->debug) {
         echo '<pre>Browse: ' . $this->client->getUrl() . "\n";
         echo "</pre>\n";
     }
     $result = $this->client->sendRequest();
     if (!PEAR::isError($result)) {
         return $this->_process($this->client->getResponseBody(), $returnSolrError);
     } else {
         return $result;
     }
 }
Example #9
0
 private function getBrowseCategoryResults($pageToLoad = 1)
 {
     $browseMode = $this->setBrowseMode();
     if ($pageToLoad == 1 && !isset($_REQUEST['reload'])) {
         // only first page is cached
         global $memCache, $solrScope;
         $key = 'browse_category_' . $this->textId . '_' . $solrScope . '_' . $browseMode;
         $browseCategoryInfo = $memCache->get($key);
         if ($browseCategoryInfo != false) {
             return $browseCategoryInfo;
         }
     }
     $result = array('result' => false);
     $browseCategory = $this->getBrowseCategory();
     if ($browseCategory) {
         global $interface;
         $interface->assign('browseCategoryId', $this->textId);
         $result['result'] = true;
         $result['textId'] = $browseCategory->textId;
         $result['label'] = $browseCategory->label;
         //$result['description'] = $browseCategory->description; // the description is not used anywhere on front end. plb 1-2-2015
         // User List Browse Category //
         if ($browseCategory->sourceListId != null && $browseCategory->sourceListId > 0) {
             require_once ROOT_DIR . '/sys/LocalEnrichment/UserList.php';
             $sourceList = new UserList();
             $sourceList->id = $browseCategory->sourceListId;
             if ($sourceList->find(true)) {
                 $records = $sourceList->getBrowseRecords(($pageToLoad - 1) * self::ITEMS_PER_PAGE, self::ITEMS_PER_PAGE);
             } else {
                 $records = array();
             }
             $result['searchUrl'] = '/MyAccount/MyList/' . $browseCategory->sourceListId;
             // Search Browse Category //
         } else {
             $this->searchObject = SearchObjectFactory::initSearchObject();
             $defaultFilterInfo = $browseCategory->defaultFilter;
             $defaultFilters = preg_split('/[\\r\\n,;]+/', $defaultFilterInfo);
             foreach ($defaultFilters as $filter) {
                 $this->searchObject->addFilter(trim($filter));
             }
             //Set Sorting, this is actually slightly mangled from the category to Solr
             $this->searchObject->setSort($browseCategory->getSolrSort());
             if ($browseCategory->searchTerm != '') {
                 $this->searchObject->setSearchTerm($browseCategory->searchTerm);
             }
             //Get titles for the list
             $this->searchObject->clearFacets();
             $this->searchObject->disableSpelling();
             $this->searchObject->disableLogging();
             $this->searchObject->setLimit(self::ITEMS_PER_PAGE);
             $this->searchObject->setPage($pageToLoad);
             $this->searchObject->processSearch();
             $records = $this->searchObject->getBrowseRecordHTML();
             $result['searchUrl'] = $this->searchObject->renderSearchUrl();
             //TODO: Check if last page
             // Shutdown the search object
             $this->searchObject->close();
         }
         if (count($records) == 0) {
             $records[] = $interface->fetch('Browse/noResults.tpl');
         }
         $result['records'] = implode('', $records);
         $result['numRecords'] = count($records);
     }
     // Store first page of browse category in the MemCache
     if ($pageToLoad == 1) {
         global $memCache, $configArray, $solrScope;
         $key = 'browse_category_' . $this->textId . '_' . $solrScope . '_' . $browseMode;
         $memCache->add($key, $result, 0, $configArray['Caching']['browse_category_info']);
     }
     return $result;
 }
Example #10
0
 /**
  * Load all recommendation settings from the relevant ini file.  Returns an
  * associative array where the key is the location of the recommendations (top
  * or side) and the value is the settings found in the file (which may be either
  * a single string or an array of strings).
  *
  * @return array associative: location (top/side) => search settings
  * @access protected
  */
 protected function getRecommendationSettings()
 {
     //collection recommendations
     $searchSettings = getExtraConfigArray('searches');
     return isset($searchSettings['CollectionModuleRecommendations']) ? $searchSettings['CollectionModuleRecommendations'] : array('side' => array('ExpandFacets:Collection'));
     // Use default case from parent class the rest of the time:
     return parent::getRecommendationSettings();
 }
Example #11
0
 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."));
     }
 }
Example #12
0
 function launch()
 {
     global $configArray;
     global $interface;
     global $user;
     // 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;
     }
     //Enable and disable functionality based on library settings
     global $library;
     global $locationSingleton;
     $location = $locationSingleton->getActiveLocation();
     if (isset($library)) {
         if ($location != null) {
             $interface->assign('showHoldButton', $location->showHoldButton == 1 && $library->showHoldButton == 1 ? 1 : 0);
         } else {
             $interface->assign('showHoldButton', $library->showHoldButton);
         }
         $interface->assign('showTagging', $library->showTagging);
         $interface->assign('showRatings', $library->showRatings);
         $interface->assign('showComments', $library->showComments);
         $interface->assign('showFavorites', $library->showFavorites);
     } else {
         if ($location != null) {
             $interface->assign('showHoldButton', $location->showHoldButton);
         } else {
             $interface->assign('showHoldButton', 1);
         }
         $interface->assign('showTagging', 1);
         $interface->assign('showRatings', 1);
         $interface->assign('showComments', 1);
         $interface->assign('showFavorites', 1);
     }
     //Build the actual view
     $interface->setTemplate('../Record/view-series.tpl');
     $eContentRecord = new EContentRecord();
     $this->id = strip_tags($_REQUEST['id']);
     $eContentRecord->id = $this->id;
     $eContentRecord->find(true);
     $similar = $this->db->getMoreLikeThis2($eContentRecord->getSolrId());
     // 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) {
         $this->similarTitles = $similar['response']['docs'];
     } else {
         $this->similarTitles = array();
     }
     $resourceList = array();
     $curIndex = 0;
     $groupingTerms = array();
     if (isset($this->similarTitles) && is_array($this->similarTitles)) {
         foreach ($this->similarTitles as $title) {
             $groupingTerm = $title['grouping_term'];
             if (array_key_exists($groupingTerm, $groupingTerms)) {
                 continue;
             }
             $groupingTerms[$groupingTerm] = $groupingTerm;
             $interface->assign('resultIndex', ++$curIndex);
             $record = RecordDriverFactory::initRecordDriver($title);
             $resourceList[] = $interface->fetch($record->getSearchResult($user, null, false));
         }
     }
     $interface->assign('recordSet', $this->similarTitles);
     $interface->assign('resourceList', $resourceList);
     $interface->assign('recordStart', 1);
     $interface->assign('recordEnd', count($resourceList));
     $interface->assign('recordCount', count($resourceList));
     $novelist = NovelistFactory::getNovelist();
     $enrichment = $novelist->loadEnrichment($eContentRecord->getIsbn());
     $interface->assign('enrichment', $enrichment);
     $interface->assign('id', $this->id);
     //Build the actual view
     $interface->setTemplate('view-similar.tpl');
     $interface->setPageTitle('Similar to ' . $eContentRecord->title);
     $interface->assign('eContentRecord', $eContentRecord);
     // Display Page
     $interface->display('layout.tpl');
 }