function launch() { global $configArray; $editorialReview = new EditorialReview(); $editorialReview->editorialReviewId = $_REQUEST['id']; $editorialReview->find(); if ($editorialReview->N > 0) { $editorialReview->fetch(); $editorialReview->delete(); } //Redirect back to the PMDA home page header('Location:' . $configArray['Site']['path'] . "/EditorialReview/Search"); exit; }
function launch() { global $interface; $interface->assign('id', $_REQUEST['id']); $editorialReview = new EditorialReview(); $editorialReview->editorialReviewId = $_REQUEST['id']; $editorialReview->find(); if ($editorialReview->N > 0) { $editorialReview->fetch(); $interface->assign('editorialReview', $editorialReview); } $interface->assign('sidebar', 'MyAccount/account-sidebar.tpl'); $interface->setTemplate('view.tpl'); $interface->display('layout.tpl'); }
function launch() { global $interface; global $configArray; $isNew = true; if (isset($_REQUEST['id']) && strlen($_REQUEST['id']) > 0) { $editorialReview = new EditorialReview(); $editorialReview->editorialReviewId = $_REQUEST['id']; $editorialReview->find(); if ($editorialReview->N > 0) { $editorialReview->fetch(); $interface->assign('object', $editorialReview); $interface->setPageTitle('Edit Editorial Review'); $isNew = false; } } $structure = EditorialReview::getObjectStructure(); if ($isNew) { if (isset($_REQUEST['recordId'])) { $structure['recordId']['default'] = strip_tags($_REQUEST['recordId']); } } if (isset($_REQUEST['submit']) || isset($_REQUEST['submitStay']) || isset($_REQUEST['submitReturnToList']) || isset($_REQUEST['submitAddAnother'])) { //Save the object $results = DataObjectUtil::saveObject($structure, 'EditorialReview'); $editorialReview = $results['object']; //redirect to the view of the competency if we saved ok. if (!$results['validatedOk'] || !$results['saveOk']) { //Display the errors for the user. $interface->assign('errors', $results['errors']); $interface->assign('object', $editorialReview); $_REQUEST['id'] = $editorialReview->editorialReviewId; } else { //Show the new tip that was created if (isset($_REQUEST['submitReturnToList'])) { if (strpos($editorialReview->recordId, 'econtentRecord') === 0) { $shortId = str_replace('econtentRecord', '', $editorialReview->recordId); header('Location:' . $configArray['Site']['path'] . "/EcontentRecord/{$shortId}/Home"); } else { header('Location:' . $configArray['Site']['path'] . "/Record/{$editorialReview->recordId}/Home"); } } elseif (isset($_REQUEST['submitAddAnother'])) { header('Location:' . $configArray['Site']['path'] . "/EditorialReview/Edit?recordId={$editorialReview->recordId}"); } else { header('Location:' . $configArray['Site']['path'] . "/EditorialReview/{$editorialReview->editorialReviewId}/View"); exit; } } } //Manipulate the structure as needed if ($isNew) { } else { } $interface->assign('isNew', $isNew); $interface->assign('submitUrl', $configArray['Site']['path'] . '/EditorialReview/Edit'); $interface->assign('editForm', DataObjectUtil::getEditForm($structure)); $interface->setTemplate('edit.tpl'); $interface->display('layout.tpl'); }
function launch() { global $interface; global $configArray; $interface->assign('id', $_REQUEST['id']); $editorialReview = new EditorialReview(); $editorialReview->editorialReviewId = $_REQUEST['id']; $editorialReview->find(); if ($editorialReview->N > 0) { $editorialReview->fetch(); $interface->assign('editorialReview', $editorialReview); } //Load the pillar to display $structure = EditorialReview::getObjectStructure(); $interface->setTemplate('view.tpl'); $interface->display('layout.tpl'); }
function launch() { global $interface; global $configArray; $results = array(); $editorialReview = new EditorialReview(); $currentPage = isset($_REQUEST['page']) ? $_REQUEST['page'] : 1; $recordsPerPage = 20; $searchUrl = $configArray['Site']['path'] . '/EditorialReview/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); $editorialReview = new EditorialReview(); if (isset($_REQUEST['sortOptions'])) { $editorialReview->orderBy($_REQUEST['sortOptions']); $interface->assign('sort', $_REQUEST['sortOptions']); } $numTotalFiles = $editorialReview->count(); $editorialReview->limit(($currentPage - 1) * $recordsPerPage, 20); $editorialReview->find(); if ($editorialReview->N > 0) { while ($editorialReview->fetch()) { $results[] = clone $editorialReview; } } $interface->assign('results', $results); $options = array('totalItems' => $numTotalFiles, 'fileName' => $searchUrl, 'perPage' => $recordsPerPage); $pager = new VuFindPager($options); $interface->assign('pageLinks', $pager->getLinks()); $interface->assign('sidebar', 'MyAccount/account-sidebar.tpl'); $interface->setTemplate('search.tpl'); $interface->display('layout.tpl'); }
function loadReviews($eContentRecord) { global $interface; //Load the Editorial Reviews //Populate an array of editorialReviewIds that match up with the recordId require_once ROOT_DIR . '/sys/LocalEnrichment/EditorialReview.php'; $editorialReview = new EditorialReview(); $editorialReviewResults = array(); $editorialReview->recordId = 'econtentRecord' . $eContentRecord->id; $editorialReview->find(); $reviewTabs = array(); $editorialReviewResults['reviews'] = array('tabName' => 'Reviews', 'reviews' => array()); if ($editorialReview->N > 0) { $ctr = 0; while ($editorialReview->fetch()) { $reviewKey = preg_replace('/\\W/', '_', strtolower($editorialReview->tabName)); if (!array_key_exists($reviewKey, $editorialReviewResults)) { $editorialReviewResults[$reviewKey] = array('tabName' => $editorialReview->tabName, 'reviews' => array()); } $editorialReviewResults[$reviewKey]['reviews'][$ctr++] = get_object_vars($editorialReview); } } if ($interface->isMobile()) { //If we are in mobile interface, load standard reviews $reviews = array(); require_once ROOT_DIR . '/sys/Reviews.php'; if ($eContentRecord->getIsbn()) { $externalReviews = new ExternalReviews($eContentRecord->getIsbn()); $reviews = $externalReviews->fetch(); } if (count($editorialReviewResults) > 0) { foreach ($editorialReviewResults as $tabName => $reviewsList) { foreach ($reviewsList['reviews'] as $key => $result) { $reviews["editorialReviews"][$key]["Content"] = $result['review']; $reviews["editorialReviews"][$key]["Copyright"] = $result['source']; $reviews["editorialReviews"][$key]["Source"] = $result['source']; $reviews["editorialReviews"][$key]["ISBN"] = null; $reviews["editorialReviews"][$key]["username"] = null; $reviews["editorialReviews"][$key] = ExternalReviews::cleanupReview($reviews["editorialReviews"][$key]); if ($result['teaser']) { $reviews["editorialReviews"][$key]["Teaser"] = $result['teaser']; } } } } $interface->assign('reviews', $reviews); $interface->assign('editorialReviews', $editorialReviewResults); } else { $interface->assign('reviews', $editorialReviewResults); } }
function launch() { global $interface; global $timer; global $configArray; global $user; // Load Supplemental Information Record_UserComments::loadComments(); $timer->logTime('Loaded Comments'); Record_Cite::loadCitation(); $timer->logTime('Loaded Citations'); if (isset($_REQUEST['id'])) { $recordId = $_REQUEST['id']; } if (isset($_REQUEST['strandsReqId']) && isset($configArray['Strands']['APID'])) { $url = "http://bizsolutions.strands.com/api2/event/clickedrecommendation.sbs?apid={$configArray['Strands']['APID']}&item={$recordId}&user={$user->id}&rrq={$_REQUEST['strandsReqId']}&tpl={$_REQUEST['strandsTpl']}"; $response = file_get_contents($url); } if (isset($_REQUEST['searchId'])) { $_SESSION['searchId'] = $_REQUEST['searchId']; $interface->assign('searchId', $_SESSION['searchId']); } else { if (isset($_SESSION['searchId'])) { $interface->assign('searchId', $_SESSION['searchId']); } } //Load the Editorial Reviews //Populate an array of editorialReviewIds that match up with the recordId $editorialReview = new EditorialReview(); $editorialReviewResults = array(); $editorialReview->recordId = $recordId; $editorialReview->find(); $editorialReviewResults['reviews'] = array('tabName' => 'Reviews', 'reviews' => array()); if ($editorialReview->N > 0) { $ctr = 0; while ($editorialReview->fetch()) { $reviewKey = preg_replace('/\\W/', '_', strtolower($editorialReview->tabName)); if (!array_key_exists($reviewKey, $editorialReviewResults)) { $editorialReviewResults[$reviewKey] = array('tabName' => $editorialReview->tabName, 'reviews' => array()); } $editorialReviewResults[$reviewKey]['reviews'][$ctr++] = get_object_vars($editorialReview); } } $interface->assign('editorialReviews', $editorialReviewResults); $interface->assign('recordId', $recordId); //Enable and disable functionality based on library settings global $library; global $locationSingleton; $location = $locationSingleton->getActiveLocation(); if (isset($library)) { $interface->assign('showTextThis', $library->showTextThis); $interface->assign('showEmailThis', $library->showEmailThis); $interface->assign('showFavorites', $library->showFavorites); $interface->assign('linkToAmazon', $library->linkToAmazon); $interface->assign('enablePurchaseLinks', $library->linkToAmazon); $interface->assign('enablePospectorIntegration', $library->enablePospectorIntegration); if ($location != null) { $interface->assign('showAmazonReviews', $location->showAmazonReviews == 1 && $library->showAmazonReviews == 1 ? 1 : 0); $interface->assign('showStandardReviews', $location->showStandardReviews == 1 && $library->showStandardReviews == 1 ? 1 : 0); $interface->assign('showHoldButton', $location->showHoldButton == 1 && $library->showHoldButton == 1 ? 1 : 0); } else { $interface->assign('showAmazonReviews', $library->showAmazonReviews); $interface->assign('showStandardReviews', $library->showStandardReviews); $interface->assign('showHoldButton', $library->showHoldButton); } $interface->assign('showTagging', $library->showTagging); $interface->assign('showRatings', $library->showRatings); $interface->assign('showComments', $library->showComments); $interface->assign('tabbedDetails', $library->tabbedDetails); $interface->assign('showSeriesAsTab', $library->showSeriesAsTab); $interface->assign('showOtherEditionsPopup', 0); $interface->assign('show856LinksAsTab', $library->show856LinksAsTab); $interface->assign('showProspectorTitlesAsTab', $library->showProspectorTitlesAsTab); } else { $interface->assign('showTextThis', 1); $interface->assign('showEmailThis', 1); $interface->assign('showFavorites', 1); $interface->assign('linkToAmazon', 1); $interface->assign('enablePospectorIntegration', isset($configArray['Content']['Prospector']) && $configArray['Content']['Prospector'] == true ? 1 : 0); $interface->assign('enablePurchaseLinks', 1); if ($location != null) { $interface->assign('showAmazonReviews', $location->showAmazonReviews); $interface->assign('showStandardReviews', $location->showStandardReviews); $interface->assign('showHoldButton', $location->showHoldButton); } else { $interface->assign('showAmazonReviews', 1); $interface->assign('showStandardReviews', 1); $interface->assign('showHoldButton', 1); } $interface->assign('showTagging', 1); $interface->assign('showRatings', 1); $interface->assign('showComments', 1); $interface->assign('tabbedDetails', !isset($configArray['Content']['tabbedDetails']) || $configArray['Content']['tabbedDetails'] == false ? 0 : 1); $interface->assign('showSeriesAsTab', 0); $interface->assign('showOtherEditionsPopup', 0); $interface->assign('show856LinksAsTab', 1); $interface->assign('showProspectorTitlesAsTab', 0); } if (!isset($this->isbn)) { $interface->assign('showOtherEditionsPopup', false); } $resource = new Resource(); $resource->record_id = $this->id; $resource->source = 'VuFind'; $solrId = $this->id; if ($resource->find(true)) { $otherEditions = OtherEditionHandler::getEditions($solrId, $resource->isbn, null, 10); 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); } } } else { $editionResources = null; } } else { $otherEditions = null; $editionResources = null; } $interface->assign('otherEditions', $otherEditions); $interface->assign('editionResources', $editionResources); $interface->assign('chiliFreshAccount', $configArray['Content']['chiliFreshAccount']); $timer->logTime('Configure UI for library and location'); //Build the actual view $interface->setTemplate('view.tpl'); $titleField = $this->marcRecord->getField('245'); if ($titleField) { if ($titleField->getSubfield('a')) { $mainTitle = $titleField->getSubfield('a')->getData(); } else { $mainTitle = 'Title not available'; } $interface->setPageTitle($mainTitle); } // Display Page $interface->display('layout.tpl'); }
function getReviewInfo() { require_once ROOT_DIR . '/RecordDrivers/GroupedWorkDriver.php'; $id = $_REQUEST['id']; $recordDriver = new GroupedWorkDriver($id); $isbn = $recordDriver->getCleanISBN(); //Load external (syndicated reviews) require_once ROOT_DIR . '/sys/Reviews.php'; $externalReviews = new ExternalReviews($isbn); $reviews = $externalReviews->fetch(); global $interface; $interface->assign('id', $id); $numSyndicatedReviews = 0; foreach ($reviews as $providerReviews) { $numSyndicatedReviews += count($providerReviews); } $interface->assign('syndicatedReviews', $reviews); //Load editorial reviews require_once ROOT_DIR . '/sys/LocalEnrichment/EditorialReview.php'; $editorialReviews = new EditorialReview(); $editorialReviews->recordId = $id; $editorialReviews->find(); $allEditorialReviews = array(); while ($editorialReviews->fetch()) { $allEditorialReviews[] = clone $editorialReviews; } $interface->assign('editorialReviews', $allEditorialReviews); $userReviews = $recordDriver->getUserReviews(); $interface->assign('userReviews', $userReviews); $results = array('numSyndicatedReviews' => $numSyndicatedReviews, 'syndicatedReviewsHtml' => $interface->fetch('GroupedWork/view-syndicated-reviews.tpl'), 'numEditorialReviews' => count($allEditorialReviews), 'editorialReviewsHtml' => $interface->fetch('GroupedWork/view-editorial-reviews.tpl'), 'numCustomerReviews' => count($userReviews), 'customerReviewsHtml' => $interface->fetch('GroupedWork/view-user-reviews.tpl')); return json_encode($results); }
/** * Load information from the review provider and update the interface with the data. * * @return array Returns array with review data, otherwise a * PEAR_Error. */ static function loadReviews($id, $isbn, $includeEditorial = false) { global $interface; global $configArray; /** @var Memcache $memCache */ global $memCache; $reviews = $memCache->get("reviews_{$isbn}"); if (!$reviews || isset($_REQUEST['reload'])) { // Fetch from provider if (isset($configArray['Content']['reviews'])) { $providers = explode(',', $configArray['Content']['reviews']); foreach ($providers as $provider) { $provider = explode(':', trim($provider)); $func = strtolower($provider[0]); $key = $provider[1]; $reviews[$func] = Record_Reviews::$func($isbn, $key); // If the current provider had no valid reviews, store nothing: if (empty($reviews[$func]) || PEAR_Singleton::isError($reviews[$func])) { unset($reviews[$func]); } else { if (is_array($reviews[$func])) { foreach ($reviews[$func] as $key => $reviewData) { $reviews[$func][$key] = Record_Reviews::cleanupReview($reviews[$func][$key]); } } else { $reviews[$func] = Record_Reviews::cleanupReview($reviews[$func]); } } } } $memCache->set("reviews_{$isbn}", $reviews, 0, $configArray['Caching']['purchased_reviews']); } //Load Editorial Reviews if ($includeEditorial) { if (isset($id)) { $recordId = $id; $editorialReview = new EditorialReview(); $editorialReviewResults = array(); $editorialReview->whereAdd("recordId = '{$recordId}'"); $editorialReview->find(); if ($editorialReview->N > 0) { while ($editorialReview->fetch()) { $editorialReviewResults[] = clone $editorialReview; } } //$reviews["editorialReviews"] = array(); if (count($editorialReviewResults) > 0) { foreach ($editorialReviewResults as $key => $result) { $reviews["editorialReviews"][$key]["Content"] = $result->review; $reviews["editorialReviews"][$key]["Copyright"] = $result->source; $reviews["editorialReviews"][$key]["Source"] = $result->source; $reviews["editorialReviews"][$key]["ISBN"] = null; $reviews["editorialReviews"][$key]["username"] = null; $reviews["editorialReviews"][$key] = Record_Reviews::cleanupReview($reviews["editorialReviews"][$key]); if ($result->teaser) { $reviews["editorialReviews"][$key]["Teaser"] = $result->teaser; } } } } } //Load Reviews from Good Reads if ($isbn) { require_once ROOT_DIR . '/sys/NovelistFactory.php'; $novelist = NovelistFactory::getNovelist(); $enrichment = $novelist->loadEnrichment($isbn); if (isset($enrichment['goodReads'])) { $reviews['goodReads'] = $enrichment['goodReads']; } } if ($reviews) { if (!PEAR_Singleton::isError($reviews)) { $interface->assign('reviews', $reviews); } else { echo $reviews; } } return $reviews; }