Skip to content

Commit

Permalink
update path for cover image and PDF files
Browse files Browse the repository at this point in the history
  • Loading branch information
Godoy0722 committed Jul 3, 2024
1 parent 6738cc9 commit e798a7a
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions plugins/importexport/csv/CSVImportExportPlugin.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -277,9 +277,11 @@ function executeCLI($scriptName, &$args) {
import('lib.pkp.classes.file.TemporaryFileManager');
import('lib.pkp.classes.file.FileManager');
import('lib.pkp.classes.core.Core');
import('classes.file.PublicFileManager');

// Submission File.
$fileManager = new FileManager();
$publicFileManager = new PublicFileManager();
$extension = $fileManager->parseFileExtension($pdfUrl);
$dirNames = Application::getFileDirectories();
$submissionDir = sprintf(
Expand All @@ -290,7 +292,8 @@ function executeCLI($scriptName, &$args) {
$submissionId
);

$filePath = getcwd() . '/plugins/importexport/csv/submissionPdfs/' . $pdfUrl;
$publicFilesDir = Config::getVar('files', 'public_files_dir');
$filePath = $publicFilesDir . '/importexport/csv/submissionPdfs/' . $pdfUrl;

if (!file_exists($filePath) || !is_readable($filePath)) {
echo __('plugins.importexport.csv.invalidPdfFilename', ['title' => $title]) . "\n";
Expand Down Expand Up @@ -359,7 +362,7 @@ function executeCLI($scriptName, &$args) {
$coverImage['uploadName'] = uniqid() . '-' . $sanitizedCoverImageName;
$coverImage['altText'] = $bookCoverImageAltText ?? '';

$srcFilePath = getcwd() . '/plugins/importexport/csv/coverImages/' . $bookCoverImageName;
$srcFilePath = $publicFilesDir . '/importexport/csv/coverImages/' . $bookCoverImageName;

if (!file_exists($srcFilePath) || !is_readable($srcFilePath)) {
echo __('plugins.importexport.csv.invalidCoverImageFilename', ['title' => $title]) . "\n";
Expand All @@ -368,11 +371,7 @@ function executeCLI($scriptName, &$args) {

$coverImageData = file_get_contents($srcFilePath);
$coverImageBase64 = base64_encode($coverImageData);

import('classes.file.PublicFileManager');
$publicFileManager = new PublicFileManager();
$destFilePath = $publicFileManager->getContextFilesPath($press->getId()) . '/' . $coverImage['uploadName'];

file_put_contents($destFilePath, base64_decode($coverImageBase64));

Services::get('publication')->makeThumbnail(
Expand Down

0 comments on commit e798a7a

Please sign in to comment.