Example #1
0
$sourceBible = $database_config_user->getSourceXrefBible();
$targetBible = $database_config_user->getTargetXrefBible();
// Save book / abbreviation pair.
if (isset($_POST['save'])) {
    $fullname = $_POST['fullname'];
    $abbreviation = $_POST['abbreviation'];
    $abbreviations = $database_config_bible->getBookAbbreviations($targetBible);
    $abbreviations = Filter_Abbreviations::display($abbreviations);
    $abbreviations .= "\n{$fullname} = {$abbreviation}";
    $database_config_bible->setBookAbbreviations($targetBible, $abbreviations);
}
$sourceAbbreviations = $database_config_bible->getBookAbbreviations($sourceBible);
$sourceAbbreviations = Filter_Abbreviations::read($sourceAbbreviations);
$sourceAbbreviations = array_values($sourceAbbreviations);
$targetAbbreviations = $database_config_bible->getBookAbbreviations($targetBible);
$targetAbbreviations = Filter_Abbreviations::read($targetAbbreviations);
$targetAbbreviations = array_values($targetAbbreviations);
$unknown_abbreviations = array_diff($sourceAbbreviations, $targetAbbreviations);
$unknown_abbreviations = array_unique($unknown_abbreviations);
foreach ($unknown_abbreviations as &$abbreviation) {
    $abbreviation = $database_books->getEnglishFromId($abbreviation);
}
$unknown_abbreviations = array_values($unknown_abbreviations);
if (empty($unknown_abbreviations)) {
    Filter_Url::redirect("clear.php");
    die;
}
$header = new Assets_Header(Locale_Translate::_("Cross references"));
$header->run();
$view = new Assets_View(__FILE__);
$view->view->remaining = count($unknown_abbreviations) - 1;
Example #2
0
page_access_level(Filter_Roles::TRANSLATOR_LEVEL);
Assets_Page::header(Locale_Translate::_("Abbreviations"));
$view = new Assets_View(__FILE__);
$database_config_bible = Database_Config_Bible::getInstance();
$success_message = "";
$error_message = "";
// The name of the Bible.
$bible = Access_Bible::clamp($_GET['bible']);
$view->view->bible = Filter_Html::sanitize($bible);
// Data submission.
if (isset($_POST['submit'])) {
    $data = $_POST['data'];
    $data = trim($data);
    if ($data != "") {
        if (Validate_Utf8::valid($data)) {
            $database_config_bible->setBookAbbreviations($bible, $data);
            $success_message = Locale_Translate::_("The abbreviations were saved.");
        } else {
            $error_message = Locale_Translate::_("Please supply valid Unicode UTF-8 text.");
        }
    } else {
        $success_message = Locale_Translate::_("Nothing was saved.");
    }
}
$data = $database_config_bible->getBookAbbreviations($bible);
$data = Filter_Abbreviations::display($data);
$view->view->data = $data;
$view->view->success_message = $success_message;
$view->view->error_message = $error_message;
$view->render("abbreviations.php");
Assets_Page::footer();
Example #3
0
    public function testDisplay()
    {
        $input = <<<EOD
Psalms = Ps.

Exodus = Exod.

EOD;
        $data = Filter_Abbreviations::display($input);
        $output = <<<EOD
Genesis = 
Exodus = Exod.
Leviticus = 
Numbers = 
Deuteronomy = 
Joshua = 
Judges = 
Ruth = 
1 Samuel = 
2 Samuel = 
1 Kings = 
2 Kings = 
1 Chronicles = 
2 Chronicles = 
Ezra = 
Nehemiah = 
Esther = 
Job = 
Psalms = Ps.
Proverbs = 
Ecclesiastes = 
Song of Solomon = 
Isaiah = 
Jeremiah = 
Lamentations = 
Ezekiel = 
Daniel = 
Hosea = 
Joel = 
Amos = 
Obadiah = 
Jonah = 
Micah = 
Nahum = 
Habakkuk = 
Zephaniah = 
Haggai = 
Zechariah = 
Malachi = 
Matthew = 
Mark = 
Luke = 
John = 
Acts = 
Romans = 
1 Corinthians = 
2 Corinthians = 
Galatians = 
Ephesians = 
Philippians = 
Colossians = 
1 Thessalonians = 
2 Thessalonians = 
1 Timothy = 
2 Timothy = 
Titus = 
Philemon = 
Hebrews = 
James = 
1 Peter = 
2 Peter = 
1 John = 
2 John = 
3 John = 
Jude = 
Revelation = 
Front Matter = 
Back Matter = 
Other Material = 
EOD;
        $this->assertEquals($output, $data);
    }
Example #4
0
    $fullname = $_POST['fullname'];
    $abbreviations = $database_config_bible->getBookAbbreviations($bible);
    $abbreviations = Filter_Abbreviations::display($abbreviations);
    $abbreviations .= "\n{$fullname} = {$abbreviation}";
    $database_config_bible->setBookAbbreviations($bible, $abbreviations);
}
// Storage identifier, based on the user's name.
$identifier = Filter_User::myIdentifier();
// Retrieve all notes from the database.
$allnotes = $database_volatile->getValue($identifier, "sourcexrefs");
$allnotes = unserialize($allnotes);
// Retrieve all abbreviations, sort them, longest first.
// The replace routines replaces the longer strings first,
// to be sure that no partial book abbreviations are replaced.
$abbreviations = $database_config_bible->getBookAbbreviations($bible);
$abbreviations = Filter_Abbreviations::read($abbreviations);
$sorter = array();
foreach ($abbreviations as $abbrev => $book) {
    $sorter[] = mb_strlen($abbrev);
}
array_multisort($sorter, SORT_DESC, SORT_NUMERIC, $abbreviations);
$abbreviations = array_keys($abbreviations);
$unknown_abbreviations = array();
// Go through notes, do the replacement, collect unknown abbreviations.
foreach ($allnotes as $note) {
    $note = $note['text'];
    $note = str_replace('\\x*', "", $note);
    $note = str_replace('\\x', "", $note);
    $note = str_replace($abbreviations, "", $note);
    $note = explode(" ", $note);
    foreach ($note as $fragment) {