Ejemplo n.º 1
0
 public function testInsertNotesTwo()
 {
     // Test notes placement where non-placed notes are added to the very end of the string.
     $usfm = '\\v 1 Melusi kaIsrayeli, beka indlebe, okhokhela uJosefa njengomhlambi, ohlezi \\add phakathi\\add* \\w kwamakherubhi\\w**, khanyisa.';
     $notes = array(array(55, '\\x + Hlab. 81.5.\\x*'), array(69, '\\x + Gen. 48.15. 49.24. Hlab. 77.20. Hlab. 95.7.\\x*'), array(117, '\\x + Hlab. 99.1. Eks. 25.22.\\x*'), array(127, '\\x + Hlab. 50.2.\\x*'));
     $usfm = Filter_Usfm::insertNotes($usfm, $notes, 1.5);
     $standard = '\\v 1 Melusi kaIsrayeli, beka indlebe, okhokhela uJosefa njengomhlambi, ohlezi \\add phakathi\\add*\\x + Hlab. 81.5.\\x* \\w kwamakherubhi\\w**\\x + Gen. 48.15. 49.24. Hlab. 77.20. Hlab. 95.7.\\x*, khanyisa\\x + Hlab. 50.2.\\x*\\x + Hlab. 99.1. Eks. 25.22.\\x*.';
     $this->assertEquals($standard, $usfm);
 }
Ejemplo n.º 2
0
        if ($xref['verse'] == $verse) {
            $xrefs[] = array($xref['offset'], $xref['text']);
        }
    }
    if (empty($xrefs)) {
        continue;
    }
    // Get the USFM for the current verse in the target Bible, if any.
    if (!isset($usfmArray[$verse])) {
        continue;
    }
    $usfm = $usfmArray[$verse];
    // Get the length of the text of the verse in the source Bible without the xrefs.
    // Get the ratio for positioning the xrefs by comparing the lengths of source and target verse text.
    $sourceUsfm = $database_bibles->getChapter($sourceBible, $book, $chapter);
    $sourceUsfm = Filter_Usfm::getVerseText($sourceUsfm, $verse);
    $sourceUsfm = Filter_Usfm::removeNotes($sourceUsfm, array("x"));
    $sourceLength = mb_strlen($sourceUsfm);
    $targetLength = mb_strlen($usfm);
    $ratio = $targetLength / $sourceLength;
    // Insert the notes.
    $usfm = Filter_Usfm::insertNotes($usfm, $xrefs, $ratio);
    $usfmArray[$verse] = $usfm;
}
$usfm = implode("\n", $usfmArray);
Bible_Logic::storeChapter($targetBible, $book, $chapter, $usfm);
$header = new Assets_Header(Locale_Translate::_("Cross references"));
$header->run();
$view = new Assets_View(__FILE__);
$view->render("insert.php");
Assets_Page::footer();