Example #1
4
 /**
  * Constructs a book dialog
  * $action - GET or POST action to take.
  * $inclusions - NULL (in which case it does nothing), or an array of book IDs to include.
  * $exclusions - NULL (in which case it does nothing), or an array of book IDs to exclude.
  */
 public function __construct($header, $info_top, $info_bottom, $action, $inclusions, $exclusions)
 {
     $this->view = new Assets_View(__FILE__);
     $caller = $_SERVER["PHP_SELF"] . "?" . http_build_query(array());
     $this->view->view->caller = $caller;
     $this->view->view->header = $header;
     $this->view->view->info_top = $info_top;
     $this->view->view->info_bottom = $info_bottom;
     $this->view->view->action = $action;
     $database_books = Database_Books::getInstance();
     $book_ids = $database_books->getIDs();
     if (is_array($inclusions)) {
         $book_ids = $inclusions;
     }
     if (is_array($exclusions)) {
         $book_ids = array_diff($book_ids, $exclusions);
         $book_ids = array_values($book_ids);
     }
     foreach ($book_ids as $id) {
         $book_names[] = $database_books->getEnglishFromId($id);
     }
     $this->view->view->book_ids = $book_ids;
     $this->view->view->book_names = $book_names;
     $this->view->render("books2.php");
     Assets_Page::footer();
     die;
 }
Example #2
0
 public static function getInstance()
 {
     if (empty(self::$instance)) {
         self::$instance = new Database_Books();
     }
     return self::$instance;
 }
Example #3
0
 public static function htmlFileNameBible($path = "", $book = "", $chapter = "")
 {
     $database_books = Database_Books::getInstance();
     $filename = "";
     // If a path is given, prefix it.
     if ($path != "") {
         $filename = $path . '/';
     }
     // No book ID given: Return the name for the index file for the Bible.
     if ($book == "") {
         $filename .= "index.html";
         return $filename;
     }
     // Add the name for the book. No spaces.
     $filename .= str_pad($book, 2, "0", STR_PAD_LEFT);
     $book = $database_books->getEnglishFromId($book);
     $book = str_replace(" ", "", $book);
     $filename .= '-' . $book;
     // No chapter given: Provide name for the index files of all chapters in a book.
     if ($chapter !== "") {
         $filename .= '-' . str_pad($chapter, 3, "0", STR_PAD_LEFT);
     }
     $filename .= ".html";
     return $filename;
 }
Example #4
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;
 }
Example #5
0
 /**
  * Creates book template with ID $book in Bible $bible.
  * If a $chapter is given instead of NULL, it creates that chapter only.
  */
 public static function create($bible, $book, $chapter, &$feedback)
 {
     $database_bibles = Database_Bibles::getInstance();
     $database_versifications = Database_Versifications::getInstance();
     $database_books = Database_Books::getInstance();
     $database_logs = Database_Logs::getInstance();
     $database_config_bible = Database_Config_Bible::getInstance();
     $bible_id = $database_bibles->getID($bible);
     if ($bible_id == 0) {
         $feedback[] = Locale_Translate::_("Bible {$bible} does not exist: Cannot create book");
         return false;
     }
     if ($book == 0) {
         $feedback[] = Locale_Translate::_("Invalid book while creating a book template");
         return false;
     }
     // The chapters that have been created.
     $chaptersCreated = array();
     // Chapter 0.
     if (!isset($chapter) || $chapter == 0) {
         $data = "\\id " . $database_books->getUsfmFromId($book) . "\n";
         $data .= "\\h " . $database_books->getEnglishFromId($book) . "\n";
         $data .= "\\toc2 " . $database_books->getEnglishFromId($book) . "\n";
         Bible_Logic::storeChapter($bible, $book, 0, $data);
         $chaptersCreated[] = 0;
     }
     // Subsequent chapters.
     $versification = $database_config_bible->getVersificationSystem($bible);
     $versification_data = $database_versifications->getBooksChaptersVerses($versification);
     foreach ($versification_data as $row) {
         if ($book == $row["book"]) {
             $ch = $row["chapter"];
             $verse = $row["verse"];
             if (!isset($chapter) || $chapter == $ch) {
                 $data = "\\c {$ch}\n";
                 $data .= "\\p\n";
                 for ($i = 1; $i <= $verse; $i++) {
                     $data .= "\\v {$i}\n";
                 }
                 Bible_Logic::storeChapter($bible, $book, $ch, $data);
                 $chaptersCreated[] = $ch;
             }
         }
     }
     // Done.
     if (count($chaptersCreated) == 0) {
         $feedback[] = Locale_Translate::_("No chapters have been craeted");
         return false;
     }
     $chaptersCreated = implode(" ", $chaptersCreated);
     $feedback[] = Locale_Translate::_("The following chapters have been created:") . " " . $chaptersCreated;
     return true;
 }
Example #6
0
 /**
  * This filter produces files in USFM, html and text format.
  * The text files are to be used for showing the differences between them.
  * The files contain all verses that differ.
  * $bible: The Bible to go through.
  * $directory: The existing directory where to put the files.
  * Two files are created: verses_old.usfm and verses_new.usfm.
  * The book chapter.verse precede each verse.
  */
 public static function produceVerseLevel($bible, $directory)
 {
     $database_bibles = Database_Bibles::getInstance();
     $database_modifications = Database_Modifications::getInstance();
     $database_books = Database_Books::getInstance();
     $database_config_bible = Database_Config_Bible::getInstance();
     $stylesheet = $database_config_bible->getExportStylesheet($bible);
     $old_vs_usfm = array();
     $new_vs_usfm = array();
     $filter_text_old = new Filter_Text($bible);
     $filter_text_old->html_text_standard = new Html_Text(Locale_Translate::_("Bible"));
     $filter_text_old->text_text = new Text_Text();
     $filter_text_new = new Filter_Text($bible);
     $filter_text_new->html_text_standard = new Html_Text(Locale_Translate::_("Bible"));
     $filter_text_new->text_text = new Text_Text();
     $books = $database_modifications->getTeamDiffBooks($bible);
     foreach ($books as $book) {
         $bookname = $database_books->getEnglishFromId($book);
         $chapters = $database_modifications->getTeamDiffChapters($bible, $book);
         foreach ($chapters as $chapter) {
             // Go through the combined verse numbers in the old and new chapter.
             $old_chapter_usfm = $database_modifications->getTeamDiff($bible, $book, $chapter);
             $new_chapter_usfm = $database_bibles->getChapter($bible, $book, $chapter);
             $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_text = Filter_Usfm::getVerseText($old_chapter_usfm, $verse);
                 $new_verse_text = Filter_Usfm::getVerseText($new_chapter_usfm, $verse);
                 if ($old_verse_text != $new_verse_text) {
                     $usfmCode = "\\p {$bookname} {$chapter}.{$verse} {$old_verse_text}";
                     $old_vs_usfm[] = $usfmCode;
                     $filter_text_old->addUsfmCode($usfmCode);
                     $usfmCode = "\\p {$bookname} {$chapter}.{$verse} {$new_verse_text}";
                     $new_vs_usfm[] = $usfmCode;
                     $filter_text_new->addUsfmCode($usfmCode);
                 }
             }
         }
     }
     file_put_contents("{$directory}/verses_old.usfm", implode("\n", $old_vs_usfm));
     file_put_contents("{$directory}/verses_new.usfm", implode("\n", $new_vs_usfm));
     $filter_text_old->run($stylesheet);
     $filter_text_new->run($stylesheet);
     $filter_text_old->html_text_standard->save("{$directory}/verses_old.html");
     $filter_text_new->html_text_standard->save("{$directory}/verses_new.html");
     $filter_text_old->text_text->save("{$directory}/verses_old.txt");
     $filter_text_new->text_text->save("{$directory}/verses_new.txt");
 }
Example #7
0
 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 = "";
             }
         }
     }
 }
Example #8
0
 public static function display($data)
 {
     $data = self::read($data);
     $database_books = Database_Books::getInstance();
     $output = array();
     // Check for books, order them, supply missing ones.
     $books = $database_books->getIDs();
     foreach ($books as $book) {
         $found = false;
         foreach ($data as $abbreviation => $bookId) {
             if ($book == $bookId) {
                 $output[] = $database_books->getEnglishFromId($book) . " = " . $abbreviation;
                 $found = true;
             }
         }
         if (!$found) {
             $output[] = $database_books->getEnglishFromId($book) . " = ";
         }
     }
     // Get data as a string for display.
     return implode("\n", $output);
 }
Example #9
0
 public static function safeStoreChapter($bible, $book, $chapter, $usfm)
 {
     $database_bibles = Database_Bibles::getInstance();
     $database_logs = Database_Logs::getInstance();
     $database_books = Database_Books::getInstance();
     // Existing chapter contents.
     $existing = $database_bibles->getChapter($bible, $book, $chapter);
     // Bail out if the existing chapter equals the USFM to be saved.
     if ($usfm == $existing) {
         return true;
     }
     // The length of the new USFM code should not differ more than 20% from the existing USFM code.
     $existingLength = strlen($existing);
     $newLength = strlen($usfm);
     $percentage = 100 * ($newLength - $existingLength) / $existingLength;
     $percentage = abs($percentage);
     $percentage = round($percentage);
     if ($percentage > 20) {
         $database_logs->log("The chapter was not saved for safety reasons. The length differs {$percentage}% from the existing chapter. Make minor changes and save often.");
         $database_logs->log("{$bible} " . $database_books->getEnglishFromId($book) . " {$chapter}");
         $database_logs->log($usfm);
         return false;
     }
     // The text of the new chapter should not differ more than 20% from the existing text.
     similar_text($existing, $usfm, $percentage);
     $percentage = abs($percentage);
     $percentage = 100 - $percentage;
     $percentage = round($percentage);
     if ($percentage > 20) {
         $database_logs->log("The chapter was not saved for safety reasons. The new text differs {$percentage}% from the existing text. Make minor changes and save often.");
         $database_logs->log("{$bible} " . $database_books->getEnglishFromId($book) . " {$chapter}");
         $database_logs->log($usfm);
         return false;
     }
     // Safety checks have passed: Save chapter.
     Bible_Logic::storeChapter($bible, $book, $chapter, $usfm);
     return true;
 }
Example #10
0
 public function exportBibleditXmlFile($name)
 {
     $database_books = Database_Books::getInstance();
     $xml = new SimpleXMLElement("<bibledit-versification-system></bibledit-versification-system>");
     $versification_data = $this->getBooksChaptersVerses($name);
     foreach ($versification_data as $row) {
         $triad = $xml->addChild("triad");
         $book = $row["book"];
         $book = $database_books->getEnglishFromId($book);
         $triad->addChild("book", $book);
         $chapter = $row["chapter"];
         $triad->addChild("chapter", $chapter);
         $verse = $row["verse"];
         $triad->addChild("verse", $verse);
     }
     $domnode = dom_import_simplexml($xml);
     $dom = new DOMDocument("1.0", "UTF-8");
     $domnode = $dom->importNode($domnode, true);
     $dom->appendChild($domnode);
     $dom->formatOutput = true;
     $string = $dom->saveXML();
     return $string;
 }
Example #11
0
 public static function interpretBook($book)
 {
     $book = trim($book);
     $identifier = 0;
     $database_books = Database_Books::getInstance();
     // Recognize names like "I Peter", where the "I" can also be "II" or "III".
     // Do the longest ones first.
     $book = str_replace("III ", "3 ", $book);
     $book = str_replace("II ", "2 ", $book);
     $book = str_replace("I ", "1 ", $book);
     // Check on names entered like "Genesis" or "1 Corinthians", the full English name.
     // A bug was discovered so that "Judges" was interpreted as "Jude", because
     // of the three letters "Jud". Solved by checking on full English name first.
     $identifier = $database_books->getIdFromEnglish($book);
     if ($identifier) {
         return $identifier;
     }
     // Recognise the USFM book abbreviations.
     $identifier = $database_books->getIdFromUsfm($book);
     if ($identifier) {
         return $identifier;
     }
     // Try the OSIS abbreviations.
     $identifier = $database_books->getIdFromOsis($book);
     if ($identifier) {
         return $identifier;
     }
     // Try the abbreviations of BibleWorks.
     $identifier = $database_books->getIdFromBibleworks($book);
     if ($identifier) {
         return $identifier;
     }
     // Handle names from BibleWorks when copying the verse list to the clipboard.
     // These are not handled elsewhere.
     if ($book == "Cant") {
         return 22;
     }
     if ($book == "Mk") {
         return 41;
     }
     if ($book == "Lk") {
         return 42;
     }
     if ($book == "Jn") {
         return 43;
     }
     if ($book == "1 Jn") {
         return 62;
     }
     if ($book == "2 Jn") {
         return 63;
     }
     if ($book == "3 Jn") {
         return 64;
     }
     // Try the abbreviations of the Online Bible.
     $identifier = $database_books->getIdFromOnlinebible($book);
     if ($identifier) {
         return $identifier;
     }
     // Do a case-insensitive search in the books database for something like the book given.
     $identifier = $database_books->getIdLikeText($book);
     if ($identifier) {
         return $identifier;
     }
     /*
         Here's some code from Bibledit-Gtk that could help to further aid in interpreting book names.
     // Not found yet, check on names like "1Corinthians".
         if (rawbook.length() >= 1) {
           ustring s = rawbook.substr(0, 1);
           ustring s2 = rawbook;
           if (s == "1" || s == "2" || s == "3")
             s2.insert(1, " ");
           identifier = books_english_to_id(s2);
           if (identifier) {
             return identifier;
           }
         }
         // Not yet found.
         // Go through the language of the project, and see if the book is among the
         // booknames or abbreviations.
         {
           extern Settings *settings;
           ProjectConfiguration *projectconfig = settings->projectconfig(settings->genconfig.project_get());
           identifier = books_name_to_id(projectconfig->language_get(), rawbook);
           if (identifier)
             return identifier;
           identifier = books_abbreviation_to_id(projectconfig->language_get(), rawbook);
           if (identifier)
             return identifier;
           identifier = books_abbreviation_to_id_loose(projectconfig->language_get(), rawbook);
           if (identifier)
             return identifier;
         }
         // Still not found.
         // Go through all available languages, and see if the book is among the
         // names or abbreviations of the book.
         {
           extern BookLocalizations *booklocalizations;
           vector < ustring > languages = booklocalizations->localizations_get();
           for (unsigned int i = 0; i < languages.size(); i++) {
             identifier = books_name_to_id(languages[i], rawbook);
             if (identifier)
               return identifier;
             identifier = books_abbreviation_to_id(languages[i], rawbook);
             if (identifier)
               return identifier;
             identifier = books_abbreviation_to_id_loose(languages[i], rawbook);
             if (identifier)
               return identifier;
           }
         }
     For language searches, one would need to load all book translations through a series of Locale_Translate::_calls,
         then sort these out.
     The soundex function of PHP could aid too.
     */
     return 0;
 }
Example #12
0
 /**
  * This creates and saves the information document.
  * It contains formatting information, collected from the USFM code.
  * $path: Path to the document.
  */
 public function produceInfoDocument($path)
 {
     $database_books = Database_Books::getInstance();
     $information = new Html_Text(Locale_Translate::_("Information"));
     // Number of chapters per book.
     $information->newHeading1(Locale_Translate::_("Number of chapters per book"));
     foreach ($this->numberOfChaptersPerBook as $book => $chapterCount) {
         $line = $database_books->getEnglishFromId($book) . " => " . $chapterCount;
         $information->newParagraph();
         $information->addText($line);
     }
     // Running headers.
     $information->newHeading1(Locale_Translate::_("Running headers"));
     foreach ($this->runningHeaders as $item) {
         $line = $database_books->getEnglishFromId($item['book']) . " (USFM " . $item['marker'] . ") => " . $item['value'];
         $information->newParagraph();
         $information->addText($line);
     }
     // Table of Contents entries.
     $information->newHeading1(Locale_Translate::_("Long table of contents entries"));
     foreach ($this->longTOCs as $item) {
         $line = $database_books->getEnglishFromId($item['book']) . " (USFM " . $item['marker'] . ") => " . $item['value'];
         $information->newParagraph();
         $information->addText($line);
     }
     $information->newHeading1(Locale_Translate::_("Short table of contents entries"));
     foreach ($this->shortTOCs as $item) {
         $line = $database_books->getEnglishFromId($item['book']) . " (USFM " . $item['marker'] . ") => " . $item['value'];
         $information->newParagraph();
         $information->addText($line);
     }
     // Book abbreviations.
     $information->newHeading1(Locale_Translate::_("Book abbreviations"));
     foreach ($this->bookAbbreviations as $item) {
         $line = $database_books->getEnglishFromId($item['book']) . " (USFM " . $item['marker'] . ") => " . $item['value'];
         $information->newParagraph();
         $information->addText($line);
     }
     // Chapter specials.
     $information->newHeading1(Locale_Translate::_("Publishing chapter labels"));
     foreach ($this->chapterLabels as $item) {
         $line = $database_books->getEnglishFromId($item['book']) . " (USFM " . $item['marker'] . ") => " . $item['value'];
         $information->newParagraph();
         $information->addText($line);
     }
     $information->newHeading1(Locale_Translate::_("Publishing alternate chapter numbers"));
     foreach ($this->publishedChapterMarkers as $item) {
         $line = $database_books->getEnglishFromId($item['book']) . " (USFM " . $item['marker'] . ") => " . $item['value'];
         $information->newParagraph();
         $information->addText($line);
     }
     // Word lists.
     $information->newHeading1(Locale_Translate::_("Word list, glossary, dictionary entries"));
     foreach ($this->wordListGlossaryDictionary as $item) {
         $information->newParagraph();
         $information->addText($item);
     }
     $information->newHeading1(Locale_Translate::_("Hebrew word list entries"));
     foreach ($this->hebrewWordList as $item) {
         $information->newParagraph();
         $information->addText($item);
     }
     $information->newHeading1(Locale_Translate::_("Greek word list entries"));
     foreach ($this->greekWordList as $item) {
         $information->newParagraph();
         $information->addText($item);
     }
     $information->newHeading1(Locale_Translate::_("Subject index entries"));
     foreach ($this->subjectIndex as $item) {
         $information->newParagraph();
         $information->addText($item);
     }
     // Other info.
     $information->newHeading1(Locale_Translate::_("Other information"));
     foreach ($this->info as $line) {
         $information->newParagraph();
         $information->addText($line);
     }
     $information->save($path);
 }
Example #13
0
 public function testGetType()
 {
     $database_books = Database_Books::getInstance();
     $type = $database_books->getType(40);
     $this->assertEquals("nt", $type);
     $type = $database_books->getType(39);
     $this->assertEquals("ot", $type);
     $type = $database_books->getType(0);
     $this->assertEquals("", $type);
 }
Example #14
0
 public static function baseBookFileName($book)
 {
     if ($book) {
         $database_books = Database_Books::getInstance();
         $filename = sprintf("%0" . 2 . "d", $book) . "_" . $database_books->getEnglishFromId($book);
     } else {
         $filename = "00_Bible";
     }
     return $filename;
 }
Example #15
0
 private function malformedId()
 {
     $item = substr($this->usfmItem, 0, 3);
     if ($item == '\\id') {
         $code = Filter_Usfm::peekTextFollowingMarker($this->usfmMarkersAndText, $this->usfmMarkersAndTextPointer);
         $id = substr($code, 0, 3);
         $id = explode(" ", $code);
         $id = $id[0];
         $database_books = Database_Books::getInstance();
         $book = $database_books->getIdFromUsfm($id);
         if ($book == 0) {
             $this->addResult("Unknown ID", Checks_Usfm::displayFull);
         } else {
             if (strtoupper($id) != $id) {
                 $this->addResult("ID is not in uppercase", Checks_Usfm::displayFull);
             }
         }
     }
 }
Example #16
0
 public static function import($input, $stylesheet)
 {
     $result = array();
     $book_number = 0;
     $chapter_number = 0;
     $chapter_data = "";
     $input = Filter_Usfm::oneString($input);
     $markers_and_text = Filter_Usfm::getMarkersAndText($input);
     $retrieve_book_number_on_next_iteration = false;
     $retrieve_chapter_number_on_next_iteration = false;
     foreach ($markers_and_text as $marker_or_text) {
         if ($retrieve_book_number_on_next_iteration) {
             $database_books = Database_Books::getInstance();
             $book_number = $database_books->getIdFromUsfm(substr($marker_or_text, 0, 3));
             $chapter_number = 0;
             $retrieve_book_number_on_next_iteration = false;
         }
         if ($retrieve_chapter_number_on_next_iteration) {
             $retrieve_chapter_number_on_next_iteration = false;
             $chapter_number = Filter_Numeric::integer_in_string($marker_or_text);
             if ($chapter_number == "") {
                 $chapter_number = 0;
             }
         }
         $marker = Filter_Usfm::getMarker($marker_or_text);
         if ($marker != "") {
             // USFM marker found.
             if ($marker == "id") {
                 $retrieve_book_number_on_next_iteration = true;
                 $store_chapter_data = true;
             }
             if ($marker == "c") {
                 $retrieve_chapter_number_on_next_iteration = true;
                 $store_chapter_data = true;
             }
             if ($store_chapter_data) {
                 $chapter_data = trim($chapter_data);
                 if ($chapter_data != "") {
                     $result[] = array($book_number, $chapter_number, $chapter_data);
                 }
                 $chapter_number = 0;
                 $chapter_data = "";
                 $store_chapter_data = false;
             }
             $database_styles = Database_Styles::getInstance();
             $marker_data = $database_styles->getMarkerData($stylesheet, $marker);
             $type = $marker_data['type'];
             $subtype = $marker_data['subtype'];
             $styles_logic = Styles_Logic::getInstance();
             if ($styles_logic->startsNewLineInUsfm($type, $subtype)) {
                 $chapter_data .= "\n";
             }
         }
         $chapter_data .= $marker_or_text;
     }
     $chapter_data = trim($chapter_data);
     if ($chapter_data != "") {
         $result[] = array($book_number, $chapter_number, $chapter_data);
     }
     return $result;
 }
Example #17
0
 public function export($name)
 {
     $data = array();
     $database_books = Database_Books::getInstance();
     $name = Database_SQLiteInjection::no($name);
     $query = "SELECT * FROM maps WHERE name = '{$name}' ORDER BY book ASC, chapter ASC, verse ASC;";
     $result = Database_SQLite::query($this->db, $query);
     foreach ($result as $row) {
         $book = $row['book'];
         $book = $database_books->getEnglishFromId($book);
         $chapter = $row['chapter'];
         $verse = $row['verse'];
         $origbook = $row['origbook'];
         $origbook = $database_books->getEnglishFromId($origbook);
         $origchapter = $row['origchapter'];
         $origverse = $row['origverse'];
         $item = "{$book} {$chapter}:{$verse} = {$origbook} {$origchapter}:{$origverse}";
         $data[] = $item;
     }
     $data = implode("\n", $data);
     return $data;
 }
Example #18
0
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
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::TRANSLATOR_LEVEL);
$header = new Assets_Header(Locale_Translate::_("Order"));
$header->jQueryUIOn("sortable");
$header->run();
$view = new Assets_View(__FILE__);
$database_config_bible = Database_Config_Bible::getInstance();
$database_books = Database_Books::getInstance();
$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;
    }
Example #19
0
 public static function getBooksFragment($bible)
 {
     $database_bibles = Database_Bibles::getInstance();
     $database_books = Database_Books::getInstance();
     $ipc_focus = Ipc_Focus::getInstance();
     $activeBook = $ipc_focus->getBook();
     // Take standard books in case of no Bible.
     if ($bible == "") {
         $books = $database_books->getIDs();
     } else {
         $books = Filter_Books::getOrdered($bible);
     }
     $html = "";
     foreach ($books as $book) {
         $bookName = $database_books->getEnglishFromId($book);
         $selected = "";
         if ($book == $activeBook) {
             $selected = " selected";
         }
         $html .= "<option{$selected}>" . $bookName . "</option>";
     }
     return $html;
 }
Example #20
0
 public static function explodePath($path)
 {
     $data = basename($path);
     if ($data == "data") {
         $path = dirname($path);
         $chapter = basename($path);
         if (is_numeric($chapter)) {
             $book = dirname($path);
             $database_books = Database_Books::getInstance();
             $book = $database_books->getIdFromEnglish($book);
             if ($book != 0) {
                 return array('book' => $book, 'chapter' => $chapter);
             }
         }
     }
     return NULL;
 }
Example #21
0
 public function getBooks($bible)
 {
     // Read the books from the database.
     $folder = $this->bibleFolder($bible);
     @($books = scandir($folder));
     if ($books == false) {
         return array();
     }
     foreach ($books as $offset => $book) {
         if (!is_numeric($book)) {
             unset($books[$offset]);
         }
     }
     // Sort the books according to the sequence defined in the books database.
     $sequence = array();
     $database_books = Database_Books::getInstance();
     foreach ($books as $book) {
         $sequence[] = $database_books->getSequenceFromId($book);
     }
     array_multisort($sequence, $books);
     // Result.
     return $books;
 }