function attemptToIndexDocument($post_id, $document, $attempt)
{
    try {
        indexDocument($post_id, $document);
    } catch (APICouldNotIndexDocumentException $e) {
        echo "<span style=\"color:#dd3d36\">Error indexing document \"{$document->title}\": {$e->getMessage()}</span>\n";
    } catch (WordPressCouldNotConnectToAPIException $e) {
        echo "{$e->getMessage()} {$document->title}.";
        if (++$attempt < $MAX_ATTEMPTS_PER_POST) {
            echo " Trying again...";
            attemptToIndexDocument($post_id, $document, $attempt);
        }
        echo "\n";
    }
}
Ejemplo n.º 2
0
require_once 'solr.php';
require_once 'db-config.php';
?>
<div class="container-fluid">
<pre>
<?php 
set_time_limit(600);
global $mysqli;
$statement = $mysqli->prepare("SELECT id,post_title,post_name,post_date,post_excerpt,post_content FROM scecms_posts WHERE post_type='entry' AND post_status='publish'");
$statement->execute();
$statement->store_result();
$statement->bind_result($id, $title, $name, $date, $excerpt, $content);
$counter = 1;
while ($statement->fetch()) {
    print $counter++ . '-' . $id . '<br>';
    $document = array('archive' => 'South Carolina Digital Encyclopedia', 'contributing_institution' => 'University of South Carolina', 'id' => 'http://www.duss.sc.edu/sce/entries/' . $name . '/', 'url' => 'http://www.duss.sc.edu/sce/entries/' . $name . '/', 'title' => utf8_encode($title), 'type_content' => 'Text', 'type_digital' => 'Text', 'geolocation_human' => 'South Carolina', 'file_format' => 'text/html', 'description' => '', 'full_text' => utf8_encode($content));
    //jjprint mb_detect_encoding($content);
    //    print_r($document);
    //print '<br>';
    //continue;
    indexDocument($document);
}
?>
</pre>
</div>
<?php 
?>

<?php 
require "layout/footer.php";
require "layout/scripts.php";
Ejemplo n.º 3
0
function importTabFileSouthworth()
{
    //global $mysqli;
    $file = NULL;
    try {
        $file = new SplFileObject("uploads/upload-southworth.txt");
    } catch (Exception $error) {
        echo '<div class="jumbotron"><h1 class="text-danger">Unable to open uploaded file. Please try again.</h1><p>' . $error->getMessage() . '</p></div>';
        return;
    }
    $counter = 0;
    while ($line = $file->fgets()) {
        if ($counter++ == 0) {
            continue;
        }
        //discard first line because it only contains headers
        $fields = explode("\t", $line);
        $document = array('title' => $fields[0], 'alternative_title' => $fields[1], 'geolocation_human' => $fields[6], 'shelfmark' => $fields[8], 'description' => $fields[10], 'archive' => $fields[12], 'contributing_institution' => $fields[14], 'language' => $fields[16], 'type_content' => $fields[19], 'file_format' => $fields[20], 'type_digital' => $fields[21], 'notes' => $fields[24], 'full_text' => $fields[25], 'url' => $fields[29], 'id' => $fields[29]);
        indexDocument($document);
        //$date_parsed = parse_date($date);
        //$date_digital_parsed = parse_date($date_digital);
    }
}