Ejemplo n.º 1
0
    public function testRead()
    {
        $input = <<<EOD
Psalms = Ps.

Exodus = Exod.

Exodu = Exod.

Psalms = Psa.

Joshua = 

EOD;
        $output = Filter_Abbreviations::read($input);
        $standard = array('Ps.' => 19, 'Exod.' => 2, 'Psa.' => 19);
        $this->assertEquals($standard, $output);
    }
Ejemplo n.º 2
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;
Ejemplo n.º 3
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) {