Example #1
0
page_access_level(Filter_Roles::TRANSLATOR_LEVEL);
$database_config_user = Database_Config_User::getInstance();
$database_logs = Database_Logs::getInstance();
$database_bibles = Database_Bibles::getInstance();
$database_modifications = Database_Modifications::getInstance();
$session_logic = Session_Logic::getInstance();
$bible = $_POST['bible'];
$book = $_POST['book'];
$chapter = $_POST['chapter'];
$html = $_POST['html'];
$checksum = $_POST['checksum'];
if (isset($bible) && isset($book) && isset($chapter) && isset($html) && isset($checksum)) {
    if (Checksum_Logic::get($html) == $checksum) {
        $html = trim($html);
        if ($html != "") {
            if (Validate_Utf8::valid($html)) {
                $stylesheet = $database_config_user->getStylesheet();
                $editor_export = Editor_Export::getInstance();
                $editor_export->load($html);
                $editor_export->stylesheet($stylesheet);
                $editor_export->run();
                $usfm = $editor_export->get();
                $book_chapter_text = Filter_Usfm::import($usfm, $stylesheet);
                foreach ($book_chapter_text as $data) {
                    $book_number = $data[0];
                    $chapter_number = $data[1];
                    $chapter_data_to_save = $data[2];
                    if (($book_number == $book || $book_number == 0) && $chapter_number == $chapter) {
                        // Collect some data about the changes for this user.
                        $username = $session_logic->currentUser();
                        $oldID = $database_bibles->getChapterId($bible, $book, $chapter);
Example #2
0
    die;
}
// Checksum.
if (Checksum_Logic::get($usfm) != $checksum) {
    http_response_code(409);
    echo Locale_Translate::_("Checksum error");
    die;
}
// Check there's anything to save at all.
$usfm = trim($usfm);
if ($usfm == "") {
    echo Locale_Translate::_("Nothing to save");
    die;
}
// Check on valid UTF-8.
if (!Validate_Utf8::valid($usfm)) {
    echo Locale_Translate::_("Cannot save: Needs Unicode");
    die;
}
// Get the old chapter USFM into an array of verse => USFM fragment.
$usfmString = $database_bibles->getChapter($bible, $book, $chapter);
$verses = Filter_Usfm::getVerseNumbers($usfmString);
$verses = array_unique($verses);
sort($verses, SORT_NUMERIC);
$usfmArray = array();
foreach ($verses as $vs) {
    $usfmArray[$vs] = Filter_Usfm::getVerseText($usfmString, $vs);
}
// Store the verse USFM in the array.
$usfmArray[$verse] = $usfm;
// Create the updated chapter USFM as a string.
Example #3
0
$database_bibles = Database_Bibles::getInstance();
$database_books = Database_Books::getInstance();
$success_message = "";
$error_message = "";
// The name of the Bible.
$bible = Access_Bible::clamp($_GET['bible']);
$view->view->bible = Filter_Html::sanitize($bible);
// Data submission.
if (isset($_POST['submit'])) {
    // Whether to keep the grammatical tags.
    $tags = isset($_POST['tags']);
    // The BibleWorks text.
    $data = $_POST['data'];
    $data = trim($data);
    if ($data != "") {
        if (Validate_Utf8::valid($data)) {
            // Convert the BibleWorks text to USFM.
            $usfm = Filter_Bibleworks::import($data, $tags);
            // Import the USFM.
            $datafile = tempnam(sys_get_temp_dir(), '');
            file_put_contents($datafile, $usfm);
            $success_message = Locale_Translate::_("Import has started. See Journal for progress.");
            $workingdirectory = dirname(__FILE__);
            Tasks_Logic::queue(Tasks_Logic::PHP, array("{$workingdirectory}/importcli.php", $datafile, $bible));
        } else {
            $error_message = Locale_Translate::_("Please supply valid Unicode UTF-8 text.");
        }
    } else {
        $success_message = Locale_Translate::_("Nothing was imported.");
    }
}