-
Notifications
You must be signed in to change notification settings - Fork 447
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'pkp:main' into structured-citations
- Loading branch information
Showing
16 changed files
with
594 additions
and
71 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
<?php | ||
/** | ||
* @file classes/components/form/counter/PKPCounterReportForm.php | ||
* | ||
* Copyright (c) 2024 Simon Fraser University | ||
* Copyright (c) 2024 John Willinsky | ||
* Distributed under the GNU GPL v3. For full terms see the file docs/COPYING. | ||
* | ||
* @class PKPCounterReportForm | ||
* | ||
* @ingroup classes_controllers_form | ||
* | ||
* @brief A form for setting a COUNTER R5 report | ||
*/ | ||
|
||
namespace PKP\components\forms\counter; | ||
|
||
use PKP\components\forms\FormComponent; | ||
|
||
define('FORM_COUNTER', 'counter'); | ||
|
||
abstract class PKPCounterReportForm extends FormComponent | ||
{ | ||
/** @copydoc FormComponent::$id */ | ||
public $id = FORM_COUNTER; | ||
|
||
/** @copydoc FormComponent::$method */ | ||
public $method = 'GET'; | ||
|
||
/** Form fields for each COUNTER R5 report */ | ||
public $reportFields = []; | ||
|
||
/** Set reportFields, that will contain form fields for each COUNTER R5 report */ | ||
abstract public function setReportFields(): void; | ||
|
||
/** | ||
* Constructor | ||
* | ||
* @param string $action URL to submit the form to | ||
* @param array $locales Supported locales | ||
*/ | ||
public function __construct(string $action, array $locales) | ||
{ | ||
$this->action = $action; | ||
$this->locales = $locales; | ||
|
||
$this->addPage(['id' => 'default', 'submitButton' => ['label' => __('common.download')]]); | ||
$this->addGroup(['id' => 'default', 'pageId' => 'default']); | ||
|
||
$this->setReportFields(); | ||
} | ||
|
||
public function getConfig() | ||
{ | ||
$config = parent::getConfig(); | ||
$config['reportFields'] = array_map(function ($reportFields) { | ||
return array_map(function ($reportField) { | ||
$field = $this->getFieldConfig($reportField); | ||
$field['groupId'] = 'default'; | ||
return $field; | ||
}, $reportFields); | ||
}, $this->reportFields); | ||
|
||
return $config; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
52 changes: 52 additions & 0 deletions
52
classes/components/listPanels/PKPCounterReportsListPanel.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
<?php | ||
/** | ||
* @file classes/components/listPanels/PKPCounterReportsListPanel.php | ||
* | ||
* Copyright (c) 2024 Simon Fraser University | ||
* Copyright (c) 2024 John Willinsky | ||
* Distributed under the GNU GPL v3. For full terms see the file docs/COPYING. | ||
* | ||
* @class PKPCounterReportsListPanel | ||
* | ||
* @ingroup classes_components_list | ||
* | ||
* @brief A ListPanel component for viewing, editing and downloading COUNTER R5 reports | ||
*/ | ||
|
||
namespace PKP\components\listPanels; | ||
|
||
use APP\components\forms\counter\CounterReportForm; | ||
use PKP\sushi\CounterR5Report; | ||
|
||
class PKPCounterReportsListPanel extends ListPanel | ||
{ | ||
/** URL to the API endpoint where items can be retrieved */ | ||
public string $apiUrl = ''; | ||
|
||
/** Form for setting up and downloading a report*/ | ||
public ?CounterReportForm $form = null; | ||
|
||
/** Query parameters to pass if this list executes GET requests */ | ||
public array $getParams = []; | ||
|
||
/** | ||
* @copydoc ListPanel::getConfig() | ||
*/ | ||
public function getConfig(): array | ||
{ | ||
$config = parent::getConfig(); | ||
|
||
$earliestDate = CounterR5Report::getEarliestDate(); | ||
$lastDate = CounterR5Report::getLastDate(); | ||
|
||
$config = array_merge( | ||
$config, | ||
[ | ||
'apiUrl' => $this->apiUrl, | ||
'form' => $this->form->getConfig(), | ||
'usagePossible' => $lastDate > $earliestDate, | ||
] | ||
); | ||
return $config; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.