示例#1
0
 /**
  * Imports BibleWorks $data as USFM code.
  * This is $data fit for the BibleWorks Version Database Compiler.
  * It a string of USFM code.
  * $keepTags: Whether to keep the grammatical tags in the BibleWorks text.
  * These are the tags between () or <>.
  */
 public static function import($data, $keepTags)
 {
     // Databases.
     $database_books = Database_Books::getInstance();
     // Storage for the generated USFM.
     $usfm = array();
     // The data comes as one string. Make it an array.
     $data = explode("\n", $data);
     // Book / chapter trackers.
     $currentBibleWorksBookAbbreviation = "";
     $currentChapter = 0;
     // Go through each line of data to be imported.
     foreach ($data as $line) {
         $line = trim($line);
         // Get the name of the book and remove the text fragment.
         // Upon encountering a new book, it generates USFM code for it.
         $bookAbbreviation = substr($line, 0, 3);
         $line = substr($line, 3, 10000);
         $line = trim($line);
         if ($bookAbbreviation != $currentBibleWorksBookAbbreviation) {
             $currentBibleWorksBookAbbreviation = $bookAbbreviation;
             $currentChapter = 0;
             $bookID = Filter_Books::interpretBook($bookAbbreviation);
             $book = $database_books->getUsfmFromId($bookID);
             $usfm[] = '\\id ' . $book;
         }
         // Get the chapter number and remove the text fragment.
         // Upon encountering a new chapter, it generates USFM code for it.
         $chapter = (int) $line;
         $line = substr($line, strlen($chapter) + 1, 10000);
         $line = trim($line);
         if ($chapter != $currentChapter) {
             $currentChapter = $chapter;
             $usfm[] = '\\c ' . $currentChapter;
             $usfm[] = '\\p';
         }
         // Get the verse number and remove the text fragment and whitespace.
         $verse = (int) $line;
         $line = substr($line, strlen($verse), 10000);
         $line = trim($line);
         // Convert markup for italics and footnotes.
         $line = Filter_Bibleworks::italics($line);
         $line = Filter_Bibleworks::notes($line);
         // Deal with the grammatical tags.
         if (!$keepTags) {
             $malformed = array();
             $line = Filter_Bibleworks::parenthesis($line, $malformed);
             $line = Filter_Bibleworks::chevrons($line, $malformed);
         }
         // Output the verse.
         $usfm[] = '\\v ' . $verse . ' ' . $line;
     }
     $usfm = implode("\n", $usfm);
     return $usfm;
 }
示例#2
0
 public function consultationNote($id)
 {
     $database_notes = Database_Notes::getInstance();
     $database_logs = Database_Logs::getInstance();
     $passage = $database_notes->getPassages($id);
     $passageText = Filter_Books::passagesDisplayInline($passage);
     $summary = $database_notes->getSummary($id);
     $contents = $database_notes->getContents($id);
     $contents = Filter_Html::html2text($contents);
     $session_logic = Session_Logic::getInstance();
     $username = $session_logic->currentUser();
     $database_logs->log("{$username} deleted / marked for deletion consultation note {$passageText} | {$summary} | {$contents}");
 }
示例#3
0
 /**
  * This imports one note from Bibledit-Gtk.
  * The note is available in $filename.
  * It returns the identifier of the note if imported successfully.
  * Else it returns NULL.
  */
 public static function importFromBibleditGtkFile($filename)
 {
     $note_identifier = NULL;
     if (file_exists($filename)) {
         // The note is in the format as used by Bibledit-Gtk.
         // The filename represents the note ID in Bibledit-Gtk.
         // This ID is not relevant for import.
         // Read the note.
         $note = file($filename);
         // line 0: date created.
         // This information is not used here. The same information will be in the logbook entries, see later.
         // line 1: user who created it.
         // This information is not used here. The same information will be in the logbook entries, see later.
         // line 2: note references.
         // Sample: Exod.29.23
         // Sample: Lev.26.16 Deut.28.22
         // It uses OSIS for book encoding.
         $passages = array();
         foreach (explode(" ", trim($note[2])) as $bibledit_gtk_reference) {
             $passages[] = Filter_Books::explodePassage($bibledit_gtk_reference);
         }
         // line 3: note category.
         $category = trim($note[3]);
         // line 4: Bible.
         $bible = trim($note[4]);
         // line 5: date modified.
         // This information is list since the note will be modified upon import.
         // line 6 and up: note text, "Logbook:", and logbook entries.
         // Summary will be taken from the first line.
         $summary = trim($note[6]);
         $contents = "";
         for ($i = 6; $i < count($note); $i++) {
             $contents .= $note[$i] . "\n";
         }
         // Store note.
         // (In client mode, upon sync to the server, these notes will be erased: Import them on the server).
         $database_notes = Database_Notes::getInstance();
         $note_identifier = $database_notes->storeNewNote($bible, 0, 0, 0, $summary, $contents, true);
         $database_notes->setPassages($note_identifier, $passages, true);
         $database_notes->setStatus($note_identifier, $category, true);
     }
     return $note_identifier;
 }
示例#4
0
$hitCount = count($ids);
echo "<font size=\"-1\" color=\"grey\"><hr /></font>\n";
echo "<p><font size=\"-1\" color=\"grey\">{$hitCount} " . Locale_Translate::_("chapters") . "</font></p>\n";
// Go through the search hits.
foreach ($ids as $id) {
    // Get the details of this search hit.
    $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";
示例#5
0
 public static function setPassage($bible, $passage)
 {
     $ipc_focus = Ipc_Focus::getInstance();
     $currentBook = $ipc_focus->getBook();
     $currentChapter = $ipc_focus->getChapter();
     $currentVerse = $ipc_focus->getVerse();
     $passage = trim($passage);
     if ($passage == "" || $passage == "+") {
         $passage = Navigation_Passage::getNextVerse($bible, $currentBook, $currentChapter, $currentVerse);
     } else {
         if ($passage == "-") {
             $passage = Navigation_Passage::getPreviousVerse($bible, $currentBook, $currentChapter, $currentVerse);
         } else {
             $passage = Filter_Books::interpretPassage(array($currentBook, $currentChapter, $currentVerse), $passage);
         }
     }
     if ($passage[0] != 0) {
         $ipc_focus->set($passage[0], $passage[1], $passage[2]);
         Navigation_Passage::recordHistory($passage[0], $passage[1], $passage[2]);
     }
 }
示例#6
0
 public function import($name, $data)
 {
     // Delete existing mapping with this name.
     $this->delete($name);
     // Begin a transaction for better speed.
     Database_SQLite::exec($this->db, "BEGIN;");
     $lastPassage = array(1, 1, 1);
     $lastOriginal = array(1, 1, 1);
     $name = Database_SQLiteInjection::no($name);
     $data = Filter_String::string2array($data);
     foreach ($data as $line) {
         // Each line looks like this:
         // Haggai 2:15 = Haggai 2:14
         // At the left is the passage in this versification.
         // At the right is the passage in the original Hebrew and Greek versification.
         $line = trim($line);
         if ($line == "") {
             continue;
         }
         // Cut the line into two: The two passages.
         $entry = explode("=", $line);
         if (count($entry) != 2) {
             continue;
         }
         $passage = trim($entry[0]);
         $original = trim($entry[1]);
         $passage = Filter_Books::interpretPassage($lastPassage, $passage);
         $lastPassage = $passage;
         $original = Filter_Books::interpretPassage($lastOriginal, $original);
         $lastOriginal = $original;
         $book = (int) $passage[0];
         $chapter = (int) $passage[1];
         $verse = (int) $passage[2];
         $origbook = (int) $original[0];
         $origchapter = (int) $original[1];
         $origverse = (int) $original[2];
         $query = "INSERT INTO maps VALUES ('{$name}', {$book}, {$chapter}, {$verse}, {$origbook}, {$origchapter}, {$origverse});";
         Database_SQLite::exec($this->db, $query);
     }
     // Commit the transaction.
     Database_SQLite::exec($this->db, "COMMIT;");
 }
示例#7
0
 /**
  * handleEmailNew - handles an email received from $from with subject $subject and body $body.
  * Returns true if the mail was processed, else false.
  * The email is considered to have been processed if it created a new Consultation Note.
  */
 public function handleEmailNew($from, $subject, $body)
 {
     // Store the original subject.
     $originalSubject = $subject;
     // Check that the subject indicates that a new consultation note is to be created.
     $pos = strpos(strtolower($subject), "new note");
     if ($pos === false) {
         return false;
     }
     // There is a new note. Remove that bit from the $subject.
     $subject = substr($subject, 0, $pos) . substr($subject, $pos + 8);
     // Clean the subject line.
     $subject = trim($subject);
     $subject = str_replace(".", " ", $subject);
     $subject = str_replace(":", " ", $subject);
     $subject = str_replace("  ", " ", $subject);
     $subject = str_replace("  ", " ", $subject);
     $subject = str_replace("  ", " ", $subject);
     $subject = str_replace("  ", " ", $subject);
     // Check that the $from address of the email belongs to an existing user.
     $from = Filter_Email::extractEmail($from);
     $database_users = Database_Users::getInstance();
     if (!$database_users->emailExists($from)) {
         return false;
     }
     $username = $database_users->getEmailToUser($from);
     // Extract book, chapter, verse, and note summary from the $subject
     $book = NULL;
     $chapter = NULL;
     $verse = NULL;
     $summary = NULL;
     $subject = explode(" ", $subject);
     if (count($subject) > 0) {
         $book = Filter_Books::interpretBook($subject[0]);
     }
     if (count($subject) > 1) {
         $chapter = Filter_Numeric::integer_in_string($subject[1]);
     }
     if (count($subject) > 2) {
         $verse = Filter_Numeric::integer_in_string($subject[2]);
     }
     unset($subject[0]);
     unset($subject[1]);
     unset($subject[2]);
     $summary = implode(" ", $subject);
     unset($subject);
     // Check book, chapter, verse, and summary. Give feedback if there's anything wrong.
     $noteCheck = "";
     if (!(is_numeric($book) && $book > 0)) {
         $noteCheck .= Locale_Translate::_("Unknown book");
     }
     if (!is_numeric($chapter)) {
         $noteCheck .= " " . Locale_Translate::_("Unknown chapter");
     }
     if (!is_numeric($verse)) {
         $noteCheck .= " " . Locale_Translate::_("Unknown verse");
     }
     if ($summary == NULL || $summary == "") {
         $noteCheck .= " " . Locale_Translate::_("Unknown summary");
     }
     // Mail user if the note could not be posted.
     $database_mail = Database_Mail::getInstance();
     if ($noteCheck != "") {
         $subject = Locale_Translate::_("Your new note could not be posted");
         $database_mail->send($username, $subject . ": " . $originalSubject, $noteCheck);
         return false;
     }
     // Clean the email's body.
     $body = Filter_Email::extractBody($body);
     // Post the note.
     $session_logic = Session_Logic::getInstance();
     $sessionuser = $session_logic->currentUser();
     $session_logic->setUsername($username);
     $database_notes = Database_Notes::getInstance();
     $identifier = $database_notes->storeNewNote("", $book, $chapter, $verse, $summary, $body, false);
     $this->handlerNewNote($identifier);
     $session_logic->setUsername($sessionuser);
     // Mail confirmation to the $username.
     $database_config_user = Database_Config_User::getInstance();
     if ($database_config_user->getUserNotifyMeOfMyPosts($username)) {
         $subject = Locale_Translate::_("Your new note was posted");
         $database_mail->send($username, $subject . ": " . $originalSubject, $body);
     }
     // Log operation.
     $database_logs = Database_Logs::getInstance();
     $database_logs->log("New note posted" . ":" . " " . $body);
     // Job done.
     return true;
 }
示例#8
0
文件: text.php 项目: alerque/bibledit
 /**
  * This function produces the text of the current passage, e.g.: Genesis 1:1.
  * Returns: The passage text
  */
 private function getCurrentPassageText()
 {
     return Filter_Books::passageDisplay($this->currentBookIdentifier, $this->currentChapterNumber, $this->currentVerseNumber);
 }
示例#9
0
        if ($check_missing_punctuation_end_verse) {
            Checks_Verses::missingPunctuationAtEnd($bible, $book, $chapter, $verses_text, $center_marks, $end_marks);
        }
        if ($check_patterns) {
            Checks_Verses::patterns($bible, $book, $chapter, $verses_text, $checking_patterns);
        }
    }
}
// Identifier for this $bible.
$bibleID = $database_bibles->getID($bible);
// Create an email with the checking results for this $bible.
$emailBody = array();
$hits = $database_check->getHits();
foreach ($hits as $hit) {
    if ($hit['bible'] == $bibleID) {
        $passage = Filter_Books::passagesDisplayInline(array(array($hit['book'], $hit['chapter'], $hit['verse'])));
        $data = Filter_Html::sanitize($hit['data']);
        $result = "<p>{$passage} {$data}</p>";
        $emailBody[] = $result;
    }
}
// Send email to users with write access to the Bible and a subscription to the notification.
if (count($emailBody) > 0) {
    $subject = Locale_Translate::_("Bible Checks") . " " . $bible;
    $emailBody = implode("\n", $emailBody);
    $users = $database_users->getUsers();
    foreach ($users as $user) {
        if ($database_config_user->getUserBibleChecksNotification($user)) {
            if (Access_Bible::write($bible, $user)) {
                if (!Filter_Client::enabled()) {
                    $database_mail->send($user, $subject, $emailBody);
示例#10
0
    $database_check->release($release);
    $view->view->success = Locale_Translate::_("The check result will no longer be suppressed.");
}
// Get the Bibles the user has write-access to.
$bibleIDs = array();
$bibles = $database_bibles->getBibles();
foreach ($bibles as $bible) {
    if (Access_Bible::write($bible)) {
        $id = $database_bibles->getID($bible);
        $bibleIDs[] = $id;
    }
}
$ids = array();
$data = array();
$suppressions = $database_check->getSuppressions();
foreach ($suppressions as $suppression) {
    $bibleID = $suppression['bible'];
    // Only display entries for Bibles the user has write access to.
    if (in_array($bibleID, $bibleIDs)) {
        $ids[] = $suppression['rowid'];
        $bible = Filter_Html::sanitize($database_bibles->getName($bibleID));
        $passage = Filter_Books::passagesDisplayInline(array(array($suppression['book'], $suppression['chapter'], $suppression['verse'])));
        $result = Filter_Html::sanitize($suppression['data']);
        $result = "{$bible} {$passage} {$result}";
        $data[] = $result;
    }
}
$view->view->ids = $ids;
$view->view->data = $data;
$view->render("suppress.php");
Assets_Page::footer();
示例#11
0
 public function testGetOrdered()
 {
     $database_bibles = Database_Bibles::getInstance();
     $database_config_bible = Database_Config_Bible::getInstance();
     $bible = "php unit";
     // No ordering.
     $database_bibles->createBible($bible);
     $database_bibles->storeChapter($bible, 1, 1, "data");
     $database_bibles->storeChapter($bible, 2, 1, "data");
     $database_bibles->storeChapter($bible, 3, 1, "data");
     $database_bibles->storeChapter($bible, 4, 1, "data");
     $database_bibles->storeChapter($bible, 5, 1, "data");
     $books = Filter_Books::getOrdered($bible);
     $standard = array(1, 2, 3, 4, 5);
     $this->assertEquals($standard, $books);
     // Existing books re-ordered.
     $database_config_bible->setBookOrder($bible, "1 3 2 5 4");
     $books = Filter_Books::getOrdered($bible);
     $standard = array(1, 3, 2, 5, 4);
     $this->assertEquals($standard, $books);
     // Some books ordered, and Bible has extra books: These are to be added to the end.
     $database_config_bible->setBookOrder($bible, "1 3 2");
     $books = Filter_Books::getOrdered($bible);
     $standard = array(1, 3, 2, 4, 5);
     $this->assertEquals($standard, $books);
     // More books ordered than in Bible: Remove the extra ones.
     $database_config_bible->setBookOrder($bible, "1 3 2 5 4 6");
     $books = Filter_Books::getOrdered($bible);
     $standard = array(1, 3, 2, 5, 4);
     $this->assertEquals($standard, $books);
 }
示例#12
0
                $filter_text_compare->text_text = new Text_Text();
                $filter_text_bible->addUsfmCode($bible_verse_usfm);
                $filter_text_compare->addUsfmCode($compare_verse_usfm);
                $filter_text_bible->run($stylesheet);
                $filter_text_compare->run($stylesheet);
                $bible_html = $filter_text_bible->html_text_standard->getInnerHtml();
                $compare_html = $filter_text_compare->html_text_standard->getInnerHtml();
                $bible_text = $filter_text_bible->text_text->get();
                $compare_text = $filter_text_compare->text_text->get();
                if ($bible_text != $compare_text) {
                    $modification = Filter_Diff::diff($compare_text, $bible_text);
                    $result[] = Filter_Books::passageDisplay($book, $chapter, $verse) . " " . $modification;
                    $new[] = Filter_Books::passageDisplay($book, $chapter, $verse) . " " . $bible_text;
                }
                $modification = Filter_Diff::diff($compare_verse_usfm, $bible_verse_usfm);
                $raw[] = Filter_Books::passageDisplay($book, $chapter, $verse) . " " . $modification;
            }
        }
    }
}
// Add the absent books / chapters to the comparison.
if (count($absent)) {
    $result[] = "";
    $result = array_merge($result, $absent);
}
// Add any differences in the raw USFM to the comparison.
if (count($raw)) {
    $result[] = "";
    $result = array_merge($result, $raw);
}
// Add the text of the new verses, as they are in the $bible.
示例#13
0
require_once "../bootstrap/bootstrap.php";
page_access_level(Filter_Roles::CONSULTANT_LEVEL);
$database_notes = Database_Notes::getInstance();
$notes_logic = Notes_Logic::getInstance();
$id = $_GET['id'];
if (isset($_POST['submit'])) {
    $verses = explode("\n", $_POST['verses']);
    $passages = array();
    $previousPassage = array(1, 1, 1);
    foreach ($verses as $line) {
        $line = trim($line);
        if ($line != "") {
            $passage = Filter_Books::interpretPassage($previousPassage, $line);
            if ($passage[0] != 0) {
                $passages[] = $passage;
                $previousPassage = $passage;
            }
        }
    }
    $notes_logic->setPassages($id, $passages);
    Filter_Url::redirect("actions.php?id={$id}");
    die;
}
$assets_header = new Assets_Header(Locale_Translate::_("Note passages"));
$assets_header->run();
$view = new Assets_View(__FILE__);
$view->view->id = $id;
$verses = Filter_Books::passagesDisplayMultiline($database_notes->getPassages($id));
$view->view->verses = $verses;
$view->render("verses.php");
Assets_Page::footer();
示例#14
0
        $passage = explode(".", $database_config_user->getPrintPassageTo());
        $usfm = $database_bibles->getChapter($bible, $passage[0], $passage[1]);
        $verses = Filter_Usfm::getVerseNumbers($usfm);
        foreach ($verses as $verse) {
            $parameter = "toverse={$verse}";
            $dialog_list->add_row($verse, $parameter);
        }
        $dialog_list->run();
    } else {
        // Set ending verse.
        $topassage = explode(".", $database_config_user->getPrintPassageTo());
        $topassage[2] = $toverse;
        $database_config_user->setPrintPassageTo(implode(".", $topassage));
        // Match starting verse.
        $frompassage = explode(".", $database_config_user->getPrintPassageFrom());
        if (Filter_Books::passage2integer($topassage) < Filter_Books::passage2integer($frompassage)) {
            // Set starting passage to a sensible value.
            $frompassage[0] = $topassage[0];
            $frompassage[1] = $topassage[1];
            $frompassage[2] = 0;
            $database_config_user->setPrintPassageFrom(implode(".", $frompassage));
        }
    }
}
$view = new Assets_View(__FILE__);
$resources = $database_config_user->getPrintResources();
$view->view->resources = $resources;
$passage = explode(".", $database_config_user->getPrintPassageFrom());
$view->view->from_book = $database_books->getEnglishFromId($passage[0]);
$view->view->from_chapter = $passage[1];
$view->view->from_verse = $passage[2];
示例#15
0
function processIdentifiers($user, $bible, $book, $chapter, $oldId, $newId, &$email)
{
    if ($oldId != 0) {
        $database_modifications = Database_Modifications::getInstance();
        $database_config_user = Database_Config_User::getInstance();
        $database_config_bible = Database_Config_Bible::getInstance();
        $database_bibles = Database_Bibles::getInstance();
        $database_history = Database_History::getInstance();
        $stylesheet = $database_config_bible->getExportStylesheet($bible);
        $old_chapter_usfm = $database_modifications->getUserChapter($user, $bible, $book, $chapter, $oldId);
        $old_chapter_usfm = $old_chapter_usfm['oldtext'];
        $new_chapter_usfm = $database_modifications->getUserChapter($user, $bible, $book, $chapter, $newId);
        $new_chapter_usfm = $new_chapter_usfm['newtext'];
        $timestamp = $database_modifications->getUserTimestamp($user, $bible, $book, $chapter, $newId);
        $old_verse_numbers = Filter_Usfm::getVerseNumbers($old_chapter_usfm);
        $new_verse_numbers = Filter_Usfm::getVerseNumbers($new_chapter_usfm);
        $verses = array_merge($old_verse_numbers, $new_verse_numbers);
        $verses = array_unique($verses);
        sort($verses, SORT_NUMERIC);
        foreach ($verses as $verse) {
            $old_verse_usfm = Filter_Usfm::getVerseText($old_chapter_usfm, $verse);
            $new_verse_usfm = Filter_Usfm::getVerseText($new_chapter_usfm, $verse);
            if ($old_verse_usfm != $new_verse_usfm) {
                $filter_text_old = new Filter_Text($bible);
                $filter_text_new = new Filter_Text($bible);
                $filter_text_old->html_text_standard = new Html_Text(Locale_Translate::_("Bible"));
                $filter_text_new->html_text_standard = new Html_Text(Locale_Translate::_("Bible"));
                $filter_text_old->text_text = new Text_Text();
                $filter_text_new->text_text = new Text_Text();
                $filter_text_old->addUsfmCode($old_verse_usfm);
                $filter_text_new->addUsfmCode($new_verse_usfm);
                $filter_text_old->run($stylesheet);
                $filter_text_new->run($stylesheet);
                $old_html = $filter_text_old->html_text_standard->getInnerHtml();
                $new_html = $filter_text_new->html_text_standard->getInnerHtml();
                $old_text = $filter_text_old->text_text->get();
                $new_text = $filter_text_new->text_text->get();
                if ($old_text != $new_text) {
                    $modification = Filter_Diff::diff($old_text, $new_text);
                    $email .= "<div>";
                    $email .= Filter_Books::passageDisplay($book, $chapter, $verse);
                    $email .= " ";
                    $email .= $modification;
                    $email .= "</div>";
                    if ($database_config_user->getUserUserChangesNotificationsOnline($user)) {
                        $changeNotificationUsers = array($user);
                        $database_modifications->recordNotification($changeNotificationUsers, "☺", $bible, $book, $chapter, $verse, $old_html, $modification, $new_html);
                    }
                    $database_history->record($timestamp, $user, $bible, $book, $chapter, $verse, $old_html, $modification, $new_html);
                }
            }
        }
    }
}
示例#16
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;
 }
示例#17
0
// Search the Bible text.
$hits = $database_search->searchText($queryString, $bibles);
$textCount = count($hits);
$view->view->textCount = $textCount;
// Assemble the search results.
$textLinks = array();
$textExcerpts = array();
foreach ($hits as $hit) {
    // Get the details of this search hit.
    $details = $database_search->getBiblePassage($hit);
    $bible = $details["bible"];
    $book = $details["book"];
    $chapter = $details["chapter"];
    $verse = $details["verse"];
    // The title plus link.
    $link = "{$bible}" . " | " . Filter_Books::linkForOpeningEditorAt($book, $chapter, $verse);
    $textLinks[] = $link;
    // 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\">{$markedLine}</p>\n";
        }
    }
    $textExcerpts[] = $excerpt;
}
示例#18
0
    $start = -1;
    $end = 0;
}
$view->view->start = $start + 1;
$view->view->end = $end;
// The various bits of the history from the database.
$passageTexts = array();
$authors = array();
$dates = array();
$bibles = array();
$oldTexts = array();
$modifications = array();
$newTexts = array();
$data = $database_history->get($author_filter, $myBibles, $book_filter, $chapter_filter, $verse_filter, $start);
foreach ($data as $entry) {
    $passageText = Filter_Books::passagesDisplayInline(array(array($entry['book'], $entry['chapter'], $entry['verse'])));
    $passageText = Filter_Html::sanitize($passageText);
    $passageTexts[] = $passageText;
    $authors[] = Filter_Html::sanitize($entry['author']);
    $dates[] = $timestamp = date('j F Y g:i:s a', $entry['timestamp']);
    $bibles[] = Filter_Html::sanitize($entry['bible']);
    $oldTexts[] = $entry['oldtext'];
    $modifications[] = $entry['modification'];
    $newTexts[] = $entry['newtext'];
}
$view->view->passageTexts = $passageTexts;
$view->view->authors = $authors;
$view->view->dates = $dates;
$view->view->bibles = $bibles;
$view->view->oldTexts = $oldTexts;
$view->view->modifications = $modifications;
示例#19
0
} else {
    if ($filter == "team") {
        $ids = $database_modifications->getNotificationTeamIdentifiers($username, "♺", true);
        $view->view->filter = 2;
    } else {
        $ids = $database_modifications->getNotificationIdentifiers($username, true);
        $view->view->filter = 0;
    }
}
$view->view->ids = $ids;
$links = array();
$categories = array();
$modifications = array();
foreach ($ids as $id) {
    $passage = $database_modifications->getNotificationPassage($id);
    $link = Filter_Books::linkForOpeningEditorAt($passage['book'], $passage['chapter'], $passage['verse']);
    $links[] = $link;
    $category = $database_modifications->getNotificationCategory($id);
    $category = Filter_Html::sanitize($category);
    $categories[] = $category;
    $modification = $database_modifications->getNotificationModification($id);
    $modifications[] = $modification;
}
$view->view->links = $links;
$view->view->categories = $categories;
$view->view->modifications = $modifications;
$loading = '"' . Locale_Translate::_("Loading ...") . '"';
$script = <<<EOD
var loading = {$loading};
EOD;
$view->view->script = $script;
示例#20
0
 public static function interpretPassage($currentPassage, $rawPassage)
 {
     $rawPassage = Filter_Books::cleanPassage($rawPassage);
     // Create an array with the bits of the raw input.
     $input = explode(" ", $rawPassage);
     // Go through the array from verse to chapter to book.
     // Check how many numerals it has after the book part.
     $numerals = array();
     $book = "";
     $invertedInput = array_reverse($input);
     foreach ($invertedInput as $bit) {
         if (Filter_Numeric::integer_in_string($bit) != "") {
             $numerals[] = $bit;
             array_pop($input);
         } else {
             $book = implode(" ", $input);
             break;
         }
     }
     // Deal with: Only book given, e.g. "Genesis".
     if ($book != "" && count($numerals) == 0) {
         return Filter_Books::explodePassage("{$book} 1 1");
     } else {
         if ($book == "" && count($numerals) == 1) {
             $book = $currentPassage[0];
             $chapter = $currentPassage[1];
             $verse = $numerals[0];
             $passage = Filter_Books::explodePassage("Unknown {$chapter} {$verse}");
             $passage[0] = $book;
             return $passage;
         } else {
             if ($book == "" && count($numerals) == 2) {
                 $book = $currentPassage[0];
                 $chapter = $numerals[1];
                 $verse = $numerals[0];
                 $passage = Filter_Books::explodePassage("Unknown {$chapter} {$verse}");
                 $passage[0] = $book;
                 return $passage;
             } else {
                 if ($book != "" && count($numerals) == 1) {
                     $chapter = $numerals[0];
                     return Filter_Books::explodePassage("{$book} {$chapter} 1");
                 } else {
                     if ($book != "" && count($numerals) == 2) {
                         return Filter_Books::explodePassage($rawPassage);
                     }
                 }
             }
         }
     }
     // Give up.
     return $currentPassage;
 }
示例#21
0
$passage = explode(".", $from);
$from = Filter_Books::passage2integer($passage);
$to = $database_config_user->getPrintPassageToForUser($user);
$passage = explode(".", $to);
$to = Filter_Books::passage2integer($passage);
$result = array();
$books = $database_bibles->getBooks($bible);
foreach ($books as $book) {
    $chapters = $database_bibles->getChapters($bible, $book);
    foreach ($chapters as $chapter) {
        $usfm = $database_bibles->getChapter($bible, $book, $chapter);
        $verses = Filter_Usfm::getVerseNumbers($usfm);
        foreach ($verses as $verse) {
            $passage = Filter_Books::passage2integer(array($book, $chapter, $verse));
            if ($passage >= $from && $passage <= $to) {
                $passageText = Filter_Books::passageDisplay($book, $chapter, $verse);
                $database_jobs->setProgress($jobId, $passageText);
                $result[] = '<div class="nextresource">';
                $result[] = "<p>{$passageText}</p>";
                foreach ($resources as $resource) {
                    $result[] = "<p>";
                    $result[] = $resource;
                    $html = Resource_Logic::getHtml($resource, $book, $chapter, $verse);
                    $result[] = $html;
                    $result[] = "</p>";
                }
                $result[] = "</div>";
                $result[] = "<br>";
            }
        }
    }
示例#22
0
        }
        echo "{$key}\n";
    }
    die;
}
@($id = $_GET['id']);
if (isset($id)) {
    // Get the and passage for this identifier.
    $passage = Filter_Books::integer2passage($id);
    $book = $passage[0];
    $chapter = $passage[1];
    $verse = $passage[2];
    // Get the plain text.
    $text = $database_search->getBibleVerseText($bible, $book, $chapter, $verse);
    // Format it.
    $link = Filter_Books::linkForOpeningEditorAt($book, $chapter, $verse);
    $output = "<div>{$link} {$text}</div>";
    // Output to browser.
    echo $output;
    // Done.
    die;
}
$header = new Assets_Header(Locale_Translate::_("Search"));
$header->run();
$view = new Assets_View(__FILE__);
$view->view->bible = $bible;
$script = <<<EOD
var searchBible = "{$bible}";
EOD;
$view->view->script = $script;
$view->render("strongs.php");
示例#23
0
文件: next.php 项目: alerque/bibledit
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();
$currentBook = $ipc_focus->getBook();
$currentChapter = $ipc_focus->getChapter();
$currentPassage = array($currentBook, $currentChapter, 1);
$currentLocation = Filter_Books::passage2integer($currentPassage);
$books = $database_bibles->getBooks($bible);
foreach ($books as $book) {
    $chapters = $database_bibles->getChapters($bible, $book);
    foreach ($chapters as $chapter) {
        if ($chapter == 0) {
            continue;
        }
        $passage = array($book, $chapter, 1);
        $location = Filter_Books::passage2integer($passage);
        if ($location > $currentLocation) {
            $usfm = $database_bibles->getChapter($bible, $book, $chapter);
            $xrefs = Filter_Usfm::extractNotes($usfm, array("x"));
            if (empty($xrefs)) {
                $ipc_focus->set($book, $chapter, 1);
                Filter_Url::redirect("index.php");
                die;
            }
        }
    }
}
Filter_Url::redirect("index.php");
示例#24
0
$database_bibles = Database_Bibles::getInstance();
$bible = Access_Bible::clamp($_GET['bible']);
$view->view->bible = Filter_Html::sanitize($bible);
@($reset = $_GET["reset"]);
if (isset($reset)) {
    $database_config_bible->setBookOrder($bible, "");
}
@($order = $_POST['order']);
if (isset($order)) {
    $order = explode(",", $order);
    $ids = array();
    foreach ($order as $english) {
        $id = $database_books->getIdFromEnglish($english);
        $ids[] = $id;
    }
    $order = implode(" ", $ids);
    $database_config_bible->setBookOrder($bible, $order);
    die;
}
$script = <<<EOD
var orderBible = '{$bible}';
EOD;
$view->view->script = $script;
$names = array();
$books = Filter_Books::getOrdered($bible);
foreach ($books as $book) {
    $names[] = $database_books->getEnglishFromId($book);
}
$view->view->names = $names;
$view->render("order.php");
Assets_Page::footer();
示例#25
0
$bibles = Access_Bible::bibles($session_logic->currentUser());
// The admin disables notes selection on Bibles, so the admin sees all notes, even notes referring to non-existing Bibles.
if ($session_logic->currentLevel() == Filter_Roles::ADMIN_LEVEL) {
    $bibles = NULL;
}
$identifiers = $database_notes->selectNotes($bibles, $book, $chapter, $verse, $passage_selector, $edit_selector, $non_edit_selector, $status_selector, $bible_selector, $assignment_selector, $subscription_selector, $severity_selector, $text_selector, $search_text, NULL);
$view->view->identifiers = $identifiers;
$count = count($identifiers);
$view->view->count = $count;
$summaries = array();
$verse_texts = array();
$contents = array();
foreach ($identifiers as $identifier) {
    $summary = $database_notes->getSummary($identifier);
    $passages = $database_notes->getPassages($identifier);
    $verses = Filter_Books::passagesDisplayInline($passages);
    $summaries[] = $summary . " | " . $verses;
    $verse_text = "";
    if ($passage_inclusion_selector) {
        $passages = $database_notes->getPassages($identifier);
        foreach ($passages as $passage) {
            $usfm = $database_bibles->getChapter($bible, $passage[0], $passage[1]);
            $text = Filter_Usfm::getVerseText($usfm, $passage[2]);
            $verse_text .= $text;
            $verse_text .= "\n";
        }
    }
    $verse_texts[] = nl2br($verse_text);
    $content = "";
    if ($text_inclusion_selector) {
        $content = $database_notes->getContents($identifier);