-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathArtsReportForm.php
More file actions
99 lines (74 loc) · 2.78 KB
/
Copy pathArtsReportForm.php
File metadata and controls
99 lines (74 loc) · 2.78 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
<?php
namespace APP\plugins\generic\arts;
use APP\core\Application;
use APP\template\TemplateManager;
use PKP\form\Form;
use PKP\form\validation\FormValidatorCSRF;
use PKP\form\validation\FormValidatorPost;
use Symfony\Component\Yaml\Yaml;
class ArtsReportForm extends Form
{
/* @var int Associated context ID */
private $contextId;
/* @var ReviewersReport */
private $plugin;
private $application;
/**
* Constructor
*
* @param $plugin ReviewersReport Manual payment plugin
*/
public function __construct($plugin)
{
$this->plugin = $plugin;
$this->application = substr(Application::getName(), 0, 3);
$request = Application::get()->getRequest();
$this->contextId = $request->getContext()->getId();
parent::__construct($plugin->getTemplateResource('form.tpl'));
$this->addCheck(new FormValidatorPost($this));
$this->addCheck(new FormValidatorCSRF($this));
}
public function display($request = null, $template = null, $args = null)
{
$templateManager = TemplateManager::getManager();
$templateManager->assign('operations', ArtsHandler::DATA_OPERATIONS);
try {
$folderPath = dirname(__FILE__, 1) . '/configs/';
$files = scandir($folderPath);
$filesnames = [];
foreach ($files as $file) {
if (is_file($folderPath . '/' . $file)) {
$yaml = Yaml::parseFile($folderPath . '/' . $file);
$temp = [];
$temp['name'] = $yaml['report']['config']['name'];
$temp['description'] = $yaml['report']['config']['description'];
$temp['filename'] = str_replace('.yaml', '', $file);
$filesnames[] = $temp;
}
}
$templateManager->assign('filesnames', $filesnames);
} catch (\Throwable $th) {
error_log("ARTS error: ".$th->getMessage());
}
$context = Application::get()
->getRequest()
->getContext();
$journalPath = $request->getContext()->getPath();
$baseUrl = $request->getBaseUrl();
$url = $baseUrl . '/index.php/' . $journalPath . '/ARTS/parseyaml/';
$templateManager->assign('baseURL', $url);
$templateManager->assign('formats', [
'json',
'csv',
]);
$templateManager->assign('auths', [
'admin',
'any',
]);
$templateManager->assign('operationsheader', [
'count',
]);
$templateManager->assign('application', $this->application);
$templateManager->display($this->plugin->getTemplateResource($template));
}
}