コード例 #1
0
ファイル: geodata.php プロジェクト: hbeyer/liddel-tool
function addPostedDataToArchive()
{
    include 'settings.php';
    $archiveGeoNames = new GeoDataArchive();
    $archiveGeoNames->loadFromFile('geoNames');
    $archiveGetty = new GeoDataArchive();
    $archiveGetty->loadFromFile('getty');
    $archiveGND = new GeoDataArchive();
    $archiveGND->loadFromFile('gnd');
    $count = 0;
    foreach ($_SESSION['unidentifiedPlaces'] as $city) {
        $placeFromWeb = NULL;
        if (isset($_POST['geoNames_' . $count])) {
            $geoNames = $_POST['geoNames_' . $count];
            if ($geoNames != '') {
                $placeFromWeb = $archiveGeoNames->makeEntryFromGeoNames($geoNames, $userGeoNames);
                //$placeFromWeb->label = $_SESSION['unidentifiedPlaces'][$count];
                $placeFromWeb->label = $city;
                $archiveGeoNames->insertEntry($placeFromWeb);
            }
        }
        if (isset($_POST['gnd_' . $count])) {
            $gnd = $_POST['gnd_' . $count];
            if ($gnd != '') {
                $placeFromWeb = $archiveGeoNames->makeEntryFromGNDTTL($gnd);
                //$placeFromWeb->label = $_SESSION['unidentifiedPlaces'][$count];
                $placeFromWeb->label = $city;
                $archiveGND->insertEntry($placeFromWeb);
            }
        } elseif (isset($_POST['getty_' . $count])) {
            $getty = $_POST['getty_' . $count];
            if ($getty != '') {
                $placeFromWeb = $archiveGetty->makeEntryFromGetty($getty);
                //$placeFromWeb->label = $_SESSION['unidentifiedPlaces'][$count];
                $placeFromWeb->label = $city;
                $archiveGetty->insertEntry($placeFromWeb);
            }
        }
        unset($_SESSION['unidentifiedPlaces'][$count]);
        $count++;
    }
    $archiveGeoNames->saveToFile('geoNames');
    $archiveGetty->saveToFile('getty');
    $archiveGND->saveToFile('gnd');
}
コード例 #2
0
ファイル: ingest.php プロジェクト: selenus/liddel-tool
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;
}