Exemplo n.º 1
0
    public function testTwo()
    {
        $string = <<<EOD
Zvino uchagadzira makumbo uye Makumbo uye maKumbo uye MAKUMBO emuakasia*, ndokuaputira negoridhe.
Zvino uchaisa makumbo muzvindori panhivi dzeareka, kuti areka itakurwe nawo.
Zvindori zvichava pamupendero kuti zvive nzvimbo dzemakumbo kutakura tafura.
Zvino uchaita makumbo nematanda neMatanda nemaTANDA emuAkasia, ugoiputira negoridhe, kuti tafura itakurwe nawo.
EOD;
        $words = array();
        $result = Filter_Markup::words($words, $string);
        $this->assertEquals($string, $result);
    }
Exemplo n.º 2
0
    $plaintext = $database_volatile->getValue($identifier, "plaintext");
    // Get the Bible and passage for this identifier.
    $details = $database_search->getBiblePassage($hit);
    $bible = $details['bible'];
    $book = $details['book'];
    $chapter = $details['chapter'];
    $verse = $details['verse'];
    // Get the plain text or USFM.
    if ($plaintext) {
        $text = $database_search->getBibleVerseText($bible, $book, $chapter, $verse);
    } else {
        $text = $database_search->getBibleVerseUsfm($bible, $book, $chapter, $verse);
    }
    // Format it.
    $link = Filter_Books::linkForOpeningEditorAt($book, $chapter, $verse);
    $text = Filter_Markup::words(array($query), $text);
    $output = "<div>{$link} {$text}</div>";
    // Output to browser.
    echo $output;
    // Done.
    die;
}
// Perform the initial search.
if (isset($query)) {
    // Get extra search parameters and store them all in the volatile database.
    @($casesensitive = $_GET['c'] == "true");
    @($plaintext = $_GET['p'] == "true");
    @($currentbook = $_GET['b'] == "true");
    @($sharing = $_GET['s']);
    $database_volatile->setValue($identifier, "query", $query);
    $database_volatile->setValue($identifier, "casesensitive", $casesensitive);
Exemplo n.º 3
0
 public function response()
 {
     // The databases to access.
     $database_config_user = Database_Config_User::getInstance();
     $database_volatile = Database_Volatile::getInstance();
     $database_bibles = Database_Bibles::getInstance();
     // The resources to display in the Consistency tool.
     $resources = array();
     $resources[] = Access_Bible::clamp($database_config_user->getBible());
     $resources = array_merge($resources, $database_config_user->getConsistencyResources());
     // The passages entered in the Consistency tool.
     $passages = $database_volatile->getValue($this->id, "passages");
     $passages = trim($passages);
     $passages = Filter_String::string2array($passages);
     // The translations from the Consistency tool.
     $translations = $database_volatile->getValue($this->id, "translations");
     $translations = trim($translations);
     $translations = Filter_String::string2array($translations);
     // Contains the response to display.
     $response = array();
     // Go through the passages interpreting them.
     $previousPassage = array(1, 1, 1);
     foreach ($passages as $line) {
         $line = trim($line);
         if ($line == "") {
             continue;
         }
         $range_sequence = Filter_Books::handleSequencesRanges($line);
         foreach ($range_sequence as $line) {
             $passage = Filter_Books::interpretPassage($previousPassage, $line);
             if ($passage[0] != 0) {
                 $book = $passage[0];
                 $chapter = $passage[1];
                 $verse = $passage[2];
                 $line = Filter_Books::linkForOpeningEditorAt($book, $chapter, $verse);
                 $line .= " ";
                 // Check whether the chapter identifier has changed for this reference.
                 // If so, set a flag so the data can be re-assembled for this verse.
                 // If there was no change, then the data can be fetched from the volatile database.
                 $redoPassage = false;
                 $passageKey = "{$book}.{$chapter}.{$verse}";
                 $currentChapterId = $database_bibles->getChapterId($resources[0], $book, $chapter);
                 $storedChapterId = $database_volatile->getValue($this->id, "{$passageKey}.id");
                 if ($currentChapterId != $storedChapterId) {
                     $database_volatile->setValue($this->id, "{$passageKey}.id", $currentChapterId);
                     $redoPassage = true;
                 }
                 // Go through each resource.
                 foreach ($resources as $resource) {
                     // Produce new verse text if the passage is to be redone, or else fetch the existing text.
                     if ($redoPassage) {
                         $text = $this->verseText($resource, $book, $chapter, $verse);
                         if ($translations != "") {
                             $text = Filter_Markup::words($translations, $text);
                         }
                         $database_volatile->setValue($this->id, "{$passageKey}.{$resource}", $text);
                     } else {
                         $text = $database_volatile->getValue($this->id, "{$passageKey}.{$resource}");
                     }
                     // Formatting.
                     if (count($resources) > 1) {
                         $line .= "<br>";
                     }
                     $line .= $text;
                 }
                 $response[] = $line;
                 $previousPassage = $passage;
             } else {
                 $response[] = '<span class="error">' . Locale_Translate::_("Unknown passage") . " " . $line . '</span>';
             }
         }
     }
     $output = "";
     foreach ($response as $line) {
         $output .= "<div>{$line}</div>\n";
     }
     return $output;
 }
Exemplo n.º 4
0
    }
}
// Generate success or failure icon.
if ($replacementOkay) {
    $icon = '<span class="success">✔</span>';
} else {
    $icon = '<span class="error">✗</span>';
}
// Store the new chapter in the database on success.
if ($replacementOkay) {
    Bible_Logic::storeChapter($bible, $book, $chapter, $updatedUsfm);
}
// Mark the new plain text.
if ($replacewith != "") {
    if ($searchplain) {
        $updatedPlainText = Filter_Markup::words(array($replacewith), $updatedPlainText);
    }
}
// Clickable passage.
$link = Filter_Books::linkForOpeningEditorAt($book, $chapter, $verse);
// Success or failure message.
if ($replacementOkay) {
    if ($searchplain) {
        $msg = $updatedPlainText;
    } else {
        $msg = $updatedUsfm;
    }
} else {
    $msg = '<span class="error">' . Locale_Translate::_("This text could not be automatically replaced. Click the passage to do it manually.") . '</span>';
}
// Create output.
Exemplo n.º 5
0
    $details = $database_search->getBiblePassage($id);
    if ($details == NULL) {
        continue;
    }
    $bible = $details["bible"];
    $book = $details["book"];
    $chapter = $details["chapter"];
    $verse = $details["verse"];
    // The title.
    $title = "{$bible}" . " | " . Filter_Books::passageDisplay($book, $chapter, $verse);
    $title = Filter_Html::sanitize($title);
    // The URL.
    $url = "../exports/{$bible}/web/" . Filter_Paths::htmlFileNameBible("", $book, $chapter);
    // Output title and URL.
    echo "<p style=\"margin-top: 0.75em; margin-bottom: 0em\"><a href=\"{$url}\">{$title}</a></p>\n";
    // The excerpt.
    $text = $database_search->getBibleVerseText($bible, $book, $chapter, $verse);
    $text = explode("\n", $text);
    $excerpt = "";
    // Go through each line of text separately.
    foreach ($text as $line) {
        $markedLine = Filter_Markup::words($queryWords, $line);
        if ($markedLine != $line) {
            // Store this bit of the excerpt.
            $excerpt .= "<p style=\"margin-top: 0em; margin-bottom: 0em\">{$markedLine}</p>\n";
        }
    }
    echo "{$excerpt}\n";
}
// Last bit of the page.
echo "</body>\n";
Exemplo n.º 6
0
@($id = $_GET['id']);
if (isset($id)) {
    // Get the Bible and passage for this identifier.
    $details = $database_search->getBiblePassage($id);
    $bible = $details['bible'];
    $book = $details['book'];
    $chapter = $details['chapter'];
    $verse = $details['verse'];
    // Get the plain text.
    $text = $database_search->getBibleVerseText($bible, $book, $chapter, $verse);
    // Format it.
    $link = Filter_Books::linkForOpeningEditorAt($book, $chapter, $verse);
    $oldtext = $text;
    $newtext = str_replace($searchfor, $replacewith, $text);
    if ($replacewith != "") {
        $newtext = Filter_Markup::words(array($replacewith), $newtext);
    }
    $output = <<<EOD
<div id="{$id}">
<p><a href="replace"> ✔ </a> <a href="delete"> ✗ </a> {$link}</p>
<p>{$oldtext}</p>
<p>{$newtext}</p>
</div>
EOD;
    // Output to browser.
    echo $output;
    // Done.
    die;
}
$header = new Assets_Header(Locale_Translate::_("Replace"));
$header->run();