Beispiel #1
0
function do_diff($formatter, $options = "")
{
    global $DBInfo;
    $range = !empty($options['range']) ? $options['range'] : '';
    $date = !empty($options['date']) ? $options['date'] : '';
    $rev = !empty($options['rev']) ? $options['rev'] : '';
    $rev2 = !empty($options['rev2']) ? $options['rev2'] : '';
    // check revision number
    if (!empty($rev) && !preg_match("/^[0-9a-f.]+\$/", $rev) || !empty($rev2) && !preg_match("/^[0-9a-f.]+\$/", $rev2)) {
        $options['title'] = _("Invalid revision numbers");
        $options['msg'] = _("Please set correct revision numbers");
        do_invalid($formatter, $options);
        return;
    }
    if (!empty($options['rcspurge'])) {
        if (!$range) {
            $range = array();
        }
        $rr = '';
        $dum = array();
        foreach (array_keys($range) as $r) {
            if (!$rr) {
                $rr = $range[$r];
            }
            if ($range[$r + 1]) {
                continue;
            } else {
                $rr .= ":" . $range[$r];
            }
            $dum[] = $rr;
            $rr = '';
        }
        $options['range'] = join(';', $dum);
        include_once "plugin/rcspurge.php";
        do_RcsPurge($formatter, $options);
        return;
    }
    if (!empty($options['type']) and !in_array($options['type'], array('smart', 'fancy', 'simple'))) {
        $options['type'] = $DBInfo->diff_type;
    } else {
        $options['type'] = $DBInfo->diff_type;
    }
    $title = '';
    if (!empty($DBInfo->use_smartdiff)) {
        $rev = substr($rev, 0, 5);
        $rev2 = substr($rev2, 0, 5);
        if ($rev and $rev2) {
            $msg = sprintf(_("Difference between r%s and r%s"), $rev, $rev2);
        } else {
            if ($rev) {
                $msg = sprintf(_("Difference between r%s and the current"), $rev);
            } else {
                $msg = _("latest changes");
            }
        }
        $title = $msg;
    }
    $retval = array();
    $options['retval'] =& $retval;
    if ($date) {
        $options['rev'] = $date;
    }
    $diff = macro_diff($formatter, '', $options);
    if (!empty($options['raw']) || $options['action_mode'] == 'ajax') {
        header('Content-Type: text/plain');
        if ($retval['msg']) {
            echo '<h2>' . $retval['msg'] . '</h2>';
        }
        $class = 'Diff';
        if ($options['type'] == 'fancy' and !empty($options['inline'])) {
            $class .= 'Inline';
        }
        if (isset($diff[0])) {
            echo '<div class="' . $options['type'] . $class . '">';
            echo $diff;
            echo '</div>';
        }
        return;
    }
    $formatter->send_header("", $options);
    $formatter->send_title($title, "", $options);
    $class = 'Diff';
    if ($options['type'] == 'fancy' and !empty($options['inline'])) {
        $class .= 'Inline';
    }
    if (!empty($retval['msg'])) {
        echo '<h2>', $retval['msg'] . '</h2>';
    }
    echo '<div class="' . $options['type'] . $class . '">';
    echo $diff;
    echo '</div>';
    if (empty($DBInfo->diffonly) and empty($options['smart'])) {
        print "<br /><hr />\n";
        $formatter->send_page();
    }
    $formatter->send_footer('', $options);
    return;
}
Beispiel #2
0
function do_diff($formatter, $options = "")
{
    global $DBInfo;
    $range = !empty($options['range']) ? $options['range'] : '';
    $date = !empty($options['date']) ? $options['date'] : '';
    $rev = !empty($options['rev']) ? $options['rev'] : '';
    $rev2 = !empty($options['rev2']) ? $options['rev2'] : '';
    if (!empty($options['rcspurge'])) {
        if (!$range) {
            $range = array();
        }
        $rr = '';
        $dum = array();
        foreach (array_keys($range) as $r) {
            if (!$rr) {
                $rr = $range[$r];
            }
            if ($range[$r + 1]) {
                continue;
            } else {
                $rr .= ":" . $range[$r];
            }
            $dum[] = $rr;
            $rr = '';
        }
        $options['range'] = join(';', $dum);
        include_once "plugin/rcspurge.php";
        do_RcsPurge($formatter, $options);
        return;
    }
    if (!empty($options['type']) and !in_array($options['type'], array('smart', 'fancy', 'simple'))) {
        $options['type'] = $DBInfo->diff_type;
    } else {
        $options['type'] = $DBInfo->diff_type;
    }
    $formatter->send_header("", $options);
    $title = '';
    if (!empty($DBInfo->use_smartdiff)) {
        $rev = substr($rev, 0, 5);
        $rev2 = substr($rev2, 0, 5);
        if ($rev and $rev2) {
            $msg = sprintf(_("Difference between r%s and r%s"), $rev, $rev2);
        } else {
            if ($rev) {
                $msg = sprintf(_("Difference between r%s and the current"), $rev);
            } else {
                $msg = _("latest changes");
            }
        }
        $title = $msg;
    }
    $formatter->send_title($title, "", $options);
    $class = 'Diff';
    if ($options['type'] == 'fancy' and !empty($options['inline'])) {
        $class .= 'Inline';
    }
    echo '<div class="' . $options['type'] . $class . '">';
    if ($date) {
        $options['rev'] = $date;
        print macro_diff($formatter, '', $options);
    } else {
        print macro_diff($formatter, '', $options);
    }
    echo '</div>';
    if (empty($DBInfo->diffonly) and empty($options['smart'])) {
        print "<br /><hr />\n";
        $formatter->send_page();
    }
    $formatter->send_footer('', $options);
    return;
}