Skip to content

Commit

Permalink
pkp/pkp-lib#1536 Fix issue cover image upload
Browse files Browse the repository at this point in the history
This commit removes the issue cover form and moves the
cover image upload field to the general issue form. It
also removes the issue-specific stylesheet upload
field, and removes a bunch of unused code around the
cover image display logic. It also removes the cover
image caption field, instead relying on the issue
description. Finally, it renames references to the
issue coverPage to coverImage in order to be more
explicit about this being an issue image rather than
a display page. Similar changes will need to be done
for the article cover image in a future commit
  • Loading branch information
NateWr committed Aug 11, 2016
1 parent e6f9084 commit d6974c1
Show file tree
Hide file tree
Showing 19 changed files with 166 additions and 621 deletions.
72 changes: 37 additions & 35 deletions classes/controllers/grid/issues/IssueGridHandler.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,7 @@ function IssueGridHandler() {
array(
'fetchGrid', 'fetchRow',
'addIssue', 'editIssue', 'editIssueData', 'updateIssue',
'uploadFile',
'editCover', 'updateCover',
'uploadFile', 'deleteCoverImage',
'issueToc',
'issueGalleys',
'deleteIssue', 'publishIssue', 'unpublishIssue',
Expand Down Expand Up @@ -184,59 +183,62 @@ function uploadFile($args, $request) {
}

/**
* Update a issue
* Delete an uploaded cover image.
* @param $args array
* `coverImage` string Filename of the cover image to be deleted.
* `issue` int Id of the issue this cover image is attached to
* @param $request PKPRequest
* @return JSONMessage JSON object
*/
function updateIssue($args, $request) {
$issue = $this->getAuthorizedContextObject(ASSOC_TYPE_ISSUE);
function deleteCoverImage($args, $request) {
assert(!empty($args['coverImage']) && !empty($args['issue']));

import('controllers.grid.issues.form.IssueForm');
$issueForm = new IssueForm($issue);
$issueForm->readInputData();
// Check if the passed filename matches the filename for this issue's
// cover page.
$issueDao = DAORegistry::getDAO('IssueDAO');
$issue = $issueDao->getById((int) $args['issue']);
if ($args['coverImage'] != $issue->getLocalizedCoverImage()) {
return new JSONMessage(false, __('editor.issues.removeCoverImageFileNameMismatch'));
}

if ($issueForm->validate($request)) {
$issueId = $issueForm->execute($request);
return DAO::getDataChangedEvent($issueId);
$file = $args['coverImage'];

// Remove cover image and alt text from issue settings
$locale = AppLocale::getLocale();
$issue->setCoverImage('', $locale);
$issue->setCoverImageAltText('', $locale);
$issueDao->updateObject($issue);

// Remove the file
$publicFileManager = new PublicFileManager();
if ($publicFileManager->removeJournalFile($issue->getJournalId(), $file)) {
$json = new JSONMessage(true);
$json->setEvent('fileDeleted');
return $json;
} else {
return new JSONMessage(true, $issueForm->fetch($request));
return new JSONMessage(false, __('editor.issues.removeCoverImageFileNotFound'));
}
}

/**
* An action to edit a issue's cover
* @param $args array
* @param $request PKPRequest
* @return JSONMessage JSON object
*/
function editCover($args, $request) {
$issue = $this->getAuthorizedContextObject(ASSOC_TYPE_ISSUE);

import('controllers.grid.issues.form.CoverForm');
$coverForm = new CoverForm($issue);
$coverForm->initData($request);
return new JSONMessage(true, $coverForm->fetch($request));
}

/**
* Update an issue cover
* Update a issue
* @param $args array
* @param $request PKPRequest
* @return JSONMessage JSON object
*/
function updateCover($args, $request) {
function updateIssue($args, $request) {
$issue = $this->getAuthorizedContextObject(ASSOC_TYPE_ISSUE);

import('controllers.grid.issues.form.CoverForm');
$coverForm = new CoverForm($issue);
$coverForm->readInputData();
import('controllers.grid.issues.form.IssueForm');
$issueForm = new IssueForm($issue);
$issueForm->readInputData();

if ($coverForm->validate($request)) {
$coverForm->execute($request);
return DAO::getDataChangedEvent($issue->getId());
if ($issueForm->validate($request)) {
$issueId = $issueForm->execute($request);
return DAO::getDataChangedEvent($issueId);
} else {
return new JSONMessage(false);
return new JSONMessage(true, $issueForm->fetch($request));
}
}

Expand Down
228 changes: 15 additions & 213 deletions classes/issue/Issue.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -348,250 +348,52 @@ function setShowTitle($showTitle) {
* Get the localized issue cover filename
* @return string
*/
function getLocalizedFileName() {
return $this->getLocalizedData('fileName');
function getLocalizedCoverImage() {
return $this->getLocalizedData('coverImage');
}

/**
* Get issue cover image file name
* @param $locale string
* @return string
*/
function getFileName($locale) {
return $this->getData('fileName', $locale);
function getCoverImage($locale) {
return $this->getData('coverImage', $locale);
}

/**
* set file name
* @param $fileName string
* Set issue cover image file name
* @param $coverImage string
* @param $locale string
*/
function setFileName($fileName, $locale) {
return $this->setData('fileName', $fileName, $locale);
}

/**
* Get the localized issue cover width
* @return string
*/
function getLocalizedWidth() {
return $this->getLocalizedData('width');
}

/**
* get width of cover page image
* @param $locale string
* @return string
*/
function getWidth($locale) {
return $this->getData('width', $locale);
}

/**
* set width of cover page image
* @param $locale string
* @param $width int
*/
function setWidth($width, $locale) {
return $this->setData('width', $width, $locale);
}

/**
* Get the localized issue cover height
* @return string
*/
function getLocalizedHeight() {
return $this->getLocalizedData('height');
}

/**
* get height of cover page image
* @param $locale string
* @return string
*/
function getHeight($locale) {
return $this->getData('height', $locale);
}

/**
* set height of cover page image
* @param $locale string
* @param $height int
*/
function setHeight($height, $locale) {
return $this->setData('height', $height, $locale);
}

/**
* Get the localized issue cover filename on the uploader's computer
* @return string
*/
function getLocalizedOriginalFileName() {
return $this->getLocalizedData('originalFileName');
}

/**
* Get original issue cover image file name
* @param $locale string
* @return string
*/
function getOriginalFileName($locale) {
return $this->getData('originalFileName', $locale);
}

/**
* set original file name
* @param $originalFileName string
* @param $locale string
*/
function setOriginalFileName($originalFileName, $locale) {
return $this->setData('originalFileName', $originalFileName, $locale);
function setCoverImage($coverImage, $locale) {
return $this->setData('coverImage', $coverImage, $locale);
}

/**
* Get the localized issue cover alternate text
* @return string
*/
function getLocalizedCoverPageAltText() {
return $this->getLocalizedData('coverPageAltText');
function getLocalizedCoverImageAltText() {
return $this->getLocalizedData('coverImageAltText');
}

/**
* Get issue cover image alternate text
* @param $locale string
* @return string
*/
function getCoverPageAltText($locale) {
return $this->getData('coverPageAltText', $locale);
function getCoverImageAltText($locale) {
return $this->getData('coverImageAltText', $locale);
}

/**
* Set issue cover image alternate text
* @param $coverPageAltText string
* @param $locale string
*/
function setCoverPageAltText($coverPageAltText, $locale) {
return $this->setData('coverPageAltText', $coverPageAltText, $locale);
}

/**
* Get the localized issue cover description
* @return string
*/
function getLocalizedCoverPageDescription() {
return $this->getLocalizedData('coverPageDescription');
}

/**
* get cover page description
* @param $locale string
* @return string
*/
function getCoverPageDescription($locale) {
return $this->getData('coverPageDescription', $locale);
}

/**
* set cover page description
* @param $coverPageDescription string
* @param $locale string
*/
function setCoverPageDescription($coverPageDescription, $locale) {
return $this->setData('coverPageDescription', $coverPageDescription, $locale);
}

/**
* Get the localized issue cover enable/disable flag
* @return string
*/
function getLocalizedShowCoverPage() {
return $this->getLocalizedData('showCoverPage');
}

/**
* Get show issue cover image flag
* @param $locale string
* @return int
*/
function getShowCoverPage($locale) {
return $this->getData('showCoverPage', $locale);
}

/**
* Set show issue cover image flag
* @param $showCoverPage int
* @param $locale string
*/
function setShowCoverPage($showCoverPage, $locale) {
return $this->setData('showCoverPage', $showCoverPage, $locale);
}

/**
* get hide cover page in archives
* @param $locale string
* @return int
*/
function getHideCoverPageArchives($locale) {
return $this->getData('hideCoverPageArchives', $locale);
}

/**
* set hide cover page in archives
* @param $hideCoverPageArchives int
* @param $locale string
*/
function setHideCoverPageArchives($hideCoverPageArchives, $locale) {
return $this->setData('hideCoverPageArchives', $hideCoverPageArchives, $locale);
}

/**
* get hide cover page prior to ToC
* @param $coverImageAltText string
* @param $locale string
* @return int
*/
function getHideCoverPageCover($locale) {
return $this->getData('hideCoverPageCover', $locale);
}

/**
* set hide cover page prior to ToC
* @param $hideCoverPageCover int
* @param $locale string
*/
function setHideCoverPageCover($hideCoverPageCover, $locale) {
return $this->setData('hideCoverPageCover', $hideCoverPageCover, $locale);
}

/**
* get style file name
* @return string
*/
function getStyleFileName() {
return $this->getData('styleFileName');
}

/**
* set style file name
* @param $styleFileName string
*/
function setStyleFileName($styleFileName) {
return $this->setData('styleFileName', $styleFileName);
}

/**
* get original style file name
* @return string
*/
function getOriginalStyleFileName() {
return $this->getData('originalStyleFileName');
}

/**
* set original style file name
* @param $originalStyleFileName string
*/
function setOriginalStyleFileName($originalStyleFileName) {
return $this->setData('originalStyleFileName', $originalStyleFileName);
function setCoverImageAltText($coverImageAltText, $locale) {
return $this->setData('coverImageAltText', $coverImageAltText, $locale);
}

/**
Expand Down
Loading

0 comments on commit d6974c1

Please sign in to comment.