|
| 1 | +<?php |
| 2 | + |
| 3 | +require_once dirname(__FILE__) . '/../classes/headstart/library/CommUtils.php'; |
| 4 | +require_once dirname(__FILE__) . '/../classes/headstart/library/APIClient.php'; |
| 5 | +require_once dirname(__FILE__) . '/../classes/headstart/library/toolkit.php'; |
| 6 | +use headstart\library; |
| 7 | + |
| 8 | +function export($export_format, $metadata_json) { |
| 9 | + $INI_DIR = dirname(__FILE__) . "/../preprocessing/conf/"; |
| 10 | + $ini_array = library\Toolkit::loadIni($INI_DIR); |
| 11 | + $apiclient = new \headstart\library\APIClient($ini_array); |
| 12 | + |
| 13 | + |
| 14 | + $payload = $metadata_json; |
| 15 | + #$res = $apiclient->call_persistence("export/" . $export_format, $payload); |
| 16 | + $res = $apiclient->call_api("export/" . $export_format, $payload); |
| 17 | + return $res; |
| 18 | +}; |
| 19 | + |
| 20 | +$json = $_POST['paper']; |
| 21 | +$format = (isset($_REQUEST['format'])) ? $_REQUEST['format'] : "bibtex"; |
| 22 | +$download = (isset($_REQUEST['download'])) ? $_REQUEST['download'] : false; |
| 23 | +$result = export($format, $json); |
| 24 | + |
| 25 | +if (isset($result["status"]) && $result["status"] === "error") { |
| 26 | + header('Content-type: application/json'); |
| 27 | + echo json_encode($result); |
| 28 | +} |
| 29 | + |
| 30 | +if ($format == "bibtex") { |
| 31 | + $format = "bib"; |
| 32 | +} |
| 33 | + |
| 34 | +if (isset($download) & $download==true ) { |
| 35 | + header('Content-type: application/text'); |
| 36 | + header('Content-Disposition: attachment; filename=metadata.' . $format); |
| 37 | +} else { |
| 38 | + header('Content-type: text/plain'); |
| 39 | +} |
| 40 | + |
| 41 | +$result = json_decode($result["result"], true); |
| 42 | +echo $result["export"]; |
| 43 | + |
| 44 | +?> |
0 commit comments