]> src.bluestatic.org Git - viewsvn.git/blob - diff.php
Remove the extra link parts
[viewsvn.git] / diff.php
1 <?php
2 /*=====================================================================*\
3 || ###################################################################
4 || # ViewSVN [#]version[#]
5 || # Copyright ©2002-[#]year[#] Iris Studios, Inc.
6 || #
7 || # This program is free software; you can redistribute it and/or modify
8 || # it under the terms of the GNU General Public License as published by
9 || # the Free Software Foundation; version [#]gpl[#] of the License.
10 || #
11 || # This program is distributed in the hope that it will be useful, but
12 || # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
13 || # or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
14 || # more details.
15 || #
16 || # You should have received a copy of the GNU General Public License along
17 || # with this program; if not, write to the Free Software Foundation, Inc.,
18 || # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
19 || ###################################################################
20 \*=====================================================================*/
21
22 $fetchtemplates = array(
23 'diff_line',
24 'diff_hunk',
25 'diff_file',
26 'diff',
27 'file_change',
28 'property'
29 );
30
31 require_once('./global.php');
32
33 $navbar = $controller->construct_breadcrumb();
34
35 // ###################################################################
36
37 $link['log'] = $controller->href_compound('log.php');
38
39 // ###################################################################
40
41 if (isset($viewsvn->in['rev']))
42 {
43 $high = Paths::fetch_rev_num(false);
44 }
45 else
46 {
47 $revs = Paths::fetch_rev_num(true);
48 $high = $revs['high'];
49 $low = $revs['low'];
50 }
51
52 if ($high == 'HEAD')
53 {
54 $high = $controller->cachev->fetch_head_revision();
55 }
56
57 if ($low == 0)
58 {
59 $low = $controller->cachev->fetch_prev_revision($high);
60 $low = $low['revision'];
61 }
62
63 // ###################################################################
64
65 $show['fullchangeset'] = (Paths::is_root_path($controller->path) ? false : true);
66 if ($show['fullchangeset'])
67 {
68 $link['changeset'] = $controller->href_struct('diff.php' . Paths::fetch_rev_str(true, $high, $low), $controller->repos . '/');
69 }
70
71 $log = $controller->cachev->fetch_revision($high);
72
73 $log['message_clean'] = SVNCommon::format_log_message($log['message']);
74 $log['date'] = SVNCommon::format_date_string($log['dateline']);
75
76 $files = SVNCommon::construct_file_changes($log['files'], $controller->repos, $high);
77
78 // ###################################################################
79
80 $diff = new SVNDiff($controller, $low, $high);
81
82 $isdir = (bool)$controller->cachev->isdir();
83
84 $changes = '';
85
86 foreach ($diff->fetch() AS $filename => $file)
87 {
88 $hunktpl = '';
89 $proplist = '';
90
91 if (!$filename)
92 {
93 continue;
94 }
95
96 $props = $file['props'];
97 $show['props'] = (bool)$props;
98 unset($file['props']);
99
100 foreach ($file AS $hunk)
101 {
102 $lines = '';
103 foreach ($hunk AS $key => $line)
104 {
105 $show['hunk'] = false;
106 if ($key == 'hunk' AND isset($line['old']))
107 {
108 $filepath = ($isdir ? $controller->path . $filename : $controller->path);
109 $rlow = $controller->href_struct('view.php' . Paths::fetch_rev_str(false, $low), $filepath);
110 $rhigh = $controller->href_struct('view.php' . Paths::fetch_rev_str(false, $high), $filepath);
111 $show['hunk'] = true;
112 }
113 else
114 {
115 if ($line['act'] == '+')
116 {
117 $class = 'diff_add';
118 }
119 else if ($line['act'] == '-')
120 {
121 $class = 'diff_del';
122 }
123 else
124 {
125 $class = 'diff_norm';
126 }
127
128 $line['line_clean'] = SVNCommon::format($line['line']);
129 }
130
131 eval('$lines .= "' . $template->fetch('diff_line') . '";');
132 }
133 eval('$hunktpl .= "' . $template->fetch('diff_hunk') . '";');
134 }
135
136 foreach ($props AS $name => $values)
137 {
138 // modified
139 if (isset($values['add']) AND isset($values['del']))
140 {
141 $data = sprintf($lang->string('Property <strong>%1$s</strong> changed from <em>%2$s</em> to <em>%3$s</em>'), $name, $values['del'], $values['add']);
142 }
143 // added
144 else if (isset($values['add']))
145 {
146 $data = sprintf($lang->string('Property <strong>%1$s</strong> set to <em>%2$s</em>'), $name, $values['add']);
147 }
148 // removed
149 else if (isset($values['del']))
150 {
151 $data = sprintf($lang->string('Property <strong>%1$s</strong> deleted'), $name);
152 }
153 eval('$proplist .= "' . $template->fetch('property') . '";');
154 }
155
156 eval('$changes .= "' . $template->fetch('diff_file') . '";');
157 }
158
159 // ###################################################################
160
161 //echo('$template->flush("' . $template->fetch('diff') . '");');
162 eval('$template->flush("' . $template->fetch('diff') . '");');
163
164 /*=====================================================================*\
165 || ###################################################################
166 || # $HeadURL$
167 || # $Id$
168 || ###################################################################
169 \*=====================================================================*/
170 ?>