/** * Process incoming parameters and display the page. * * @return void * @access public */ public function launch() { global $interface; if (!$interface->is_cached($this->cacheId)) { $rev = new ExternalReviews($this->isbn); $reviews = $rev->fetch(); if ($reviews) { $interface->assign('reviews', $reviews); } $interface->assign('subTemplate', '../Record/view-reviews.tpl'); $interface->setTemplate('view.tpl'); } // Display Page $interface->display('layout.tpl', $this->cacheId); }
/** * Get any reviews associated with this record. For details of * the return format, see sys/Reviews.php. * * @return array Review information. * @access public */ public function getReviews() { include_once 'sys/Reviews.php'; $rev = new ExternalReviews($this->getCleanISBN()); return $rev->fetch(); }
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); }
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); } }
/** * Get any reviews associated with this record. For details of * the return format, see sys/Reviews.php. * * @access public * @return array Review information. */ public function getReviews() { require_once ROOT_DIR . '/sys/Reviews.php'; $rev = new ExternalReviews($this->getCleanISBN()); return $rev->fetch(); }