File: patchsets.php

package info (click to toggle)
chora2 2.0.1-2
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 2,208 kB
  • ctags: 302
  • sloc: php: 1,298; xml: 406; makefile: 66
file content (82 lines) | stat: -rw-r--r-- 3,500 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
<?php
/**
 * $Horde: chora/patchsets.php,v 1.18.8.1 2005/01/03 12:25:30 jan Exp $
 *
 * Copyright 1999-2005 Anil Madhavapeddy <anil@recoil.org>
 * Copyright 1999-2005 Charles Hagenbuch <chuck@horde.org>
 *
 * See the enclosed file COPYING for license information (GPL).  If you
 * did not receive this file, see http://www.fsf.org/copyleft/gpl.html.
 */

@define('CHORA_BASE', dirname(__FILE__));
require_once CHORA_BASE . '/lib/base.php';

// Exit if cvsps isn't active or it's not a subversion repository.
if (empty($conf['paths']['cvsps']) && !is_a($VC, 'VC_svn')) {
    header('Location: ' . Chora::url('', $where));
    exit;
}

if (@is_dir($fullname)) {
    Chora::fatal('No patchsets for directories yet.');
} elseif ($VC->isFile($fullname)) {
    $ps = $VC->getPatchsetObject($where, $cache);
    Chora::checkError($ps);

    $title = sprintf(_("Patchsets for %s"), Text::htmlallspaces($where));
    $upwhere = preg_replace('|[^/]+$|', '', $where);
    $extraLink = Chora::getFileViews();

    require CHORA_TEMPLATES . '/common-header.inc';
    require CHORA_TEMPLATES . '/menu.inc';
    require CHORA_TEMPLATES . '/headerbar.inc';

    foreach ($ps->_patchsets as $id => $patchset) {
        $commitDate = strftime('%c', $patchset['date']);
        $readableDate = Chora::readableTime($patchset['date'], true);
        $author = Chora::showAuthorName($patchset['author'], true);
        if (is_a($VC, 'VC_svn')) {
            // The diff should be from the top of the source tree so
            // as to get all files.
            $topDir = substr($where, 0, strpos($where, '/', 1));

            // Subversion supports patchset diffs natively.
            $allDiffsLink = Horde::link(Chora::url('diff', $topDir, array('r1' => $id - 1, 'r2' => $id, 'ty' => 'u')),
                                        _("Diff All Files")) . _("Diff All Files") . '</a>';
        } else {
            // Not supported in any other VC systems yet.
            $allDiffsLink = '';
        }

        $files = array();
        $dir = dirname($where);
        foreach ($patchset['members'] as $member) {
            $file = array();
            $mywhere = is_a($VC, 'VC_svn') ? $member['file'] : $dir . '/' . $member['file'];
            $file['file'] = Horde::link(Chora::url('patchsets', $mywhere), $member['file']) . $member['file'] . '</a>';
            if ($member['from'] == 'INITIAL') {
                $file['from'] = '<i>' . _("New File") . '</i>';
                $file['diff'] = '';
            } else {
                $file['from'] = Horde::link(Chora::url('co', $mywhere, array('r' => $member['from'])), $member['from']) . $member['from'] . '</a>';
                $file['diff'] = Horde::link(Chora::url('diff', $mywhere, array('r1' => $member['from'], 'r2' => $member['to'], 'ty' => 'u')), _("Diff")) . '(' . _("Diff") . ')';
            }
            if (substr($member['to'], -6) == '(DEAD)') {
                $file['to'] = '<i>' . _("Deleted") . '</i>';
                $file['diff'] = '';
            } else {
                $file['to'] = Horde::link(Chora::url('co', $mywhere, array('r' => $member['to'])), $member['to']) . $member['to'] . '</a>';
            }

            $files[] = $file;
        }

        $logMessage = Chora::formatLogMessage($patchset['log']);
        require CHORA_TEMPLATES . '/patchsets/ps.inc';
    }

    require $registry->get('templates', 'horde') . '/common-footer.inc';
} else {
    Chora::fatal('404 Not Found', "$where: no such file or directory");
}