Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion application/configs/doctypes_templates/doi.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,8 @@ $config = Config::get();
doiimport_button_cancel: "<?= $this->translate('doiimport_button_cancel'); ?>",
doiimport_button_showId: "<?= $this->translate('doiimport_button_showId'); ?>",
doiimport_button_back: "<?= $this->translate('doiimport_button_back'); ?>",
doiimport_button_tryAgain: "<?= $this->translate('doiimport_button_tryAgain'); ?>"
doiimport_button_tryAgain: "<?= $this->translate('doiimport_button_tryAgain'); ?>",
doiimport_hint_manyAuthors: "<?= $this->translate('doiimport_hint_manyAuthors'); ?>"
};

let opusConfig = {
Expand Down
9 changes: 9 additions & 0 deletions modules/publish/language/doiimport.tmx
Original file line number Diff line number Diff line change
Expand Up @@ -124,5 +124,14 @@
</tuv>
</tu>

<tu tuid="doiimport_hint_manyAuthors">
<tuv xml:lang="en">
<seg>The DOI dataset has too many authors (%s). The first 49 authors and the last author are imported.</seg>
</tuv>
<tuv xml:lang="de">
<seg>Der DOI-Datensatz hat zu viele AutorInnen (%s). Importiert werden die ersten 49 AutorInnen sowie der/die letzte AutorIn.</seg>
</tuv>
</tu>

</body>
</tmx>
29 changes: 24 additions & 5 deletions public/layouts/opus4/js/doiAssist.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ function finalize(field)
{
// Grüne Farbe und Feldname wird in populatedFields geschrieben, um die Feldfarben nach einem Reload neu aufzubauen
colorGreen(field);
populatedFields.push(field);
populatedFields.push(" " + field);
}

function colorGreen(field)
Expand Down Expand Up @@ -325,7 +325,9 @@ function getAuthor(json)

var authors = [];
var _laenge = json.message.author.length;

if (_laenge > 0) {
// Zuerst alle Autoren in das 'authors'-Array einfügen
for (_z = 0; _z < _laenge; _z++) {
if (json.message.author[_z].given != null || json.message.author[_z].family != null) {
vorname = json.message.author[_z].given;
Expand All @@ -337,22 +339,39 @@ function getAuthor(json)
if (re != null) {
orcid = re[0];
} else {
orcid = ''
orcid = '';
}
} else {
orcid = json.message.author[_z].ORCID;
}
} else {
orcid = ''
orcid = '';
}
complete_name = nachname + ',' + vorname + ',' + orcid;
authors.push(complete_name);
}
}

// Prüfen, ob es mehr als 50 Autoren gibt
if (_laenge > 50) {
// Den letzten Autor extrahieren
let lastAuthor;
//lastAuthor = authors[_laenge - 1];
if (authors[_laenge - 1]) {
lastAuthor = authors[_laenge - 1];
} else {
lastAuthor = authors[_laenge - 2];
}
// Entferne den letzten Autor vom Array (da wir ihn an Position 50 wieder einfügen)
authors.pop();
// Füge den letzten Autor an der 50. Position ein
authors.splice(49, 0, lastAuthor);
//alert("lastAuthor: "+lastAuthor);
}
}
return authors
return authors; // Gibt das Autoren-Array direkt zurück
} else {
return ''
return '';
}
}
exports.getAuthor = getAuthor;
Expand Down
84 changes: 48 additions & 36 deletions public/layouts/opus4/js/getDoi.js
Original file line number Diff line number Diff line change
Expand Up @@ -239,48 +239,60 @@ function expandPages(page)

function expandAuthor(author)
{
if (author[0] !== undefined) {
var _laenge = author.length;
var completeName = author[0] + '';
// Abbruch, wenn kein Autor vorhanden
if (! author[0]) {
document.getElementById("Enrichmentopus_doi_flag").value = "true";
return;
}

var vorname = completeName.split(',')[1].trim(); // [1] = Vorname
document.getElementById("PersonAuthorFirstName_1").value = vorname;
finalize("PersonAuthorFirstName_1");
const maxAuthors = 50;
const authorLength = author.length;

var nachname = completeName.split(',')[0].trim(); // [0] = Nachname
document.getElementById("PersonAuthorLastName_1").value = nachname;
finalize("PersonAuthorLastName_1");
// Setzen von Autor-Informationen
const setAuthorInfo = (index, feld) => {
const completeName = author[index] + '';
const [nachname, vorname, orcid] = completeName.split(',').map(s => s.trim());

if (completeName.split(',')[2].trim() !== '') {
var orcid = completeName.split(',')[2].trim(); // [2] = ORCID
document.getElementById("PersonAuthorIdentifierOrcid_1").value = orcid;
finalize("PersonAuthorIdentifierOrcid_1");
document.getElementById(`PersonAuthorFirstName_${feld}`).value = vorname;
finalize(`PersonAuthorFirstName_${feld}`);

document.getElementById(`PersonAuthorLastName_${feld}`).value = nachname;
finalize(`PersonAuthorLastName_${feld}`);

if (orcid) {
document.getElementById(`PersonAuthorIdentifierOrcid_${feld}`).value = orcid;
finalize(`PersonAuthorIdentifierOrcid_${feld}`);
}
};

if (document.getElementById('PersonAuthorLastName_' + _laenge) === null) {
var button = document.getElementById("addMorePersonAuthor");
button.click();
} else {
var _z;
for (_z = 1; _z < _laenge; _z++) {
var feld = _z + 1;
var completeName = author[_z] + '';
var vorname = completeName.split(',')[1].trim(); // [1] = Vorname
document.getElementById("PersonAuthorFirstName_" + feld).value = vorname;
finalize("PersonAuthorFirstName_" + feld);
var nachname = completeName.split(',')[0].trim(); // [0] = Nachname
document.getElementById("PersonAuthorLastName_" + feld).value = nachname;
finalize("PersonAuthorLastName_" + feld);
if (completeName.split(',')[2].trim() !== '') {
var orcid = completeName.split(',')[2].trim(); // [2] = ORCID
document.getElementById("PersonAuthorIdentifierOrcid_" + feld).value = orcid;
finalize("PersonAuthorIdentifierOrcid_" + feld);
}
}
document.getElementById("Enrichmentopus_doi_flag").value = "true"; // Hier wird das Ende der Reloads erreicht! (alle Felder sind vorhanden)
// Überprüfen und ggf. weitere Autor-Felder hinzufügen
let maxFields = Math.min(maxAuthors, authorLength);
const ensureAuthorFields = () => {
if (document.getElementById(`PersonAuthorLastName_${maxFields}`) === null) {
document.getElementById("addMorePersonAuthor").click();
return false;
}
} else {
colorPink("PersonAuthorLastName_1");
return true;
};

// Überprüfen und Hinweis für zu viele Autoren
if (document.getElementById('PersonAuthorLastName_' + maxAuthors) !== null ) {
openDialog(translations.doiimport_header_note, translations.doiimport_hint_manyAuthors.replace('%s', authorLength), "OK");
}

// Ersten Autor setzen
setAuthorInfo(0, 1);

// Weitere Autoren setzen
if (ensureAuthorFields()) {
const limitedLength = Math.min(authorLength, maxAuthors);

for (let i = 1; i < limitedLength; i++) {
setAuthorInfo(i, i + 1);
}

// Flag setzen, dass alle Felder vorhanden sind
document.getElementById("Enrichmentopus_doi_flag").value = "true";
}
}

Expand Down
Loading