Adding language settings to config.php so that people can control the language output...
[viewsvn.git] / diff.php
1 <?php
2 /*=====================================================================*\
3 || ###################################################################
4 || # ViewSVN [#]version[#]
5 || # Copyright ©2002-[#]year[#] Blue Static
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 define('SVN', '$Id$');
32
33 require_once('./global.php');
34 require_once('./includes/class_diff.php');
35
36 $navbar = ConstructNavbar();
37
38 // ###################################################################
39
40 $link['log'] = ConstructLink('log', $input->in['repos'], $input->in['path'], $input->in['rev']);
41
42 // ###################################################################
43
44 $show['fullchangeset'] = !($input->in['path'] == '' OR $input->in['path'] == '/');
45 if ($show['fullchangeset'])
46 {
47 $link['changeset'] = ConstructLink('diff', $input->in['repos'], null, $input->in['rev']);
48 }
49
50 $revision = new Revision($input->in['repos'], $input->in['rev'], $input->in['path']);
51 $revision->getRevisionInfo();
52
53 $files = ConstructFileChanges($revision->files, $input->in['repos'], $revision->revision);
54
55 // ###################################################################
56
57 $diff = new Diff($lib->run('diff -c' . $revision->revision . ' ' . $lib->arg($repos->fetchPath($input->in['repos']) . '/' . $input->in['path'])));
58
59 $changes = '';
60 foreach ($diff->fetch() AS $filename => $file)
61 {
62 $hunktpl = '';
63 $proplist = '';
64
65 if (!$filename)
66 {
67 continue;
68 }
69
70 if (is_array($file['lines']))
71 {
72 foreach ($file['lines'] AS $hunk)
73 {
74 $lines = '';
75
76 $show['hunk'] = true;
77 $low = $file['revision']['low'];
78 $high = $file['revision']['high'];
79
80 $filename = (preg_match('/' . preg_quote($filename, '/') . '$/', $input->in['path']) ? $input->in['path'] : BSFunctions::FetchSourcePath($input->in['path']) . $filename);
81 $rlow = ConstructLink('view', $input->in['repos'], $filename, $low);
82 $rhigh = ConstructLink('view', $input->in['repos'], $filename, $high);
83 eval('$lines .= "' . $template->fetch('diff_line') . '";');
84
85 foreach ($hunk AS $key => $line)
86 {
87 $show['hunk'] = false;
88 if ($line['act'] == '+')
89 {
90 $class = 'diff_add';
91 }
92 else if ($line['act'] == '-')
93 {
94 $class = 'diff_del';
95 }
96 else
97 {
98 $class = 'diff_norm';
99 }
100
101 $line['line_clean'] = FormatCode($line['line']);
102
103 eval('$lines .= "' . $template->fetch('diff_line') . '";');
104 }
105 eval('$hunktpl .= "' . $template->fetch('diff_hunk') . '";');
106 }
107 }
108
109 if (is_array($file['props']))
110 {
111 $show['props'] = true;
112 foreach ($file['props'] AS $name => $values)
113 {
114 // modified
115 if (isset($values['add']) AND isset($values['del']))
116 {
117 $data = sprintf(_('Property <strong>%1$s</strong> changed from <em>%2$s</em> to <em>%3$s</em>'), $name, $values['del'], $values['add']);
118 }
119 // added
120 else if (isset($values['add']))
121 {
122 $data = sprintf(_('Property <strong>%1$s</strong> set to <em>%2$s</em>'), $name, $values['add']);
123 }
124 // removed
125 else if (isset($values['del']))
126 {
127 $data = sprintf(_('Property <strong>%1$s</strong> deleted'), $name);
128 }
129 eval('$proplist .= "' . $template->fetch('property') . '";');
130 }
131 }
132
133 eval('$changes .= "' . $template->fetch('diff_file') . '";');
134 }
135
136 // ###################################################################
137
138 eval('$template->flush("' . $template->fetch('diff') . '");');
139
140 /*=====================================================================*\
141 || ###################################################################
142 || # $HeadURL$
143 || # $Id$
144 || ###################################################################
145 \*=====================================================================*/
146 ?>