Extracted HTML from files and into templates
[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 $navbar = $viewsvn->paths->construct_breadcrumb($path, false);
16
17 // ###################################################################
18
19 $link['log'] = $viewsvn->paths->out('log.php' . $viewsvn->paths->fetch_rev_str(), $path);
20
21 // ###################################################################
22
23 $revs = $viewsvn->paths->fetch_rev_num(true);
24 $high = $revs['high'];
25 $low = $revs['low'];
26
27 if ($high == 'HEAD')
28 {
29 $high = $viewsvn->svn->common->fetch_head_rev($path);
30 }
31
32 if ($low == 0)
33 {
34 $low = $viewsvn->svn->common->fetch_prev_rev($path, $high);
35 }
36
37 $diff = new SVNDiff($repos, $relpath, $low, $high);
38
39 $isdir = (bool)$viewsvn->svn->common->isdir($path);
40
41 $changes = '';
42
43 foreach ($diff->fetch() AS $filename => $file)
44 {
45 $hunktpl = '';
46
47 foreach ($file AS $hunk)
48 {
49 $lines = '';
50 foreach ($hunk AS $key => $line)
51 {
52 $show['hunk'] = false;
53 if ($key == 'hunk' AND isset($line['old']))
54 {
55 $filepath = ($isdir ? $path . $filename : $path);
56 $rlow = $viewsvn->paths->out('view.php' . $viewsvn->paths->fetch_rev_str(false, $low), $filepath);
57 $rhigh = $viewsvn->paths->out('view.php' . $viewsvn->paths->fetch_rev_str(false, $high), $filepath);
58 $show['hunk'] = true;
59 }
60 else
61 {
62 if ($line['act'] == '+')
63 {
64 $color = '#DDFFDD';
65 }
66 else if ($line['act'] == '-')
67 {
68 $color = '#FFDDDD';
69 }
70 else
71 {
72 $color = 'white';
73 }
74
75 $line['line_clean'] = $viewsvn->svn->format($line['line']);
76 }
77
78 eval('$lines .= "' . $template->fetch('diff_line') . '";');
79 }
80 eval('$hunktpl .= "' . $template->fetch('diff_hunk') . '";');
81 }
82
83 eval('$changes .= "' . $template->fetch('diff_file') . '";');
84 }
85
86 // ###################################################################
87
88 eval('$template->flush("' . $template->fetch('diff') . '");');
89
90 /*=====================================================================*\
91 || ###################################################################
92 || # $HeadURL$
93 || # $Id$
94 || ###################################################################
95 \*=====================================================================*/
96 ?>