You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ require_once "../bootstrap/bootstrap.php"; page_access_level(Filter_Roles::TRANSLATOR_LEVEL); $database_config_user = Database_Config_User::getInstance(); $database_bibles = Database_Bibles::getInstance(); $ipc_focus = Ipc_Focus::getInstance(); $bible = $database_config_user->getTargetXrefBible(); $book = $ipc_focus->getBook(); $chapter = $ipc_focus->getChapter(); $usfm = $database_bibles->getChapter($bible, $book, $chapter); if (isset($_GET['overwrite'])) { $usfm = Filter_Usfm::removeNotes($usfm, array("x")); Bible_Logic::storeChapter($bible, $book, $chapter, $usfm); } // Count the cross references in this chapter. $xrefs = Filter_Usfm::extractNotes($usfm, array("x")); // Count the number of xref openers / closers in this chapter. $opener = Filter_Usfm::getOpeningUsfm("x"); str_replace($opener, "", $usfm, $openers); $closer = Filter_Usfm::getClosingUsfm("x"); str_replace($closer, "", $usfm, $closers); if (empty($xrefs)) { Filter_Url::redirect("insert.php"); die; } $header = new Assets_Header(Locale_Translate::_("Cross references")); $header->run();
public function testRemoveNotesOne() { $usfm = '\\v 1 Melusi kaIsrayeli, beka indlebe, okhokhela uJosefa njengomhlambi\\f + Hlab. 81.5.\\f*\\fe + Gen. 48.15. 49.24. Hlab. 77.20. Hlab. 95.7.\\fe*, ohlezi \\add phakathi\\add* \\w kwamakherubhi\\w**\\x + Hlab. 99.1. Eks. 25.22.\\x*, khanyisa\\x + Hlab. 50.2.\\x*.'; $usfm = Filter_Usfm::removeNotes($usfm, array("x", "f", "fe")); $standard = '\\v 1 Melusi kaIsrayeli, beka indlebe, okhokhela uJosefa njengomhlambi, ohlezi \\add phakathi\\add* \\w kwamakherubhi\\w**, khanyisa.'; $this->assertEquals($standard, $usfm); }
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();