Ejemplo n.º 1
0
     Checks_Versification::chapters($bible, $book, $chapters);
 }
 foreach ($chapters as $chapter) {
     $chapterUsfm = $database_bibles->getChapter($bible, $book, $chapter);
     $verses = Filter_Usfm::getVerseNumbers($chapterUsfm);
     if ($check_versification) {
         Checks_Versification::verses($bible, $book, $chapter, $verses);
     }
     foreach ($verses as $verse) {
         $verseUsfm = Filter_Usfm::getVerseText($chapterUsfm, $verse);
         if ($check_double_spaces_usfm) {
             Checks_Space::doubleSpaceUsfm($bible, $book, $chapter, $verse, $verseUsfm);
         }
     }
     $filter_text = new Filter_Text($bible);
     $filter_text->initializeHeadingsAndTextPerVerse();
     $filter_text->addUsfmCode($chapterUsfm);
     $filter_text->run($stylesheet);
     $verses_headings = $filter_text->verses_headings;
     $verses_text = $filter_text->getVersesText();
     if ($check_full_stop_in_headings) {
         Checks_Headers::noPunctuationAtEnd($bible, $book, $chapter, $verses_headings, $center_marks, $end_marks);
     }
     if ($check_space_before_punctuation) {
         Checks_Space::spaceBeforePunctuation($bible, $book, $chapter, $verses_text);
     }
     if ($check_sentence_structure || $check_paragraph_structure) {
         $checks_sentences->initialize();
         if ($check_sentence_structure) {
             $checks_sentences->check($verses_text);
         }
Ejemplo n.º 2
0
 public function updateSearchFields($name, $book, $chapter)
 {
     $database_bibles = Database_Bibles::getInstance();
     $database_config_bible = Database_Config_Bible::getInstance();
     $usfm = $database_bibles->getChapter($name, $book, $chapter);
     $stylesheet = $database_config_bible->getExportStylesheet($name);
     // Data to store.
     $usfmraw = array();
     $usfmlower = array();
     $plainraw = array();
     $plainlower = array();
     // Get the verses in the chapter.
     $verses = Filter_Usfm::getVerseNumbers($usfm);
     $verses = array_unique($verses);
     sort($verses, SORT_NUMERIC);
     // One column contains the raw USFM as it is, and another one the lowercase text.
     foreach ($verses as $verse) {
         $raw = Filter_Usfm::getVerseText($usfm, $verse);
         $lower = mb_convert_case($raw, MB_CASE_LOWER);
         $usfmraw[$verse] = $raw;
         $usfmlower[$verse] = $lower;
     }
     // Text filter for getting the plain text.
     $filter_text = new Filter_Text($name);
     $filter_text->text_text = new Text_Text();
     $filter_text->initializeHeadingsAndTextPerVerse();
     $filter_text->addUsfmCode($usfm);
     $filter_text->run($stylesheet);
     // Get the clean verse texts.
     $texts = $filter_text->getVersesText();
     foreach ($texts as $verse => $text) {
         if (!isset($plainraw[$verse])) {
             $plainraw[$verse] = "";
         }
         $plainraw[$verse] .= "{$text}\n";
     }
     // Add any clean headings.
     $headings = $filter_text->verses_headings;
     foreach ($headings as $verse => $heading) {
         if (!isset($plainraw[$verse])) {
             $plainraw[$verse] = "";
         }
         $plainraw[$verse] .= "{$heading}\n";
     }
     // Create the lower case plain text.
     foreach ($plainraw as $verse => $raw) {
         $plainlower[$verse] = mb_convert_case($raw, MB_CASE_LOWER);
     }
     // Get all possible verses.
     $allverses = array_merge(array_keys($usfmraw), array_keys($plainraw));
     $allverses = array_unique($allverses);
     // Store everything.
     Database_SQLite::exec($this->db, "BEGIN;");
     $name = Database_SQLiteInjection::no($name);
     $book = Database_SQLiteInjection::no($book);
     $chapter = Database_SQLiteInjection::no($chapter);
     $query = "DELETE FROM bibles WHERE bible = '{$name}' AND book = {$book} AND chapter = {$chapter};";
     Database_SQLite::exec($this->db, $query);
     foreach ($allverses as $verse) {
         if ($verse == "") {
             $verse = 0;
         }
         $verse = (int) $verse;
         @($ur = Database_SQLiteInjection::no($usfmraw[$verse]));
         @($ul = Database_SQLiteInjection::no($usfmlower[$verse]));
         @($pr = Database_SQLiteInjection::no($plainraw[$verse]));
         @($pl = Database_SQLiteInjection::no($plainlower[$verse]));
         $query = "INSERT INTO bibles (bible, book, chapter, verse, usfmraw, usfmlower, plainraw, plainlower) VALUES ('{$name}', {$book}, {$chapter}, {$verse}, '{$ur}', '{$ul}', '{$pr}', '{$pl}');";
         Database_SQLite::exec($this->db, $query);
     }
     Database_SQLite::exec($this->db, "COMMIT;");
 }
Ejemplo n.º 3
0
    public function testEmbeddedTextOne()
    {
        $usfm = <<<'EOD'
\c 1
\p
\v 1 He said: I will sing \add to the \+nd Lord\+nd*\add*.
\v 2 The \nd Lord\nd* is my strength.
EOD;
        $filter_text = new Filter_Text("phpunit");
        $filter_text->initializeHeadingsAndTextPerVerse();
        $filter_text->addUsfmCode($usfm);
        $filter_text->run("Standard");
        $text = $filter_text->getVersesText();
        $standard = array(1 => "He said: I will sing to the Lord.", 2 => "The Lord is my strength.");
        $this->assertEquals($standard, $text);
    }