コード例 #1
0
ファイル: Viewer.php プロジェクト: bryandease/VuFind-Plus
 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');
     }
 }
コード例 #2
0
ファイル: Viewer.php プロジェクト: victorfcm/VuFind-Plus
 function launch()
 {
     global $interface;
     global $configArray;
     global $user;
     $id = $_REQUEST['id'];
     $interface->assign('id', $id);
     $itemId = $_REQUEST['itemId'];
     $interface->assign('itemId', $itemId);
     $file = $_REQUEST['file'];
     $interface->assign('file', $file);
     $recordDriver = new RestrictedEContentDriver($id);
     $isAudio = false;
     if (!$recordDriver->isValid()) {
         $interface->setTemplate('../Record/invalidRecord.tpl');
         $interface->display('layout.tpl');
         die;
     } else {
         $interface->assign('recordDriver', $recordDriver);
         $itemId = $_REQUEST['itemId'];
         $errorOccurred = false;
         if ($user == false) {
             $interface->assign('errorMessage', 'Sorry, you must be logged in to view this title.');
             $errorOccurred = true;
             $interface->assign('showLogin', true);
         } else {
             if (!$recordDriver->isCheckedOut($itemId)) {
                 $interface->assign('errorMessage', "You must checkout this title before you view it, please <a href='{$configArray['Site']['path']}/PublicEContent/{$id}/Checkout'>click here</a> to checkout the title.");
                 $errorOccurred = true;
                 $interface->assign('showLogin', false);
             } else {
                 require_once ROOT_DIR . '/sys/eContent/EContentRecord.php';
                 $filename = $_REQUEST['file'];
                 $bookFile = $configArray['EContent']['library'] . '/' . $filename;
                 if (file_exists($bookFile)) {
                     //Check the database to see if there is an existing title
                     $fileExtension = '';
                     if (strpos($bookFile, '.') !== FALSE) {
                         $fileExtension = substr($bookFile, strrpos($bookFile, '.') + 1);
                     }
                     //Record that the title is being viewed.
                     require_once ROOT_DIR . '/sys/eContent/EContentHistoryEntry.php';
                     $entry = new EContentHistoryEntry();
                     $entry->userId = $user->id;
                     $entry->recordId = $id;
                     $entry->itemId = $itemId;
                     $entry->action = 'Read Online';
                     //Open date will be filled out automatically.
                     $entry->insert();
                     if ($fileExtension == 'epub') {
                         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();
                             $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;
                         }
                     } elseif ($fileExtension == 'txt') {
                         header("Content-Type: text/plain;\n");
                         header('Content-Length: ' . filesize($bookFile));
                         readfile($bookFile);
                         exit;
                     } elseif (is_dir($bookFile)) {
                         //A folder of mp3 files?
                         //Display information so patron can listen to the recording.
                         //Table of contents is based on the actual files uploaded.
                         $isAudio = true;
                         $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 that title in our online library.');
                 }
             }
             $interface->assign('errorOccurred', $errorOccurred);
             if ($isAudio) {
                 $interface->display('EcontentRecord/viewer-mp3.tpl');
             } else {
                 $interface->display('EcontentRecord/viewer-custom.tpl');
             }
         }
     }
 }
コード例 #3
0
								</div>
							</div>
						</div>
					</header>
					<section class="clearfix mb_80">
						<div class="readerBlock">
							<div class="container1160 readOnlineTextContainer">
								<table id="read-online-table" class="read-online-table">
									<tr>
										<td class="read-online-table-left">
											<div id="info-part-container">
												<div id="info-part">
													<div class="book-head">
														<span class="book-title">
															<?php 
            $authors = $ebook->getDcCreator();
            if (is_array($authors)) {
                $author = implode(array_map(function ($author) {
                    return $author->post_title;
                }, $authors));
            } else {
                $author = $authors;
            }
            echo $author;
            ?>
														</span>
														<span class="book-description">
															<?php 
            echo $ebook->getDcTitle();
            ?>
														</span>