00001 <?php
00002
00015 import('lib.pkp.classes.handler.PKPHandler');
00016
00017 class CoverHandler extends PKPHandler {
00019 var $_press;
00020
00022 var $monographId;
00023
00027 function CoverHandler() {
00028 parent::PKPHandler();
00029 }
00030
00037 function authorize(&$request, $args, $roleAssignments) {
00038 import('classes.security.authorization.OmpPublishedMonographAccessPolicy');
00039 $this->addPolicy(new OmpPublishedMonographAccessPolicy($request, $args, $roleAssignments));
00040 return parent::authorize($request, $args, $roleAssignments);
00041 }
00042
00047 function setMonographId($monographId) {
00048 $this->monographId = $monographId;
00049 }
00050
00055 function getMonographId() {
00056 return $this->monographId;
00057 }
00058
00063 function setPress(&$press) {
00064 $this->_press =& $press;
00065 }
00066
00071 function &getPress() {
00072 return $this->_press;
00073 }
00074
00078 function cover($args, &$request) {
00079 $publishedMonograph =& $this->getAuthorizedContextObject(ASSOC_TYPE_PUBLISHED_MONOGRAPH);
00080 if (!$coverImage = $publishedMonograph->getCoverImage()) {
00081
00082
00083 header('Location: ' . $request->getBaseUrl() . '/templates/images/book-default.png');
00084 exit;
00085 }
00086
00087 import('file.SimpleMonographFileManager');
00088 $simpleMonographFileManager = new SimpleMonographFileManager($publishedMonograph->getPressId(), $publishedMonograph->getId());
00089 $simpleMonographFileManager->downloadFile($simpleMonographFileManager->getBasePath() . $coverImage['name'], null, true);
00090 }
00091
00095 function thumbnail($args, &$request) {
00096 $publishedMonograph =& $this->getAuthorizedContextObject(ASSOC_TYPE_PUBLISHED_MONOGRAPH);
00097 if (!$coverImage = $publishedMonograph->getCoverImage()) {
00098
00099
00100 header('Location: ' . $request->getBaseUrl() . '/templates/images/book-default-small.png');
00101 exit;
00102 }
00103
00104 import('file.SimpleMonographFileManager');
00105 $simpleMonographFileManager = new SimpleMonographFileManager($publishedMonograph->getPressId(), $publishedMonograph->getId());
00106 $simpleMonographFileManager->downloadFile($simpleMonographFileManager->getBasePath() . $coverImage['thumbnailName'], null, true);
00107 }
00108
00112 function catalog($args, &$request) {
00113 $publishedMonograph =& $this->getAuthorizedContextObject(ASSOC_TYPE_PUBLISHED_MONOGRAPH);
00114 if (!$coverImage = $publishedMonograph->getCoverImage()) {
00115
00116
00117 header('Location: ' . $request->getBaseUrl() . '/templates/images/book-default.png');
00118 exit;
00119 }
00120
00121 import('file.SimpleMonographFileManager');
00122 $simpleMonographFileManager = new SimpleMonographFileManager($publishedMonograph->getPressId(), $publishedMonograph->getId());
00123 $simpleMonographFileManager->downloadFile($simpleMonographFileManager->getBasePath() . $coverImage['catalogName'], null, true);
00124 }
00125 }
00126
00127 ?>