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

(-)ojs-2.2.4/classes/submission/form/MetadataForm.inc.php (-4 / +28 lines)
 Lines 17-22    Link Here 
17
17
18
import('form.Form');
18
import('form.Form');
19
19
20
define('COVER_PAGE_IMAGE_NAME', 'coverPage');
21
20
class MetadataForm extends Form {
22
class MetadataForm extends Form {
21
	/** @var Article current article */
23
	/** @var Article current article */
22
	var $article;
24
	var $article;
 Lines 234-239    Link Here 
234
	}
236
	}
235
237
236
	/**
238
	/**
239
	 * Check to ensure that the form is correctly validated.
240
	 */
241
	function validate() {
242
		// Verify that an image cover, if supplied, is actually an image.
243
		import('classes.file.PublicFileManager');
244
		$publicFileManager = new PublicFileManager();
245
		if ($publicFileManager->uploadedFileExists(COVER_PAGE_IMAGE_NAME)) {
246
			$type = $publicFileManager->getUploadedFileType(COVER_PAGE_IMAGE_NAME);
247
			$extension = $publicFileManager->getImageExtension($type);
248
			if (!$extension) {
249
				// Not a valid image.
250
				$this->addError('imageFile', Locale::translate('submission.layout.imageInvalid'));
251
				return false;
252
			}
253
		}
254
255
		// Fall back on parent validation
256
		return parent::validate();
257
	}
258
259
260
	/**
237
	 * Save changes to article.
261
	 * Save changes to article.
238
	 * @return int the article ID
262
	 * @return int the article ID
239
	 */
263
	 */
 Lines 252-262    Link Here 
252
276
253
		import('file.PublicFileManager');
277
		import('file.PublicFileManager');
254
		$publicFileManager =& new PublicFileManager();
278
		$publicFileManager =& new PublicFileManager();
255
		if ($publicFileManager->uploadedFileExists('coverPage')) {
279
		if ($publicFileManager->uploadedFileExists(COVER_PAGE_IMAGE_NAME)) {
256
			$journal = Request::getJournal();
280
			$journal = Request::getJournal();
257
			$originalFileName = $publicFileManager->getUploadedFileName('coverPage');
281
			$originalFileName = $publicFileManager->getUploadedFileName(COVER_PAGE_IMAGE_NAME);
258
			$newFileName = 'cover_article_' . $this->getData('articleId') . '_' . $this->getFormLocale() . '.' . $publicFileManager->getExtension($originalFileName);
282
			$newFileName = 'cover_article_' . $this->article->getArticleId() . '_' . $this->getFormLocale() . '.' . $publicFileManager->getExtension($originalFileName);
259
			$publicFileManager->uploadJournalFile($journal->getJournalId(), 'coverPage', $newFileName);
283
			$publicFileManager->uploadJournalFile($journal->getJournalId(), COVER_PAGE_IMAGE_NAME, $newFileName);
260
			$article->setOriginalFileName($publicFileManager->truncateFileName($originalFileName, 127), $this->getFormLocale());
284
			$article->setOriginalFileName($publicFileManager->truncateFileName($originalFileName, 127), $this->getFormLocale());
261
			$article->setFileName($newFileName, $this->getFormLocale());
285
			$article->setFileName($newFileName, $this->getFormLocale());
262
286

Return to bug 6689