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

Collapse All | Expand All

(-)ojs-2.3.0/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 238-243    Link Here 
238
	}
240
	}
239
241
240
	/**
242
	/**
243
	 * Check to ensure that the form is correctly validated.
244
	 */
245
	function validate() {
246
		// Verify that an image cover, if supplied, is actually an image.
247
		import('classes.file.PublicFileManager');
248
		$publicFileManager = new PublicFileManager();
249
		if ($publicFileManager->uploadedFileExists(COVER_PAGE_IMAGE_NAME)) {
250
			$type = $publicFileManager->getUploadedFileType(COVER_PAGE_IMAGE_NAME);
251
			$extension = $publicFileManager->getImageExtension($type);
252
			if (!$extension) {
253
				// Not a valid image.
254
				$this->addError('imageFile', Locale::translate('submission.layout.imageInvalid'));
255
				return false;
256
			}
257
		}
258
259
		// Fall back on parent validation
260
		return parent::validate();
261
	}
262
263
264
	/**
241
	 * Save changes to article.
265
	 * Save changes to article.
242
	 * @return int the article ID
266
	 * @return int the article ID
243
	 */
267
	 */
 Lines 256-266    Link Here 
256
280
257
		import('file.PublicFileManager');
281
		import('file.PublicFileManager');
258
		$publicFileManager = new PublicFileManager();
282
		$publicFileManager = new PublicFileManager();
259
		if ($publicFileManager->uploadedFileExists('coverPage')) {
283
		if ($publicFileManager->uploadedFileExists(COVER_PAGE_IMAGE_NAME)) {
260
			$journal = Request::getJournal();
284
			$journal = Request::getJournal();
261
			$originalFileName = $publicFileManager->getUploadedFileName('coverPage');
285
			$originalFileName = $publicFileManager->getUploadedFileName(COVER_PAGE_IMAGE_NAME);
262
			$newFileName = 'cover_article_' . $this->getData('articleId') . '_' . $this->getFormLocale() . '.' . $publicFileManager->getExtension($originalFileName);
286
			$newFileName = 'cover_article_' . $this->article->getArticleId() . '_' . $this->getFormLocale() . '.' . $publicFileManager->getExtension($originalFileName);
263
			$publicFileManager->uploadJournalFile($journal->getJournalId(), 'coverPage', $newFileName);
287
			$publicFileManager->uploadJournalFile($journal->getJournalId(), COVER_PAGE_IMAGE_NAME, $newFileName);
264
			$article->setOriginalFileName($publicFileManager->truncateFileName($originalFileName, 127), $this->getFormLocale());
288
			$article->setOriginalFileName($publicFileManager->truncateFileName($originalFileName, 127), $this->getFormLocale());
265
			$article->setFileName($newFileName, $this->getFormLocale());
289
			$article->setFileName($newFileName, $this->getFormLocale());
266
290

Return to bug 6689