Ejemplo n.º 1
0
 /**
  * Assign necessary Smarty variables and return a template name to
  * load in order to display a summary of the item suitable for use in
  * search results.
  *
  * @access  public
  *
  * @param string $view The current view.
  * @param boolean $useUnscopedHoldingsSummary Whether or not the result should show an unscoped holdings summary.
  *
  * @return  string              Name of Smarty template file to display.
  */
 public function getSearchResult($view = 'list', $useUnscopedHoldingsSummary = false)
 {
     global $interface;
     global $user;
     if (!isset($this->eContentRecord)) {
         $this->eContentRecord = new EContentRecord();
         $this->eContentRecord->id = $this->getUniqueID();
         $this->eContentRecord->find(true);
     }
     $interface->assign('source', $this->eContentRecord->source);
     $interface->assign('eContentRecord', $this->eContentRecord);
     $interface->assign('useUnscopedHoldingsSummary', $useUnscopedHoldingsSummary);
     parent::getSearchResult();
     $linkUrl = '/EcontentRecord/' . $this->getUniqueID() . '/Home?searchId=' . $interface->get_template_vars('searchId') . '&recordIndex=' . $interface->get_template_vars('recordIndex') . '&page=' . $interface->get_template_vars('page');
     if ($useUnscopedHoldingsSummary) {
         $linkUrl .= '&searchSource=marmot';
     } else {
         $linkUrl .= '&searchSource=' . $interface->get_template_vars('searchSource');
     }
     $interface->assign('summUrl', $linkUrl);
     //Get Rating
     require_once ROOT_DIR . '/sys/eContent/EContentRating.php';
     $econtentRating = new EContentRating();
     $econtentRating->recordId = $this->getUniqueID();
     //$logger->log("Loading ratings for econtent record {$this->getUniqueID()}", PEAR_LOG_DEBUG);
     $interface->assign('summRating', $econtentRating->getRatingData($user, false));
     $interface->assign('summAjaxStatus', true);
     //Override fields as needed
     return 'RecordDrivers/Econtent/result.tpl';
 }
Ejemplo n.º 2
0
 function launch()
 {
     global $configArray;
     global $interface;
     global $user;
     global $timer;
     require_once ROOT_DIR . '/Drivers/OverDriveDriverFactory.php';
     $overDriveDriver = OverDriveDriverFactory::getDriver();
     $overDriveWishList = $overDriveDriver->getOverDriveWishList($user);
     //Load the full record for each item in the wishlist
     foreach ($overDriveWishList['items'] as $key => $item) {
         if ($item['recordId'] != -1) {
             $econtentRecord = new EContentRecord();
             $econtentRecord->id = $item['recordId'];
             $econtentRecord->find(true);
             $item['record'] = clone $econtentRecord;
         } else {
             $item['record'] = null;
         }
         $item['numRows'] = count($item['formats']) + 1;
         $overDriveWishList['items'][$key] = $item;
     }
     $interface->assign('overDriveWishList', $overDriveWishList['items']);
     if (isset($overDriveWishList['error'])) {
         $interface->assign('error', $overDriveWishList['error']);
     }
     $interface->setTemplate('overDriveWishList.tpl');
     $interface->setPageTitle('OverDrive Wish List');
     $interface->display('layout.tpl');
 }
Ejemplo n.º 3
0
 function launch()
 {
     global $configArray;
     global $interface;
     global $user;
     global $timer;
     require_once ROOT_DIR . '/Drivers/OverDriveDriverFactory.php';
     $overDriveDriver = OverDriveDriverFactory::getDriver();
     $overDriveCheckedOutItems = $overDriveDriver->getOverDriveCheckedOutItems($user);
     //Load the full record for each item in the wishlist
     foreach ($overDriveCheckedOutItems['items'] as $key => $item) {
         if ($item['recordId'] != -1) {
             $econtentRecord = new EContentRecord();
             $econtentRecord->id = $item['recordId'];
             $econtentRecord->find(true);
             $item['record'] = clone $econtentRecord;
         } else {
             $item['record'] = null;
         }
         $overDriveCheckedOutItems['items'][$key] = $item;
     }
     $interface->assign('overDriveCheckedOutItems', $overDriveCheckedOutItems['items']);
     $interface->assign('ButtonBack', true);
     $interface->assign('ButtonHome', true);
     $interface->assign('MobileTitle', 'OverDrive Checked Out Items');
     $interface->assign('showNotInterested', false);
     global $configArray;
     if (!isset($configArray['OverDrive']['interfaceVersion']) || $configArray['OverDrive']['interfaceVersion'] == 1) {
         $interface->setTemplate('overDriveCheckedOut.tpl');
     } else {
         $interface->setTemplate('overDriveCheckedOut2.tpl');
     }
     $interface->setPageTitle('OverDrive Checked Out Items');
     $interface->display('layout.tpl');
 }
Ejemplo n.º 4
0
 function processExternalLinks($source)
 {
     $eContentAttachmentLogEntry = new EContentAttachmentLogEntry();
     $eContentAttachmentLogEntry->dateStarted = time();
     $eContentAttachmentLogEntry->sourcePath = 'Attaching External links to ' . $source;
     $eContentAttachmentLogEntry->recordsProcessed = 0;
     $eContentAttachmentLogEntry->insert();
     //Get a list of all records that do not have items for the source
     $econtentRecord = new EContentRecord();
     $econtentRecord->source = $source;
     $econtentRecord->find();
     while ($econtentRecord->fetch()) {
         if ($econtentRecord->getNumItems() == 0 && $econtentRecord->sourceUrl != null && strlen($econtentRecord->sourceUrl) > 0) {
             $sourceUrl = $econtentRecord->sourceUrl;
             $econtentItem = new EContentItem();
             $econtentItem->recordId = $econtentRecord->id;
             $econtentItem->item_type = 'externalLink';
             $econtentItem->addedBy = 1;
             $econtentItem->date_added = time();
             $econtentItem->date_updated = time();
             $econtentItem->link = $sourceUrl;
             $econtentItem->insert();
             $eContentAttachmentLogEntry->recordsProcessed++;
             //Increase processing time since this can take awhile
             set_time_limit(30);
         }
     }
     $eContentAttachmentLogEntry->dateFinished = time();
     $eContentAttachmentLogEntry->status = 'finished';
     $eContentAttachmentLogEntry->update();
 }
Ejemplo n.º 5
0
 function launch()
 {
     global $configArray;
     global $interface;
     global $user;
     global $timer;
     require_once ROOT_DIR . '/Drivers/OverDriveDriverFactory.php';
     $overDriveDriver = OverDriveDriverFactory::getDriver();
     $overDriveHolds = $overDriveDriver->getOverDriveHolds($user);
     //Load the full record for each item in the wishlist
     foreach ($overDriveHolds['holds'] as $sectionKey => $sectionData) {
         foreach ($sectionData as $key => $item) {
             if ($item['recordId'] != -1) {
                 $econtentRecord = new EContentRecord();
                 $econtentRecord->id = $item['recordId'];
                 $econtentRecord->find(true);
                 $item['record'] = clone $econtentRecord;
             } else {
                 $item['record'] = null;
             }
             if ($sectionKey == 'available') {
                 if (isset($item['formats'])) {
                     $item['numRows'] = count($item['formats']) + 1;
                 }
             }
             $overDriveHolds['holds'][$sectionKey][$key] = $item;
         }
     }
     $interface->assign('overDriveHolds', $overDriveHolds['holds']);
     $interface->assign('ButtonBack', true);
     $interface->assign('ButtonHome', true);
     $interface->assign('MobileTitle', 'OverDrive Holds');
     $hasSeparateTemplates = $interface->template_exists('MyResearch/overDriveAvailableHolds.tpl');
     if ($hasSeparateTemplates) {
         $section = isset($_REQUEST['section']) ? $_REQUEST['section'] : 'available';
         if ($section == 'available') {
             $interface->setPageTitle('Available Holds from OverDrive');
             if (!isset($configArray['OverDrive']['interfaceVersion']) || $configArray['OverDrive']['interfaceVersion'] == 1) {
                 $interface->setTemplate('overDriveAvailableHolds.tpl');
             } else {
                 $interface->setTemplate('overDriveAvailableHolds2.tpl');
             }
         } else {
             $interface->setPageTitle('On Hold in OverDrive');
             $interface->setTemplate('overDriveUnavailableHolds.tpl');
         }
     } else {
         $interface->setTemplate('overDriveHolds.tpl');
         $interface->setPageTitle('OverDrive Holds');
     }
     $interface->display('layout.tpl');
 }
Ejemplo n.º 6
0
 function launch()
 {
     global $configArray;
     global $interface;
     global $user;
     //Build the actual view
     $interface->setTemplate('../Record/view-series.tpl');
     $eContentRecord = new EContentRecord();
     $id = strip_tags($_REQUEST['id']);
     $eContentRecord->id = $id;
     $eContentRecord->find(true);
     require_once 'Enrichment.php';
     $enrichment = new EcontentRecord_Enrichment();
     $enrichmentData = $enrichment->loadEnrichment($eContentRecord->getIsbn());
     $seriesTitle = '';
     $seriesAuthors = array();
     $seriesTitles = array();
     $resourceList = array();
     if (isset($enrichmentData['novelist']) && isset($enrichmentData['novelist']['series'])) {
         $seriesTitles = $enrichmentData['novelist']['series'];
         //Loading the series title is not reliable.  Do not try to load it.
         if (isset($seriesTitles) && is_array($seriesTitles)) {
             foreach ($seriesTitles as $title) {
                 if (isset($title['series']) && strlen($title['series']) > 0 && !isset($seriesTitle)) {
                     $seriesTitle = $title['series'];
                     $interface->assign('seriesTitle', $seriesTitle);
                 }
                 if (isset($title['author'])) {
                     $seriesAuthors[$title['author']] = $title['author'];
                 }
                 if ($title['libraryOwned']) {
                     $record = RecordDriverFactory::initRecordDriver($title);
                     $resourceList[] = $interface->fetch($record->getSearchResult($user, null, false));
                 } else {
                     $interface->assign('record', $title);
                     $resourceList[] = $interface->fetch('RecordDrivers/Index/nonowned_result.tpl');
                 }
             }
         }
     }
     $interface->assign('seriesAuthors', $seriesAuthors);
     $interface->assign('recordSet', $seriesTitles);
     $interface->assign('resourceList', $resourceList);
     $interface->assign('recordStart', 1);
     $interface->assign('recordEnd', count($seriesTitles));
     $interface->assign('recordCount', count($seriesTitles));
     $interface->setPageTitle($seriesTitle);
     // Display Page
     $interface->display('layout.tpl');
 }
Ejemplo n.º 7
0
 function launch()
 {
     global $configArray;
     global $interface;
     $libraryName = $configArray['Site']['title'];
     //Grab the tracking data
     $store = urldecode(strip_tags($_GET['store']));
     $recordId = $_REQUEST['id'];
     $ipAddress = $_SERVER['REMOTE_ADDR'];
     // Retrieve Full Marc Record
     $eContentRecord = new EContentRecord();
     $eContentRecord->id = $recordId;
     if (!$eContentRecord->find(true)) {
         PEAR_Singleton::raiseError(new PEAR_Error('Record Does Not Exist'));
     }
     $title = str_replace("/", "", $eContentRecord->title);
     if ($eContentRecord->purchaseUrl == null) {
         switch ($store) {
             case "Tattered Cover":
                 $purchaseLinkUrl = "http://www.tatteredcover.com/search/apachesolr_search/" . urlencode($title) . "?source=" . urlencode($libraryName);
                 break;
             case "Barnes and Noble":
                 $purchaseLinkUrl = "http://www.barnesandnoble.com/s/?title=" . urlencode($title) . "&source=" . urlencode($libraryName);
                 break;
             case "Amazon":
                 $purchaseLinkUrl = "http://www.amazon.com/s/ref=nb_sb_noss?url=search-alias%3Daps&field-keywords=" . urlencode($title) . "&source=" . urlencode($libraryName);
                 break;
         }
     } else {
         // Process MARC Data
         $purchaseLinkUrl = $eContentRecord->purchaseUrl;
     }
     //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 = 'econtentRecord' . $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 link for this title."));
     }
 }
Ejemplo n.º 8
0
 function launch()
 {
     global $interface;
     $id = $_REQUEST['id'];
     $eContentRecord = new EContentRecord();
     $eContentRecord->id = $id;
     $eContentRecord->find(true);
     $goDeeperOptions = GoDeeperData::getGoDeeperOptions($eContentRecord->getIsbn(), $eContentRecord->upc, true);
     $interface->assign('options', $goDeeperOptions['options']);
     if (isset($goDeeperOptions['defaultOption'])) {
         $defaultData = GoDeeperData::getHtmlData($goDeeperOptions['defaultOption'], 'eContentRecord', $eContentRecord->getIsbn(), $eContentRecord->upc);
         $interface->assign('defaultGoDeeperData', $defaultData);
     }
     $interface->assign('title', translate("Additional information about this title"));
     echo $interface->fetch('Record/goDeeper.tpl');
 }
Ejemplo n.º 9
0
 /**
  * @param array $record An array of record data from Solr
  * @return File_MARC_Record
  */
 public static function loadMarcRecordFromRecord($record)
 {
     if ($record['recordtype'] == 'marc') {
         return MarcLoader::loadMarcRecordByILSId($record['id'], $record['recordtype']);
     } elseif ($record['recordtype'] == 'econtentRecord') {
         require_once ROOT_DIR . '/sys/eContent/EContentRecord.php';
         $econtentRecord = new EContentRecord();
         $econtentRecord->id = $record['id'];
         if ($econtentRecord->find(true)) {
             return MarcLoader::loadMarcRecordByILSId($econtentRecord->ilsId, $record['recordtype']);
         } else {
             return null;
         }
     } else {
         return null;
     }
 }
Ejemplo n.º 10
0
 function launch()
 {
     global $interface;
     global $user;
     global $configArray;
     // Process Delete Comment
     if (isset($_GET['delete']) && is_object($user)) {
         $comment = new Comments();
         $comment->id = $_GET['delete'];
         if ($comment->find(true)) {
             if ($user->id == $comment->user_id) {
                 $comment->delete();
             }
         }
     }
     $interface->assign('id', $_GET['id']);
     if (isset($_REQUEST['comment'])) {
         if (!$user) {
             $interface->assign('recordId', $_GET['id']);
             $interface->assign('comment', $_REQUEST['comment']);
             $interface->assign('followup', true);
             $interface->assign('followupModule', 'EContentRecord');
             $interface->assign('followupAction', 'UserComments');
             $interface->setPageTitle('You must be logged in first');
             $interface->assign('subTemplate', '../MyResearch/login.tpl');
             $interface->setTemplate('view-alt.tpl');
             $interface->display('layout.tpl', 'UserComments' . $_GET['id']);
             exit;
         }
         $result = $this->saveComment();
     }
     $interface->assign('user', $user);
     $eContentRecord = new EContentRecord();
     $eContentRecord->id = $_GET['id'];
     $eContentRecord->find(true);
     $recordDriver = new EcontentRecordDriver();
     $recordDriver->setDataObject($eContentRecord);
     $interface->setPageTitle(translate('Comments') . ': ' . $recordDriver->getBreadcrumb());
     $this->loadEContentComments();
     $interface->assign('subTemplate', 'view-comments.tpl');
     $interface->setTemplate('view.tpl');
     // Display Page
     $interface->display('layout.tpl');
 }
Ejemplo n.º 11
0
 function launch()
 {
     global $interface;
     global $configArray;
     global $user;
     $recordId = $_REQUEST['id'];
     $quick = isset($_REQUEST['quick']) ? true : false;
     $eContentRecord = new EContentRecord();
     $eContentRecord->id = $recordId;
     if ($eContentRecord->find(true)) {
         $ret = $eContentRecord->saveToSolr($quick);
         if ($ret) {
             echo json_encode(array("success" => true));
         } else {
             echo json_encode(array("success" => false, "error" => "Could not update solr"));
         }
     } else {
         echo json_encode(array("success" => false, "error" => "Could not find a record with that id"));
     }
 }
Ejemplo n.º 12
0
 function sendEmail($to, $from, $message)
 {
     global $interface;
     global $configArray;
     $id = $_REQUEST['id'];
     $eContentRecord = new EContentRecord();
     $eContentRecord->id = $id;
     $eContentRecord->find(true);
     $subject = translate("Library Catalog Record") . ": " . $eContentRecord->title;
     $interface->assign('from', $from);
     $emailDetails = $eContentRecord->title . "\n";
     if (strlen($eContentRecord->author) > 0) {
         $emailDetails .= "by: {$eContentRecord->author}\n";
     }
     $interface->assign('emailDetails', $emailDetails);
     $interface->assign('id', $id);
     $interface->assign('message', $message);
     $body = $interface->fetch('Emails/eContent-record.tpl');
     $mail = new VuFindMailer();
     return $mail->send($to, $configArray['Site']['email'], $subject, $body, $from);
 }
Ejemplo n.º 13
0
 function launch()
 {
     global $configArray;
     global $interface;
     //Grab the tracking data
     $recordId = $_REQUEST['id'];
     $ipAddress = $_SERVER['REMOTE_ADDR'];
     $itemId = $_REQUEST['itemId'];
     // Retrieve Full Marc Record
     $eContentRecord = new EContentRecord();
     $eContentRecord->id = $recordId;
     if (!$eContentRecord->find(true)) {
         PEAR_Singleton::raiseError(new PEAR_Error('Record Does Not Exist'));
     }
     $eContentItem = new EContentItem();
     $eContentItem->id = $itemId;
     if (!$eContentItem->find(true)) {
         PEAR_Singleton::raiseError(new PEAR_Error('Item Does Not Exist'));
     }
     $linkUrl = $eContentItem->link;
     $linkParts = parse_url($linkUrl);
     $title = str_replace("/", "", $eContentRecord->title);
     //Insert into the externalLinkTracking table
     require_once ROOT_DIR . '/sys/BotChecker.php';
     if (!BotChecker::isRequestFromBot()) {
         require_once ROOT_DIR . '/sys/ExternalLinkTracking.php';
         $externalLinkTracking = new ExternalLinkTracking();
         $externalLinkTracking->ipAddress = $ipAddress;
         $externalLinkTracking->recordId = "econtentRecord" . $recordId;
         $externalLinkTracking->linkUrl = $linkUrl;
         $externalLinkTracking->linkHost = $linkParts['host'];
         $result = $externalLinkTracking->insert();
     }
     //redirects them to the link they clicked
     if ($linkUrl != "") {
         header("Location:" . $linkUrl);
     } else {
         PEAR_Singleton::raiseError(new PEAR_Error("Failed to load link for this title."));
     }
 }
Ejemplo n.º 14
0
 function launch()
 {
     global $interface;
     global $configArray;
     $results = array();
     $epubFile = new EContentItem();
     $currentPage = isset($_REQUEST['page']) ? $_REQUEST['page'] : 1;
     $recordsPerPage = 25;
     $searchUrl = $configArray['Site']['path'] . '/EContent/Search';
     $searchParams = array();
     foreach ($_REQUEST as $key => $value) {
         if (!in_array($key, array('module', 'action', 'page'))) {
             $searchParams[] = "{$key}={$value}";
         }
     }
     $searchUrl = $searchUrl . '?page=%d&' . implode('&', $searchParams);
     $interface->assign('page', $currentPage);
     $epubFile = new EContentRecord();
     if (isset($_REQUEST['sortOptions'])) {
         $epubFile->orderBy($_REQUEST['sortOptions']);
         $interface->assign('sort', $_REQUEST['sortOptions']);
     }
     $numTotalFiles = $epubFile->count();
     $epubFile->limit(($currentPage - 1) * $recordsPerPage, 20);
     $epubFile->find();
     if ($epubFile->N > 0) {
         while ($epubFile->fetch()) {
             $results[] = clone $epubFile;
         }
     }
     $interface->assign('results', $results);
     $options = array('totalItems' => $numTotalFiles, 'fileName' => $searchUrl, 'perPage' => $recordsPerPage);
     $pager = new VuFindPager($options);
     $interface->assign('pageLinks', $pager->getLinks());
     $interface->setTemplate('search.tpl');
     $interface->display('layout.tpl');
 }
Ejemplo n.º 15
0
 function sendSMS()
 {
     global $configArray;
     global $interface;
     // Get Holdings
     $driver = new EContentDriver();
     $id = strip_tags($_REQUEST['id']);
     $eContentRecord = new EContentRecord();
     $eContentRecord->id = $id;
     $eContentRecord->find(true);
     $holdings = $driver->getHolding($id);
     $holdingsSummary = $driver->getStatusSummary($id, $holdings);
     if (PEAR_Singleton::isError($holdingsSummary)) {
         return $holdingsSummary;
     }
     if ($holdingsSummary['status']) {
         $interface->assign('status', $holdingsSummary['status']);
     }
     $interface->assign('title', $eContentRecord->title);
     $interface->assign('author', $eContentRecord->author);
     $interface->assign('recordID', $_GET['id']);
     $message = $interface->fetch('Emails/eContent-sms.tpl');
     return $this->sms->text($_REQUEST['provider'], $_REQUEST['to'], $configArray['Site']['email'], $message);
 }
Ejemplo n.º 16
0
 function launch()
 {
     global $interface;
     global $configArray;
     global $user;
     $driver = new EContentDriver();
     $id = strip_tags($_REQUEST['id']);
     $interface->assign('id', $id);
     global $logger;
     //Get title information for the record.
     $eContentRecord = new EContentRecord();
     $eContentRecord->id = $id;
     if (!$eContentRecord->find(true)) {
         PEAR_Singleton::raiseError("Unable to find eContent record for id: {$id}");
     }
     if (isset($_REQUEST['autologout'])) {
         $_SESSION['autologout'] = true;
     }
     if (isset($_POST['submit']) || $user) {
         if (isset($_REQUEST['username']) && isset($_REQUEST['password'])) {
             //Log the user in
             $user = UserAccount::login();
         }
         if (!PEAR_Singleton::isError($user) && $user) {
             //The user is already logged in
             $return = $driver->placeHold($id, $user);
             $interface->assign('result', $return['result']);
             $message = $return['message'];
             $interface->assign('message', $message);
             $showMessage = true;
         } else {
             $message = 'Incorrect Patron Information';
             $interface->assign('message', $message);
             $interface->assign('focusElementId', 'username');
             $showMessage = true;
         }
     } else {
         //Get the referrer so we can go back there.
         if (isset($_SERVER['HTTP_REFERER'])) {
             $referer = $_SERVER['HTTP_REFERER'];
             $_SESSION['hold_referrer'] = $referer;
         }
         //Showing place hold form.
         if (!PEAR_Singleton::isError($user) && $user) {
             //set focus to the submit button if the user is logged in since the campus will be correct most of the time.
             $interface->assign('focusElementId', 'submit');
         } else {
             //set focus to the username field by default.
             $interface->assign('focusElementId', 'username');
         }
     }
     if (isset($return) && $showMessage) {
         $hold_message_data = array('successful' => $return['result'] ? 'all' : 'none', 'error' => $return['error'], 'titles' => array($return));
         $_SESSION['hold_message'] = $hold_message_data;
         if (isset($_SESSION['hold_referrer'])) {
             $logger->log('Hold Referrer is set, redirecting to there.  type = ' . $_REQUEST['type'], PEAR_LOG_INFO);
             header("Location: " . $_SESSION['hold_referrer']);
             unset($_SESSION['hold_referrer']);
             if (isset($_SESSION['autologout'])) {
                 unset($_SESSION['autologout']);
                 UserAccount::softLogout();
             }
         } else {
             $logger->log('No referrer set, but there is a message to show, go to the main holds page', PEAR_LOG_INFO);
             header("Location: " . $configArray['Site']['path'] . '/MyResearch/EContentHolds?section=unavailable');
         }
     } else {
         $logger->log('placeHold finished, do not need to show a message', PEAR_LOG_INFO);
         $interface->setPageTitle('Request an Item');
         $interface->assign('subTemplate', 'hold.tpl');
         $interface->setTemplate('hold.tpl');
         $interface->display('layout.tpl', 'RecordHold' . $_GET['id']);
     }
 }
Ejemplo n.º 17
0
 /**
  * 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.');
         }
     }
 }
Ejemplo n.º 18
0
 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;
 }
Ejemplo n.º 19
0
 function returnRecord($id)
 {
     global $user;
     global $logger;
     //Get the item information for the record
     require_once ROOT_DIR . '/sys/eContent/EContentCheckout.php';
     $checkout = new EContentCheckout();
     $checkout->userId = $user->id;
     $checkout->recordId = $id;
     $checkout->status = 'out';
     $return = array();
     //$trans->whereAdd('timeReturned = null');
     if ($checkout->find(true)) {
         $output = array();
         $checkout->dateReturned = time();
         $checkout->status = 'returned';
         $ret = $checkout->update();
         if ($ret != 0) {
             $this->processHoldQueue($id);
             $eContentRecord = new EContentRecord();
             $eContentRecord->id = $id;
             $eContentRecord->find(true);
             //Record that the title was checked in
             $this->recordEContentAction($id, "Checked In", $eContentRecord->accessType);
             $eContentRecord->saveToSolr();
             $return = array('success' => true, 'message' => "The title was returned successfully.");
         } else {
             $return = array('success' => false, 'message' => "Could not return the item");
         }
         $output['database-response'] = $ret;
     } else {
         $logger->log("Could not find a checked out item for that title in the database.", PEAR_LOG_INFO);
         $return = array('success' => false, 'message' => "Could not find a checked out item for that title in the database.  It may have already been returned.");
     }
     return $return;
 }
Ejemplo n.º 20
0
 function launch()
 {
     global $interface;
     global $configArray;
     $interface->setPageTitle('eContent Help');
     $defaultFormat = "";
     require_once ROOT_DIR . '/sys/eContent/EContentRecord.php';
     if (isset($_REQUEST['id'])) {
         $id = $_REQUEST['id'];
         $interface->assign('id', $id);
         $eContentRecord = new EContentRecord();
         $eContentRecord->id = $id;
         if ($eContentRecord->find(true)) {
             require_once ROOT_DIR . '/sys/eContent/EContentItem.php';
             $eContentItem = new EContentItem();
             $eContentItem->id = $_REQUEST['itemId'];
             if ($eContentItem->find(true)) {
                 $displayFormat = $eContentItem->getDisplayFormat();
                 $popupContent = "Sorry, there is not detailed help available for this format yet.";
                 if ($eContentItem->item_type == 'mp3') {
                     $defaultFormat = 'mp3';
                 } else {
                     if ($eContentItem->item_type == 'epub') {
                         $defaultFormat = 'ebook';
                     } else {
                         if ($eContentItem->item_type == 'kindle') {
                             $defaultFormat = 'kindle';
                         } else {
                             if ($eContentItem->item_type == 'plucker') {
                                 $defaultFormat = 'other';
                             } else {
                                 if ($eContentItem->item_type == 'pdf') {
                                     $defaultFormat = 'other';
                                 } else {
                                     if ($eContentItem->item_type == 'externalMP3') {
                                         $defaultFormat = 'mp3';
                                     } else {
                                         if ($eContentItem->item_type == 'external_ebook') {
                                             if ($eContentItem->getSource() == 'SpringerLink') {
                                                 $defaultFormat = 'springerlink';
                                             } elseif (preg_match('/ebsco/i', $eContentItem->getSource())) {
                                                 $defaultFormat = 'ebsco';
                                             } else {
                                                 $defaultFormat = 'other';
                                             }
                                         } else {
                                             if ($eContentItem->item_type == 'externalLink') {
                                                 $defaultFormat = 'other';
                                             } else {
                                                 if ($eContentItem->item_type == 'overdrive') {
                                                     if ($eContentItem->externalFormatId == 'audiobook-mp3') {
                                                         $defaultFormat = 'mp3';
                                                     } else {
                                                         if ($eContentItem->externalFormatId == 'audiobook-wma') {
                                                             $defaultFormat = 'wma';
                                                         } else {
                                                             if ($eContentItem->externalFormatId == 'video-wmv') {
                                                                 $defaultFormat = 'eVideo';
                                                             } else {
                                                                 if ($eContentItem->externalFormatId == 'music-wma') {
                                                                     $defaultFormat = 'eMusic';
                                                                 } else {
                                                                     if ($eContentItem->externalFormatId == 'ebook-kindle') {
                                                                         $defaultFormat = 'kindle';
                                                                     } else {
                                                                         if ($eContentItem->externalFormatId == 'ebook-epub-adobe') {
                                                                             $defaultFormat = 'ebook';
                                                                         } else {
                                                                             if ($eContentItem->externalFormatId == 'ebook-pdf-adobe') {
                                                                                 $defaultFormat = 'other';
                                                                             } else {
                                                                                 if ($eContentItem->externalFormatId == 'ebook-epub-open') {
                                                                                     $defaultFormat = 'ebook';
                                                                                 } else {
                                                                                     if ($eContentItem->externalFormatId == 'ebook-pdf-open') {
                                                                                         $defaultFormat = 'other';
                                                                                     } else {
                                                                                         $defaultFormat = 'other';
                                                                                     }
                                                                                 }
                                                                             }
                                                                         }
                                                                     }
                                                                 }
                                                             }
                                                         }
                                                     }
                                                 } else {
                                                     if ($eContentItem->item_type == 'external_eaudio') {
                                                         $defaultFormat = 'other';
                                                     } else {
                                                         if ($eContentItem->item_type == 'external_emusic') {
                                                             $defaultFormat = 'eMusic';
                                                         } else {
                                                             if ($eContentItem->item_type == 'text') {
                                                                 $defaultFormat = 'other';
                                                             } else {
                                                                 if ($eContentItem->item_type == 'itunes') {
                                                                     $defaultFormat = 'other';
                                                                 } else {
                                                                     if ($eContentItem->item_type == 'gifs') {
                                                                         $defaultFormat = 'other';
                                                                     } else {
                                                                         $defaultFormat = 'other';
                                                                     }
                                                                 }
                                                             }
                                                         }
                                                     }
                                                 }
                                             }
                                         }
                                     }
                                 }
                             }
                         }
                     }
                 }
             }
         }
     }
     $interface->assign('defaultFormat', $defaultFormat);
     $device = get_device_name();
     $defaultDevice = '';
     if ($device == 'Kindle') {
         $defaultDevice = 'kindle';
     } elseif ($device == 'Kindle Fire') {
         $defaultDevice = 'kindle_fire';
     } elseif ($device == 'iPad' || $device == 'iPhone') {
         $defaultDevice = 'ios';
     } elseif ($device == 'Android Phone' || $device == 'Android Tablet') {
         $defaultDevice = 'android';
     } elseif ($device == 'Android Phone' || $device == 'Android Tablet' || $device == 'Google TV') {
         $defaultDevice = 'android';
     } elseif ($device == 'BlackBerry') {
         $defaultDevice = 'other';
     } elseif ($device == 'Mac') {
         $defaultDevice = 'mac';
     } elseif ($device == 'PC') {
         $defaultDevice = 'pc';
     }
     $interface->assign('defaultDevice', $defaultDevice);
     if (isset($_REQUEST['lightbox'])) {
         $interface->assign('popupTitle', 'Step by Step Instructions for using eContent');
         $popupContent = $interface->fetch('Help/eContentHelp.tpl');
         $interface->assign('popupContent', $popupContent);
         $interface->display('popup-wrapper.tpl');
     } else {
         $interface->setTemplate('eContentHelp.tpl');
         $interface->display('layout.tpl');
     }
 }
Ejemplo n.º 21
0
 /**
  * Places a hold on an item within OverDrive
  *
  * @param string $overDriveId
  * @param int $format
  * @param User $user
  *
  * @return array (result, message)
  */
 public function placeOverDriveHold($overDriveId, $format, $user)
 {
     /** @var Memcache $memCache */
     global $memCache;
     global $configArray;
     global $logger;
     $holdResult = array();
     $holdResult['result'] = false;
     $holdResult['message'] = '';
     $ch = curl_init();
     $overDriveInfo = $this->_loginToOverDrive($ch, $user);
     if ($overDriveInfo['result'] == false) {
         $holdResult = $overDriveInfo;
     } else {
         //Switch back to get method
         curl_setopt($overDriveInfo['ch'], CURLOPT_HTTPGET, true);
         //Open the record page
         $contentInfoPage = $overDriveInfo['contentInfoPage'] . "?ID=" . $overDriveId;
         curl_setopt($overDriveInfo['ch'], CURLOPT_URL, $contentInfoPage);
         $recordPage = curl_exec($overDriveInfo['ch']);
         curl_getinfo($overDriveInfo['ch']);
         $logger->log("View record " . $contentInfoPage, PEAR_LOG_DEBUG);
         //Navigate to place a hold page
         $waitingListUrl = $overDriveInfo['waitingListUrl'];
         if ($format == "" || $format == 'undefined') {
             if (preg_match('/<a href="BANGAuthenticate\\.dll\\?Action=AuthCheck&ForceLoginFlag=0&URL=WaitingListForm.htm%3FID=(.*?)%26Format=(.*?)" class="radius large button details-title-button" data-checkedout="(.*?)" data-contentstatus="(.*?)">Place a Hold<\\/a>/si', $recordPage, $formatInfo)) {
                 $format = $formatInfo[2];
             } else {
                 $logger->log("Did not find hold button for this title to retrieve format", PEAR_LOG_INFO);
                 $holdResult['result'] = false;
                 $holdResult['message'] = "This title is available for checkout.";
                 $holdResult['availableForCheckout'] = true;
                 return $holdResult;
             }
         }
         $waitingListUrl .= '%3FID=' . $overDriveId . '%26Format=' . $format;
         //echo($waitingListUrl . "\r\n");
         curl_setopt($overDriveInfo['ch'], CURLOPT_URL, $waitingListUrl);
         $logger->log("Click place a hold button " . $waitingListUrl, PEAR_LOG_DEBUG);
         $setEmailPage = curl_exec($overDriveInfo['ch']);
         $setEmailPageInfo = curl_getinfo($ch);
         if (preg_match('/already placed a hold or borrowed this title/', $setEmailPage)) {
             $holdResult['result'] = false;
             $holdResult['message'] = "We're sorry, but you are already on the waiting list for the selected title or have it checked out.";
         } else {
             $secureBaseUrl = preg_replace('~[^/.]+?.htm.*~', '', $setEmailPageInfo['url']);
             //Login (again)
             curl_setopt($overDriveInfo['ch'], CURLOPT_POST, true);
             $barcodeProperty = isset($configArray['Catalog']['barcodeProperty']) ? $configArray['Catalog']['barcodeProperty'] : 'cat_username';
             $barcode = $user->{$barcodeProperty};
             $postParams = array('LibraryCardNumber' => $barcode, 'URL' => 'MyAccount.htm');
             if (isset($configArray['OverDrive']['LibraryCardILS']) && strlen($configArray['OverDrive']['LibraryCardILS']) > 0) {
                 $postParams['LibraryCardILS'] = $configArray['OverDrive']['LibraryCardILS'];
             }
             $post_items = array();
             foreach ($postParams as $key => $value) {
                 $post_items[] = $key . '=' . urlencode($value);
             }
             $post_string = implode('&', $post_items);
             curl_setopt($overDriveInfo['ch'], CURLOPT_POSTFIELDS, $post_string);
             curl_setopt($overDriveInfo['ch'], CURLOPT_URL, $secureBaseUrl . 'BANGAuthenticate.dll');
             $waitingListPage = curl_exec($overDriveInfo['ch']);
             $waitingListPageInfo = curl_getinfo($overDriveInfo['ch']);
             //echo($waitingListPage);
             if (preg_match('/already on/', $waitingListPage)) {
                 $holdResult['result'] = false;
                 $holdResult['message'] = "We're sorry, but you are already on the waiting list for the selected title or have it checked out.";
             } else {
                 //Get the format from the form
                 //Fill out the email address to use for notification
                 //echo($user->overdriveEmail . "\r\n");
                 $postParams = array('ID' => $overDriveId, 'Format' => $format, 'URL' => 'WaitingListConfirm.htm', 'Email' => $user->overdriveEmail, 'Email2' => $user->overdriveEmail);
                 $post_items = array();
                 foreach ($postParams as $key => $value) {
                     $post_items[] = $key . '=' . urlencode($value);
                 }
                 $post_string = implode('&', $post_items);
                 curl_setopt($ch, CURLOPT_POSTFIELDS, $post_string);
                 curl_setopt($overDriveInfo['ch'], CURLOPT_URL, $secureBaseUrl . "BANGAuthenticate.dll?Action=LibraryWaitingList");
                 $waitingListConfirm = curl_exec($overDriveInfo['ch']);
                 $logger->log("Submitting email for notification {$secureBaseUrl}BANGAuthenticate.dll?Action=LibraryWaitingList  {$post_string}", PEAR_LOG_INFO);
                 //$logger->log($waitingListConfirm, PEAR_LOG_INFO);
                 $waitingListConfirm = strip_tags($waitingListConfirm, "'<p><a><li><ul><div><em><b>'");
                 if (preg_match('/<section id="mainContent" class=".*?">(.*?)<\\/section>/is', $waitingListConfirm, $matches)) {
                     $logger->log("Found main content section", PEAR_LOG_INFO);
                     $mainSection = $matches[1];
                     if (preg_match('/already on/si', $mainSection)) {
                         $holdResult['result'] = false;
                         $holdResult['message'] = 'This title is already on hold or checked out to you.';
                     } elseif (preg_match('/did not complete all of the required fields/', $mainSection)) {
                         $holdResult['result'] = false;
                         $holdResult['message'] = 'You must provide an e-mail address to request titles from OverDrive.  Please add an e-mail address to your profile.';
                     } elseif (preg_match('/reached the request \\(hold\\) limit of \\d+ titles./', $mainSection)) {
                         $holdResult['result'] = false;
                         $holdResult['message'] = 'You have reached the maximum number of holds for your account.';
                     } elseif (preg_match('/Some of our digital titles are only available for a limited time\\. This title may be available in the future\\. Be sure to check back/', $waitingListConfirm)) {
                         $holdResult['result'] = false;
                         $holdResult['message'] = 'This title is no longer available.  Some of our digital titles are only available for a limited time. This title may be available in the future. Be sure to check back.';
                     } else {
                         $holdResult['result'] = false;
                         $holdResult['message'] = 'There was an error placing your hold.';
                         global $logger;
                         $logger->log("Placing hold on OverDrive item. OverDriveId " . $overDriveId, PEAR_LOG_INFO);
                         $logger->log('URL: ' . $secureBaseUrl . "BANGAuthenticate.dll?Action=LibraryWaitingList {$post_string}\r\n" . $mainSection, PEAR_LOG_INFO);
                     }
                 } elseif (preg_match('/Unfortunately this title is not available to your library at this time./', $waitingListConfirm)) {
                     $holdResult['result'] = false;
                     $holdResult['message'] = 'This title is not available to your library at this time.';
                 } elseif (preg_match('/You will receive an email when the title becomes available./', $waitingListConfirm)) {
                     $holdResult['result'] = true;
                     $holdResult['message'] = 'Your hold was placed successfully.';
                     $memCache->delete('overdrive_summary_' . $user->id);
                     //Record that the entry was checked out in strands
                     global $configArray;
                     if (isset($configArray['Strands']['APID']) && $user->disableRecommendations == 0) {
                         //Get the record for the item
                         $eContentRecord = new EContentRecord();
                         $eContentRecord->whereAdd("sourceUrl like '%{$overDriveId}'");
                         if ($eContentRecord->find(true)) {
                             $orderId = $user->id . '_' . time();
                             $strandsUrl = "http://bizsolutions.strands.com/api2/event/addshoppingcart.sbs?needresult=true&apid={$configArray['Strands']['APID']}&item=econtentRecord{$eContentRecord->id}::0.00::1&user={$user->id}&orderid={$orderId}";
                             $ret = file_get_contents($strandsUrl);
                             /*global $logger;
                             		$logger->log("Strands Hold\r\n$ret", PEAR_LOG_INFO);*/
                         }
                     }
                     //Delete the cache for the record
                     $memCache->delete('overdrive_record_' . $overDriveId);
                 } else {
                     global $logger;
                     $holdResult['result'] = false;
                     $holdResult['message'] = 'Unknown error placing your hold.';
                     $logger->log("Placing hold on OverDrive item. OverDriveId " . $overDriveId, PEAR_LOG_INFO);
                     $logger->log('URL: ' . $secureBaseUrl . "BANGAuthenticate.dll?Action=LibraryWaitingList {$post_string}\r\n" . $waitingListConfirm, PEAR_LOG_INFO);
                 }
             }
         }
     }
     curl_close($ch);
     return $holdResult;
 }
Ejemplo n.º 22
0
 function launch()
 {
     global $interface;
     global $configArray;
     $id = $_REQUEST['id'];
     $interface->assign('id', $id);
     $item = $_REQUEST['item'];
     $interface->assign('item', $item);
     $viewer = 'custom';
     $errorOccurred = false;
     if ($this->user == false) {
         $interface->assign('errorMessage', 'User is not logged in.');
         $errorOccurred = true;
         $interface->assign('showLogin', true);
     } else {
         require_once ROOT_DIR . '/sys/eContent/EContentRecord.php';
         $eContentRecord = new EContentRecord();
         $eContentRecord->id = $id;
         if ($eContentRecord->find(true)) {
             //Check the database to see if there is an existing title
             require_once ROOT_DIR . '/sys/eContent/EContentItem.php';
             $eContentItem = new EContentItem();
             $eContentItem->id = $_REQUEST['item'];
             if ($eContentItem->find(true)) {
                 $bookFile = null;
                 $libraryPath = $configArray['EContent']['library'];
                 if ($eContentItem->item_type == 'mp3') {
                     $bookFile = "{$libraryPath}/{$eContentItem->folder}";
                 } else {
                     $bookFile = "{$libraryPath}/{$eContentItem->filename}";
                 }
                 if (!file_exists($bookFile)) {
                     $bookFile = null;
                 }
             }
         } else {
             $errorOccurred = true;
             $interface->assign('errorMessage', 'Could not find the selected title.');
         }
         if (file_exists($bookFile) && $errorOccurred == false) {
             require_once ROOT_DIR . '/Drivers/EContentDriver.php';
             $driver = new EContentDriver();
             //Check to see if the user has access to the title.
             $isCheckedOut = $driver->isRecordCheckedOutToUser($id);
             if (!$isCheckedOut) {
                 $errorOccurred = true;
                 $interface->assign('errorMessage', "Sorry, you do not have access to that title, please <a href='{$configArray['Site']['path']}/Record/{$id}/Hold'>place a hold</a> on the title and you will be notified when it is ready for pickup.");
             }
             if (!$errorOccurred) {
                 //Record that the e-pub file is being opened.
                 if (strcasecmp($eContentItem->item_type, 'epub') === 0) {
                     $driver->recordEContentAction($id, "Read Online", $eContentRecord->accessType);
                     require_once ROOT_DIR . '/sys/eReader/ebook.php';
                     $ebook = new ebook($bookFile);
                     if ($ebook->readErrorOccurred()) {
                         $errorOccurred = true;
                         $interface->assign('errorMessage', $ebook->readError());
                     } else {
                         $spineInfo = $ebook->getSpine();
                         $toc = $ebook->getTOC();
                         if ($viewer == 'monocle') {
                             $spineData = addslashes(json_encode($spineInfo));
                             $interface->assign('spineData', $spineData);
                             $contents = addslashes(json_encode($toc));
                             $interface->assign('contents', $contents);
                             $metaData = addslashes(json_encode(array("title" => $ebook->getTitle(), "creator" => $ebook->getDcCreator())));
                             $interface->assign('metaData', $metaData);
                         } else {
                             $interface->assign('spineData', $spineInfo);
                             $interface->assign('contents', $toc);
                             $interface->assign('bookCreator', $ebook->getDcCreator());
                             //Load a translation map to translate locations into ids
                             $manifest = array();
                             for ($i = 0; $i < $ebook->getManifestSize(); $i++) {
                                 $manifestId = $ebook->getManifestItem($i, 'id');
                                 $manifestHref = $ebook->getManifestItem($i, 'href');
                                 $manifestType = $ebook->getManifestItem($i, 'type');
                                 $manifest[$manifestHref] = $manifestId;
                             }
                             $interface->assign('manifest', $manifest);
                         }
                         $interface->assign('bookTitle', $ebook->getTitle());
                         $errorOccurred = false;
                     }
                 } else {
                     if ($eContentItem->item_type == 'mp3') {
                         //Display information so patron can listen to the recording.
                         //Table of contents is based on the actual files uploaded.
                         $viewer = 'mp3';
                         $dirHnd = opendir($bookFile);
                         $mp3Files = array();
                         while (false !== ($file = readdir($dirHnd))) {
                             if (preg_match('/^.*?\\.mp3$/i', $file)) {
                                 $mp3Files[] = preg_replace('/\\.mp3/i', '', $file);
                             }
                         }
                         $files = readdir($dirHnd);
                         closedir($dirHnd);
                         //Sort the mp3 files by name.
                         sort($mp3Files);
                         $interface->assign('mp3Filenames', $mp3Files);
                     } else {
                         $errorOccurred = true;
                         $interface->assign('errorMessage', "Sorry, we could not find a viewer for that type of item, please contact support.");
                     }
                 }
             }
         } else {
             $errorOccurred = true;
             $interface->assign('errorMessage', 'Sorry, we could not find that book in our online library.');
         }
     }
     $interface->assign('errorOccurred', $errorOccurred);
     if ($viewer == 'mp3') {
         $interface->display('EcontentRecord/viewer-mp3.tpl');
     } else {
         $interface->display('EcontentRecord/viewer-custom.tpl');
     }
 }
Ejemplo n.º 23
0
 private function getCoverFromEContent()
 {
     if ($this->configArray['EContent']['library'] && isset($this->id) && is_numeric($this->id)) {
         $this->log("Looking for eContent Cover", PEAR_LOG_INFO);
         $this->initMemcache();
         $this->log("Checking eContent database to see if there is a record for {$this->id}", PEAR_LOG_INFO);
         //Check the database to see if there is an existing title
         require_once ROOT_DIR . '/sys/eContent/EContentRecord.php';
         $epubFile = new EContentRecord();
         $epubFile->id = $this->id;
         if ($epubFile->find(true)) {
             $this->log("Found an eContent record for {$this->id}, source is {$epubFile->source}", PEAR_LOG_INFO);
             //Get the cover for the epub if one exists.
             if (strcasecmp($epubFile->source, 'OverDrive') == 0 && ($epubFile->cover == null || strlen($epubFile->cover) == 0)) {
                 $this->log("Record is an OverDrive record that needs cover information fetched.", PEAR_LOG_INFO);
                 //Get the image from OverDrive
                 require_once ROOT_DIR . '/Drivers/OverDriveDriverFactory.php';
                 $overDriveDriver = OverDriveDriverFactory::getDriver();
                 $filename = $overDriveDriver->getCoverUrl($epubFile);
                 $this->log("Got OverDrive cover information for {$epubFile->id} {$epubFile->sourceUrl}", PEAR_LOG_INFO);
                 $this->log("Received filename {$filename}", PEAR_LOG_INFO);
                 if ($filename != null) {
                     $epubFile->cover = $filename;
                     $ret = $epubFile->update();
                     //Don't update solr for performance reasons
                     $this->log("Result of saving cover url is {$ret}", PEAR_LOG_INFO);
                 }
             } elseif (preg_match('/Colorado State Gov\\. Docs/si', $epubFile->source) == 1 || $epubFile->source == 'CO State Gov Docs') {
                 //Cover is colorado state flag
                 $this->log("Record is a gov docs file.", PEAR_LOG_INFO);
                 $themeName = $this->configArray['Site']['theme'];
                 $filename = "interface/themes/{$themeName}/images/state_flag_of_colorado.png";
                 if ($this->processImageURL($filename, true)) {
                     return;
                 }
             }
             if ($epubFile->cover && strlen($epubFile->cover) > 0) {
                 $this->log("Cover for the file is specified as {$epubFile->cover}.", PEAR_LOG_INFO);
                 if (strpos($epubFile->cover, 'http://') === 0) {
                     $filename = $epubFile->cover;
                     if ($this->processImageURL($filename, true)) {
                         $this->timer->writeTimings();
                         exit;
                     }
                 } else {
                     $filename = $this->bookCoverPath . '/original/' . $epubFile->cover;
                     $this->localFile = $this->bookCoverPath . '/' . $this->size . '/' . $this->cacheName . '.png';
                     if (file_exists($filename)) {
                         if ($this->processImageURL($filename, true)) {
                             $this->timer->writeTimings();
                             exit;
                         }
                     } else {
                         $this->log("Did not find econtent cover file {$filename}", PEAR_LOG_ERR);
                     }
                 }
             }
         }
     }
     $this->log("Did not find a cover based on eContent information.", PEAR_LOG_INFO);
 }
Ejemplo n.º 24
0
 function getOtherEditions()
 {
     global $interface;
     global $analytics;
     $id = $_REQUEST['id'];
     $isEContent = $_REQUEST['isEContent'];
     if ($isEContent == 'true') {
         require_once ROOT_DIR . '/sys/eContent/EContentRecord.php';
         $econtentRecord = new EContentRecord();
         $econtentRecord->id = $id;
         if ($econtentRecord->find(true)) {
             $otherEditions = OtherEditionHandler::getEditions($econtentRecord->id, $econtentRecord->getIsbn(), $econtentRecord->getIssn(), 10);
         } else {
             $error = "Sorry we couldn't find that record in the catalog.";
         }
     } else {
         $resource = new Resource();
         $resource->record_id = $id;
         $resource->source = 'VuFind';
         $solrId = $id;
         if ($resource->find(true)) {
             $otherEditions = OtherEditionHandler::getEditions($solrId, $resource->isbn, null, 10);
         } else {
             $error = "Sorry we couldn't find that record in the catalog.";
         }
     }
     if (isset($otherEditions)) {
         //Get resource for each edition
         $editionResources = array();
         if (is_array($otherEditions)) {
             foreach ($otherEditions as $edition) {
                 /** @var Resource $editionResource */
                 $editionResource = new Resource();
                 if (preg_match('/econtentRecord(\\d+)/', $edition['id'], $matches)) {
                     $editionResource->source = 'eContent';
                     $editionResource->record_id = trim($matches[1]);
                 } else {
                     $editionResource->record_id = $edition['id'];
                     $editionResource->source = 'VuFind';
                 }
                 if ($editionResource->find(true)) {
                     $editionResources[] = $editionResource;
                 } else {
                     $logger = new Logger();
                     $logger->log("Could not find resource {$editionResource->source} {$editionResource->record_id} - {$edition['id']}", PEAR_LOG_DEBUG);
                 }
             }
             $analytics->addEvent('Enrichment', 'Other Editions', count($otherEditions));
         } else {
             $analytics->addEvent('Enrichment', 'Other Editions Error');
         }
         $interface->assign('otherEditions', $editionResources);
         $interface->assign('popupTitle', 'Other Editions');
         $interface->assign('popupTemplate', 'Resource/otherEditions.tpl');
         echo $interface->fetch('popup-wrapper.tpl');
     } elseif (isset($error)) {
         $analytics->addEvent('Enrichment', 'Other Editions Error', $error);
         echo $error;
     } else {
         echo "There are no other editions for this title currently in the catalog.";
         $analytics->addEvent('Enrichment', 'Other Editions', 0, 'No Other ISBNs');
     }
 }
Ejemplo n.º 25
0
 function getPurchaseOptions()
 {
     global $interface;
     if (isset($_REQUEST['id'])) {
         $id = $_REQUEST['id'];
         $interface->assign('id', $id);
         $eContentRecord = new EContentRecord();
         $eContentRecord->id = $id;
         if ($eContentRecord->find(true)) {
             $purchaseLinks = array();
             if ($eContentRecord->purchaseUrl != null) {
                 $purchaseLinks[] = array('link' => $eContentRecord->purchaseUrl, 'linkText' => 'Buy from ' . $eContentRecord->publisher, 'storeName' => $eContentRecord->publisher, 'field856Index' => 1);
             }
             if (count($purchaseLinks) > 0) {
                 $interface->assign('purchaseLinks', $purchaseLinks);
             } else {
                 $title = $eContentRecord->title;
                 $author = $eContentRecord->author;
                 require_once ROOT_DIR . '/services/Record/Purchase.php';
                 $purchaseLinks = Purchase::getStoresForTitle($title, $author);
                 if (count($purchaseLinks) > 0) {
                     $interface->assign('purchaseLinks', $purchaseLinks);
                 } else {
                     $interface->assign('errors', array("Sorry we couldn't find any stores that offer this title."));
                 }
             }
         } else {
             $errors = array("Could not load record for that id.");
             $interface->assign('errors', $errors);
         }
     } else {
         $errors = array("You must provide the id of the title to be purchased. ");
         $interface->assign('errors', $errors);
     }
     echo $interface->fetch('EcontentRecord/ajax-purchase-options.tpl');
 }
Ejemplo n.º 26
0
 function __construct($subAction = false, $record_id = null)
 {
     global $interface;
     global $configArray;
     global $library;
     global $timer;
     global $logger;
     $interface->assign('page_body_style', 'sidebar_left');
     $interface->assign('libraryThingUrl', $configArray['LibraryThing']['url']);
     //Determine whether or not materials request functionality should be enabled
     $interface->assign('enableMaterialsRequest', MaterialsRequest::enableMaterialsRequest());
     //Load basic information needed in subclasses
     if ($record_id == null || !isset($record_id)) {
         $this->id = $_GET['id'];
     } else {
         $this->id = $record_id;
     }
     //Check to see if the record exists within the resources table
     $resource = new Resource();
     $resource->record_id = $this->id;
     $resource->source = 'VuFind';
     $resource->deleted = 0;
     if (!$resource->find()) {
         //Check to see if the record has been converted to an eContent record
         require_once ROOT_DIR . '/sys/eContent/EContentRecord.php';
         $econtentRecord = new EContentRecord();
         $econtentRecord->ilsId = $this->id;
         $econtentRecord->status = 'active';
         if ($econtentRecord->find(true)) {
             header("Location: /EcontentRecord/{$econtentRecord->id}/Home");
             die;
         }
         $logger->log("Did not find a record for id {$this->id} in resources table.", PEAR_LOG_DEBUG);
         $interface->setTemplate('invalidRecord.tpl');
         $interface->display('layout.tpl');
         die;
     }
     if ($configArray['Catalog']['ils'] == 'Millennium') {
         $interface->assign('classicId', substr($this->id, 1, strlen($this->id) - 2));
         $interface->assign('classicUrl', $configArray['Catalog']['linking_url']);
     }
     // Setup Search Engine Connection
     $class = $configArray['Index']['engine'];
     $url = $configArray['Index']['url'];
     $this->db = new $class($url);
     $this->db->disableScoping();
     // Retrieve Full Marc Record
     if (!($record = $this->db->getRecord($this->id))) {
         $logger->log("Did not find a record for id {$this->id} in solr.", PEAR_LOG_DEBUG);
         $interface->setTemplate('invalidRecord.tpl');
         $interface->display('layout.tpl');
         die;
     }
     $this->db->enableScoping();
     $this->record = $record;
     $interface->assign('record', $record);
     $this->recordDriver = RecordDriverFactory::initRecordDriver($record);
     $timer->logTime('Initialized the Record Driver');
     $interface->assign('coreMetadata', $this->recordDriver->getCoreMetadata());
     // Process MARC Data
     require_once ROOT_DIR . '/sys/MarcLoader.php';
     $marcRecord = MarcLoader::loadMarcRecordFromRecord($record);
     if ($marcRecord) {
         $this->marcRecord = $marcRecord;
         $interface->assign('marc', $marcRecord);
     } else {
         $interface->assign('error', 'Cannot Process MARC Record');
     }
     $timer->logTime('Processed the marc record');
     //Load information for display in the template rather than processing specific fields in the template
     $marcField = $marcRecord->getField('245');
     $recordTitle = $this->getSubfieldData($marcField, 'a');
     $interface->assign('recordTitle', $recordTitle);
     $recordTitleSubtitle = trim($this->concatenateSubfieldData($marcField, array('a', 'b', 'h', 'n', 'p')));
     $recordTitleSubtitle = preg_replace('~\\s+[\\/:]$~', '', $recordTitleSubtitle);
     $interface->assign('recordTitleSubtitle', $recordTitleSubtitle);
     $recordTitleWithAuth = trim($this->concatenateSubfieldData($marcField, array('a', 'b', 'h', 'n', 'p', 'c')));
     $interface->assign('recordTitleWithAuth', $recordTitleWithAuth);
     $marcField = $marcRecord->getField('100');
     if ($marcField) {
         $mainAuthor = $this->concatenateSubfieldData($marcField, array('a', 'b', 'c', 'd'));
         $interface->assign('mainAuthor', $mainAuthor);
     }
     $marcField = $marcRecord->getField('110');
     if ($marcField) {
         $corporateAuthor = $this->getSubfieldData($marcField, 'a');
         $interface->assign('corporateAuthor', $corporateAuthor);
     }
     $marcFields = $marcRecord->getFields('700');
     if ($marcFields) {
         $contributors = array();
         foreach ($marcFields as $marcField) {
             $contributors[] = $this->concatenateSubfieldData($marcField, array('a', 'b', 'c', 'd'));
         }
         $interface->assign('contributors', $contributors);
     }
     $published = $this->recordDriver->getPublicationDetails();
     $interface->assign('published', $published);
     $marcFields = $marcRecord->getFields('250');
     if ($marcFields) {
         $editionsThis = array();
         foreach ($marcFields as $marcField) {
             $editionsThis[] = $this->getSubfieldData($marcField, 'a');
         }
         $interface->assign('editionsThis', $editionsThis);
     }
     $marcFields = $marcRecord->getFields('300');
     if ($marcFields) {
         $physicalDescriptions = array();
         foreach ($marcFields as $marcField) {
             $description = $this->concatenateSubfieldData($marcField, array('a', 'b', 'c', 'e', 'f', 'g'));
             if ($description != 'p. cm.') {
                 $description = preg_replace("/[\\/|;:]\$/", '', $description);
                 $description = preg_replace("/p\\./", 'pages', $description);
                 $physicalDescriptions[] = $description;
             }
         }
         $interface->assign('physicalDescriptions', $physicalDescriptions);
     }
     // Get ISBN for cover and review use
     $mainIsbnSet = false;
     /** @var File_MARC_Data_Field[] $isbnFields */
     if ($isbnFields = $this->marcRecord->getFields('020')) {
         $isbns = array();
         //Use the first good ISBN we find.
         foreach ($isbnFields as $isbnField) {
             /** @var File_MARC_Subfield $isbnSubfieldA */
             if ($isbnSubfieldA = $isbnField->getSubfield('a')) {
                 $tmpIsbn = trim($isbnSubfieldA->getData());
                 if (strlen($tmpIsbn) > 0) {
                     $isbns[] = $isbnSubfieldA->getData();
                     $pos = strpos($tmpIsbn, ' ');
                     if ($pos > 0) {
                         $tmpIsbn = substr($tmpIsbn, 0, $pos);
                     }
                     $tmpIsbn = trim($tmpIsbn);
                     if (strlen($tmpIsbn) > 0) {
                         if (strlen($tmpIsbn) < 10) {
                             $tmpIsbn = str_pad($tmpIsbn, 10, "0", STR_PAD_LEFT);
                         }
                         if (!$mainIsbnSet) {
                             $this->isbn = $tmpIsbn;
                             $interface->assign('isbn', $tmpIsbn);
                             $mainIsbnSet = true;
                         }
                     }
                 }
             }
         }
         if (isset($this->isbn)) {
             if (strlen($this->isbn) == 13) {
                 require_once ROOT_DIR . '/Drivers/marmot_inc/ISBNConverter.php';
                 $this->isbn10 = ISBNConverter::convertISBN13to10($this->isbn);
             } else {
                 $this->isbn10 = $this->isbn;
             }
             $interface->assign('isbn10', $this->isbn10);
         }
         $interface->assign('isbns', $isbns);
     }
     if ($upcField = $this->marcRecord->getField('024')) {
         /** @var File_MARC_Data_Field $upcField */
         if ($upcSubField = $upcField->getSubfield('a')) {
             $this->upc = trim($upcSubField->getData());
             $interface->assign('upc', $this->upc);
         }
     }
     if ($issnField = $this->marcRecord->getField('022')) {
         /** @var File_MARC_Data_Field $issnField */
         if ($issnSubField = $issnField->getSubfield('a')) {
             $this->issn = trim($issnSubField->getData());
             if ($pos = strpos($this->issn, ' ')) {
                 $this->issn = substr($this->issn, 0, $pos);
             }
             $interface->assign('issn', $this->issn);
             //Also setup GoldRush link
             if (isset($library) && strlen($library->goldRushCode) > 0) {
                 $interface->assign('goldRushLink', "http://goldrush.coalliance.org/index.cfm?fuseaction=Search&amp;inst_code={$library->goldRushCode}&amp;search_type=ISSN&amp;search_term={$this->issn}");
             }
         }
     }
     $timer->logTime("Got basic data from Marc Record subaction = {$subAction}, record_id = {$record_id}");
     //stop if this is not the main action.
     if ($subAction == true) {
         return;
     }
     //Get street date
     if ($streetDateField = $this->marcRecord->getField('263')) {
         $streetDate = $this->getSubfieldData($streetDateField, 'a');
         if ($streetDate != '') {
             $interface->assign('streetDate', $streetDate);
         }
     }
     /** @var File_MARC_Data_Field[] $marcField440 */
     $marcField440 = $marcRecord->getFields('440');
     /** @var File_MARC_Data_Field[] $marcField490 */
     $marcField490 = $marcRecord->getFields('490');
     /** @var File_MARC_Data_Field[] $marcField830 */
     $marcField830 = $marcRecord->getFields('830');
     if ($marcField440 || $marcField490 || $marcField830) {
         $series = array();
         foreach ($marcField440 as $field) {
             $series[] = $this->getSubfieldData($field, 'a');
         }
         foreach ($marcField490 as $field) {
             if ($field->getIndicator(1) == 0) {
                 $series[] = $this->getSubfieldData($field, 'a');
             }
         }
         foreach ($marcField830 as $field) {
             $series[] = $this->getSubfieldData($field, 'a');
         }
         $interface->assign('series', $series);
     }
     //Load description from Syndetics
     $useMarcSummary = true;
     if ($this->isbn || $this->upc) {
         if ($library && $library->preferSyndeticsSummary == 1) {
             require_once ROOT_DIR . '/Drivers/marmot_inc/GoDeeperData.php';
             $summaryInfo = GoDeeperData::getSummary($this->isbn, $this->upc);
             if (isset($summaryInfo['summary'])) {
                 $interface->assign('summaryTeaser', $summaryInfo['summary']);
                 $interface->assign('summary', $summaryInfo['summary']);
                 $useMarcSummary = false;
             }
         }
     }
     if ($useMarcSummary) {
         if ($summaryField = $this->marcRecord->getField('520')) {
             $interface->assign('summary', $this->getSubfieldData($summaryField, 'a'));
             $interface->assign('summaryTeaser', $this->getSubfieldData($summaryField, 'a'));
         } elseif ($library && $library->preferSyndeticsSummary == 0) {
             require_once ROOT_DIR . '/Drivers/marmot_inc/GoDeeperData.php';
             $summaryInfo = GoDeeperData::getSummary($this->isbn, $this->upc);
             if (isset($summaryInfo['summary'])) {
                 $interface->assign('summaryTeaser', $summaryInfo['summary']);
                 $interface->assign('summary', $summaryInfo['summary']);
                 $useMarcSummary = false;
             }
         }
     }
     if ($mpaaField = $this->marcRecord->getField('521')) {
         $interface->assign('mpaaRating', $this->getSubfieldData($mpaaField, 'a'));
     }
     if (isset($configArray['Content']['subjectFieldsToShow'])) {
         $subjectFieldsToShow = $configArray['Content']['subjectFieldsToShow'];
         $subjectFields = explode(',', $subjectFieldsToShow);
         $subjects = array();
         foreach ($subjectFields as $subjectField) {
             /** @var File_MARC_Data_Field[] $marcFields */
             $marcFields = $marcRecord->getFields($subjectField);
             if ($marcFields) {
                 foreach ($marcFields as $marcField) {
                     $searchSubject = "";
                     $subject = array();
                     foreach ($marcField->getSubFields() as $subField) {
                         /** @var File_MARC_Subfield $subField */
                         if ($subField->getCode() != 2) {
                             $searchSubject .= " " . $subField->getData();
                             $subject[] = array('search' => trim($searchSubject), 'title' => $subField->getData());
                         }
                     }
                     $subjects[] = $subject;
                 }
             }
             $interface->assign('subjects', $subjects);
         }
     }
     $format = $record['format'];
     $interface->assign('recordFormat', $record['format']);
     $format_category = isset($record['format_category'][0]) ? $record['format_category'][0] : '';
     $interface->assign('format_category', $format_category);
     $interface->assign('recordLanguage', isset($record['language']) ? $record['language'] : null);
     $timer->logTime('Got detailed data from Marc Record');
     $tableOfContents = array();
     $marcFields505 = $marcRecord->getFields('505');
     if ($marcFields505) {
         $tableOfContents = $this->processTableOfContentsFields($marcFields505);
     }
     $notes = array();
     $marcFields500 = $marcRecord->getFields('500');
     $marcFields504 = $marcRecord->getFields('504');
     $marcFields511 = $marcRecord->getFields('511');
     $marcFields518 = $marcRecord->getFields('518');
     $marcFields520 = $marcRecord->getFields('520');
     if ($marcFields500 || $marcFields504 || $marcFields505 || $marcFields511 || $marcFields518 || $marcFields520) {
         $allFields = array_merge($marcFields500, $marcFields504, $marcFields511, $marcFields518, $marcFields520);
         $notes = $this->processNoteFields($allFields);
     }
     if (isset($library) && $library->showTableOfContentsTab == 0 || count($tableOfContents) == 0) {
         $notes = array_merge($notes, $tableOfContents);
     } else {
         $interface->assign('tableOfContents', $tableOfContents);
     }
     if (isset($library) && strlen($library->notesTabName) > 0) {
         $interface->assign('notesTabName', $library->notesTabName);
     } else {
         $interface->assign('notesTabName', 'Notes');
     }
     $additionalNotesFields = array('310' => 'Current Publication Frequency', '321' => 'Former Publication Frequency', '351' => 'Organization & arrangement of materials', '362' => 'Dates of publication and/or sequential designation', '501' => '"With"', '502' => 'Dissertation', '506' => 'Restrictions on Access', '507' => 'Scale for Graphic Material', '508' => 'Creation/Production Credits', '510' => 'Citation/References', '511' => 'Participant or Performer', '513' => 'Type of Report an Period Covered', '515' => 'Numbering Peculiarities', '518' => 'Date/Time and Place of Event', '521' => 'Target Audience', '522' => 'Geographic Coverage', '525' => 'Supplement', '526' => 'Study Program Information', '530' => 'Additional Physical Form', '533' => 'Reproduction', '534' => 'Original Version', '536' => 'Funding Information', '538' => 'System Details', '545' => 'Biographical or Historical Data', '546' => 'Language', '547' => 'Former Title Complexity', '550' => 'Issuing Body', '555' => 'Cumulative Index/Finding Aids', '556' => 'Information About Documentation', '561' => 'Ownership and Custodial History', '563' => 'Binding Information', '580' => 'Linking Entry Complexity', '581' => 'Publications About Described Materials', '586' => 'Awards', '590' => 'Local note', '599' => 'Differentiable Local note');
     foreach ($additionalNotesFields as $tag => $label) {
         $marcFields = $marcRecord->getFields($tag);
         foreach ($marcFields as $marcField) {
             $noteText = array();
             foreach ($marcField->getSubFields() as $subfield) {
                 /** @var File_MARC_Subfield $subfield */
                 $noteText[] = $subfield->getData();
             }
             $note = implode(',', $noteText);
             if (strlen($note) > 0) {
                 $notes[] = "<b>{$label}</b>: " . $note;
             }
         }
     }
     if (count($notes) > 0) {
         $interface->assign('notes', $notes);
     }
     /** @var File_MARC_Data_Field[] $linkFields */
     $linkFields = $marcRecord->getFields('856');
     if ($linkFields) {
         $internetLinks = array();
         $purchaseLinks = array();
         $field856Index = 0;
         foreach ($linkFields as $marcField) {
             $field856Index++;
             //Get the link
             if ($marcField->getSubfield('u')) {
                 $link = $marcField->getSubfield('u')->getData();
                 if ($marcField->getSubfield('3')) {
                     $linkText = $marcField->getSubfield('3')->getData();
                 } elseif ($marcField->getSubfield('y')) {
                     $linkText = $marcField->getSubfield('y')->getData();
                 } elseif ($marcField->getSubfield('z')) {
                     $linkText = $marcField->getSubfield('z')->getData();
                 } else {
                     $linkText = $link;
                 }
                 $showLink = true;
                 //Process some links differently so we can either hide them
                 //or show them in different areas of the catalog.
                 if (preg_match('/purchase|buy/i', $linkText) || preg_match('/barnesandnoble|tatteredcover|amazon|smashwords\\.com/i', $link)) {
                     $showLink = false;
                 }
                 $isBookLink = preg_match('/acs\\.dcl\\.lan|vufind\\.douglascountylibraries\\.org|catalog\\.douglascountylibraries\\.org/i', $link);
                 if ($isBookLink == 1) {
                     //e-book link, don't show
                     $showLink = false;
                 }
                 if ($showLink) {
                     //Rewrite the link so we can track usage
                     $link = $configArray['Site']['path'] . '/Record/' . $this->id . '/Link?index=' . $field856Index;
                     $internetLinks[] = array('link' => $link, 'linkText' => $linkText);
                 }
             }
         }
         if (count($internetLinks) > 0) {
             $interface->assign('internetLinks', $internetLinks);
         }
     }
     if (isset($purchaseLinks) && count($purchaseLinks) > 0) {
         $interface->assign('purchaseLinks', $purchaseLinks);
     }
     //Determine the cover to use
     $bookCoverUrl = $configArray['Site']['coverUrl'] . "/bookcover.php?id={$this->id}&amp;isn={$this->isbn}&amp;issn={$this->issn}&amp;size=large&amp;upc={$this->upc}&amp;category=" . urlencode($format_category) . "&amp;format=" . urlencode(isset($format[0]) ? $format[0] : '');
     $interface->assign('bookCoverUrl', $bookCoverUrl);
     //Load accelerated reader data
     if (isset($record['accelerated_reader_interest_level'])) {
         $arData = array('interestLevel' => $record['accelerated_reader_interest_level'], 'pointValue' => $record['accelerated_reader_point_value'], 'readingLevel' => $record['accelerated_reader_reading_level']);
         $interface->assign('arData', $arData);
     }
     if (isset($record['lexile_score']) && $record['lexile_score'] > -1) {
         $lexileScore = $record['lexile_score'];
         if (isset($record['lexile_code'])) {
             $lexileScore = $record['lexile_code'] . $lexileScore;
         }
         $interface->assign('lexileScore', $lexileScore . 'L');
     }
     //Do actions needed if this is the main action.
     //$interface->caching = 1;
     $interface->assign('id', $this->id);
     if (substr($this->id, 0, 1) == '.') {
         $interface->assign('shortId', substr($this->id, 1));
     } else {
         $interface->assign('shortId', $this->id);
     }
     $interface->assign('addHeader', '<link rel="alternate" type="application/rdf+xml" title="RDF Representation" href="' . $configArray['Site']['path'] . '/Record/' . urlencode($this->id) . '/RDF" />');
     // Define Default Tab
     $tab = isset($_GET['action']) ? $_GET['action'] : 'Description';
     $interface->assign('tab', $tab);
     if (isset($_REQUEST['detail'])) {
         $detail = strip_tags($_REQUEST['detail']);
         $interface->assign('defaultDetailsTab', $detail);
     }
     // Define External Content Provider
     if ($this->marcRecord->getField('020')) {
         if (isset($configArray['Content']['reviews'])) {
             $interface->assign('hasReviews', true);
         }
         if (isset($configArray['Content']['excerpts'])) {
             $interface->assign('hasExcerpt', true);
         }
     }
     // Retrieve User Search History
     $interface->assign('lastsearch', isset($_SESSION['lastSearchURL']) ? $_SESSION['lastSearchURL'] : false);
     // Retrieve tags associated with the record
     $limit = 5;
     $resource = new Resource();
     $resource->record_id = $_GET['id'];
     $resource->source = 'VuFind';
     $resource->find(true);
     $tags = $resource->getTags($limit);
     $interface->assign('tagList', $tags);
     $timer->logTime('Got tag list');
     $this->cacheId = 'Record|' . $_GET['id'] . '|' . get_class($this);
     // Find Similar Records
     /** @var Memcache $memCache */
     global $memCache;
     $similar = $memCache->get('similar_titles_' . $this->id);
     if ($similar == false) {
         $similar = $this->db->getMoreLikeThis($this->id);
         // Send the similar items to the template; if there is only one, we need
         // to force it to be an array or things will not display correctly.
         if (isset($similar) && count($similar['response']['docs']) > 0) {
             $similar = $similar['response']['docs'];
         } else {
             $similar = array();
             $timer->logTime("Did not find any similar records");
         }
         $memCache->set('similar_titles_' . $this->id, $similar, 0, $configArray['Caching']['similar_titles']);
     }
     $this->similarTitles = $similar;
     $interface->assign('similarRecords', $similar);
     $timer->logTime('Loaded similar titles');
     // Find Other Editions
     if ($configArray['Content']['showOtherEditionsPopup'] == false) {
         $editions = OtherEditionHandler::getEditions($this->id, $this->isbn, isset($this->record['issn']) ? $this->record['issn'] : null);
         if (!PEAR_Singleton::isError($editions)) {
             $interface->assign('editions', $editions);
         } else {
             $timer->logTime("Did not find any other editions");
         }
         $timer->logTime('Got Other editions');
     }
     $interface->assign('showStrands', isset($configArray['Strands']['APID']) && strlen($configArray['Strands']['APID']) > 0);
     // Send down text for inclusion in breadcrumbs
     $interface->assign('breadcrumbText', $this->recordDriver->getBreadcrumb());
     // Send down OpenURL for COinS use:
     $interface->assign('openURL', $this->recordDriver->getOpenURL());
     // Send down legal export formats (if any):
     $interface->assign('exportFormats', $this->recordDriver->getExportFormats());
     // Set AddThis User
     $interface->assign('addThis', isset($configArray['AddThis']['key']) ? $configArray['AddThis']['key'] : false);
     // Set Proxy URL
     if (isset($configArray['EZproxy']['host'])) {
         $interface->assign('proxy', $configArray['EZproxy']['host']);
     }
     //setup 5 star ratings
     global $user;
     $ratingData = $resource->getRatingData($user);
     $interface->assign('ratingData', $ratingData);
     $timer->logTime('Got 5 star data');
     //Get Next/Previous Links
     $searchSource = isset($_REQUEST['searchSource']) ? $_REQUEST['searchSource'] : 'local';
     $searchObject = SearchObjectFactory::initSearchObject();
     $searchObject->init($searchSource);
     $searchObject->getNextPrevLinks();
     //Load Staff Details
     $interface->assign('staffDetails', $this->recordDriver->getStaffView());
 }
Ejemplo n.º 27
0
 function getItemAvailability()
 {
     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;
     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 {
             require_once ROOT_DIR . '/Drivers/EContentDriver.php';
             $driver = new EContentDriver();
             $itemData['holdings'] = $driver->getHolding($eContentRecord->id);
         }
     } else {
         $this->recordDriver = RecordDriverFactory::initRecordDriver($record);
         $timer->logTime('Initialized the Record Driver');
         //Load Holdings
         $itemData['holdings'] = Record_Holdings::loadHoldings($this->id);
         $timer->logTime('Loaded Holdings');
     }
     return $itemData;
 }
Ejemplo n.º 28
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');
     }
 }
Ejemplo n.º 29
0
 function update()
 {
     //Check to see if we are adding copies.
     //If so, we wil need to process the hold queue after
     //The tile is saved
     $currentValue = new EContentRecord();
     $currentValue->id = $this->id;
     $currentValue->find(true);
     //Don't update solr, rely on the nightly reindex
     $ret = parent::update();
     if ($ret) {
         $this->clearCachedCover();
         if ($currentValue->N == 1 && $currentValue->availableCopies != $this->availableCopies) {
             require_once ROOT_DIR . '/Drivers/EContentDriver.php';
             $eContentDriver = new EContentDriver();
             $eContentDriver->processHoldQueue($this->id);
         }
     }
     return $ret;
 }
Ejemplo n.º 30
0
 function launch()
 {
     global $interface;
     global $configArray;
     // Check if user is logged in
     if (!$this->user) {
         // Needed for "back to record" link in view-alt.tpl:
         $interface->assign('id', $_GET['id']);
         // Needed for login followup:
         $interface->assign('recordId', $_GET['id']);
         if (isset($_GET['lightbox'])) {
             $interface->assign('title', $_GET['message']);
             $interface->assign('message', 'You must be logged in first');
             $interface->assign('followup', true);
             $interface->assign('followupModule', 'EContentRecord');
             $interface->assign('followupAction', 'SaveToList');
             return $interface->fetch('AJAX/login.tpl');
         } else {
             $interface->assign('followup', true);
             $interface->assign('followupModule', 'EContentRecord');
             $interface->assign('followupAction', 'SaveToList');
             $interface->setPageTitle('You must be logged in first');
             $interface->assign('subTemplate', '../MyResearch/login.tpl');
             $interface->setTemplate('view-alt.tpl');
             $interface->display('layout.tpl', 'RecordSave' . $_GET['id']);
         }
         exit;
     }
     if (isset($_GET['submit'])) {
         $this->saveRecord();
         header('Location: ' . $configArray['Site']['path'] . '/EcontentRecord/' . urlencode($_GET['id']));
         exit;
     }
     // Setup Search Engine Connection
     $class = $configArray['Index']['engine'];
     $db = new $class($configArray['Index']['url']);
     if ($configArray['System']['debugSolr']) {
         $db->debug = true;
     }
     // Get Record Information
     $id = strip_tags($_REQUEST['id']);
     $eContentRecord = new EContentRecord();
     $eContentRecord->id = $id;
     $eContentRecord->find(true);
     $interface->assign('record', $eContentRecord);
     // Find out if the item is already part of any lists; save list info/IDs
     $saved = $this->user->getSavedData($_GET['id'], 'eContent');
     $containingLists = array();
     $containingListIds = array();
     foreach ($saved as $current) {
         $containingLists[] = array('id' => $current->list_id, 'title' => $current->list_title);
         $containingListIds[] = $current->list_id;
     }
     $interface->assign('containingLists', $containingLists);
     // Create a list of all the lists that do NOT already contain the item:
     $lists = $this->user->getLists();
     $nonContainingLists = array();
     foreach ($lists as $current) {
         if (!in_array($current->id, $containingListIds)) {
             $nonContainingLists[] = array('id' => $current->id, 'title' => $current->title);
         }
     }
     $interface->assign('nonContainingLists', $nonContainingLists);
     // Display Page
     $interface->assign('id', $_GET['id']);
     if (isset($_GET['lightbox'])) {
         $interface->assign('title', $_GET['message']);
         return $interface->fetch('EContentRecord/save.tpl');
     } else {
         $interface->setPageTitle('Add to favorites');
         $interface->assign('subTemplate', 'save.tpl');
         $interface->setTemplate('view-alt.tpl');
         $interface->display('layout.tpl', 'RecordSave' . $_GET['id']);
     }
 }