- silence cat call in svnlib::common::isdir
[viewsvn.git] / diff.php
1 <?php
2 /*=====================================================================*\
3 || ################################################################### ||
4 || # ViewSVN [#]version[#]
5 || # --------------------------------------------------------------- # ||
6 || # Copyright ©2002-[#]year[#] by Iris Studios, Inc. All Rights Reserved. # ||
7 || # This file may not be reproduced in any way without permission. # ||
8 || # --------------------------------------------------------------- # ||
9 || # User License Agreement at http://www.iris-studios.com/license/ # ||
10 || ################################################################### ||
11 \*=====================================================================*/
12
13 require_once('./global.php');
14
15 $path = $viewsvn->paths->parse();
16 $repos = $viewsvn->paths->fetch_repos($path);
17 $relpath = $viewsvn->paths->fetch_path($path);
18
19 echo $viewsvn->paths->construct_breadcrumb($path, false);
20
21 if (empty($viewsvn->in['high']))
22 {
23 $viewsvn->in['high'] = $viewsvn->svn->common->fetch_head_rev($path);
24 }
25
26 if (empty($viewsvn->in['low']))
27 {
28 $viewsvn->in['low'] = $viewsvn->svn->common->fetch_prev_rev($path, $viewsvn->in['high']);
29 }
30
31 $diff = new SVNDiff($repos, $relpath, $viewsvn->in['low'], $viewsvn->in['high']);
32
33 $isdir = (bool)$viewsvn->svn->common->isdir($path);
34
35 echo <<<HTML
36 <style type="text/css">
37 <!--
38
39 .diff_add
40 {
41 background-color: #99EE99;
42 }
43
44 .diff_del
45 {
46 background-color: #EE9999;
47 }
48
49 table
50 {
51 font: normal 11px monospace;
52 }
53
54 //-->
55 </style>
56 HTML;
57
58 foreach ($diff->fetch() AS $filename => $file)
59 {
60 echo '<h2>' . $filename . '</h2>';
61
62 foreach ($file AS $hunk)
63 {
64 echo '<table cellspacing="1" cellpadding="1" width="100%">';
65
66 foreach ($hunk AS $key => $line)
67 {
68 if ($key == 'hunk' AND isset($line['old']))
69 {
70 $filepath = ($isdir ? $path . $filename : $path);
71 echo '
72 <tr style="background-color: #F7F7F7">
73 <td><a href="/viewsvn/' . $viewsvn->paths->out('view.php?rev=' . $viewsvn->in['low'], $filepath) . '">r' . $viewsvn->in['low'] . '</a></td>
74 <td><a href="/viewsvn/' . $viewsvn->paths->out('view.php?rev=' . $viewsvn->in['high'], $filepath) . '">r' . $viewsvn->in['high'] . '</a></td>
75 <td>&nbsp;</td>
76 </tr>';
77 continue;
78 }
79
80 if ($line['act'] == '+')
81 {
82 $color = '#DDFFDD';
83 }
84 else if ($line['act'] == '-')
85 {
86 $color = '#FFDDDD';
87 }
88 else
89 {
90 $color = 'white';
91 }
92
93 echo '
94 <tr style="background-color: #EEEEDD; border-width: 0px 1px 1px 0px">
95 <td>' . $line['oldlineno'] . '</td>
96 <td>' . $line['newlineno'] . '</td>
97 <td style="background-color: ' . $color . '">' . $viewsvn->svn->format($line['line']) . '</td>
98 </tr>';
99 }
100
101 echo '
102 </table>';
103 }
104
105 echo '<hr />';
106 }
107
108 /*=====================================================================*\
109 || ###################################################################
110 || # $HeadURL$
111 || # $Id$
112 || ###################################################################
113 \*=====================================================================*/
114 ?>