function loadEContentComments() { global $interface; $resource = new Resource(); $resource->record_id = $_GET['id']; $resource->source = 'EContent'; if ($resource->find(true)) { $commentLists = $resource->getComments(); $interface->assign('commentList', $commentLists['user']); $interface->assign('staffCommentList', $commentLists['staff']); } }
/** * Get information about a particular item and return it as JSON */ function getItem() { 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))) { return array('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 { $itemData['isbn'] = $eContentRecord->getIsbn(); $itemData['issn'] = $eContentRecord->getissn(); $itemData['upc'] = $eContentRecord->getUpc(); $itemData['issn'] = ''; $itemData['title'] = $record['title']; $itemData['author'] = $eContentRecord->author; $itemData['publisher'] = $eContentRecord->publisher; $itemData['allIsbn'] = $eContentRecord->getPropertyArray('isbn'); $itemData['allUpc'] = $eContentRecord->getPropertyArray('upc'); $itemData['allIssn'] = $eContentRecord->getPropertyArray('issn'); $itemData['format'] = $eContentRecord->format(); $itemData['formatCategory'] = $eContentRecord->format_category(); $itemData['language'] = $eContentRecord->language; $itemData['cover'] = $configArray['Site']['coverUrl'] . "/bookcover.php?id={$itemData['id']}&isbn={$itemData['isbn']}&issn={$itemData['issn']}&upc={$itemData['upc']}&category={$itemData['formatCategory']}&format={$itemData['format'][0]}&size=medium"; $itemData['description'] = $eContentRecord->description; require_once ROOT_DIR . '/sys/eContent/EContentRating.php'; $eContentRating = new EContentRating(); $eContentRating->recordId = $eContentRecord->id; $itemData['ratingData'] = $eContentRating->getRatingData(false, false); // Retrieve tags associated with the record $limit = 5; $resource = new Resource(); $resource->record_id = $eContentRecord->id; $resource->source = 'eContent'; if ($tags = $resource->getTags()) { array_slice($tags, 0, $limit); } $itemData['tagList'] = $tags; $timer->logTime('Got tag list'); $itemData['userComments'] = $resource->getComments(); 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'); // Process MARC Data require_once ROOT_DIR . '/sys/MarcLoader.php'; $marcRecord = MarcLoader::loadMarcRecordFromRecord($record); if ($marcRecord) { $this->marcRecord = $marcRecord; } else { $itemData['error'] = 'Cannot Process MARC Record'; } $timer->logTime('Processed the marc record'); // Get ISBN for cover and review use if ($isbnFields = $this->marcRecord->getFields('020')) { //Use the first good ISBN we find. /** @var File_MARC_Data_Field[] $isbnFields */ foreach ($isbnFields as $isbnField) { if ($isbnField = $isbnField->getSubfield('a')) { $this->isbn = trim($isbnField->getData()); if ($pos = strpos($this->isbn, ' ')) { $this->isbn = substr($this->isbn, 0, $pos); } if (strlen($this->isbn) < 10) { $this->isbn = str_pad($this->isbn, 10, "0", STR_PAD_LEFT); } $itemData['isbn'] = $this->isbn; break; } } } /** @var File_MARC_Data_Field $upcField */ if ($upcField = $this->marcRecord->getField('024')) { if ($upcSubfield = $upcField->getSubfield('a')) { $this->upc = trim($upcSubfield->getData()); $itemData['upc'] = $this->upc; } } /** @var File_MARC_Data_Field $issnField */ if ($issnField = $this->marcRecord->getField('022')) { if ($issnSubfield = $issnField->getSubfield('a')) { $this->issn = trim($issnSubfield->getData()); if ($pos = strpos($this->issn, ' ')) { $this->issn = substr($this->issn, 0, $pos); } $itemData['issn'] = $this->issn; } } $timer->logTime('Got UPC, ISBN, and ISSN'); //Generate basic information from the marc file to make display easier. $itemData['title'] = $record['title']; $itemData['author'] = $record['author']; $itemData['publisher'] = $record['publisher']; $itemData['allIsbn'] = $record['isbn']; $itemData['allUpc'] = $record['upc']; $itemData['allIssn'] = $record['issn']; $itemData['edition'] = $record['edition']; $itemData['callnumber'] = $record['callnumber']; $itemData['genre'] = $record['genre']; $itemData['series'] = $record['series']; $itemData['physical'] = $record['physical']; $itemData['lccn'] = $record['lccn']; $itemData['contents'] = $record['contents']; $itemData['format'] = $record['format']; $itemData['formatCategory'] = $record['format_category'][0]; $itemData['language'] = $record['language']; //Retrieve description from MARC file $description = ''; /** @var File_MARC_Data_Field $descriptionField */ if ($descriptionField = $this->marcRecord->getField('520')) { if ($descriptionSubfield = $descriptionField->getSubfield('a')) { $description = trim($descriptionSubfield->getData()); } } $itemData['description'] = $description; // Retrieve tags associated with the record $limit = 5; $resource = new Resource(); $resource->record_id = $this->id; $resource->source = 'VuFind'; if ($tags = $resource->getTags()) { array_slice($tags, 0, $limit); } $itemData['tagList'] = $tags; $timer->logTime('Got tag list'); //setup 5 star ratings global $user; $ratingData = $resource->getRatingData($user); $itemData['ratingData'] = $ratingData; $timer->logTime('Got 5 star data'); // Load User comments $itemData['userComments'] = Record_UserComments::getComments($this->id); $timer->logTime('Loaded Comments'); //Load Holdings $itemData['holdings'] = Record_Holdings::loadHoldings($this->id); $timer->logTime('Loaded Holdings'); // Add Marc Record to the output if ($this->marcRecord) { $itemData['marc'] = $this->marcRecord->toJSON(); } } return $itemData; }
function GetComments() { global $interface; require_once ROOT_DIR . '/services/MyResearch/lib/Resource.php'; require_once ROOT_DIR . '/services/MyResearch/lib/Comments.php'; $interface->assign('id', $_GET['id']); $resource = new Resource(); $resource->record_id = $_GET['id']; $resource->source = 'eContent'; $commentList = array(); if ($resource->find(true)) { $commentList = $resource->getComments(); } $interface->assign('commentList', $commentList['user']); $userComments = $interface->fetch('Record/view-comments-list.tpl'); $interface->assign('staffCommentList', $commentList['staff']); $staffComments = $interface->fetch('Record/view-staff-reviews-list.tpl'); return json_encode(array('staffComments' => $staffComments, 'userComments' => $userComments)); }
/** * Return comments for a particular record and return them as an array. * * @param $id * @return array|null */ static function getComments($id) { $resource = new Resource(); $resource->record_id = $id; $resource->source = 'VuFind'; if ($resource->find(true)) { $commentList = $resource->getComments(); return $commentList; } else { return null; } }