first commit

This commit is contained in:
CHIEFSOFT\ameye
2024-06-08 17:09:23 -04:00
commit df3a033196
17887 changed files with 8637778 additions and 0 deletions
@@ -0,0 +1,65 @@
<?php
/**
* @file controllers/grid/files/fileList/FileGenreGridColumn.php
*
* Copyright (c) 2014-2021 Simon Fraser University
* Copyright (c) 2000-2021 John Willinsky
* Distributed under the GNU GPL v3. For full terms see the file docs/COPYING.
*
* @class FileGenreGridColumn
*
* @ingroup controllers_grid_files_fileList
*
* @brief Implements a file name column.
*/
namespace PKP\controllers\grid\files\fileList;
use PKP\controllers\grid\ColumnBasedGridCellProvider;
use PKP\controllers\grid\GridColumn;
use PKP\db\DAORegistry;
use PKP\submission\GenreDAO;
use PKP\submissionFile\SubmissionFile;
class FileGenreGridColumn extends GridColumn
{
/**
* Constructor
*/
public function __construct()
{
$cellProvider = new ColumnBasedGridCellProvider();
parent::__construct('type', 'common.component', null, null, $cellProvider);
}
//
// Public methods
//
/**
* Method expected by ColumnBasedGridCellProvider
* to render a cell in this column.
*
* @see ColumnBasedGridCellProvider::getTemplateVarsFromRowColumn()
*/
public function getTemplateVarsFromRow($row)
{
// Retrieve the submission file.
$submissionFileData = & $row->getData();
assert(isset($submissionFileData['submissionFile']));
$submissionFile = & $submissionFileData['submissionFile']; /** @var SubmissionFile $submissionFile */
assert(is_a($submissionFile, 'SubmissionFile'));
// Retrieve the genre label for the submission file.
$genreDao = DAORegistry::getDAO('GenreDAO'); /** @var GenreDAO $genreDao */
$genre = $genreDao->getById($submissionFile->getGenreId());
// If no label exists (e.g. for review attachments)
if (!$genre) {
return ['label' => null];
}
// Otherwise, the label exists.
return ['label' => $genre->getLocalizedName()];
}
}
@@ -0,0 +1,49 @@
<?php
/**
* @defgroup controllers_grid_files_fileList File List Grid
*/
/**
* @file controllers/grid/files/fileList/FileListGridHandler.php
*
* Copyright (c) 2014-2021 Simon Fraser University
* Copyright (c) 2003-2021 John Willinsky
* Distributed under the GNU GPL v3. For full terms see the file docs/COPYING.
*
* @class FileListGridHandler
*
* @ingroup controllers_grid_files_fileList
*
* @brief Base grid for simple file lists. This grid shows the file type in
* addition to the file name.
*/
namespace PKP\controllers\grid\files\fileList;
use PKP\controllers\grid\files\SubmissionFilesGridHandler;
class FileListGridHandler extends SubmissionFilesGridHandler
{
//
// Extended methods from SubmissionFilesGridHandler.
//
/**
* @copydoc SubmissionFilesGridHandler::initialize()
*
* @param null|mixed $args
*/
public function initialize($request, $args = null)
{
parent::initialize($request, $args);
// Add the "manage files" action if required.
$capabilities = $this->getCapabilities();
if ($capabilities->canManage()) {
$dataProvider = $this->getDataProvider();
$this->addAction($dataProvider->getSelectAction($request));
}
// The file list grid layout has an additional file genre column.
$this->addColumn(new FileGenreGridColumn());
}
}
@@ -0,0 +1,55 @@
<?php
/**
* @file controllers/grid/files/fileList/SelectableFileListGridHandler.php
*
* Copyright (c) 2014-2021 Simon Fraser University
* Copyright (c) 2003-2021 John Willinsky
* Distributed under the GNU GPL v3. For full terms see the file docs/COPYING.
*
* @class SelectableFileListGridHandler
*
* @ingroup controllers_grid_files_fileList
*
* @brief Base grid for selectable file lists. The grid use the SelectableItemFeature
* to show a check box for each row so that the user can make a selection
* among grid entries.
*/
namespace PKP\controllers\grid\files\fileList;
use PKP\controllers\grid\feature\selectableItems\SelectableItemsFeature;
class SelectableFileListGridHandler extends FileListGridHandler
{
//
// Overriden methods from GridHandler.
//
/**
* @copydoc GridHandler::initFeatures()
*/
public function initFeatures($request, $args)
{
return [new SelectableItemsFeature()];
}
//
// Implemented methods from GridHandler.
//
/**
* @copydoc GridHandler::isDataElementSelected()
*/
public function isDataElementSelected($gridDataElement)
{
$file = $gridDataElement['submissionFile'];
return $file->getViewable();
}
/**
* @copydoc GridHandler::getSelectName()
*/
public function getSelectName()
{
return 'selectedFiles';
}
}
@@ -0,0 +1,46 @@
<?php
/**
* @defgroup controllers_grid_files_fileList_linkAction File List Link Actions
*/
/**
* @file controllers/grid/files/fileList/linkAction/DownloadAllLinkAction.php
*
* Copyright (c) 2014-2021 Simon Fraser University
* Copyright (c) 2003-2021 John Willinsky
* Distributed under the GNU GPL v3. For full terms see the file docs/COPYING.
*
* @class DownloadAllLinkAction
*
* @ingroup controllers_grid_files_fileList_linkAction
*
* @brief An action to download all files in a submission file grid.
*/
namespace PKP\controllers\grid\files\fileList\linkAction;
use APP\core\Request;
use PKP\linkAction\LinkAction;
use PKP\linkAction\request\PostAndRedirectAction;
class DownloadAllLinkAction extends LinkAction
{
/**
* Constructor
*
* @param Request $request
* @param array $actionArgs
*/
public function __construct($request, $actionArgs)
{
// Instantiate the redirect action request.
$router = $request->getRouter();
$redirectRequest = new PostAndRedirectAction(
$router->url($request, null, 'api.file.FileApiHandler', 'recordDownload', null, $actionArgs),
$router->url($request, null, 'api.file.FileApiHandler', 'downloadAllFiles', null, $actionArgs)
);
// Configure the link action.
parent::__construct('downloadAll', $redirectRequest, __('submission.files.downloadAll'), 'getPackage');
}
}
@@ -0,0 +1,49 @@
<?php
/**
* @file controllers/grid/files/fileList/linkAction/SelectFilesLinkAction.php
*
* Copyright (c) 2014-2021 Simon Fraser University
* Copyright (c) 2003-2021 John Willinsky
* Distributed under the GNU GPL v3. For full terms see the file docs/COPYING.
*
* @class SelectFilesLinkAction
*
* @ingroup controllers_grid_files_fileList_linkAction
*
* @brief An abstract base action for actions to open up a modal that allows users to
* select files from a file list grid.
*/
namespace PKP\controllers\grid\files\fileList\linkAction;
use APP\core\Request;
use PKP\linkAction\LinkAction;
use PKP\linkAction\request\AjaxModal;
class SelectFilesLinkAction extends LinkAction
{
/**
* Constructor
*
* @param Request $request
* @param array $actionArgs The parameters required by the
* link action target to identify a list of files.
* @param string $actionLabel The localized label of the link action.
* @param string $modalTitle the (optional) title to be used for the modal.
*/
public function __construct($request, $actionArgs, $actionLabel, $modalTitle = null)
{
// Create an ajax action request that'll contain
// the file selection grid.
$modalTitle ??= $actionLabel;
$router = $request->getRouter();
$ajaxModal = new AjaxModal(
$router->url($request, null, null, 'selectFiles', null, $actionArgs),
$modalTitle,
'modal_add_file'
);
// Configure the link action.
parent::__construct('selectFiles', $ajaxModal, $actionLabel, 'add');
}
}
@@ -0,0 +1,40 @@
<?php
/**
* @file controllers/grid/files/fileList/linkAction/SelectReviewFilesLinkAction.php
*
* Copyright (c) 2014-2021 Simon Fraser University
* Copyright (c) 2003-2021 John Willinsky
* Distributed under the GNU GPL v3. For full terms see the file docs/COPYING.
*
* @class SelectReviewFilesLinkAction
*
* @ingroup controllers_grid_files_fileList_linkAction
*
* @brief An action to open up the modal that allows users to select review files
* from a file list grid.
*/
namespace PKP\controllers\grid\files\fileList\linkAction;
use APP\core\Request;
use PKP\submission\reviewRound\ReviewRound;
class SelectReviewFilesLinkAction extends SelectFilesLinkAction
{
/**
* Constructor
*
* @param Request $request
* @param ReviewRound $reviewRound The review round from which to
* select review files.
* @param string $actionLabel The localized label of the link action.
* @param string $modalTitle the (optional) title to be used for the modal.
*/
public function __construct($request, $reviewRound, $actionLabel, $modalTitle = null)
{
$actionArgs = ['submissionId' => $reviewRound->getSubmissionId(),
'stageId' => $reviewRound->getStageId(), 'reviewRoundId' => $reviewRound->getId()];
parent::__construct($request, $actionArgs, $actionLabel, $modalTitle);
}
}