function processIdentifiers($user, $bible, $book, $chapter, $oldId, $newId, &$email) { if ($oldId != 0) { $database_modifications = Database_Modifications::getInstance(); $database_config_user = Database_Config_User::getInstance(); $database_config_bible = Database_Config_Bible::getInstance(); $database_bibles = Database_Bibles::getInstance(); $database_history = Database_History::getInstance(); $stylesheet = $database_config_bible->getExportStylesheet($bible); $old_chapter_usfm = $database_modifications->getUserChapter($user, $bible, $book, $chapter, $oldId); $old_chapter_usfm = $old_chapter_usfm['oldtext']; $new_chapter_usfm = $database_modifications->getUserChapter($user, $bible, $book, $chapter, $newId); $new_chapter_usfm = $new_chapter_usfm['newtext']; $timestamp = $database_modifications->getUserTimestamp($user, $bible, $book, $chapter, $newId); $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_usfm = Filter_Usfm::getVerseText($old_chapter_usfm, $verse); $new_verse_usfm = Filter_Usfm::getVerseText($new_chapter_usfm, $verse); if ($old_verse_usfm != $new_verse_usfm) { $filter_text_old = new Filter_Text($bible); $filter_text_new = new Filter_Text($bible); $filter_text_old->html_text_standard = new Html_Text(Locale_Translate::_("Bible")); $filter_text_new->html_text_standard = new Html_Text(Locale_Translate::_("Bible")); $filter_text_old->text_text = new Text_Text(); $filter_text_new->text_text = new Text_Text(); $filter_text_old->addUsfmCode($old_verse_usfm); $filter_text_new->addUsfmCode($new_verse_usfm); $filter_text_old->run($stylesheet); $filter_text_new->run($stylesheet); $old_html = $filter_text_old->html_text_standard->getInnerHtml(); $new_html = $filter_text_new->html_text_standard->getInnerHtml(); $old_text = $filter_text_old->text_text->get(); $new_text = $filter_text_new->text_text->get(); if ($old_text != $new_text) { $modification = Filter_Diff::diff($old_text, $new_text); $email .= "<div>"; $email .= Filter_Books::passageDisplay($book, $chapter, $verse); $email .= " "; $email .= $modification; $email .= "</div>"; if ($database_config_user->getUserUserChangesNotificationsOnline($user)) { $changeNotificationUsers = array($user); $database_modifications->recordNotification($changeNotificationUsers, "☺", $bible, $book, $chapter, $verse, $old_html, $modification, $new_html); } $database_history->record($timestamp, $user, $bible, $book, $chapter, $verse, $old_html, $modification, $new_html); } } } } }
public function testDiff() { $output = Filter_Diff::diff("Old text", "New text"); $standard = '<span style="text-decoration: line-through;">Old </span><span style="font-weight: bold;">New </span>text'; $this->assertEquals($standard, $output); }
$filter_text_bible->text_text = new Text_Text(); $filter_text_compare->text_text = new Text_Text(); $filter_text_bible->addUsfmCode($bible_verse_usfm); $filter_text_compare->addUsfmCode($compare_verse_usfm); $filter_text_bible->run($stylesheet); $filter_text_compare->run($stylesheet); $bible_html = $filter_text_bible->html_text_standard->getInnerHtml(); $compare_html = $filter_text_compare->html_text_standard->getInnerHtml(); $bible_text = $filter_text_bible->text_text->get(); $compare_text = $filter_text_compare->text_text->get(); if ($bible_text != $compare_text) { $modification = Filter_Diff::diff($compare_text, $bible_text); $result[] = Filter_Books::passageDisplay($book, $chapter, $verse) . " " . $modification; $new[] = Filter_Books::passageDisplay($book, $chapter, $verse) . " " . $bible_text; } $modification = Filter_Diff::diff($compare_verse_usfm, $bible_verse_usfm); $raw[] = Filter_Books::passageDisplay($book, $chapter, $verse) . " " . $modification; } } } } // Add the absent books / chapters to the comparison. if (count($absent)) { $result[] = ""; $result = array_merge($result, $absent); } // Add any differences in the raw USFM to the comparison. if (count($raw)) { $result[] = ""; $result = array_merge($result, $raw); }
$verses = array_unique($verses); sort($verses, SORT_NUMERIC); foreach ($verses as $verse) { $old_verse_usfm = Filter_Usfm::getVerseText($oldusfm, $verse); $new_verse_usfm = Filter_Usfm::getVerseText($newusfm, $verse); if ($old_verse_usfm != $new_verse_usfm) { $filter_text_old = new Filter_Text($bible); $filter_text_new = new Filter_Text($bible); $filter_text_old->html_text_standard = new Html_Text(""); $filter_text_new->html_text_standard = new Html_Text(""); $filter_text_old->text_text = new Text_Text(); $filter_text_new->text_text = new Text_Text(); $filter_text_old->addUsfmCode($old_verse_usfm); $filter_text_new->addUsfmCode($new_verse_usfm); $filter_text_old->run($stylesheet); $filter_text_new->run($stylesheet); $old_html = $filter_text_old->html_text_standard->getInnerHtml(); $new_html = $filter_text_new->html_text_standard->getInnerHtml(); $old_text = $filter_text_old->text_text->get(); $new_text = $filter_text_new->text_text->get(); $modification = Filter_Diff::diff($old_text, $new_text); $database_history->record($timestamp, $author, $bible, $book, $chapter, $verse, $old_html, $modification, $new_html); } } } } // Store this commit so it won't be combed through next time. $database_commits->record($bible, $sha1); } } $database_logs->log("{$history} Ready", Filter_Roles::MANAGER_LEVEL);