/** * @param ReadingHistoryEntry $readingHistoryDB * @return mixed */ public function getHistoryEntryForDatabaseEntry($readingHistoryDB) { $historyEntry = array(); $historyEntry['itemindex'] = $readingHistoryDB->id; $historyEntry['deletable'] = true; $historyEntry['source'] = $readingHistoryDB->source; $historyEntry['id'] = $readingHistoryDB->sourceId; $historyEntry['recordId'] = $readingHistoryDB->sourceId; $historyEntry['shortId'] = $readingHistoryDB->sourceId; $historyEntry['title'] = $readingHistoryDB->title; $historyEntry['author'] = $readingHistoryDB->author; $historyEntry['format'] = array($readingHistoryDB->format); $historyEntry['checkout'] = $readingHistoryDB->checkOutDate; $historyEntry['checkin'] = $readingHistoryDB->checkInDate; $historyEntry['ratingData'] = null; $historyEntry['permanentId'] = null; $historyEntry['linkUrl'] = null; $historyEntry['coverUrl'] = null; $recordDriver = null; if ($readingHistoryDB->source == 'ILS') { require_once ROOT_DIR . '/RecordDrivers/MarcRecord.php'; $recordDriver = new MarcRecord($historyEntry['id']); } elseif ($readingHistoryDB->source == 'OverDrive') { require_once ROOT_DIR . '/RecordDrivers/OverDriveRecordDriver.php'; $recordDriver = new OverDriveRecordDriver($historyEntry['id']); } elseif ($readingHistoryDB->source == 'PublicEContent') { require_once ROOT_DIR . '/RecordDrivers/PublicEContentDriver.php'; $recordDriver = new PublicEContentDriver($historyEntry['id']); } elseif ($readingHistoryDB->source == 'RestrictedEContent') { require_once ROOT_DIR . '/RecordDrivers/RestrictedEContentDriver.php'; $recordDriver = new RestrictedEContentDriver($historyEntry['id']); } if ($recordDriver != null && $recordDriver->isValid()) { $historyEntry['ratingData'] = $recordDriver->getRatingData(); $historyEntry['permanentId'] = $recordDriver->getPermanentId(); $historyEntry['linkUrl'] = $recordDriver->getLinkUrl(); $historyEntry['coverUrl'] = $recordDriver->getBookcoverUrl('medium'); $historyEntry['format'] = $recordDriver->getFormats(); } $recordDriver = null; return $historyEntry; }