function test_add_markers()
 {
     $html = '01frog67890zombie789';
     $words = array();
     $words[] = new ouwiki_word('frog', 2);
     $words[] = new ouwiki_word('zombie', 11);
     $result = ouwiki_diff_add_markers($html, $words, 'ouw_marker', '!!', '??');
     $this->assertEqual($result, '01!!<span class="ouw_marker">frog</span>??67890!!<span class="ouw_marker">zombie</span>??789');
 }
/**
 * Compares two HTML files. (This is the main function that everything else supports.)
 * @param string $html1 XHTML for file 1  
 * @param string $html2 XHTML for file 2
 * @return array ($result1,$result2,$changes); result1 and result2 are XHTML 
 *   to be displayed indicating the differences, while $changes is the total
 *   number of changed (added or deleted) words. May be 0 if there are no
 *   differences or if differences are only to HTML 
 */
function ouwiki_diff_html($html1, $html2)
{
    $lines1 = ouwiki_diff_html_to_lines($html1);
    $lines2 = ouwiki_diff_html_to_lines($html2);
    list($deleted, $added) = ouwiki_diff_words($lines1, $lines2);
    $changes = count($deleted) + count($added);
    $result1 = ouwiki_diff_add_markers($html1, $deleted, 'ouw_deleted', '<img src="diff_deleted_begins.gif" alt="' . get_string('deletedbegins', 'ouwiki') . '" />', '<img src="diff_added_ends.gif" alt="' . get_string('deletedends', 'ouwiki') . '" />');
    $result2 = ouwiki_diff_add_markers($html2, $added, 'ouw_added', '<img src="diff_added_begins.gif" alt="' . get_string('addedbegins', 'ouwiki') . '" />', '<img src="diff_added_ends.gif" alt="' . get_string('addedends', 'ouwiki') . '" />');
    return array($result1, $result2, $changes);
}
Beispiel #3
0
/**
 * Compares two HTML files. (This is the main function that everything else supports.)
 * @param string $html1 XHTML for file 1  
 * @param string $html2 XHTML for file 2
 * @return array ($result1,$result2) to be displayed indicating the differences  
 */
function ouwiki_diff_html($html1, $html2)
{
    $lines1 = ouwiki_diff_html_to_lines($html1);
    $lines2 = ouwiki_diff_html_to_lines($html2);
    list($deleted, $added) = ouwiki_diff_words($lines1, $lines2);
    $result1 = ouwiki_diff_add_markers($html1, $deleted, 'ouw_deleted', '<strong class="accesshide">' . get_string('deletedbegins', 'wiki') . '</strong>', '<strong class="accesshide">' . get_string('deletedends', 'wiki') . '</strong>');
    $result2 = ouwiki_diff_add_markers($html2, $added, 'ouw_added', '<strong class="accesshide">' . get_string('addedbegins', 'wiki') . '</strong>', '<strong class="accesshide">' . get_string('addedends', 'wiki') . '</strong>');
    return array($result1, $result2);
}