Пример #1
0
    foreach ($chapters as $chapter) {
        // Get the USFM code for the current chapter.
        $chapter_data = $database_bibles->getChapter($bible, $book, $chapter);
        $chapter_data = trim($chapter_data);
        // Add the chapter USFM code to the book's USFM code.
        $bookUsfmDataFull .= $chapter_data;
        $bookUsfmDataFull .= "\n";
    }
    // The filename for the USFM for this book.
    $filename = Export_Logic::baseBookFileName($book);
    $path = "{$usfmDirectoryFull}/{$filename}.usfm";
    // Save.
    file_put_contents($path, $bookUsfmDataFull);
}
// Compress USFM files into one zip file.
$zipfile = "{$usfmDirectoryFull}/" . Export_Logic::baseBookFileName(0) . ".zip";
@unlink($zipfile);
$archive = Filter_Archive::zip($usfmDirectoryFull);
rename($archive, $zipfile);
if ($database_config_bible->getSecureUsfmExport($bible)) {
    // Securing the full USFM export means that there will be one zip file secured with a password.
    // This zip file contains all exported USFM data.
    // All other files will be removed.
    // It uses the external zip binary.
    // PHP 5.6 supports password protected archives: ZipArchive::setPassword ($password).
    $files = scandir($usfmDirectoryFull);
    $files = Filter_Folders::cleanup($files);
    $basefile = basename($zipfile);
    foreach ($files as $file) {
        if ($file != $basefile) {
            unlink("{$usfmDirectoryFull}/{$file}");
Пример #2
0
$database_bibles = Database_Bibles::getInstance();
$database_books = Database_Books::getInstance();
$stylesheet = $database_config_bible->getExportStylesheet($bible);
// Create stylesheet.
$styles_sheets = new Styles_Sheets();
$styles_sheets->create($stylesheet, $filecss, false, $bible);
// Copy font to the output directory.
$font = $database_config_bible->getTextFont($bible);
if ($font) {
    if (Fonts_Logic::fontExists($font)) {
        $fontpath = Fonts_Logic::getFontPath($font);
        copy($fontpath, "{$directory}/{$font}");
    }
}
$filter_text = new Filter_Text($bible);
$filter_text->html_text_standard = new Html_Text(Locale_Translate::_("Bible"));
$filter_text->html_text_standard->customClass = Filter_CustomCSS::getClass($bible);
// Load one book.
$chapters = $database_bibles->getChapters($bible, $book);
foreach ($chapters as $chapter) {
    $usfm = $database_bibles->getChapter($bible, $book, $chapter);
    $usfm = trim($usfm);
    // Use small chunks of USFM at a time for much better performance.
    $filter_text->addUsfmCode($usfm);
}
// Convert the USFM.
$filter_text->run($stylesheet);
// Save file.
$filter_text->html_text_standard->save($filename);
$database_logs->log(Locale_Translate::_("Exported to html") . " {$bible} " . Export_Logic::baseBookFileName($book), Filter_Roles::TRANSLATOR_LEVEL);
Пример #3
0
foreach ($chapters as $chapter) {
    // The text filter for this chapter.
    $filter_text_chapter = new Filter_Text($bible);
    // Basic USFM for this chapter.
    $filter_text_chapter->initializeHeadingsAndTextPerVerse();
    // Get the USFM code for the current chapter.
    $chapter_data = $database_bibles->getChapter($bible, $book, $chapter);
    $chapter_data = trim($chapter_data);
    // Add the chapter's USFM code to the Text_* filter for the book, and for the chapter.
    // Use small chunks of USFM at a time. This provides much better performance.
    $filter_text_book->addUsfmCode($chapter_data);
    $filter_text_chapter->addUsfmCode($chapter_data);
    // Convert the chapter
    $filter_text_chapter->run($stylesheet);
    // Deal with basic USFM.
    if ($chapter > 0) {
        $verses_text = $filter_text_chapter->getVersesText();
        $basicUsfm = "\\c {$chapter}\n";
        $basicUsfm .= "\\p\n";
        foreach ($verses_text as $verse => $text) {
            $basicUsfm .= "\\v {$verse} {$text}\n";
        }
        file_put_contents($usfmFilename, $basicUsfm, FILE_APPEND);
    }
}
// Convert the book.
$filter_text_book->run($stylesheet);
// Save the text export.
$filter_text_book->text_text->save($textFilename);
$database_logs->log($bible . " " . Export_Logic::baseBookFileName($book) . ": " . Locale_Translate::_("Exported to basic USFM and text"), Filter_Roles::TRANSLATOR_LEVEL);