first commit
This commit is contained in:
@@ -0,0 +1,136 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file controllers/grid/pubIds/PubIdExportIssuesListGridCellProvider.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 PubIdExportIssuesListGridCellProvider
|
||||
*
|
||||
* @ingroup controllers_grid_pubIds
|
||||
*
|
||||
* @brief Class for a cell provider that can retrieve labels from issues with pub ids
|
||||
*/
|
||||
|
||||
namespace APP\controllers\grid\pubIds;
|
||||
|
||||
use APP\core\Application;
|
||||
use PKP\controllers\grid\DataObjectGridCellProvider;
|
||||
use PKP\controllers\grid\GridHandler;
|
||||
use PKP\core\PKPApplication;
|
||||
use PKP\linkAction\LinkAction;
|
||||
use PKP\linkAction\request\AjaxModal;
|
||||
use PKP\linkAction\request\RedirectAction;
|
||||
use PKP\plugins\ImportExportPlugin;
|
||||
|
||||
class PubIdExportIssuesListGridCellProvider extends DataObjectGridCellProvider
|
||||
{
|
||||
/** @var ImportExportPlugin */
|
||||
public $_plugin;
|
||||
|
||||
public $_authorizedRoles;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param null|mixed $authorizedRoles
|
||||
*/
|
||||
public function __construct($plugin, $authorizedRoles = null)
|
||||
{
|
||||
$this->_plugin = $plugin;
|
||||
if ($authorizedRoles) {
|
||||
$this->_authorizedRoles = $authorizedRoles;
|
||||
}
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
//
|
||||
// Template methods from GridCellProvider
|
||||
//
|
||||
/**
|
||||
* Get cell actions associated with this row/column combination
|
||||
*
|
||||
* @copydoc GridCellProvider::getCellActions()
|
||||
*/
|
||||
public function getCellActions($request, $row, $column, $position = GridHandler::GRID_ACTION_POSITION_DEFAULT)
|
||||
{
|
||||
$publishedIssue = $row->getData();
|
||||
$columnId = $column->getId();
|
||||
assert(is_a($publishedIssue, 'Issue') && !empty($columnId));
|
||||
|
||||
switch ($columnId) {
|
||||
case 'identification':
|
||||
// Link to the issue edit modal
|
||||
$application = Application::get();
|
||||
$dispatcher = $application->getDispatcher();
|
||||
return [
|
||||
new LinkAction(
|
||||
'edit',
|
||||
new AjaxModal(
|
||||
$dispatcher->url($request, PKPApplication::ROUTE_COMPONENT, null, 'grid.issues.BackIssueGridHandler', 'editIssue', null, ['issueId' => $publishedIssue->getId()]),
|
||||
__('plugins.importexport.common.settings.DOIPluginSettings')
|
||||
),
|
||||
$publishedIssue->getIssueIdentification(),
|
||||
null
|
||||
)
|
||||
];
|
||||
case 'status':
|
||||
$status = $publishedIssue->getData($this->_plugin->getDepositStatusSettingName());
|
||||
$statusNames = $this->_plugin->getStatusNames();
|
||||
$statusActions = $this->_plugin->getStatusActions($publishedIssue);
|
||||
if ($status && array_key_exists($status, $statusActions)) {
|
||||
assert(array_key_exists($status, $statusNames));
|
||||
return [
|
||||
new LinkAction(
|
||||
'edit',
|
||||
new RedirectAction(
|
||||
$statusActions[$status],
|
||||
'_blank'
|
||||
),
|
||||
$statusNames[$status]
|
||||
)
|
||||
];
|
||||
}
|
||||
}
|
||||
return parent::getCellActions($request, $row, $column, $position);
|
||||
}
|
||||
|
||||
/**
|
||||
* Extracts variables for a given column from a data element
|
||||
* so that they may be assigned to template before rendering.
|
||||
*
|
||||
* @copydoc DataObjectGridCellProvider::getTemplateVarsFromRowColumn()
|
||||
*/
|
||||
public function getTemplateVarsFromRowColumn($row, $column)
|
||||
{
|
||||
$publishedIssue = $row->getData();
|
||||
$columnId = $column->getId();
|
||||
assert(is_a($publishedIssue, 'Issue') && !empty($columnId));
|
||||
|
||||
switch ($columnId) {
|
||||
case 'identification':
|
||||
return ['label' => ''];
|
||||
case 'published':
|
||||
return ['label' => $publishedIssue->getDatePublished()];
|
||||
case 'pubId':
|
||||
return ['label' => $publishedIssue->getStoredPubId($this->_plugin->getPubIdType())];
|
||||
case 'status':
|
||||
$status = $publishedIssue->getData($this->_plugin->getDepositStatusSettingName());
|
||||
$statusNames = $this->_plugin->getStatusNames();
|
||||
$statusActions = $this->_plugin->getStatusActions($publishedIssue);
|
||||
if ($status) {
|
||||
if (array_key_exists($status, $statusActions)) {
|
||||
$label = '';
|
||||
} else {
|
||||
assert(array_key_exists($status, $statusNames));
|
||||
$label = $statusNames[$status];
|
||||
}
|
||||
} else {
|
||||
$label = $statusNames[EXPORT_STATUS_NOT_DEPOSITED];
|
||||
}
|
||||
return ['label' => $label];
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,247 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file controllers/grid/pubIds/PubIdExportIssuesListGridHandler.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 PubIdExportIssuesListGridHandler
|
||||
*
|
||||
* @ingroup controllers_grid_pubIds
|
||||
*
|
||||
* @brief Handle exportable issues with pub ids list grid requests.
|
||||
*/
|
||||
|
||||
namespace APP\controllers\grid\pubIds;
|
||||
|
||||
use APP\core\Application;
|
||||
use APP\plugins\PubIdPlugin;
|
||||
use APP\plugins\PubObjectsExportPlugin;
|
||||
use PKP\controllers\grid\feature\PagingFeature;
|
||||
use PKP\controllers\grid\feature\selectableItems\SelectableItemsFeature;
|
||||
use PKP\controllers\grid\GridColumn;
|
||||
use PKP\controllers\grid\GridHandler;
|
||||
use PKP\plugins\PluginRegistry;
|
||||
use PKP\security\authorization\PolicySet;
|
||||
use PKP\security\authorization\RoleBasedHandlerOperationPolicy;
|
||||
use PKP\security\Role;
|
||||
|
||||
class PubIdExportIssuesListGridHandler extends GridHandler
|
||||
{
|
||||
/** @var PubObjectsExportPlugin */
|
||||
public $_plugin;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->addRoleAssignment(
|
||||
[Role::ROLE_ID_MANAGER, Role::ROLE_ID_SITE_ADMIN],
|
||||
['fetchGrid', 'fetchRow']
|
||||
);
|
||||
}
|
||||
|
||||
//
|
||||
// Implement template methods from PKPHandler
|
||||
//
|
||||
/**
|
||||
* @copydoc PKPHandler::authorize()
|
||||
*/
|
||||
public function authorize($request, &$args, $roleAssignments)
|
||||
{
|
||||
$rolePolicy = new PolicySet(PolicySet::COMBINING_PERMIT_OVERRIDES);
|
||||
|
||||
foreach ($roleAssignments as $role => $operations) {
|
||||
$rolePolicy->addPolicy(new RoleBasedHandlerOperationPolicy($request, $role, $operations));
|
||||
}
|
||||
$this->addPolicy($rolePolicy);
|
||||
|
||||
return parent::authorize($request, $args, $roleAssignments);
|
||||
}
|
||||
|
||||
/**
|
||||
* @copydoc GridHandler::initialize()
|
||||
*
|
||||
* @param null|mixed $args
|
||||
*/
|
||||
public function initialize($request, $args = null)
|
||||
{
|
||||
parent::initialize($request, $args);
|
||||
|
||||
// Basic grid configuration.
|
||||
$this->setTitle('plugins.importexport.common.export.issues');
|
||||
|
||||
$pluginCategory = $request->getUserVar('category');
|
||||
$pluginPathName = $request->getUserVar('plugin');
|
||||
|
||||
// Allow for plugins that have already been loaded (e.g. by injection from a generic plugin)
|
||||
$this->_plugin = PluginRegistry::getPlugin($pluginCategory, $pluginPathName);
|
||||
|
||||
// Otherwise, load the plugin as specified
|
||||
/** @var PubIdPlugin */
|
||||
$this->_plugin ??= PluginRegistry::loadPlugin($pluginCategory, $pluginPathName);
|
||||
|
||||
assert(isset($this->_plugin));
|
||||
|
||||
// Fetch the authorized roles.
|
||||
$authorizedRoles = $this->getAuthorizedContextObject(Application::ASSOC_TYPE_USER_ROLES);
|
||||
|
||||
// Grid columns.
|
||||
$cellProvider = new PubIdExportIssuesListGridCellProvider($this->_plugin, $authorizedRoles);
|
||||
$this->addColumn(
|
||||
new GridColumn(
|
||||
'identification',
|
||||
'issue.issue',
|
||||
null,
|
||||
null,
|
||||
$cellProvider,
|
||||
['html' => true,
|
||||
'alignment' => GridColumn::COLUMN_ALIGNMENT_LEFT]
|
||||
)
|
||||
);
|
||||
$this->addColumn(
|
||||
new GridColumn(
|
||||
'published',
|
||||
'editor.issues.published',
|
||||
null,
|
||||
null,
|
||||
$cellProvider,
|
||||
['html' => true,
|
||||
'alignment' => GridColumn::COLUMN_ALIGNMENT_LEFT]
|
||||
)
|
||||
);
|
||||
$this->addColumn(
|
||||
new GridColumn(
|
||||
'pubId',
|
||||
null,
|
||||
$this->_plugin->getPubIdDisplayType(),
|
||||
null,
|
||||
$cellProvider,
|
||||
['alignment' => GridColumn::COLUMN_ALIGNMENT_LEFT,
|
||||
'width' => 15]
|
||||
)
|
||||
);
|
||||
$this->addColumn(
|
||||
new GridColumn(
|
||||
'status',
|
||||
'common.status',
|
||||
null,
|
||||
null,
|
||||
$cellProvider,
|
||||
['alignment' => GridColumn::COLUMN_ALIGNMENT_LEFT,
|
||||
'width' => 10]
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Implemented methods from GridHandler.
|
||||
//
|
||||
/**
|
||||
* @copydoc GridHandler::initFeatures()
|
||||
*/
|
||||
public function initFeatures($request, $args)
|
||||
{
|
||||
return [new SelectableItemsFeature(), new PagingFeature()];
|
||||
}
|
||||
|
||||
/**
|
||||
* @copydoc GridHandler::getRequestArgs()
|
||||
*/
|
||||
public function getRequestArgs()
|
||||
{
|
||||
return array_merge(parent::getRequestArgs(), ['category' => $this->_plugin->getCategory(), 'plugin' => basename($this->_plugin->getPluginPath())]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @copydoc GridHandler::isDataElementSelected()
|
||||
*/
|
||||
public function isDataElementSelected($gridDataElement)
|
||||
{
|
||||
return false; // Nothing is selected by default
|
||||
}
|
||||
|
||||
/**
|
||||
* @copydoc GridHandler::getSelectName()
|
||||
*/
|
||||
public function getSelectName()
|
||||
{
|
||||
return 'selectedIssues';
|
||||
}
|
||||
|
||||
/**
|
||||
* @copydoc GridHandler::getFilterForm()
|
||||
*/
|
||||
protected function getFilterForm()
|
||||
{
|
||||
return 'controllers/grid/pubIds/pubIdExportIssuesGridFilter.tpl';
|
||||
}
|
||||
|
||||
/**
|
||||
* @copydoc GridHandler::renderFilter()
|
||||
*/
|
||||
public function renderFilter($request, $filterData = [])
|
||||
{
|
||||
$statusNames = $this->_plugin->getStatusNames();
|
||||
$allFilterData = array_merge(
|
||||
$filterData,
|
||||
[
|
||||
'status' => $statusNames,
|
||||
'gridId' => $this->getId(),
|
||||
]
|
||||
);
|
||||
return parent::renderFilter($request, $allFilterData);
|
||||
}
|
||||
|
||||
/**
|
||||
* @copydoc GridHandler::getFilterSelectionData()
|
||||
*/
|
||||
public function getFilterSelectionData($request)
|
||||
{
|
||||
$statusId = (string) $request->getUserVar('statusId');
|
||||
return [
|
||||
'statusId' => $statusId,
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @copydoc GridHandler::loadData()
|
||||
*/
|
||||
protected function loadData($request, $filter)
|
||||
{
|
||||
$context = $request->getContext();
|
||||
[$statusId] = $this->getFilterValues($filter);
|
||||
$pubIdStatusSettingName = null;
|
||||
if ($statusId) {
|
||||
$pubIdStatusSettingName = $this->_plugin->getDepositStatusSettingName();
|
||||
}
|
||||
return \APP\facades\Repo::issue()->dao->getExportable(
|
||||
$context->getId(),
|
||||
$this->_plugin->getPubIdType(),
|
||||
$pubIdStatusSettingName,
|
||||
$statusId,
|
||||
$this->getGridRangeInfo($request, $this->getId())
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Process filter values, assigning default ones if
|
||||
* none was set.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected function getFilterValues($filter)
|
||||
{
|
||||
if (isset($filter['statusId']) && $filter['statusId'] != EXPORT_STATUS_ANY) {
|
||||
$statusId = $filter['statusId'];
|
||||
} else {
|
||||
$statusId = null;
|
||||
}
|
||||
return [$statusId];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,166 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file controllers/grid/pubIds/PubIdExportRepresentationsListGridCellProvider.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 PubIdExportRepresentationsListGridCellProvider
|
||||
*
|
||||
* @ingroup controllers_grid_pubIds
|
||||
*
|
||||
* @brief Class for a cell provider that can retrieve labels from representations with pub ids
|
||||
*/
|
||||
|
||||
namespace APP\controllers\grid\pubIds;
|
||||
|
||||
use APP\core\Application;
|
||||
use APP\facades\Repo;
|
||||
use PKP\controllers\grid\DataObjectGridCellProvider;
|
||||
use PKP\controllers\grid\GridHandler;
|
||||
use PKP\core\PKPApplication;
|
||||
use PKP\linkAction\LinkAction;
|
||||
use PKP\linkAction\request\AjaxModal;
|
||||
use PKP\linkAction\request\RedirectAction;
|
||||
use PKP\plugins\ImportExportPlugin;
|
||||
|
||||
class PubIdExportRepresentationsListGridCellProvider extends DataObjectGridCellProvider
|
||||
{
|
||||
/** @var ImportExportPlugin */
|
||||
public $_plugin;
|
||||
|
||||
public $_authorizedRoles;
|
||||
|
||||
public $_titleColumn;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param null|mixed $authorizedRoles
|
||||
*/
|
||||
public function __construct($plugin, $authorizedRoles = null)
|
||||
{
|
||||
$this->_plugin = $plugin;
|
||||
if ($authorizedRoles) {
|
||||
$this->_authorizedRoles = $authorizedRoles;
|
||||
}
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
//
|
||||
// Template methods from GridCellProvider
|
||||
//
|
||||
/**
|
||||
* Get cell actions associated with this row/column combination
|
||||
*
|
||||
* @copydoc GridCellProvider::getCellActions()
|
||||
*/
|
||||
public function getCellActions($request, $row, $column, $position = GridHandler::GRID_ACTION_POSITION_DEFAULT)
|
||||
{
|
||||
$galley = $row->getData();
|
||||
$columnId = $column->getId();
|
||||
assert(is_a($galley, 'Galley') && !empty($columnId));
|
||||
|
||||
$publication = Repo::publication()->get($galley->getData('publicationId'));
|
||||
$submission = Repo::submission()->get($publication->getData('submissionId'));
|
||||
switch ($columnId) {
|
||||
case 'title':
|
||||
$this->_titleColumn = $column;
|
||||
$title = $submission->getLocalizedTitle();
|
||||
if (empty($title)) {
|
||||
$title = __('common.untitled');
|
||||
}
|
||||
$authorsInTitle = $publication->getShortAuthorString();
|
||||
$title = $authorsInTitle . '; ' . $title;
|
||||
return [
|
||||
new LinkAction(
|
||||
'itemWorkflow',
|
||||
new RedirectAction(
|
||||
Repo::submission()->getWorkflowUrlByUserRoles($submission)
|
||||
),
|
||||
htmlspecialchars($title)
|
||||
)
|
||||
];
|
||||
case 'issue':
|
||||
$contextId = $submission->getContextId();
|
||||
$issueId = $submission->getCurrentPublication()->getData('issueId');
|
||||
$issue = Repo::issue()->get($issueId);
|
||||
$issue = $issue->getJournalId() == $contextId ? $issue : null;
|
||||
// Link to the issue edit modal
|
||||
$application = Application::get();
|
||||
$dispatcher = $application->getDispatcher();
|
||||
return [
|
||||
new LinkAction(
|
||||
'edit',
|
||||
new AjaxModal(
|
||||
$dispatcher->url($request, PKPApplication::ROUTE_COMPONENT, null, 'grid.issues.BackIssueGridHandler', 'editIssue', null, ['issueId' => $issue->getId()]),
|
||||
__('plugins.importexport.common.settings.DOIPluginSettings')
|
||||
),
|
||||
$issue->getIssueIdentification(),
|
||||
null
|
||||
)
|
||||
];
|
||||
case 'status':
|
||||
$status = $galley->getData($this->_plugin->getDepositStatusSettingName());
|
||||
$statusNames = $this->_plugin->getStatusNames();
|
||||
$statusActions = $this->_plugin->getStatusActions($submission);
|
||||
if ($status && array_key_exists($status, $statusActions)) {
|
||||
assert(array_key_exists($status, $statusNames));
|
||||
return [
|
||||
new LinkAction(
|
||||
'edit',
|
||||
new RedirectAction(
|
||||
$statusActions[$status],
|
||||
'_blank'
|
||||
),
|
||||
htmlspecialchars($statusNames[$status])
|
||||
)
|
||||
];
|
||||
}
|
||||
}
|
||||
return parent::getCellActions($request, $row, $column, $position);
|
||||
}
|
||||
|
||||
/**
|
||||
* Extracts variables for a given column from a data element
|
||||
* so that they may be assigned to template before rendering.
|
||||
*
|
||||
* @copydoc DataObjectGridCellProvider::getTemplateVarsFromRowColumn()
|
||||
*/
|
||||
public function getTemplateVarsFromRowColumn($row, $column)
|
||||
{
|
||||
$submissionGalley = $row->getData();
|
||||
$columnId = $column->getId();
|
||||
assert(is_a($submissionGalley, 'Galley') && !empty($columnId));
|
||||
|
||||
switch ($columnId) {
|
||||
case 'id':
|
||||
return ['label' => $submissionGalley->getId()];
|
||||
case 'title':
|
||||
return ['label' => ''];
|
||||
case 'issue':
|
||||
return ['label' => ''];
|
||||
case 'galley':
|
||||
return ['label' => $submissionGalley->getGalleyLabel()];
|
||||
case 'pubId':
|
||||
return ['label' => $submissionGalley->getStoredPubId($this->_plugin->getPubIdType())];
|
||||
case 'status':
|
||||
$status = $submissionGalley->getData($this->_plugin->getDepositStatusSettingName());
|
||||
$statusNames = $this->_plugin->getStatusNames();
|
||||
$statusActions = $this->_plugin->getStatusActions($submissionGalley);
|
||||
if ($status) {
|
||||
if (array_key_exists($status, $statusActions)) {
|
||||
$label = '';
|
||||
} else {
|
||||
assert(array_key_exists($status, $statusNames));
|
||||
$label = $statusNames[$status];
|
||||
}
|
||||
} else {
|
||||
$label = $statusNames[EXPORT_STATUS_NOT_DEPOSITED];
|
||||
}
|
||||
return ['label' => $label];
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,331 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file controllers/grid/pubIds/PubIdExportRepresentationsListGridHandler.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 PubIdExportRepresentationsListGridHandler
|
||||
*
|
||||
* @ingroup controllers_grid_pubIds
|
||||
*
|
||||
* @brief Handle exportable representations with pub ids list grid requests.
|
||||
*/
|
||||
|
||||
namespace APP\controllers\grid\pubIds;
|
||||
|
||||
use APP\core\Application;
|
||||
use APP\facades\Repo;
|
||||
use APP\issue\Collector;
|
||||
use APP\plugins\PubObjectsExportPlugin;
|
||||
use PKP\controllers\grid\feature\PagingFeature;
|
||||
use PKP\controllers\grid\feature\selectableItems\SelectableItemsFeature;
|
||||
use PKP\controllers\grid\GridColumn;
|
||||
use PKP\controllers\grid\GridHandler;
|
||||
use PKP\plugins\PluginRegistry;
|
||||
use PKP\security\authorization\PolicySet;
|
||||
use PKP\security\authorization\RoleBasedHandlerOperationPolicy;
|
||||
use PKP\security\Role;
|
||||
|
||||
class PubIdExportRepresentationsListGridHandler extends GridHandler
|
||||
{
|
||||
/** @var PubObjectsExportPlugin */
|
||||
public $_plugin;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->addRoleAssignment(
|
||||
[Role::ROLE_ID_MANAGER, Role::ROLE_ID_SITE_ADMIN],
|
||||
['fetchGrid', 'fetchRow']
|
||||
);
|
||||
}
|
||||
|
||||
//
|
||||
// Implement template methods from PKPHandler
|
||||
//
|
||||
/**
|
||||
* @copydoc PKPHandler::authorize()
|
||||
*/
|
||||
public function authorize($request, &$args, $roleAssignments)
|
||||
{
|
||||
$rolePolicy = new PolicySet(PolicySet::COMBINING_PERMIT_OVERRIDES);
|
||||
|
||||
foreach ($roleAssignments as $role => $operations) {
|
||||
$rolePolicy->addPolicy(new RoleBasedHandlerOperationPolicy($request, $role, $operations));
|
||||
}
|
||||
$this->addPolicy($rolePolicy);
|
||||
|
||||
return parent::authorize($request, $args, $roleAssignments);
|
||||
}
|
||||
|
||||
/**
|
||||
* @copydoc GridHandler::initialize()
|
||||
*
|
||||
* @param null|mixed $args
|
||||
*/
|
||||
public function initialize($request, $args = null)
|
||||
{
|
||||
parent::initialize($request, $args);
|
||||
$context = $request->getContext();
|
||||
|
||||
// Basic grid configuration.
|
||||
$this->setTitle('plugins.importexport.common.export.articles');
|
||||
|
||||
$pluginCategory = $request->getUserVar('category');
|
||||
$pluginPathName = $request->getUserVar('plugin');
|
||||
|
||||
// Allow for plugins that have already been loaded (e.g. by injection from a generic plugin)
|
||||
$this->_plugin = PluginRegistry::getPlugin($pluginCategory, $pluginPathName);
|
||||
|
||||
// Otherwise, load the plugin as specified
|
||||
$this->_plugin ??= PluginRegistry::loadPlugin($pluginCategory, $pluginPathName);
|
||||
|
||||
assert(isset($this->_plugin));
|
||||
|
||||
// Fetch the authorized roles.
|
||||
$authorizedRoles = $this->getAuthorizedContextObject(Application::ASSOC_TYPE_USER_ROLES);
|
||||
|
||||
// Grid columns.
|
||||
$cellProvider = new PubIdExportRepresentationsListGridCellProvider($this->_plugin, $authorizedRoles);
|
||||
$this->addColumn(
|
||||
new GridColumn(
|
||||
'id',
|
||||
null,
|
||||
__('common.id'),
|
||||
'controllers/grid/gridCell.tpl',
|
||||
$cellProvider,
|
||||
['alignment' => GridColumn::COLUMN_ALIGNMENT_LEFT,
|
||||
'width' => 10]
|
||||
)
|
||||
);
|
||||
$this->addColumn(
|
||||
new GridColumn(
|
||||
'title',
|
||||
'grid.submission.itemTitle',
|
||||
null,
|
||||
null,
|
||||
$cellProvider,
|
||||
['html' => true,
|
||||
'alignment' => GridColumn::COLUMN_ALIGNMENT_LEFT]
|
||||
)
|
||||
);
|
||||
$this->addColumn(
|
||||
new GridColumn(
|
||||
'issue',
|
||||
'issue.issue',
|
||||
null,
|
||||
null,
|
||||
$cellProvider,
|
||||
['alignment' => GridColumn::COLUMN_ALIGNMENT_LEFT,
|
||||
'width' => 20]
|
||||
)
|
||||
);
|
||||
$this->addColumn(
|
||||
new GridColumn(
|
||||
'galley',
|
||||
'submission.layout.galleyLabel',
|
||||
null,
|
||||
null,
|
||||
$cellProvider,
|
||||
['alignment' => GridColumn::COLUMN_ALIGNMENT_LEFT,
|
||||
'width' => 20]
|
||||
)
|
||||
);
|
||||
$this->addColumn(
|
||||
new GridColumn(
|
||||
'pubId',
|
||||
null,
|
||||
$this->_plugin->getPubIdDisplayType(),
|
||||
null,
|
||||
$cellProvider,
|
||||
['alignment' => GridColumn::COLUMN_ALIGNMENT_LEFT,
|
||||
'width' => 15]
|
||||
)
|
||||
);
|
||||
$this->addColumn(
|
||||
new GridColumn(
|
||||
'status',
|
||||
'common.status',
|
||||
null,
|
||||
null,
|
||||
$cellProvider,
|
||||
['alignment' => GridColumn::COLUMN_ALIGNMENT_LEFT,
|
||||
'width' => 10]
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Implemented methods from GridHandler.
|
||||
//
|
||||
/**
|
||||
* @copydoc GridHandler::initFeatures()
|
||||
*/
|
||||
public function initFeatures($request, $args)
|
||||
{
|
||||
return [new SelectableItemsFeature(), new PagingFeature()];
|
||||
}
|
||||
|
||||
/**
|
||||
* @copydoc GridHandler::getRequestArgs()
|
||||
*/
|
||||
public function getRequestArgs()
|
||||
{
|
||||
return array_merge(parent::getRequestArgs(), ['category' => $this->_plugin->getCategory(), 'plugin' => basename($this->_plugin->getPluginPath())]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @copydoc GridHandler::isDataElementSelected()
|
||||
*/
|
||||
public function isDataElementSelected($gridDataElement)
|
||||
{
|
||||
return false; // Nothing is selected by default
|
||||
}
|
||||
|
||||
/**
|
||||
* @copydoc GridHandler::getSelectName()
|
||||
*/
|
||||
public function getSelectName()
|
||||
{
|
||||
return 'selectedRepresentations';
|
||||
}
|
||||
|
||||
/**
|
||||
* @copydoc GridHandler::getFilterForm()
|
||||
*/
|
||||
protected function getFilterForm()
|
||||
{
|
||||
return 'controllers/grid/pubIds/pubIdExportRepresentationsGridFilter.tpl';
|
||||
}
|
||||
|
||||
/**
|
||||
* @copydoc GridHandler::renderFilter()
|
||||
*/
|
||||
public function renderFilter($request, $filterData = [])
|
||||
{
|
||||
$context = $request->getContext();
|
||||
$issues = Repo::issue()->getCollector()
|
||||
->filterByContextIds([$context->getId()])
|
||||
->filterByPublished(true)
|
||||
->orderBy(Collector::ORDERBY_PUBLISHED_ISSUES)
|
||||
->getMany();
|
||||
foreach ($issues as $issue) {
|
||||
$issueOptions[$issue->getId()] = $issue->getIssueIdentification();
|
||||
}
|
||||
$issueOptions[0] = __('plugins.importexport.common.filter.issue');
|
||||
ksort($issueOptions);
|
||||
$statusNames = $this->_plugin->getStatusNames();
|
||||
$filterColumns = $this->getFilterColumns();
|
||||
$allFilterData = array_merge(
|
||||
$filterData,
|
||||
[
|
||||
'columns' => $filterColumns,
|
||||
'issues' => $issueOptions,
|
||||
'status' => $statusNames,
|
||||
'gridId' => $this->getId(),
|
||||
]
|
||||
);
|
||||
return parent::renderFilter($request, $allFilterData);
|
||||
}
|
||||
|
||||
/**
|
||||
* @copydoc GridHandler::getFilterSelectionData()
|
||||
*/
|
||||
public function getFilterSelectionData($request)
|
||||
{
|
||||
$search = (string) $request->getUserVar('search');
|
||||
$column = (string) $request->getUserVar('column');
|
||||
$issueId = (int) $request->getUserVar('issueId');
|
||||
$statusId = (string) $request->getUserVar('statusId');
|
||||
return [
|
||||
'search' => $search,
|
||||
'column' => $column,
|
||||
'issueId' => $issueId,
|
||||
'statusId' => $statusId,
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @copydoc GridHandler::loadData()
|
||||
*/
|
||||
protected function loadData($request, $filter)
|
||||
{
|
||||
$context = $request->getContext();
|
||||
[$search, $column, $issueId, $statusId] = $this->getFilterValues($filter);
|
||||
$title = $author = null;
|
||||
if ($column == 'title') {
|
||||
$title = $search;
|
||||
} elseif ($column == 'author') {
|
||||
$author = $search;
|
||||
}
|
||||
$pubIdStatusSettingName = null;
|
||||
if ($statusId) {
|
||||
$pubIdStatusSettingName = $this->_plugin->getDepositStatusSettingName();
|
||||
}
|
||||
return Repo::galley()->dao->getExportable(
|
||||
$context->getId(),
|
||||
$this->_plugin->getPubIdType(),
|
||||
$title,
|
||||
$author,
|
||||
$issueId,
|
||||
$pubIdStatusSettingName,
|
||||
$statusId,
|
||||
$this->getGridRangeInfo($request, $this->getId())
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Own protected methods
|
||||
//
|
||||
/**
|
||||
* Get which columns can be used by users to filter data.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected function getFilterColumns()
|
||||
{
|
||||
return [
|
||||
'title' => __('submission.title'),
|
||||
'author' => __('submission.authors')
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Process filter values, assigning default ones if
|
||||
* none was set.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected function getFilterValues($filter)
|
||||
{
|
||||
if (isset($filter['search']) && $filter['search']) {
|
||||
$search = $filter['search'];
|
||||
} else {
|
||||
$search = null;
|
||||
}
|
||||
if (isset($filter['column']) && $filter['column']) {
|
||||
$column = $filter['column'];
|
||||
} else {
|
||||
$column = null;
|
||||
}
|
||||
if (isset($filter['issueId']) && $filter['issueId']) {
|
||||
$issueId = $filter['issueId'];
|
||||
} else {
|
||||
$issueId = null;
|
||||
}
|
||||
if (isset($filter['statusId']) && $filter['statusId'] != EXPORT_STATUS_ANY) {
|
||||
$statusId = $filter['statusId'];
|
||||
} else {
|
||||
$statusId = null;
|
||||
}
|
||||
return [$search, $column, $issueId, $statusId];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file controllers/grid/pubIds/PubIdExportSubmissionsListGridCellProvider.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 PubIdExportSubmissionsListGridCellProvider
|
||||
*
|
||||
* @ingroup controllers_grid_pubIds
|
||||
*
|
||||
* @brief Class for a cell provider that can retrieve labels from submissions with pub ids
|
||||
*/
|
||||
|
||||
namespace APP\controllers\grid\pubIds;
|
||||
|
||||
use APP\controllers\grid\submissions\ExportPublishedSubmissionsListGridCellProvider;
|
||||
use APP\submission\Submission;
|
||||
|
||||
class PubIdExportSubmissionsListGridCellProvider extends ExportPublishedSubmissionsListGridCellProvider
|
||||
{
|
||||
/**
|
||||
* @copydoc ExportPublishedSubmissionsListGridCellProvider::getTemplateVarsFromRowColumn()
|
||||
*/
|
||||
public function getTemplateVarsFromRowColumn($row, $column)
|
||||
{
|
||||
$submission = $row->getData();
|
||||
$columnId = $column->getId();
|
||||
assert($submission instanceof Submission && !empty($columnId));
|
||||
|
||||
switch ($columnId) {
|
||||
case 'pubId':
|
||||
return ['label' => $submission->getStoredPubId($this->_plugin->getPubIdType())];
|
||||
}
|
||||
return parent::getTemplateVarsFromRowColumn($row, $column);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,85 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file controllers/grid/pubIds/PubIdExportSubmissionsListGridHandler.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 PubIdExportSubmissionsListGridHandler
|
||||
*
|
||||
* @ingroup controllers_grid_pubIds
|
||||
*
|
||||
* @brief Handle exportable submissions with pub ids list grid requests.
|
||||
*/
|
||||
|
||||
namespace APP\controllers\grid\pubIds;
|
||||
|
||||
use APP\controllers\grid\submissions\ExportPublishedSubmissionsListGridHandler;
|
||||
use APP\core\Application;
|
||||
use APP\facades\Repo;
|
||||
use PKP\controllers\grid\DataObjectGridCellProvider;
|
||||
use PKP\controllers\grid\GridColumn;
|
||||
|
||||
class PubIdExportSubmissionsListGridHandler extends ExportPublishedSubmissionsListGridHandler
|
||||
{
|
||||
/**
|
||||
* @copydoc GridHandler::loadData()
|
||||
*/
|
||||
protected function loadData($request, $filter)
|
||||
{
|
||||
$context = $request->getContext();
|
||||
[$search, $column, $issueId, $statusId] = $this->getFilterValues($filter);
|
||||
$title = $author = null;
|
||||
if ($column == 'title') {
|
||||
$title = $search;
|
||||
} elseif ($column == 'author') {
|
||||
$author = $search;
|
||||
}
|
||||
$pubIdStatusSettingName = null;
|
||||
if ($statusId) {
|
||||
$pubIdStatusSettingName = $this->_plugin->getDepositStatusSettingName();
|
||||
}
|
||||
return Repo::submission()->dao->getExportable(
|
||||
$context->getId(),
|
||||
$this->_plugin->getPubIdType(),
|
||||
$title,
|
||||
$author,
|
||||
$issueId,
|
||||
$pubIdStatusSettingName,
|
||||
$statusId,
|
||||
$this->getGridRangeInfo($request, $this->getId())
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @copydoc ExportPublishedSubmissionsListGridHandler::getGridCellProvider()
|
||||
*/
|
||||
public function getGridCellProvider()
|
||||
{
|
||||
// Fetch the authorized roles.
|
||||
$authorizedRoles = $this->getAuthorizedContextObject(Application::ASSOC_TYPE_USER_ROLES);
|
||||
return new PubIdExportSubmissionsListGridCellProvider($this->_plugin, $authorizedRoles);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the grid cell provider instance
|
||||
*
|
||||
* @return DataObjectGridCellProvider
|
||||
*/
|
||||
public function addAdditionalColumns($cellProvider)
|
||||
{
|
||||
$this->addColumn(
|
||||
new GridColumn(
|
||||
'pubId',
|
||||
null,
|
||||
$this->_plugin->getPubIdDisplayType(),
|
||||
null,
|
||||
$cellProvider,
|
||||
['alignment' => GridColumn::COLUMN_ALIGNMENT_LEFT,
|
||||
'width' => 15]
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,69 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file controllers/grid/pubIds/form/AssignPublicIdentifiersForm.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 AssignPublicIdentifiersForm
|
||||
*
|
||||
* @ingroup controllers_grid_pubIds_form
|
||||
*
|
||||
* @brief Displays the assign pub id form.
|
||||
*/
|
||||
|
||||
namespace APP\controllers\grid\pubIds\form;
|
||||
|
||||
use APP\template\TemplateManager;
|
||||
use PKP\controllers\grid\pubIds\form\PKPAssignPublicIdentifiersForm;
|
||||
|
||||
class AssignPublicIdentifiersForm extends PKPAssignPublicIdentifiersForm
|
||||
{
|
||||
/**
|
||||
* @var array Parameters to configure the form template.
|
||||
*/
|
||||
public $_formParams;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param string $template Form template
|
||||
* @param object $pubObject
|
||||
* @param bool $approval
|
||||
* @param string $confirmationText
|
||||
* @param array $formParams
|
||||
*/
|
||||
public function __construct($template, $pubObject, $approval, $confirmationText, $formParams = null)
|
||||
{
|
||||
parent::__construct($template, $pubObject, $approval, $confirmationText);
|
||||
|
||||
$this->_formParams = $formParams;
|
||||
}
|
||||
|
||||
/**
|
||||
* @copydoc Form::fetch()
|
||||
*
|
||||
* @param null|mixed $template
|
||||
*/
|
||||
public function fetch($request, $template = null, $display = false)
|
||||
{
|
||||
$templateMgr = TemplateManager::getManager($request);
|
||||
$templateMgr->assign('formParams', $this->getFormParams());
|
||||
return parent::fetch($request, $template, $display);
|
||||
}
|
||||
|
||||
//
|
||||
// Getters and Setters
|
||||
//
|
||||
/**
|
||||
* Get the extra form parameters.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getFormParams()
|
||||
{
|
||||
return $this->_formParams;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user