HEX
Server: Apache/2.4.41 (Ubuntu)
System: Linux vmi1674223.contaboserver.net 5.4.0-182-generic #202-Ubuntu SMP Fri Apr 26 12:29:36 UTC 2024 x86_64
User: root (0)
PHP: 7.4.3-4ubuntu2.22
Disabled: pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare,
Upload Files
File: /var/www/ojs/classes/components/listPanels/SubmissionsListPanel.inc.php
<?php
/**
 * @file components/listPanels/SubmissionsListPanel.inc.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 SubmissionsListPanel
 * @ingroup classes_components_listPanels
 *
 * @brief Instantiates and manages a UI component to list submissions.
 */

namespace APP\components\listPanels;

use APP\components\forms\FieldSelectIssues;
use PKP\components\listPanels\PKPSubmissionsListPanel;
use PKP\components\forms\FieldAutosuggestPreset;

class SubmissionsListPanel extends PKPSubmissionsListPanel {

	/** @var boolean Whether to show inactive section filters */
	public $includeActiveSectionFiltersOnly = false;

	/** @var boolean Whether to show issue filters */
	public $includeIssuesFilter = false;

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

		$request = \Application::get()->getRequest();
		if ($request->getContext()) {
			$config['filters'][] = $this->getSectionFilters($this->includeActiveSectionFiltersOnly);
		}

		if ($this->includeIssuesFilter) {
			$issueAutosuggestField = new FieldSelectIssues('issueIds', [
				'label' => __('issue.issues'),
				'value' => [],
				'apiUrl' => $request->getDispatcher()->url($request, ROUTE_API, $request->getContext()->getPath(), 'issues'),
			]);
			$config['filters'][] = [
				'filters' => [
					[
						'title' => __('issue.issues'),
						'param' => 'issueIds',
						'value' => [],
						'filterType' => 'pkp-filter-autosuggest',
						'component' => 'field-select-issues',
						'autosuggestProps' => $issueAutosuggestField->getConfig(),
					]
				]
			];
		}
		return $config;
	}

	/**
	 * Get an array of workflow stages supported by the current app
	 *
	 * @return array
	 */
	public function getWorkflowStages() {
		return array(
			array(
				'param' => 'stageIds',
				'value' => WORKFLOW_STAGE_ID_SUBMISSION,
				'title' => __('manager.publication.submissionStage'),
			),
			array(
				'param' => 'stageIds',
				'value' => WORKFLOW_STAGE_ID_EXTERNAL_REVIEW,
				'title' => __('manager.publication.reviewStage'),
			),
			array(
				'param' => 'stageIds',
				'value' => WORKFLOW_STAGE_ID_EDITING,
				'title' => __('submission.copyediting'),
			),
			array(
				'param' => 'stageIds',
				'value' => WORKFLOW_STAGE_ID_PRODUCTION,
				'title' => __('manager.publication.productionStage'),
			),
		);
	}

	/**
	 * Compile the sections for passing as filters
	 *
	 * @param $activeOnly boolean show inactive section filters or not
	 * @return array
	 */
	public function getSectionFilters($activeOnly = false) {
		$request = \Application::get()->getRequest();
		$context = $request->getContext();

		$sections = \Services::get('section')->getSectionList($context->getId(), $activeOnly);

		// Use an autosuggest field if the list of submissions is too long
		if (count($sections) > 5) {
			$autosuggestField = new FieldAutosuggestPreset('sectionIds', [
				'label' => __('section.sections'),
				'value' => [],
				'options' => array_map(function($section) {
					return [
						'value' => (int) $section['id'],
						'label' => $section['title'],
					];
				}, $sections),
			]);
			return [
				'filters' => [
					[
						'title' => __('section.sections'),
						'param' => 'sectionIds',
						'filterType' => 'pkp-filter-autosuggest',
						'component' => 'field-autosuggest-preset',
						'value' => [],
						'autosuggestProps' => $autosuggestField->getConfig(),
					]
				],
			];
		}

		return [
			'heading' => __('section.sections'),
			'filters' => array_map(function($section) {
				return [
					'param' => 'sectionIds',
					'value' => (int) $section['id'],
					'title' => $section['title'],
				];
			}, $sections),
		];
	}
}