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#2612 Submission filtering #1490

Merged
merged 6 commits into from
Aug 21, 2017
Merged
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
5 changes: 5 additions & 0 deletions classes/services/OJSServiceProvider.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,5 +35,10 @@ public function register(Container $pimple) {
$pimple['issue'] = function() {
return new IssueService();
};

// Section service
$pimple['section'] = function() {
return new SectionService();
};
}
}
41 changes: 41 additions & 0 deletions classes/services/SectionService.inc.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<?php

/**
* @file classes/services/SectionService.php
*
* Copyright (c) 2014-2017 Simon Fraser University
* Copyright (c) 2000-2017 John Willinsky
* Distributed under the GNU GPL v2. For full terms see the file docs/COPYING.
*
* @class SectionService
* @ingroup services
*
* @brief Helper class that encapsulates section business logic
*/

namespace OJS\Services;

class SectionService {

/**
* Get array of sections
*
* @param int $contextId
*
* @return array
*/
public function getSectionList($contextId) {
$sectionDao = \DAORegistry::getDAO('SectionDAO');
$sectionIterator = $sectionDao->getByContextId($contextId);

$sections = array();
while ($section = $sectionIterator->next()) {
$sections[] = array(
'id' => $section->getId(),
'title' => $section->getLocalizedTitle(),
);
}

return $sections;
}
}
94 changes: 94 additions & 0 deletions controllers/list/submissions/SubmissionsListHandler.inc.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
<?php
/**
* @file controllers/list/submissions/SubmissionsListHandler.inc.php
*
* Copyright (c) 2014-2017 Simon Fraser University
* Copyright (c) 2000-2017 John Willinsky
* Distributed under the GNU GPL v2. For full terms see the file docs/COPYING.
*
* @class SubmissionsListHandler
* @ingroup controllers_list
*
* @brief Instantiates and manages a UI component to list submissions.
*/
import('lib.pkp.controllers.list.submissions.PKPSubmissionsListHandler');
import('lib.pkp.classes.db.DBResultRange');
import('lib.pkp.classes.submission.Submission');

class SubmissionsListHandler extends PKPSubmissionsListHandler {

/**
* @copydoc PKPSubmissionsListHandler::getConfig()
*/
public function getConfig() {
$config = parent::getConfig();

$request = Application::getRequest();
if ($request->getContext()) {
if (!isset($config['filters'])) {
$config['filters'] = array();
}
$config['filters']['sectionIds'] = array(
'heading' => __('section.sections'),
'filters' => $this->getSectionFilters(),
);
}

return $config;
}

/**
* @copydoc PKPSubmissionsListHandler::getWorkflowStages()
*/
public function getWorkflowStages() {
return array(
array(
'param' => 'stageIds',
'val' => WORKFLOW_STAGE_ID_SUBMISSION,
'title' => __('manager.publication.submissionStage'),
),
array(
'param' => 'stageIds',
'val' => WORKFLOW_STAGE_ID_EXTERNAL_REVIEW,
'title' => __('manager.publication.reviewStage'),
),
array(
'param' => 'stageIds',
'val' => WORKFLOW_STAGE_ID_EDITING,
'title' => __('submission.copyediting'),
),
array(
'param' => 'stageIds',
'val' => WORKFLOW_STAGE_ID_PRODUCTION,
'title' => __('manager.publication.productionStage'),
),
);
}

/**
* Compile the sections for passing as filters
*
* @return array
*/
public function getSectionFilters() {
$request = Application::getRequest();
$context = $request->getContext();

if (!$context) {
return array();
}

import('classes.core.ServicesContainer');
$sections = ServicesContainer::instance()
->get('section')
->getSectionList($context->getId());

return array_map(function($section) {
return array(
'param' => 'sectionIds',
'val' => $section['id'],
'title' => $section['title'],
);
}, $sections);
}
}
2 changes: 2 additions & 0 deletions js/load.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,5 +36,7 @@ window.pkp = {
return true;
}
}

return false;
}
};