Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pkp/pkp-lib#2444: Refactor GridCellProvider::__construct() #1352

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion classes/controllers/grid/issues/IssueGridHandler.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ function initialize($request, $args = null) {

// Grid columns.
import('controllers.grid.issues.IssueGridCellProvider');
$issueGridCellProvider = new IssueGridCellProvider();
$issueGridCellProvider = new IssueGridCellProvider($request);

// Issue identification
$this->addColumn(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,11 @@ class ArticleGalleyGridCellProvider extends DataObjectGridCellProvider {

/**
* Constructor
* @param $request PKPRequest
* @param $submission Submission
*/
function __construct($submission) {
parent::__construct();
function __construct($request, $submission) {
parent::__construct($request);
$this->_submission = $submission;
}

Expand Down Expand Up @@ -65,7 +66,7 @@ function getRequestArgs($row) {
/**
* @copydoc GridCellProvider::getCellActions()
*/
function getCellActions($request, $row, $column) {
function getCellActions($row, $column) {
switch ($column->getId()) {
case 'label':
$element = $row->getData();
Expand All @@ -79,9 +80,9 @@ function getCellActions($request, $row, $column) {
$element->getSubmissionId()
);
import('lib.pkp.controllers.api.file.linkAction.DownloadFileLinkAction');
return array(new DownloadFileLinkAction($request, $submissionFile, $request->getUserVar('stageId'), $element->getLabel()));
return array(new DownloadFileLinkAction($this->_request, $submissionFile, $this->_request->getUserVar('stageId'), $element->getLabel()));
}
return parent::getCellActions($request, $row, $column);
return parent::getCellActions($row, $column);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ function initialize($request, $args = null) {
);

import('controllers.grid.articleGalleys.ArticleGalleyGridCellProvider');
$cellProvider = new ArticleGalleyGridCellProvider($this->getSubmission());
$cellProvider = new ArticleGalleyGridCellProvider($request, $this->getSubmission());

// Columns
$this->addColumn(new GridColumn(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,7 @@

class IssueGalleyGridCellProvider extends GridCellProvider {
/**
* Constructor
*/
function __construct() {
parent::__construct();
}

/**
* Extracts variables for a given column from a data element
* so that they may be assigned to template before rendering.
* @param $row GridRow
* @param $column GridColumn
* @return array
* @copydoc GridCellProvider::getTemplateVarsFromRowColumn()
*/
function getTemplateVarsFromRowColumn($row, $column) {
$issueGalley = $row->getData();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ function initialize($request, $args = null) {

// Grid columns.
import('controllers.grid.issueGalleys.IssueGalleyGridCellProvider');
$issueGalleyGridCellProvider = new IssueGalleyGridCellProvider();
$issueGalleyGridCellProvider = new IssueGalleyGridCellProvider($request);

// Issue identification
$this->addColumn(
Expand Down
16 changes: 6 additions & 10 deletions controllers/grid/issues/IssueGridCellProvider.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ class IssueGridCellProvider extends GridCellProvider {
/**
* Constructor
*/
function __construct() {
parent::__construct();
function __constuct($request) {
parent::__constuct($request);
$this->dateFormatShort = Config::getVar('general', 'date_format_short');
}

Expand All @@ -33,17 +33,17 @@ function __construct() {
* @param $column GridColumn
* @return array an array of LinkAction instances
*/
function getCellActions($request, $row, $column, $position = GRID_ACTION_POSITION_DEFAULT) {
function getCellActions($row, $column, $position = GRID_ACTION_POSITION_DEFAULT) {
if ($column->getId() == 'identification') {
$issue = $row->getData();
assert(is_a($issue, 'Issue'));
$router = $request->getRouter();
$router = $this->_request->getRouter();
import('lib.pkp.classes.linkAction.request.AjaxModal');
return array(
new LinkAction(
'edit',
new AjaxModal(
$router->url($request, null, null, 'editIssue', null, array('issueId' => $issue->getId())),
$router->url($this->_request, null, null, 'editIssue', null, array('issueId' => $issue->getId())),
__('editor.issues.editIssue', array('issueIdentification' => $issue->getIssueIdentification())),
'modal_edit',
true
Expand All @@ -56,11 +56,7 @@ function getCellActions($request, $row, $column, $position = GRID_ACTION_POSITIO
}

/**
* Extracts variables for a given column from a data element
* so that they may be assigned to template before rendering.
* @param $row GridRow
* @param $column GridColumn
* @return array
* @copydoc GridCellProvider::getTemplateVarsFromRowColumn()
*/
function getTemplateVarsFromRowColumn($row, $column) {
$issue = $row->getData();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,16 @@ class PubIdExportIssuesListGridCellProvider extends DataObjectGridCellProvider {

/**
* Constructor
* @param $request PKPRequest
* @param $plugin PKPPlugin
* @param $authorizedRoles mixed
*/
function __construct($plugin, $authorizedRoles = null) {
function __construct($request, $plugin, $authorizedRoles = null) {
$this->_plugin = $plugin;
if ($authorizedRoles) {
$this->_authorizedRoles = $authorizedRoles;
}
parent::__construct();
parent::__construct($request);
}

//
Expand All @@ -38,7 +41,7 @@ function __construct($plugin, $authorizedRoles = null) {
*
* @copydoc GridCellProvider::getCellActions()
*/
function getCellActions($request, $row, $column, $position = GRID_ACTION_POSITION_DEFAULT) {
function getCellActions($row, $column, $position = GRID_ACTION_POSITION_DEFAULT) {
$publishedIssue = $row->getData();
$columnId = $column->getId();
assert(is_a($publishedIssue, 'Issue') && !empty($columnId));
Expand All @@ -53,7 +56,7 @@ function getCellActions($request, $row, $column, $position = GRID_ACTION_POSITIO
new LinkAction(
'edit',
new AjaxModal(
$dispatcher->url($request, ROUTE_COMPONENT, null, 'grid.issues.BackIssueGridHandler', 'editIssue', null, array('issueId' => $publishedIssue->getId())),
$dispatcher->url($this->_request, ROUTE_COMPONENT, null, 'grid.issues.BackIssueGridHandler', 'editIssue', null, array('issueId' => $publishedIssue->getId())),
__('plugins.importexport.common.settings.DOIPluginSettings')
),
$publishedIssue->getIssueIdentification(),
Expand All @@ -79,7 +82,7 @@ function getCellActions($request, $row, $column, $position = GRID_ACTION_POSITIO
);
}
}
return parent::getCellActions($request, $row, $column, $position);
return parent::getCellActions($row, $column, $position);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ function initialize($request, $args = null) {
$authorizedRoles = $this->getAuthorizedContextObject(ASSOC_TYPE_USER_ROLES);

// Grid columns.
$cellProvider = new PubIdExportIssuesListGridCellProvider($this->_plugin, $authorizedRoles);
$cellProvider = new PubIdExportIssuesListGridCellProvider($request, $this->_plugin, $authorizedRoles);
$this->addColumn(
new GridColumn(
'identification',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,16 @@ class PubIdExportRepresentationsListGridCellProvider extends DataObjectGridCellP

/**
* Constructor
* @param $request PKPRequest
* @param $plugin PKPPlugin
* @param $authorizedRoles mixed
*/
function __construct($plugin, $authorizedRoles = null) {
function __construct($request, $plugin, $authorizedRoles = null) {
$this->_plugin = $plugin;
if ($authorizedRoles) {
$this->_authorizedRoles = $authorizedRoles;
}
parent::__construct();
parent::__construct($request);
}

//
Expand All @@ -39,7 +42,7 @@ function __construct($plugin, $authorizedRoles = null) {
*
* @copydoc GridCellProvider::getCellActions()
*/
function getCellActions($request, $row, $column, $position = GRID_ACTION_POSITION_DEFAULT) {
function getCellActions($row, $column, $position = GRID_ACTION_POSITION_DEFAULT) {
$publishedSubmissionGalley = $row->getData();
$columnId = $column->getId();
assert(is_a($publishedSubmissionGalley, 'ArticleGalley') && !empty($columnId));
Expand All @@ -59,7 +62,7 @@ function getCellActions($request, $row, $column, $position = GRID_ACTION_POSITIO
new LinkAction(
'itemWorkflow',
new RedirectAction(
SubmissionsListGridCellProvider::getUrlByUserRoles($request, $publishedSubmission)
SubmissionsListGridCellProvider::getUrlByUserRoles($this->_request, $publishedSubmission)
),
$title
)
Expand All @@ -77,7 +80,7 @@ function getCellActions($request, $row, $column, $position = GRID_ACTION_POSITIO
new LinkAction(
'edit',
new AjaxModal(
$dispatcher->url($request, ROUTE_COMPONENT, null, 'grid.issues.BackIssueGridHandler', 'editIssue', null, array('issueId' => $issue->getId())),
$dispatcher->url($this->_request, ROUTE_COMPONENT, null, 'grid.issues.BackIssueGridHandler', 'editIssue', null, array('issueId' => $issue->getId())),
__('plugins.importexport.common.settings.DOIPluginSettings')
),
$issue->getIssueIdentification(),
Expand All @@ -102,14 +105,11 @@ function getCellActions($request, $row, $column, $position = GRID_ACTION_POSITIO
);
}
}
return parent::getCellActions($request, $row, $column, $position);
return parent::getCellActions($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()
* @copydoc GridCellProvider::getTemplateVarsFromRowColumn()
*/
function getTemplateVarsFromRowColumn($row, $column) {
$publishedSubmissionGalley = $row->getData();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ function initialize($request, $args = null) {
$authorizedRoles = $this->getAuthorizedContextObject(ASSOC_TYPE_USER_ROLES);

// Grid columns.
$cellProvider = new PubIdExportRepresentationsListGridCellProvider($this->_plugin, $authorizedRoles);
$cellProvider = new PubIdExportRepresentationsListGridCellProvider($request, $this->_plugin, $authorizedRoles);
$this->addColumn(
new GridColumn(
'id',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,7 @@

class PubIdExportSubmissionsListGridCellProvider extends ExportPublishedSubmissionsListGridCellProvider {
/**
* Constructor
*/
function __construct($plugin, $authorizedRoles = null) {
parent::__construct($plugin, $authorizedRoles);
}

/**
* @copydoc ExportPublishedSubmissionsListGridCellProvider::getTemplateVarsFromRowColumn()
* @copydoc GridCellProvider::getTemplateVarsFromRowColumn()
*/
function getTemplateVarsFromRowColumn($row, $column) {
$publishedSubmission = $row->getData();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,9 @@ function getGridCellProvider() {
// Fetch the authorized roles.
$authorizedRoles = $this->getAuthorizedContextObject(ASSOC_TYPE_USER_ROLES);
import('controllers.grid.pubIds.PubIdExportSubmissionsListGridCellProvider');
return new PubIdExportSubmissionsListGridCellProvider($this->_plugin, $authorizedRoles);
// TODO: pkp/pkp-lib#2444 Where should the request come from?
$request = PKPApplication::getRequest();
return new PubIdExportSubmissionsListGridCellProvider($request, $this->_plugin, $authorizedRoles);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,16 @@ class ExportPublishedSubmissionsListGridCellProvider extends DataObjectGridCellP

/**
* Constructor
* @param $request PKPRequest
* @param $plugin PKPPlugin
* @param $authorizedRoles mixed
*/
function __construct($plugin, $authorizedRoles = null) {
function __construct($request, $plugin, $authorizedRoles = null) {
$this->_plugin = $plugin;
if ($authorizedRoles) {
$this->_authorizedRoles = $authorizedRoles;
}
parent::__construct();
parent::__construct($request);
}

//
Expand All @@ -38,7 +41,7 @@ function __construct($plugin, $authorizedRoles = null) {
*
* @copydoc GridCellProvider::getCellActions()
*/
function getCellActions($request, $row, $column, $position = GRID_ACTION_POSITION_DEFAULT) {
function getCellActions($row, $column, $position = GRID_ACTION_POSITION_DEFAULT) {
$publishedSubmission = $row->getData();
$columnId = $column->getId();
assert(is_a($publishedSubmission, 'PublishedArticle') && !empty($columnId));
Expand All @@ -56,7 +59,7 @@ function getCellActions($request, $row, $column, $position = GRID_ACTION_POSITIO
new LinkAction(
'itemWorkflow',
new RedirectAction(
SubmissionsListGridCellProvider::getUrlByUserRoles($request, $publishedSubmission)
SubmissionsListGridCellProvider::getUrlByUserRoles($this->_request, $publishedSubmission)
),
$title
)
Expand All @@ -74,7 +77,7 @@ function getCellActions($request, $row, $column, $position = GRID_ACTION_POSITIO
new LinkAction(
'edit',
new AjaxModal(
$dispatcher->url($request, ROUTE_COMPONENT, null, 'grid.issues.BackIssueGridHandler', 'editIssue', null, array('issueId' => $issue->getId())),
$dispatcher->url($this->_request, ROUTE_COMPONENT, null, 'grid.issues.BackIssueGridHandler', 'editIssue', null, array('issueId' => $issue->getId())),
__('plugins.importexport.common.settings.DOIPluginSettings')
),
$issue->getIssueIdentification(),
Expand All @@ -99,14 +102,11 @@ function getCellActions($request, $row, $column, $position = GRID_ACTION_POSITIO
);
}
}
return parent::getCellActions($request, $row, $column, $position);
return parent::getCellActions($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()
* @copydoc GridCellProvider::getTemplateVarsFromRowColumn()
*/
function getTemplateVarsFromRowColumn($row, $column) {
$publishedSubmission = $row->getData();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,9 @@ function getGridCellProvider() {
// Fetch the authorized roles.
$authorizedRoles = $this->getAuthorizedContextObject(ASSOC_TYPE_USER_ROLES);
import('controllers.grid.submissions.ExportPublishedSubmissionsListGridCellProvider');
return new ExportPublishedSubmissionsListGridCellProvider($this->_plugin, $authorizedRoles);
// TODO: pkp/pkp-lib#2444 Where should the request come from?
$request = PKPApplication::getRequest();
return new ExportPublishedSubmissionsListGridCellProvider($request, $this->_plugin, $authorizedRoles);
}

}
Expand Down
12 changes: 5 additions & 7 deletions controllers/grid/toc/TocGridCellProvider.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,15 @@
class TocGridCellProvider extends GridCellProvider {
/**
* Constructor
* @param $request PKPRequest
* @param $translate boolean
*/
function __construct($translate = false) {
parent::__construct();
function __construct($request, $translate = false) {
parent::__construct($request);
}

/**
* Extracts variables for a given column from a data element
* so that they may be assigned to template before rendering.
* @param $row GridRow
* @param $column GridColumn
* @return array
* @copydoc GridCellProvider::getTemplateVarsFromRowColumn()
*/
function getTemplateVarsFromRowColumn($row, $column) {
$element = $row->getData();
Expand Down
2 changes: 1 addition & 1 deletion controllers/grid/toc/TocGridHandler.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ function initialize($request) {
// Grid columns.
//
import('controllers.grid.toc.TocGridCellProvider');
$tocGridCellProvider = new TocGridCellProvider();
$tocGridCellProvider = new TocGridCellProvider($request);

// Article title
$this->addColumn(
Expand Down