forked from pkp/pkp-lib
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request pkp#10149 from bozana/9666
pkp#9666 COUNTER R5 TSV reports
- Loading branch information
Showing
9 changed files
with
519 additions
and
18 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; | ||
} | ||
} |
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.