-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathKBARTExportHandler.inc.php
101 lines (84 loc) · 3.19 KB
/
KBARTExportHandler.inc.php
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
100
101
<?php
import('classes.handler.Handler');
class KBARTExportHandler extends Handler {
/** @var KBARTExportPlugin The kbart export plugin */
static $plugin;
/**
* Provide the kbart export plugin to the handler.
* @param $plugin KBARTExportPlugin
*/
static function setPlugin($plugin) {
self::$plugin = $plugin;
}
/**
* Handle index request (redirect to "view")
* @param $args array Arguments array.
* @param $request PKPRequest Request object.
*/
function index($args, $request) {
$context = Application::get()->getRequest()->getContext();
$contextId = $context ? $context->getId() : CONTEXT_SITE;
$plugin = PluginRegistry::getPlugin('generic','kbartexportplugin');
$providerName = $plugin->getSetting($contextId, 'providerName');
$regionConsortium = $plugin->getSetting($contextId, 'regionConsortium');
$packageName = $plugin->getSetting($contextId, 'packageName');
$timestamp = time();
$date = date("Y-m-d",$timestamp);
$fileName = $providerName . "_" . $regionConsortium . "_" . $packageName . "_" . $date . ".txt";
// Define file header
$headers = [
"Journal-Titel ; ",
"URL ; ",
"Print ISSN ; ",
"Online ISSN ; ",
"Publisher ; ",
"Journal ID\n"
];
// Build Rows
$journals = DAORegistry::getDAO('JournalDAO')->getAll(true)->toArray();
foreach($journals as $journal) {
$title = $journal->getLocalizedName();
$journalId = $journal->getData('id');
$url = $request->getRouter()->url($request, $journal->getPath());
$printIssn = $journal->getSetting('printIssn');
$onlineIssn = $journal->getSetting('onlineIssn');
$publisherName = $journal->getSetting('publisherInstitution');
$entry = [
$title,
$url,
$printIssn,
$onlineIssn,
// $dateFirstIssueOnline,
// $numberFirstVolumeOnline,
// $numberFirstIssueOnline,
// $dateLastIssueOnline,
// $numberLastVolumeOnline,
// $numberLastIssueOnline,
$publisherName,
//$titleUrl
$journalId
];
$entries[] = $entry;
}
// List table entries in alphabetical order by journal title
usort($entries, function ($item1, $item2) {
return strnatcasecmp($item1[0], $item2[0]);
});
// Trigger the "Save as" dialog
header('Content-Description: File Transfer');
header('Content-Disposition: attachment; filename=' . $fileName);
header('Expires: 0');
header('Cache-Control: must-revalidate');
header('Pragma: public');
//header('Content-Length: ' . filesize($file));
header("Content-Type: text/plain");
// Output file header
foreach($headers as $header) {
echo $header;
}
// Output file body
foreach($entries as $entry) {
echo implode(" ; ",$entry) . "\n";
}
}
}