We are moving to Git Issues for bug tracking in future releases. During transition, content will be in both tools. If you'd like to file a new bug, please create an issue.

View | Details | Raw Unified | Return to bug 6689 | Differences between
and this patch

Collapse All | Expand All

(-)a/classes/submission/form/MetadataForm.inc.php (-4 / +28 lines)
 Lines 15-20    Link Here 
15
15
16
import('lib.pkp.classes.form.Form');
16
import('lib.pkp.classes.form.Form');
17
17
18
define('COVER_PAGE_IMAGE_NAME', 'coverPage');
19
18
class MetadataForm extends Form {
20
class MetadataForm extends Form {
19
	/** @var Article current article */
21
	/** @var Article current article */
20
	var $article;
22
	var $article;
 Lines 257-262   class MetadataForm extends Form { Link Here 
257
	}
259
	}
258
260
259
	/**
261
	/**
262
	 * Check to ensure that the form is correctly validated.
263
	 */
264
	function validate() {
265
		// Verify that an image cover, if supplied, is actually an image.
266
		import('classes.file.PublicFileManager');
267
		$publicFileManager = new PublicFileManager();
268
		if ($publicFileManager->uploadedFileExists(COVER_PAGE_IMAGE_NAME)) {
269
			$type = $publicFileManager->getUploadedFileType(COVER_PAGE_IMAGE_NAME);
270
			$extension = $publicFileManager->getImageExtension($type);
271
			if (!$extension) {
272
				// Not a valid image.
273
				$this->addError('imageFile', Locale::translate('submission.layout.imageInvalid'));
274
				return false;
275
			}
276
		}
277
278
		// Fall back on parent validation
279
		return parent::validate();
280
	}
281
282
283
	/**
260
	 * Save changes to article.
284
	 * Save changes to article.
261
	 * @param $request PKPRequest
285
	 * @param $request PKPRequest
262
	 * @return int the article ID
286
	 * @return int the article ID
 Lines 279-289   class MetadataForm extends Form { Link Here 
279
303
280
		import('classes.file.PublicFileManager');
304
		import('classes.file.PublicFileManager');
281
		$publicFileManager = new PublicFileManager();
305
		$publicFileManager = new PublicFileManager();
282
		if ($publicFileManager->uploadedFileExists('coverPage')) {
306
		if ($publicFileManager->uploadedFileExists(COVER_PAGE_IMAGE_NAME)) {
283
			$journal = Request::getJournal();
307
			$journal = Request::getJournal();
284
			$originalFileName = $publicFileManager->getUploadedFileName('coverPage');
308
			$originalFileName = $publicFileManager->getUploadedFileName(COVER_PAGE_IMAGE_NAME);
285
			$newFileName = 'cover_article_' . $this->getData('articleId') . '_' . $this->getFormLocale() . '.' . $publicFileManager->getExtension($originalFileName);
309
			$newFileName = 'cover_article_' . $this->article->getId() . '_' . $this->getFormLocale() . '.' . $publicFileManager->getExtension($originalFileName);
286
			$publicFileManager->uploadJournalFile($journal->getId(), 'coverPage', $newFileName);
310
			$publicFileManager->uploadJournalFile($journal->getId(), COVER_PAGE_IMAGE_NAME, $newFileName);
287
			$article->setOriginalFileName($publicFileManager->truncateFileName($originalFileName, 127), $this->getFormLocale());
311
			$article->setOriginalFileName($publicFileManager->truncateFileName($originalFileName, 127), $this->getFormLocale());
288
			$article->setFileName($newFileName, $this->getFormLocale());
312
			$article->setFileName($newFileName, $this->getFormLocale());
289
313

Return to bug 6689