Пример #1
0
function do_update_diff($pagestr, $poststr, $original)
{
    $obj = new line_diff();
    $obj->set_str('left', $original, $pagestr);
    $obj->compare();
    $diff1 = $obj->toArray();
    $obj->set_str('right', $original, $poststr);
    $obj->compare();
    $diff2 = $obj->toArray();
    $arr = $obj->arr_compare('all', $diff1, $diff2);
    if (PKWK_DIFF_SHOW_CONFLICT_DETAIL) {
        global $do_update_diff_table;
        $table = array();
        $table[] = <<<EOD
<p>l : between backup data and stored page data.<br />
 r : between backup data and your post data.</p>
<table class="style_table">
 <tr>
  <th>l</th>
  <th>r</th>
  <th>text</th>
 </tr>
EOD;
        $tags = array('th', 'th', 'td');
        foreach ($arr as $_obj) {
            $table[] = ' <tr>';
            $params = array($_obj->get('left'), $_obj->get('right'), $_obj->text());
            foreach ($params as $key => $text) {
                $text = htmlspecialchars(rtrim($text));
                if (empty($text)) {
                    $text = '&nbsp;';
                }
                $table[] = '  <' . $tags[$key] . ' class="style_' . $tags[$key] . '">' . $text . '</' . $tags[$key] . '>';
            }
            $table[] = ' </tr>';
        }
        $table[] = '</table>';
        $do_update_diff_table = implode("\n", $table) . "\n";
        unset($table);
    }
    $body = array();
    foreach ($arr as $_obj) {
        if ($_obj->get('left') != '-' && $_obj->get('right') != '-') {
            $body[] = $_obj->text();
        }
    }
    return array(rtrim(implode('', $body)) . "\n", 1);
}
Пример #2
0
function showComboDiff($keyword, $db=NULL) {

    global $SessSemName;

    $version2=getLatestVersion($keyword, $SessSemName[1]);
    $version1=getFirstVersion($keyword, $SessSemName[1]);
    $version2=$version2["version"];
    $version1=$version1["version"];

    showPageFrameStart();
    wikiSinglePageHeader($wikiData, $keyword);

    echo "\n<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"100%\">";

    // create combodiff

    $wd1 = getWikiPage($keyword, $version1);
    $diffarray1 = toDiffLineArray($wd1['body'], $wd1['user_id']);
    $current_version = $version1 + 1;
    $differ = new line_diff();
    while ($current_version <= $version2) {
        $wd2 = getWikiPage($keyword, $current_version);
        if ($wd2) {
            $diffarray2 = toDiffLineArray($wd2['body'], $wd2['user_id']);
            $newarray = $differ->arr_compare("diff", $diffarray1, $diffarray2);
            $diffarray1=array();
            foreach ($newarray as $i) {
                if ($i->status["diff"] != "-") {
                    $diffarray1[]=$i;
                }
            }
        }
        $current_version++;
    }
    $content="<table>";
    $count=0;
    $authors=array();
    foreach ($diffarray1 as $i) {
        if ($i && !in_array($i->who, $authors)) {
            $authors[]=$i->who;
            if ($count % 4 == 0) {
                $content.= "<tr width=\"100%\">";
            }
            $content.= "<td bgcolor=".create_color($count)." width=14>&nbsp;</td><td><font size=-1>".get_fullname($i->who,'full',1)."</font></td><td>&nbsp;</td>";
            if ($count % 4 == 3) {
                $content .= "</tr>";
            }
            $count++;
        }
    }
    echo "<tr><td class=\"table_row_even\" colspan=2>";
    echo "<p><font size=-1>&nbsp;<br>";
    echo _("Legende der Autor/-innenfarben:");
    echo "<table cellpadding=6 cellspacing=6>$content</table>\n";
    echo "</p>";
    echo "<table cellpadding=0 cellspacing=0 width=\"100%\">";
    $last_author=None;
    $collect="";
    $diffarray1[]=NULL;
    foreach ($diffarray1 as $i) {
        if (!$i || $last_author != $i->who) {
            if (trim($collect)!="") {
                $idx=array_search($last_author, $authors);
                $col=create_color($idx);
                echo "<tr bgcolor=$col>";
                echo "<td width=30 align=center valign=top>";
                echo Icon::create('info-circle', 'inactive', ['title' => _("Änderung von").' ' . get_fullname($last_author)])->asImg();
                echo "</td>";
                echo "<td><font size=-1>";
                echo wikiReady($collect);
                echo "</font></td>";
                echo "</tr>";
            }
            $collect="";
        }
        if ($i) {
            $last_author = $i->who;
            $collect .= $i->text;
        }
    }
    echo "</table></td></tr>";
    echo "</table>     ";
    getDiffPageInfobox($keyword);
    showPageFrameEnd();
}