function preprocessText($text, $field) { if ($field == 'titleBib') { $text = replaceArrowBrackets($text); $shortText = substr($text, 0, 30); if (strlen($text) > 30) { print strlen($text) . "\n"; $shortText .= '...'; } $text = $shortText; } return $text; }
function load_data_liddel($server, $user, $password, $database, $table) { $db = new mysqli($server, $user, $password, $database); $db->set_charset("utf8"); if (mysqli_connect_errno()) { die('Konnte keine Verbindung zur Datenbank aufbauen: ' . mysqli_connect_error() . '(' . mysqli_connect_errno() . ')'); } $archive = new GeoDataArchive(); $archive->loadFromFile(); $translatePlaces = array('Görlitz (Dresden)' => 'Görlitz', 'Middleburg' => 'Middelburg', 'Neustadt an der Haardt' => 'Neustadt an der Weinstraße'); if ($result = $db->query('SELECT * FROM ' . $table)) { $dataArray = array(); while ($rowBooks = $result->fetch_assoc()) { $rowBooks = array_map('trim', $rowBooks); $thisBook = new item(); $thisBook->id = $rowBooks['system_no']; //$thisBook->itemInVolume = getItemInVolume($rowBooks['nr']); $thisBook->bibliographicalLevel = 'copy'; $thisBook->titleBib = htmlspecialchars($rowBooks['title']); $thisBook->publisher = htmlspecialchars($rowBooks['printer']); $thisBook->year = $rowBooks['date']; $thisBook->subject = $rowBooks['subject']; $thisBook->mediaType = 'Book'; $thisBook->originalItem['institutionOriginal'] = 'Aberdeen, Sir Duncan Rice Library'; $thisBook->originalItem['shelfmarkOriginal'] = $rowBooks['shelfmark']; $thisBook->originalItem['targetOPAC'] = 'https://aulib.abdn.ac.uk/F?func=direct&local_base=ABN01&doc_number={ID}'; $thisBook->originalItem['searchID'] = $rowBooks['system_no']; $thisBook->language = explode(';', $rowBooks['language']); $placeName = $rowBooks['place_ger']; if ($placeName == '') { $placeName = $rowBooks['place']; } $placeName = strtr($placeName, $translatePlaces); $placeNameSearch = $placeName; if ($placeNameSearch == 'Frankfurt' or $placeNameSearch == 'Frankfurt am Main') { $placeNameSearch = 'Frankfurt/M.'; $placeName = 'Frankfurt am Main'; } elseif ($placeNameSearch == 'Frankfurt an der Oder' or $placeNameSearch == 'Frankfurt (Oder)') { $placeNameSearch = 'Frankfurt/O.'; } $place = new place(); $place->placeName = $placeName; $placeFromArchive = $archive->getByName($placeNameSearch); if ($placeFromArchive) { $place->geoData['lat'] = $placeFromArchive->lat; $place->geoData['long'] = $placeFromArchive->long; } $thisBook->places[] = $place; if (preg_match('~VD[ ]?(1[67]) (.+)~', $rowBooks['vd'], $matches)) { $thisBook->manifestation['systemManifestation'] = 'VD' . $matches[1]; $thisBook->manifestation['idManifestation'] = $matches[2]; } elseif ($rowBooks['retrieve_from'] == 'GBV') { $thisBook->manifestation['systemManifestation'] = 'GBV'; $thisBook->manifestation['idManifestation'] = $rowBooks['ppn']; } if ($rowBooks['author'] != '') { $person = new person(); $person->persName = $rowBooks['author']; if ($rowBooks['gnd']) { if ($resultAuthor = $db->query('SELECT * FROM liddel_authority WHERE gnd_aut LIKE "' . $rowBooks['gnd'] . '"')) { $rowPerson = $resultAuthor->fetch_assoc(); $person->persName = $rowPerson['name_de']; if ($person->persName == '') { $person->persName = $rowPerson['name_en']; } $person->gnd = $rowPerson['gnd_aut']; } } $thisBook->persons[] = $person; } if ($resultDigi = $db->query('SELECT * FROM liddel_library_digi WHERE id_print LIKE ' . $rowBooks['id'])) { while ($rowDigi = $resultDigi->fetch_assoc()) { $thisBook->digitalCopy = $rowDigi['value']; } } $dataArray[] = $thisBook; } } foreach ($dataArray as $item) { foreach ($item->persons as $person) { $person->perName = replaceArrowBrackets($person->persName); } } return $dataArray; }
function makeEntryFromGND($gnd) { $target = 'http://d-nb.info/gnd/' . $gnd . '/about/lds'; $response = file_get_contents($target); $RDF = new DOMDocument(); $RDF->load($target); $nodePrefName = $RDF->getElementsByTagNameNS('http://d-nb.info/standards/elementset/gnd#', 'preferredNameForThePlaceOrGeographicName'); $prefName = getTextContent($nodePrefName); $nodeVarName = $RDF->getElementsByTagNameNS('http://d-nb.info/standards/elementset/gnd#', 'variantNameForThePlaceOrGeographicName'); $varNameString = getTextContent($nodeVarName); $varNameString = replaceArrowBrackets($varNameString); $varNames = explode('|', $varNameString); $nodeGeoData = $RDF->getElementsByTagNameNS('http://www.opengis.net/ont/geosparql#', 'asWKT'); $geoDataString = getTextContent($nodeGeoData); preg_match('~ ([+-][0-9]{1,3}\\.[0-9]{1,10}) ([+-][0-9]{1,3}\\.[0-9]{1,10}) ~', $geoDataString, $matches); $long = ''; $lat = ''; if (isset($matches[1]) and isset($matches[2])) { $long = $matches[1]; $lat = $matches[2]; } $nodeSameAs = $RDF->getElementsByTagNameNS('http://www.w3.org/2002/07/owl#', 'sameAs'); $sameAs = getAttributeFromNodeList($nodeSameAs, 'rdf:resource'); preg_match('~http://sws.geonames.org/([0-9]{5,10})~', $sameAs, $matches); $geoNames = ''; if (isset($matches[1])) { $geoNames = $matches[1]; } $entry = new geoDataArchiveEntry(); $entry->label = replaceArrowBrackets($prefName); $entry->lat = $lat; $entry->long = $long; $entry->gnd = $gnd; $entry->geoNames = $geoNames; $entry->altLabels = $varNames; return $entry; }
function preprocessFields($field, $value, $item) { if ($field == 'persName') { $value = removeSpecial(trim($value, '[]')); $value = replaceArrowBrackets($value); } elseif ($field == 'placeName') { $value = trim($value, '[]'); $test = preg_match('~[oOsS][\\. ]?[OlL]|[oO]hne Ort|[sS]ine [lL]oco|[oO]hne Druckort|[oO]hne Angabe~', $value); if ($value == '' or $test == 1) { $value = 's. l.'; } } elseif ($field == 'year') { $value = normalizeYear($value); if ($value == '') { $value = getYearFromTitle($item->titleCat); } if ($value == '') { $value = 9999; // Makes empty year fields be sorted to the end } } elseif ($field == 'format') { $value = sortingFormat($value); } elseif ($field == 'titleWork') { if ($value == '') { $value = 'ohne Werktitel'; } } elseif ($value == '') { $value = 'ohne Kategorie'; } return $value; }