27 $this->installFileDirs = array(
51 $newContext = $args[0];
52 $currentContext = $args[1];
58 if ($newContext->getData(
'enabled') !== $currentContext->getData(
'enabled')) {
59 import(
'classes.publicationFormat.PublicationFormatTombstoneManager');
60 $publicationFormatTombstoneMgr = new \PublicationFormatTombstoneManager();
61 if ($newContext->getData(
'enabled')) {
62 $publicationFormatTombstoneMgr->deleteTombstonesByPressId($newContext->getId());
64 $publicationFormatTombstoneMgr->insertTombstonesByPress($newContext);
69 if (($newContext->getData(
'coverThumbnailsMaxWidth') !== $currentContext->getData(
'coverThumbnailsMaxWidth'))
70 || ($newContext->getData(
'coverThumbnailsMaxHeight') !== $currentContext->getData(
'coverThumbnailsMaxHeight'))) {
71 $this->
resizeCoverThumbnails($newContext, $newContext->getData(
'coverThumbnailsMaxWidth'), $newContext->getData(
'coverThumbnailsMaxHeight'));
75 if (!empty($params[
'pressThumbnail'])) {
76 $supportedLocales = $newContext->getSupportedFormLocales();
77 foreach ($supportedLocales as $localeKey) {
78 if (!array_key_exists($localeKey, $params[
'pressThumbnail'])) {
83 $params[
'pressThumbnail'][$localeKey],
85 $request->getUser()->getId(),
89 $newContext->setData(
'pressThumbnail', $localeValue, $localeKey);
111 import(
'classes.publicationFormat.PublicationFormatTombstoneManager');
112 $publicationFormatTombstoneMgr = new \PublicationFormatTombstoneManager();
113 $publicationFormatTombstoneMgr->insertTombstonesByPress($context);
129 $seriesDao->deleteByPressId($context->getId());
132 $submissionDao->deleteByContextId($context->getId());
135 $featureDao->deleteByAssoc(ASSOC_TYPE_PRESS, $context->getId());
138 $newReleaseDao->deleteByAssoc(ASSOC_TYPE_PRESS, $context->getId());
140 import(
'classes.file.PublicFileManager');
141 $publicFileManager = new \PublicFileManager();
142 $publicFileManager->rmtree($publicFileManager->getContextFilesPath($context->getId()));
158 if (!empty($props[
'codeType'])) {
159 if (!\
DAORegistry::getDAO(
'ONIXCodelistItemDAO')->codeExistsInList($props[
'codeType'],
'List44')) {
160 $errors[
'codeType'] = [__(
'manager.settings.publisherCodeType.invalid')];
176 import(
'lib.pkp.classes.file.FileManager');
177 import(
'classes.file.PublicFileManager');
178 import(
'lib.pkp.classes.file.ContextFileManager');
179 $fileManager = new \FileManager();
180 $publicFileManager = new \PublicFileManager();
181 $contextFileManager = new \ContextFileManager($context->getId());
188 foreach ($objectDaos as $objectDao) {
189 $objects = $objectDao->getByContextId($context->getId());
190 while ($object = $objects->next()) {
191 if (is_a($object,
'Submission')) {
192 foreach ($object->getData(
'publications') as $publication) {
193 foreach ((array) $publication->getData(
'coverImage') as $coverImage) {
194 $coverImageFilePath = $publicFileManager->getContextFilesPath($context->getId()) .
'/' . $coverImage[
'uploadName'];
197 Services::get(
'publication')->getThumbnailFileName($coverImage[
'uploadName']),
204 $cover = $object->getImage();
205 if (is_a($object,
'Series')) {
206 $basePath = $contextFileManager->getBasePath() .
'series/';
207 } elseif (is_a($object,
'Category')) {
208 $basePath = $contextFileManager->getBasePath() .
'categories/';
213 $fileManager->deleteByPath($basePath . $cover[
'thumbnailName']);
216 $coverExtension = $fileManager->getExtension($cover[
'name']);
217 $xRatio = min(1, $maxWidth / $cover[
'width']);
218 $yRatio = min(1, $maxHeight / $cover[
'height']);
219 $ratio = min($xRatio, $yRatio);
220 $thumbnailWidth = round($ratio * $cover[
'width']);
221 $thumbnailHeight = round($ratio * $cover[
'height']);
224 $thumbnail = imagecreatetruecolor($thumbnailWidth, $thumbnailHeight);
227 switch ($coverExtension) {
228 case 'jpg': $coverImage = imagecreatefromjpeg($basePath . $cover[
'name']);
break;
229 case 'png': $coverImage = imagecreatefrompng($basePath . $cover[
'name']);
break;
230 case 'gif': $coverImage = imagecreatefromgif($basePath . $cover[
'name']);
break;
231 default: $coverImage =
null;
236 imagecopyresampled($thumbnail, $coverImage, 0, 0, 0, 0, $thumbnailWidth, $thumbnailHeight, $cover[
'width'], $cover[
'height']);
239 switch ($coverExtension) {
240 case 'jpg': imagejpeg($thumbnail, $basePath . $cover[
'thumbnailName']);
break;
241 case 'png': imagepng($thumbnail, $basePath . $cover[
'thumbnailName']);
break;
242 case 'gif': imagegif($thumbnail, $basePath . $cover[
'thumbnailName']);
break;
245 imagedestroy($thumbnail);
246 if (is_a($object,
'Submission')) {
247 $object->setCoverImage(array(
248 'name' => $cover[
'name'],
249 'width' => $cover[
'width'],
250 'height' => $cover[
'height'],
251 'thumbnailName' => $cover[
'thumbnailName'],
252 'thumbnailWidth' => $thumbnailWidth,
253 'thumbnailHeight' => $thumbnailHeight,
254 'uploadName' => $cover[
'uploadName'],
255 'dateUploaded' => $cover[
'dateUploaded'],
258 $object->setImage(array(
259 'name' => $cover[
'name'],
260 'width' => $cover[
'width'],
261 'height' => $cover[
'height'],
262 'thumbnailName' => $cover[
'thumbnailName'],
263 'thumbnailWidth' => $thumbnailWidth,
264 'thumbnailHeight' => $thumbnailHeight,
265 'uploadName' => $cover[
'uploadName'],
266 'dateUploaded' => $cover[
'dateUploaded'],
270 $objectDao->updateObject($object);