public function newVerse($bookIdentifier, $chapterNumber, $verseNumber) { $this->storeData(); $database_books = Database_Books::getInstance(); // Store passage and any text only in case the book is valid, // and the chapter and verse are non-zero. $book = $database_books->getOnlinebibleFromId($bookIdentifier); if ($book != "") { if ($chapterNumber > 0) { $verse = Filter_Numeric::integer_in_string($verseNumber); if ($verse > 0) { $this->output[] = "\$\$\$ {$book} {$chapterNumber}:{$verse}"; $this->currentLine = ""; } } } }
public function testFilterEmailExtractEmail() { $this->assertEquals("1st", Filter_Numeric::add_ordinal_number_suffix(1)); $this->assertEquals("2nd", Filter_Numeric::add_ordinal_number_suffix(2)); $this->assertEquals("3rd", Filter_Numeric::add_ordinal_number_suffix(3)); $this->assertEquals("4th", Filter_Numeric::add_ordinal_number_suffix(4)); $this->assertEquals("10th", Filter_Numeric::add_ordinal_number_suffix(10)); $this->assertEquals("11th", Filter_Numeric::add_ordinal_number_suffix(11)); $this->assertEquals("21st", Filter_Numeric::add_ordinal_number_suffix(21)); $this->assertEquals("22nd", Filter_Numeric::add_ordinal_number_suffix(22)); $this->assertEquals("33rd", Filter_Numeric::add_ordinal_number_suffix(33)); $this->assertEquals("44th", Filter_Numeric::add_ordinal_number_suffix(44)); $this->assertEquals("101st", Filter_Numeric::add_ordinal_number_suffix(101)); $this->assertEquals("102nd", Filter_Numeric::add_ordinal_number_suffix(102)); $this->assertEquals("103rd", Filter_Numeric::add_ordinal_number_suffix(103)); $this->assertEquals("104th", Filter_Numeric::add_ordinal_number_suffix(104)); }
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_config_bible = Database_Config_Bible::getInstance(); $database_bibles = Database_Bibles::getInstance(); $ipc_focus = Ipc_Focus::getInstance(); @($switchbook = $_GET['switchbook']); @($switchchapter = $_GET['switchchapter']); @($switchverse = $_GET['switchverse']); if (isset($switchbook) && isset($switchchapter)) { $switchbook = Filter_Numeric::integer_in_string($switchbook); $switchchapter = Filter_Numeric::integer_in_string($switchchapter); $verse = 1; if (!isset($switchverse)) { $switchverse = 1; } $ipc_focus->set($switchbook, $switchchapter, $switchverse); Navigation_Passage::recordHistory($switchbook, $switchchapter, $switchverse); } $header = new Assets_Header(Locale_Translate::_("Edit")); $header->setNavigator(); $header->setEditorStylesheet(); $header->run(); @($changebible = $_GET['changebible']); if (isset($changebible)) { if ($changebible == "") { $dialog_list = new Dialog_List2(Locale_Translate::_("Select which Bible to open in the editor"));
public static function processUnits($length) { // If no unit is found, add %. if ($length == Filter_Numeric::integer_in_string($length)) { return $length . '%'; } // If % is found, clean the value up. if (strpos($length, '%') !== false) { $length = Filter_Numeric::integer_in_string($length) . '%'; return $length; } // If px is found, clean the value up. if (strpos($length, 'px') !== false) { $length = Filter_Numeric::integer_in_string($length) . 'px'; return $length; } // Pass the length through. return $length; }
/** * 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; }
public static function handleSequencesRanges($passage) { // A passage like Exod. 37:4-5, 14-15, 27-28 will be cut at the comma. // The resulting array contains the following: // Exod. 37:4-5 // 14-15 // 27-28 // It implies that the first sequence has book and chapter. $sequences = explode(",", $passage); foreach ($sequences as &$line) { $line = trim($line); } unset($line); // Store output lines. $output = array(); // Cut the passages at the hyphen. foreach ($sequences as $offset => $sequence) { $range = explode("-", $sequence); if (count($range) == 1) { $output[] = trim($range[0]); } else { $start = trim($range[0]); $output[] = $start; if ($offset == 0) { // Since the first bit contains book / chapter / verse, // extract the verse number. $start = strrev($start); $start = Filter_Numeric::integer_in_string($start); $start = strrev($start); } $end = trim($range[1]); for ($i = $start + 1; $i <= $end; $i++) { $output[] = $i; } } } // Result. return $output; }
/** * This function does the processing of the USFM code, * formatting the document and extracting other useful information. */ private function processUsfm() { // Go through the USFM code. $processedBooksCount = 0; $this->usfmMarkersAndTextPointer = 0; while ($this->unprocessedUsfmCodeAvailable()) { $this->getUsfmNextChapter(); for ($this->chapterUsfmMarkersAndTextPointer = 0; $this->chapterUsfmMarkersAndTextPointer < count($this->chapterUsfmMarkersAndText); $this->chapterUsfmMarkersAndTextPointer++) { $currentItem = $this->chapterUsfmMarkersAndText[$this->chapterUsfmMarkersAndTextPointer]; if (Filter_Usfm::isUsfmMarker($currentItem)) { // Indicator describing the marker. $isOpeningMarker = Filter_Usfm::isOpeningMarker($currentItem); $isEmbeddedMarker = Filter_Usfm::isEmbeddedMarker($currentItem); // Clean up the marker, so we remain with the basic version, e.g. 'id'. $marker = Filter_Usfm::getMarker($currentItem); if (array_key_exists($marker, $this->styles)) { $style = $this->styles[$marker]; switch ($style['type']) { case StyleTypeIdentifier: if ($this->odf_text_standard) { $this->odf_text_standard->closeTextStyle(false, false); } if ($this->odf_text_text_only) { $this->odf_text_text_only->closeTextStyle(false, false); } if ($this->odf_text_text_and_note_citations) { $this->odf_text_text_and_note_citations->closeTextStyle(false, false); } if ($this->odf_text_notes) { $this->odf_text_notes->closeTextStyle(false, false); } if ($this->html_text_standard) { $this->html_text_standard->closeTextStyle(false, false); } if ($this->html_text_linked) { $this->html_text_linked->closeTextStyle(false, false); } switch ($style['subtype']) { case IdentifierSubtypeBook: // Get book number. $s = Filter_Usfm::getBookIdentifier($this->chapterUsfmMarkersAndText, $this->chapterUsfmMarkersAndTextPointer); $s = str_replace(Filter_Character::softHyphen(), "", $s); // Remove possible soft hyphen. $database_books = Database_Books::getInstance(); $this->currentBookIdentifier = $database_books->getIdFromUsfm($s); // Reset chapter and verse numbers. $this->currentChapterNumber = 0; $this->currentVerseNumber = "0"; // Throw away whatever follows the \id, e.g. 'GEN xxx xxx'. Filter_Usfm::getTextFollowingMarker($this->chapterUsfmMarkersAndText, $this->chapterUsfmMarkersAndTextPointer); // Whether to insert a new page before the book. But never before the first book. if ($style['userbool1']) { if ($processedBooksCount) { if ($this->odf_text_standard) { $this->odf_text_standard->newPageBreak(); } if ($this->odf_text_text_only) { $this->odf_text_text_only->newPageBreak(); } if ($this->odf_text_text_and_note_citations) { $this->odf_text_text_and_note_citations->newPageBreak(); } if ($this->html_text_standard) { $this->html_text_standard->newPageBreak(); } if ($this->html_text_linked) { $this->html_text_linked->newPageBreak(); } } } $processedBooksCount++; // Reset notes. $this->resetNoteCitations('book'); // Online Bible. if ($this->onlinebible_text) { $this->onlinebible_text->storeData(); } // eSword. if ($this->esword_text) { $this->esword_text->newBook($this->currentBookIdentifier); } // Done. break; case IdentifierSubtypeEncoding: $this->addToFallout("Text encoding indicator not supported. Encoding is always in UTF8: \\{$marker}", true); break; case IdentifierSubtypeComment: $this->addToInfo("Comment: \\{$marker}", true); break; case IdentifierSubtypeRunningHeader: // This information already went into the Info document during the preprocessing stage. // Remove it from the USFM input stream. Filter_Usfm::getTextFollowingMarker($this->chapterUsfmMarkersAndText, $this->chapterUsfmMarkersAndTextPointer); // Ideally this information should be inserted in the headers of the standard text document. // UserBool2RunningHeaderLeft: // UserBool3RunningHeaderRight: break; case IdentifierSubtypeLongTOC: // This information already went into the Info document. Remove it from the USFM stream. Filter_Usfm::getTextFollowingMarker($this->chapterUsfmMarkersAndText, $this->chapterUsfmMarkersAndTextPointer); break; case IdentifierSubtypeShortTOC: // This information already went into the Info document. Remove it from the USFM stream. Filter_Usfm::getTextFollowingMarker($this->chapterUsfmMarkersAndText, $this->chapterUsfmMarkersAndTextPointer); break; case IdentifierSubtypeBookAbbrev: // This information already went into the Info document. Remove it from the USFM stream. Filter_Usfm::getTextFollowingMarker($this->chapterUsfmMarkersAndText, $this->chapterUsfmMarkersAndTextPointer); break; case IdentifierSubtypeChapterLabel: // This information is already in the object. Remove it from the USFM stream. Filter_Usfm::getTextFollowingMarker($this->chapterUsfmMarkersAndText, $this->chapterUsfmMarkersAndTextPointer); break; case IdentifierSubtypePublishedChapterMarker: // This information is already in the object. Remove it from the USFM stream. Filter_Usfm::getTextFollowingMarker($this->chapterUsfmMarkersAndText, $this->chapterUsfmMarkersAndTextPointer); break; case IdentifierSubtypeCommentWithEndmarker: if ($isOpeningMarker) { $this->addToInfo("Comment: \\{$marker}", true); } break; default: $this->addToFallout("Unknown markup: \\{$marker}", true); break; } break; case StyleTypeNotUsedComment: $this->addToFallout("Unknown markup: \\{$marker}", true); break; case StyleTypeNotUsedRunningHeader: $this->addToFallout("Unknown markup: \\{$marker}", true); break; case StyleTypeStartsParagraph: if ($this->odf_text_standard) { $this->odf_text_standard->closeTextStyle(false, false); } if ($this->odf_text_text_only) { $this->odf_text_text_only->closeTextStyle(false, false); } if ($this->odf_text_text_and_note_citations) { $this->odf_text_text_and_note_citations->closeTextStyle(false, false); } if ($this->odf_text_notes) { $this->odf_text_notes->closeTextStyle(false, false); } if ($this->html_text_standard) { $this->html_text_standard->closeTextStyle(false, false); } if ($this->html_text_linked) { $this->html_text_linked->closeTextStyle(false, false); } switch ($style['subtype']) { case ParagraphSubtypeMainTitle: case ParagraphSubtypeSubTitle: case ParagraphSubtypeSectionHeading: $this->newParagraph($style, true); $this->heading_started = true; $this->text_started = false; break; case ParagraphSubtypeNormalParagraph: default: $this->newParagraph($style, false); $this->heading_started = false; $this->text_started = true; if (is_array($this->verses_text)) { // If a new paragraph starts within an existing verse, // add a space to the text already in that verse. if (isset($this->verses_text[$this->currentVerseNumber])) { $this->verses_text[$this->currentVerseNumber] .= " "; } // Record the position within the text where this new paragraph starts. $contents = implode('', $this->verses_text); $this->paragraph_start_positions[] = mb_strlen($contents); unset($contents); } break; } break; case StyleTypeInlineText: // Support for a normal and an embedded character style. if ($isOpeningMarker) { if ($this->odf_text_standard) { $this->odf_text_standard->openTextStyle($style, false, $isEmbeddedMarker); } if ($this->odf_text_text_only) { $this->odf_text_text_only->openTextStyle($style, false, $isEmbeddedMarker); } if ($this->odf_text_text_and_note_citations) { $this->odf_text_text_and_note_citations->openTextStyle($style, false, $isEmbeddedMarker); } if ($this->html_text_standard) { $this->html_text_standard->openTextStyle($style, false, $isEmbeddedMarker); } if ($this->html_text_linked) { $this->html_text_linked->openTextStyle($style, false, $isEmbeddedMarker); } } else { if ($this->odf_text_standard) { $this->odf_text_standard->closeTextStyle(false, $isEmbeddedMarker); } if ($this->odf_text_text_only) { $this->odf_text_text_only->closeTextStyle(false, $isEmbeddedMarker); } if ($this->odf_text_text_and_note_citations) { $this->odf_text_text_and_note_citations->closeTextStyle(false, $isEmbeddedMarker); } if ($this->html_text_standard) { $this->html_text_standard->closeTextStyle(false, $isEmbeddedMarker); } if ($this->html_text_linked) { $this->html_text_linked->closeTextStyle(false, $isEmbeddedMarker); } } break; case StyleTypeChapterNumber: if ($this->odf_text_standard) { $this->odf_text_standard->closeTextStyle(false, false); } if ($this->odf_text_text_only) { $this->odf_text_text_only->closeTextStyle(false, false); } if ($this->odf_text_text_and_note_citations) { $this->odf_text_text_and_note_citations->closeTextStyle(false, false); } if ($this->odf_text_notes) { $this->odf_text_notes->closeTextStyle(false, false); } if ($this->html_text_standard) { $this->html_text_standard->closeTextStyle(false, false); } if ($this->html_text_linked) { $this->html_text_linked->closeTextStyle(false, false); } if ($this->onlinebible_text) { $this->onlinebible_text->storeData(); } // Get the chapter number. $number = Filter_Usfm::getTextFollowingMarker($this->chapterUsfmMarkersAndText, $this->chapterUsfmMarkersAndTextPointer); $number = Filter_Numeric::integer_in_string($number); // Update this object. $this->currentChapterNumber = $number; $this->currentVerseNumber = "0"; // If there is a published chapter character, the chapter number takes that value. foreach ($this->publishedChapterMarkers as $publishedChapterMarker) { if ($publishedChapterMarker['book'] == $this->currentBookIdentifier) { if ($publishedChapterMarker['chapter'] == $this->currentChapterNumber) { $number = $publishedChapterMarker['value']; } } } // Enter text for the running headers. $database_books = Database_Books::getInstance(); $runningHeader = $database_books->getEnglishFromId($this->currentBookIdentifier); foreach ($this->runningHeaders as $item) { if ($item['book'] == $this->currentBookIdentifier) { $runningHeader = $item['value']; } } $runningHeader = "{$runningHeader} {$number}"; if ($this->odf_text_standard) { $this->odf_text_standard->newHeading1($runningHeader, true); } if ($this->odf_text_text_only) { $this->odf_text_text_only->newHeading1($runningHeader, true); } if ($this->odf_text_text_and_note_citations) { $this->odf_text_text_and_note_citations->newHeading1($runningHeader, true); } if ($this->odf_text_notes) { $this->odf_text_notes->newHeading1($runningHeader, false); } // This is the phase of outputting the chapter number in the text body. // It always outputs the chapter number to the clear text export. if (isset($this->text_text)) { $this->text_text->paragraph($number); } // The chapter number is only output when there is more than one chapter in a book. if ($this->numberOfChaptersPerBook[$this->currentBookIdentifier] > 1) { if ($style['userbool1']) { // Output the chapter number at the first verse, not here. // Store it for later processing. $this->outputChapterTextAtFirstVerse = $number; } else { // Output the chapter in a new paragraph. // If the chapter label \cl is entered once before chapter 1 (\c 1) // it represents the text for "chapter" to be used throughout the current book. // If \cl is used after each individual chapter marker, it represents the particular text // to be used for the display of the current chapter heading // (usually done if numbers are being presented as words, not numerals). $labelEntireBook = ""; $labelCurrentChapter = ""; foreach ($this->chapterLabels as $pchapterLabel) { if ($pchapterLabel['book'] == $this->currentBookIdentifier) { if ($pchapterLabel['chapter'] == 0) { $labelEntireBook = $pchapterLabel['value']; } if ($pchapterLabel['chapter'] == $this->currentChapterNumber) { $labelCurrentChapter = $pchapterLabel['value']; } } } if ($labelEntireBook != "") { $number = "{$labelEntireBook} {$number}"; } if ($labelCurrentChapter != "") { $number = $labelCurrentChapter; } // The chapter number shows in a new paragraph. // Keep it together with the next paragraph. $this->newParagraph($style, true); if ($this->odf_text_standard) { $this->odf_text_standard->addText($number); } if ($this->odf_text_text_only) { $this->odf_text_text_only->addText($number); } if ($this->odf_text_text_and_note_citations) { $this->odf_text_text_and_note_citations->addText($number); } if ($this->html_text_standard) { $this->html_text_standard->addText($number); } if ($this->html_text_linked) { $this->html_text_linked->addText($number); } } } // Output chapter number for other formats. if ($this->esword_text) { $this->esword_text->newChapter($this->currentChapterNumber); } // Open a paragraph for the notes. It takes the style of the footnote content marker, usually 'ft'. // This is done specifically for the version that has the notes only. $this->ensureNoteParagraphStyle($this->standardContentMarkerFootEndNote, $this->styles[$this->standardContentMarkerFootEndNote]); if ($this->odf_text_notes) { $this->odf_text_notes->newParagraph($this->standardContentMarkerFootEndNote); } // UserBool2ChapterInLeftRunningHeader -> no headings implemented yet. // UserBool3ChapterInRightRunningHeader -> no headings implemented yet. // Reset. $this->resetNoteCitations('chapter'); // Done. break; case StyleTypeVerseNumber: if ($this->odf_text_standard) { $this->odf_text_standard->closeTextStyle(false, false); } if ($this->odf_text_text_only) { $this->odf_text_text_only->closeTextStyle(false, false); } if ($this->odf_text_text_and_note_citations) { $this->odf_text_text_and_note_citations->closeTextStyle(false, false); } if ($this->odf_text_notes) { $this->odf_text_notes->closeTextStyle(false, false); } if ($this->html_text_standard) { $this->html_text_standard->closeTextStyle(false, false); } if ($this->html_text_linked) { $this->html_text_linked->closeTextStyle(false, false); } if ($this->onlinebible_text) { $this->onlinebible_text->storeData(); } // Care for the situation that a new verse starts a new paragraph. if ($style['userbool1']) { if ($this->odf_text_standard) { if ($this->odf_text_standard->currentParagraphContent != "") { $this->odf_text_standard->newParagraph($this->odf_text_standard->currentParagraphStyle); } } if ($this->odf_text_text_only) { if ($this->odf_text_text_only->currentParagraphContent != "") { $this->odf_text_text_only->newParagraph($this->odf_text_text_only->currentParagraphStyle); } } if ($this->odf_text_text_and_note_citations) { if ($this->odf_text_text_and_note_citations->currentParagraphContent != "") { $this->odf_text_text_and_note_citations->newParagraph($this->odf_text_text_and_note_citations->currentParagraphStyle); } } if ($this->html_text_standard) { if ($this->html_text_standard->currentParagraphContent != "") { $this->html_text_standard->newParagraph($this->html_text_standard->currentParagraphStyle); } } if ($this->html_text_linked) { if ($this->html_text_linked->currentParagraphContent != "") { $this->html_text_linked->newParagraph($this->html_text_linked->currentParagraphStyle); } } if (isset($this->text_text)) { $this->text_text->paragraph(); } } // Deal with the case of a pending chapter number. if (isset($this->outputChapterTextAtFirstVerse)) { $database_config_bible = Database_Config_Bible::getInstance(); if (!$database_config_bible->getExportChapterDropCapsFrames($this->bible)) { $dropCapsLength = mb_strlen($this->outputChapterTextAtFirstVerse); $this->applyDropCapsToCurrentParagraph($dropCapsLength); if ($this->odf_text_standard) { $this->odf_text_standard->addText($this->outputChapterTextAtFirstVerse); } if ($this->odf_text_text_only) { $this->odf_text_text_only->addText($this->outputChapterTextAtFirstVerse); } if ($this->odf_text_text_and_note_citations) { $this->odf_text_text_and_note_citations->addText($this->outputChapterTextAtFirstVerse); } } else { $this->putChapterNumberInFrame($this->outputChapterTextAtFirstVerse); } if ($this->html_text_standard) { $this->html_text_standard->openTextStyle(array("marker" => "dropcaps"), false, false); } if ($this->html_text_standard) { $this->html_text_standard->addText($this->outputChapterTextAtFirstVerse); } if ($this->html_text_standard) { $this->html_text_standard->closeTextStyle(false, false); } if ($this->html_text_linked) { $this->html_text_linked->openTextStyle(array("marker" => "dropcaps"), false, false); } if ($this->html_text_linked) { $this->html_text_linked->addText($this->outputChapterTextAtFirstVerse); } if ($this->html_text_linked) { $this->html_text_linked->closeTextStyle(false, false); } } // Temporarily retrieve the text that follows the \v verse marker. $textFollowingMarker = Filter_Usfm::getTextFollowingMarker($this->chapterUsfmMarkersAndText, $this->chapterUsfmMarkersAndTextPointer); // Extract the verse number, and store it in the object. $number = Filter_Usfm::peekVerseNumber($textFollowingMarker); $this->currentVerseNumber = $number; // Output the verse number. But only if no chapter number was put here. if (!isset($this->outputChapterTextAtFirstVerse)) { // If the current paragraph has text already, then insert a space. if ($this->odf_text_standard) { if ($this->odf_text_standard->currentParagraphContent != "") { $this->odf_text_standard->addText(" "); } } if ($this->odf_text_text_only) { if ($this->odf_text_text_only->currentParagraphContent != "") { $this->odf_text_text_only->addText(" "); } } if ($this->odf_text_text_and_note_citations) { if ($this->odf_text_text_and_note_citations->currentParagraphContent != "") { $this->odf_text_text_and_note_citations->addText(" "); } } if ($this->html_text_standard) { if ($this->html_text_standard->currentParagraphContent != "") { $this->html_text_standard->addText(" "); } } if ($this->html_text_linked) { if ($this->html_text_linked->currentParagraphContent != "") { $this->html_text_linked->addText(" "); } } if ($this->odf_text_standard) { $this->odf_text_standard->openTextStyle($style, false, false); } if ($this->odf_text_text_only) { $this->odf_text_text_only->openTextStyle($style, false, false); } if ($this->odf_text_text_and_note_citations) { $this->odf_text_text_and_note_citations->openTextStyle($style, false, false); } if ($this->html_text_standard) { $this->html_text_standard->openTextStyle($style, false, false); } if ($this->html_text_linked) { $this->html_text_linked->openTextStyle($style, false, false); } if ($this->odf_text_standard) { $this->odf_text_standard->addText($number); } if ($this->odf_text_text_only) { $this->odf_text_text_only->addText($number); } if ($this->odf_text_text_and_note_citations) { $this->odf_text_text_and_note_citations->addText($number); } if ($this->html_text_standard) { $this->html_text_standard->addText($number); } if ($this->html_text_linked) { $this->html_text_linked->addText($number); } if ($this->odf_text_standard) { $this->odf_text_standard->closeTextStyle(false, false); } if ($this->odf_text_text_only) { $this->odf_text_text_only->closeTextStyle(false, false); } if ($this->odf_text_text_and_note_citations) { $this->odf_text_text_and_note_citations->closeTextStyle(false, false); } if ($this->html_text_standard) { $this->html_text_standard->closeTextStyle(false, false); } if ($this->html_text_linked) { $this->html_text_linked->closeTextStyle(false, false); } } // Clear text output. if (isset($this->text_text)) { if ($this->text_text->line() != "") { $this->text_text->text(" "); } $this->text_text->text($number); // Clear text output always has a space following the verse. // Important for outputting the first verse. $this->text_text->text(" "); } // If there was any text following the \v marker, remove the verse number, // put the remainder back into the object, and update the pointer. if ($textFollowingMarker != "") { @($pos = strpos($textFollowingMarker, $number)); if ($pos !== false) { $textFollowingMarker = substr($textFollowingMarker, $pos + strlen($number)); } // If a chapter number was put, remove any whitespace from the start of the following text. // Remove whitespace from the start of the following text, and replace it with the en-space. // This en-space is a fixed-width space. // This type of space makes the layout of the text following the verse number look tidier. // But if a chapter number was put, than do not put any space at the start of the following verse. $textFollowingMarker = ltrim($textFollowingMarker); if (!isset($this->outputChapterTextAtFirstVerse)) { $textFollowingMarker = Filter_Character::enSpace() . $textFollowingMarker; } $this->chapterUsfmMarkersAndText[$this->chapterUsfmMarkersAndTextPointer] = $textFollowingMarker; $this->chapterUsfmMarkersAndTextPointer--; } // Unset the chapter variable, whether it was used or not. This makes it ready for subsequent use. unset($this->outputChapterTextAtFirstVerse); // Other export formats. if ($this->onlinebible_text) { $this->onlinebible_text->newVerse($this->currentBookIdentifier, $this->currentChapterNumber, $this->currentVerseNumber); } if ($this->esword_text) { $this->esword_text->newVerse($this->currentVerseNumber); } // Done. break; case StyleTypeFootEndNote: $this->processNote(); break; case StyleTypeCrossreference: $this->processNote(); break; case StyleTypePeripheral: if ($this->odf_text_standard) { $this->odf_text_standard->closeTextStyle(false, false); } if ($this->odf_text_text_only) { $this->odf_text_text_only->closeTextStyle(false, false); } if ($this->odf_text_text_and_note_citations) { $this->odf_text_text_and_note_citations->closeTextStyle(false, false); } if ($this->odf_text_notes) { $this->odf_text_notes->closeTextStyle(false, false); } if ($this->html_text_standard) { $this->html_text_standard->closeTextStyle(false, false); } if ($this->html_text_linked) { $this->html_text_linked->closeTextStyle(false, false); } switch ($style['subtype']) { case PeripheralSubtypePublication: case PeripheralSubtypeTableOfContents: case PeripheralSubtypePreface: case PeripheralSubtypeIntroduction: case PeripheralSubtypeGlossary: case PeripheralSubtypeConcordance: case PeripheralSubtypeIndex: case PeripheralSubtypeMapIndex: case PeripheralSubtypeCover: case PeripheralSubtypeSpine: default: $this->addToFallout("Unknown pheripheral marker \\{$marker}", false); break; } break; case StyleTypePicture: if ($this->odf_text_standard) { $this->odf_text_standard->closeTextStyle(false, false); } if ($this->odf_text_text_only) { $this->odf_text_text_only->closeTextStyle(false, false); } if ($this->odf_text_text_and_note_citations) { $this->odf_text_text_and_note_citations->closeTextStyle(false, false); } if ($this->odf_text_notes) { $this->odf_text_notes->closeTextStyle(false, false); } if ($this->html_text_standard) { $this->html_text_standard->closeTextStyle(false, false); } if ($this->html_text_linked) { $this->html_text_linked->closeTextStyle(false, false); } $this->addToFallout("Picture formatting not yet implemented", true); break; case StyleTypePageBreak: if ($this->odf_text_standard) { $this->odf_text_standard->closeTextStyle(false, false); } if ($this->odf_text_text_only) { $this->odf_text_text_only->closeTextStyle(false, false); } if ($this->odf_text_text_and_note_citations) { $this->odf_text_text_and_note_citations->closeTextStyle(false, false); } if ($this->odf_text_notes) { $this->odf_text_notes->closeTextStyle(false, false); } if ($this->html_text_standard) { $this->html_text_standard->closeTextStyle(false, false); } if ($this->html_text_linked) { $this->html_text_linked->closeTextStyle(false, false); } if ($this->odf_text_standard) { $this->odf_text_standard->newPageBreak(); } if ($this->odf_text_text_only) { $this->odf_text_text_only->newPageBreak(); } if ($this->odf_text_text_and_note_citations) { $this->odf_text_text_and_note_citations->newPageBreak(); } if ($this->html_text_standard) { $this->html_text_standard->newPageBreak(); } if ($this->html_text_linked) { $this->html_text_linked->newPageBreak(); } if (isset($this->text_text)) { $this->text_text->paragraph(); } break; case StyleTypeTableElement: if ($this->odf_text_standard) { $this->odf_text_standard->closeTextStyle(false, false); } if ($this->odf_text_text_only) { $this->odf_text_text_only->closeTextStyle(false, false); } if ($this->odf_text_text_and_note_citations) { $this->odf_text_text_and_note_citations->closeTextStyle(false, false); } if ($this->odf_text_notes) { $this->odf_text_notes->closeTextStyle(false, false); } if ($this->html_text_standard) { $this->html_text_standard->closeTextStyle(false, false); } if ($this->html_text_linked) { $this->html_text_linked->closeTextStyle(false, false); } switch ($style['subtype']) { case TableElementSubtypeRow: $this->addToFallout("Table elements not yet implemented", false); break; case TableElementSubtypeHeading: case TableElementSubtypeCell: $this->newParagraph($style, false); break; default: break; } // UserInt1TableColumnNumber: break; case StyleTypeWordlistElement: switch ($style['subtype']) { case WorListElementSubtypeWordlistGlossaryDictionary: if ($isOpeningMarker) { $this->addToWordList($this->wordListGlossaryDictionary); } break; case WorListElementSubtypeHebrewWordlistEntry: if ($isOpeningMarker) { $this->addToWordList($this->hebrewWordList); } break; case WorListElementSubtypeGreekWordlistEntry: if ($isOpeningMarker) { $this->addToWordList($this->greekWordList); } break; case WorListElementSubtypeSubjectIndexEntry: if ($isOpeningMarker) { $this->addToWordList($this->subjectIndex); } break; default: if ($isOpeningMarker) { $this->addToFallout("Unknown word list marker \\{$marker}", false); } break; } // UserString1WordListEntryAddition: break; default: // This marker is not yet implemented. Add to fallout, plus any text that follows. $this->addToFallout("Marker not yet implemented \\{$marker}, possible formatting error:", true); break; } } else { // Here is an unknown marker. Add to fallout, plus any text that follows. $this->addToFallout("Unknown marker \\{$marker}, formatting error:", true); } } else { // Here is no marker. Treat it as text. if ($this->odf_text_standard) { $this->odf_text_standard->addText($currentItem); } if ($this->odf_text_text_only) { $this->odf_text_text_only->addText($currentItem); } if ($this->odf_text_text_and_note_citations) { $this->odf_text_text_and_note_citations->addText($currentItem); } if ($this->html_text_standard) { $this->html_text_standard->addText($currentItem); } if ($this->html_text_linked) { $this->html_text_linked->addText($currentItem); } if ($this->onlinebible_text) { $this->onlinebible_text->addText($currentItem); } if ($this->esword_text) { $this->esword_text->addText($currentItem); } if (isset($this->text_text)) { $this->text_text->text($currentItem); } if (is_array($this->verses_headings) && $this->heading_started) { if (!isset($this->verses_headings[$this->currentVerseNumber])) { $this->verses_headings[$this->currentVerseNumber] = ""; } $this->verses_headings[$this->currentVerseNumber] .= $currentItem; } if (is_array($this->verses_text) && $this->text_started) { if (isset($this->verses_text[$this->currentVerseNumber])) { $this->verses_text[$this->currentVerseNumber] .= $currentItem; } else { // The verse text straight after the \v starts with an enSpace. Remove it. $item = str_replace(Filter_Character::enSpace(), " ", $currentItem); $this->verses_text[$this->currentVerseNumber] = ltrim($item); unset($item); } } } } } }
// Note unsubscribe handler. @($unsubscribe = $_POST['unsubscribe']); if (isset($unsubscribe)) { $database_notes->unsubscribe(Filter_Numeric::integer_in_string($unsubscribe)); die; } // Note unassign handler. @($unassign = $_POST['unassign']); if (isset($unassign)) { $notes_logic->unassignUser(Filter_Numeric::integer_in_string($unassign), $session_logic->currentUser()); die; } // Note mark for deletion handler. @($delete = $_POST['delete']); if (isset($delete)) { $identifier = Filter_Numeric::integer_in_string($delete); $notes_logic->markForDeletion($identifier); die; } // From here on the script will produce output. $view = new Assets_View(__FILE__); $session_logic = Session_Logic::getInstance(); $username = $session_logic->currentUser(); $level = $session_logic->currentLevel(); $view->view->level = $level; // The identifier of the change notification. @($id = $_GET["get"]); $view->view->id = $id; // Get old text, modification, new text. $old_text = $database_modifications->getNotificationOldText($id); $view->view->old_text = $old_text;
public static function setBookChapterVerse($book, $chapter, $verse) { $book = Filter_Numeric::integer_in_string($book); $chapter = Filter_Numeric::integer_in_string($chapter); $verse = Filter_Numeric::integer_in_string($verse); $ipc_focus = Ipc_Focus::getInstance(); $ipc_focus->set($book, $chapter, $verse); Navigation_Passage::recordHistory($book, $chapter, $verse); }
$userint1 = $_GET['userint1']; if ($write) { $database_styles->updateUserint1($sheet, $style, $userint1); } } $view->view->userint1 = $styles_logic->noteNumberingText($userint1); break; case UserInt1TableColumnNumber: $view->view->userint1_columnnumber = true; if (isset($_GET['userint1'])) { $dialog_entry = new Dialog_Entry($standard_page_query, Locale_Translate::_("Please enter a column number between 1 and 4"), $userint1, "userint1", Locale_Translate::_("This is the column number for the style. The first columm is number 1.")); die; } if (isset($_POST['userint1'])) { $value = $_POST['entry']; $value = Filter_Numeric::integer_in_string($value); if ($value >= 1 && $value <= 4) { $userint1 = $value; if ($write) { $database_styles->updateUserint1($sheet, $style, $userint1); } } } $view->view->userint1 = $userint1; break; } // Userint2. $userint2 = $marker_data['userint2']; switch ($styles_logic->getUserInt2Function($type, $subtype)) { case UserInt2None: break;
@($id = $_GET['id']); @($moveback = $_GET['moveback']); if (isset($moveback)) { $time = mktime(0, 0, 0, $month - 1, 1, $year); $database_sprint->updateMonthYear($id, date("n", $time), date("Y", $time)); $view->view->success = Locale_Translate::_("The task was moved to the previous sprint"); } @($moveforward = $_GET['moveforward']); if (isset($moveforward)) { $time = mktime(0, 0, 0, $month + 1, 1, $year); $database_sprint->updateMonthYear($id, date("n", $time), date("Y", $time)); $view->view->success = Locale_Translate::_("The task was moved to the next sprint"); } @($complete = $_GET['complete']); if (isset($complete)) { $complete = Filter_Numeric::integer_in_string($complete); $database_sprint->updateComplete($id, $complete); } @($categories = $_POST['categories']); if (isset($categories)) { $categories2 = array(); $categories = trim($categories); $categories = explode("\n", $categories); foreach ($categories as $category) { $category = trim($category); if ($category != "") { $categories2[] = $category; } } $categories = implode("\n", $categories2); $database_config_bible->setSprintTaskCompletionCategories($bible, $categories);
$ipc_focus = Ipc_Focus::getInstance(); $database_ipc = Database_Ipc::getInstance(); // Optionally handle a call to the page to set the passage. @($switchbook = $_GET['switchbook']); @($switchchapter = $_GET['switchchapter']); @($switchverse = $_GET['switchverse']); if (isset($switchbook)) { $switchbook = Filter_Numeric::integer_in_string($switchbook); if (!isset($switchchapter)) { $switchchapter = 1; } $switchchapter = Filter_Numeric::integer_in_string($switchchapter); if (!isset($switchverse)) { $switchverse = 1; } $switchverse = Filter_Numeric::integer_in_string($switchverse); $ipc_focus->set($switchbook, $switchchapter, $switchverse); Navigation_Passage::recordHistory($switchbook, $switchchapter, $switchverse); } // Check whether a Bible editor is alive. $timestamp = $database_ipc->getBibleAlive(); $alive = $timestamp > time() - 5; if ($alive) { // If a Bible editor is alive, send javascript to the browser to close this new window. $message = Locale_Translate::_("The passage has been opened in the existing Bible editor in another browser tab."); $script = <<<EOD <!doctype html> <html> <head> </head> <body>
public static function getVerseNumbers($usfm) { $verse_numbers = array(0); $markers_and_text = Filter_Usfm::getMarkersAndText($usfm); $extract_verse = false; foreach ($markers_and_text as $marker_or_text) { if ($extract_verse) { $verse_numbers[] = Filter_Numeric::integer_in_string($marker_or_text); $extract_verse = false; } if (substr($marker_or_text, 0, 2) == '\\v') { $extract_verse = true; } } return $verse_numbers; }
GNU General Public License for more details. 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::MANAGER_LEVEL); $header = new Assets_Header(Locale_Translate::_("Edit Note Source")); $header->setBodyOnload('document.noteid.identifier.focus();'); $header->run(); $view = new Assets_View(__FILE__); @($noteIdentifier = $_GET['identifier']); if (isset($_POST['identifier'])) { $noteIdentifier = $_POST['identifier']; $noteIdentifier = Filter_Numeric::integer_in_string($noteIdentifier); } $database_notes = Database_Notes::getInstance(); if (isset($_POST['data'])) { $noteData = $_POST['data']; if ($database_notes->identifierExists($noteIdentifier)) { $noteData = $database_notes->setContents($noteIdentifier, $noteData); $view->view->success = Locale_Translate::_("The note was saved"); } else { $view->view->error = Locale_Translate::_("Unknown Note Identifier"); } } if ($noteIdentifier != "") { if ($database_notes->identifierExists($noteIdentifier)) { $noteData = $database_notes->getContents($noteIdentifier); $view->view->data = $noteData;