Skip to content

Commit

Permalink
NBBIB-451 Parse languages + correct date default return
Browse files Browse the repository at this point in the history
  • Loading branch information
camilocodes committed Aug 29, 2024
1 parent fe30be9 commit 4152f32
Showing 1 changed file with 37 additions and 2 deletions.
39 changes: 37 additions & 2 deletions custom/modules/unblib_marc/script/import_marc.php
Original file line number Diff line number Diff line change
Expand Up @@ -144,13 +144,15 @@ function migrateMarc(string $source, string $entity_type, array $map, bool $publ
}
}

if ($field == 'language' and $value) {
echo "\n*****$field\n";
var_dump($value);
}
}
$n++; // Debug.

if ($n == 100) { // Debug.
exit;
//exit;
}

// @TODO: Pass array of mandatory fields and only save if constraints met.
Expand Down Expand Up @@ -191,7 +193,7 @@ function date2dmy($date) {
return $year[0];
}

return $data;
return $date;
}

function create_author($author_name) {
Expand Down Expand Up @@ -271,6 +273,39 @@ function create_physical($data) {
return $physical;
}

function marc2lang($language) {
if (!empty($language)) {
if (strstr($language, 'ara') || strstr('ara', $language)) {
$language = 'ara';
}
elseif (strstr($language, 'deu') || strstr('deu', $language)) {
$language = 'deu';
}
elseif (strstr($language, 'fre') || strstr('fre', $language)) {
$language = 'fre';
}
elseif (strstr($language, 'lat') || strstr('lat', $language)) {
$language = 'lat';
}
elseif (strstr($language, "mic") || strstr("mic", $language)) {
$language = 'mic';
}
elseif (strstr($language, "pqm") || strstr("pqm", $language)) {
$language = 'pqm';
}
elseif (strstr($language, 'spa') || strstr('spa', $language)) {
$language = 'spa';
}
else {
$language = 'eng';
}
}
else {
$language = 'eng';
}

return $language;
}

function parseRecord($subfield, $data) {
// If $subfield == 'a', match everything starting with [a]:<space> and ending before [a] or end of string.
Expand Down

0 comments on commit 4152f32

Please sign in to comment.