Adding language settings to config.php so that people can control the language output...
[viewsvn.git] / diff.php
index f14bf0726b0c0a2d8200acb1deecb626a1fdd0c4..71de17d1a3512fd893fe351a9a30d058b2aa884f 100644 (file)
--- a/diff.php
+++ b/diff.php
@@ -2,7 +2,7 @@
 /*=====================================================================*\
 || ###################################################################
 || # ViewSVN [#]version[#]
-|| # Copyright ©2002-[#]year[#] Iris Studios, Inc.
+|| # Copyright ©2002-[#]year[#] Blue Static
 || #
 || # This program is free software; you can redistribute it and/or modify
 || # it under the terms of the GNU General Public License as published by
@@ -23,58 +23,68 @@ $fetchtemplates = array(
        'diff_line',
        'diff_hunk',
        'diff_file',
-       'diff'
+       'diff',
+       'file_change',
+       'property'
 );
 
+define('SVN', '$Id$');
+
 require_once('./global.php');
+require_once('./includes/class_diff.php');
 
-$navbar = $viewsvn->paths->construct_breadcrumb($path, false);
+$navbar = ConstructNavbar();
 
 // ###################################################################
 
-$link['log'] = $viewsvn->paths->out('log.php' . $viewsvn->paths->fetch_rev_str(), $path);
+$link['log'] = ConstructLink('log', $input->in['repos'], $input->in['path'], $input->in['rev']);
 
 // ###################################################################
 
-$revs = $viewsvn->paths->fetch_rev_num(true);
-$high = $revs['high'];
-$low = $revs['low'];
-
-if ($high == 'HEAD')
+$show['fullchangeset'] = !($input->in['path'] == '' OR $input->in['path'] == '/');
+if ($show['fullchangeset'])
 {
-       $high = $viewsvn->svn->common->fetch_head_rev($path);
+       $link['changeset'] = ConstructLink('diff', $input->in['repos'], null, $input->in['rev']);
 }
 
-if ($low == 0)
-{
-       $low = $viewsvn->svn->common->fetch_prev_rev($path, $high);
-}
+$revision = new Revision($input->in['repos'], $input->in['rev'], $input->in['path']);
+$revision->getRevisionInfo();
 
-$diff = new SVNDiff($repos, $relpath, $low, $high);
+$files = ConstructFileChanges($revision->files, $input->in['repos'], $revision->revision);
 
-$isdir = (bool)$viewsvn->svn->common->isdir($path);
+// ###################################################################
 
-$changes = '';
+$diff = new Diff($lib->run('diff -c' . $revision->revision . ' ' . $lib->arg($repos->fetchPath($input->in['repos']) . '/' . $input->in['path'])));
 
+$changes = '';
 foreach ($diff->fetch() AS $filename => $file)
 {
        $hunktpl = '';
+       $proplist = '';
        
-       foreach ($file AS $hunk)
+       if (!$filename)
        {
-               $lines = '';
-               foreach ($hunk AS $key => $line)
+               continue;
+       }
+       
+       if (is_array($file['lines']))
+       {
+               foreach ($file['lines'] AS $hunk)
                {
-                       $show['hunk'] = false;
-                       if ($key == 'hunk' AND isset($line['old']))
-                       {
-                               $filepath = ($isdir ? $path . $filename : $path);
-                               $rlow = $viewsvn->paths->out('view.php' . $viewsvn->paths->fetch_rev_str(false, $low), $filepath);
-                               $rhigh = $viewsvn->paths->out('view.php' . $viewsvn->paths->fetch_rev_str(false, $high), $filepath);
-                               $show['hunk'] = true;
-                       }
-                       else
+                       $lines = '';
+
+                       $show['hunk'] = true;
+                       $low = $file['revision']['low'];
+                       $high = $file['revision']['high'];
+
+                       $filename = (preg_match('/' . preg_quote($filename, '/') . '$/', $input->in['path']) ? $input->in['path'] : BSFunctions::FetchSourcePath($input->in['path']) . $filename);
+                       $rlow = ConstructLink('view', $input->in['repos'], $filename, $low);
+                       $rhigh = ConstructLink('view', $input->in['repos'], $filename, $high);
+                       eval('$lines .= "' . $template->fetch('diff_line') . '";');
+
+                       foreach ($hunk AS $key => $line)
                        {
+                               $show['hunk'] = false;
                                if ($line['act'] == '+')
                                {
                                        $class = 'diff_add';
@@ -87,13 +97,37 @@ foreach ($diff->fetch() AS $filename => $file)
                                {
                                        $class = 'diff_norm';
                                }
-                               
-                               $line['line_clean'] = $viewsvn->svn->format($line['line']);
+
+                               $line['line_clean'] = FormatCode($line['line']);
+
+                               eval('$lines .= "' . $template->fetch('diff_line') . '";');
                        }
-                       
-                       eval('$lines .= "' . $template->fetch('diff_line') . '";');
+                       eval('$hunktpl .= "' . $template->fetch('diff_hunk') . '";');
+               }
+       }
+       
+       if (is_array($file['props']))
+       {
+               $show['props'] = true;
+               foreach ($file['props'] AS $name => $values)
+               {
+                       // modified
+                       if (isset($values['add']) AND isset($values['del']))
+                       {
+                               $data = sprintf(_('Property <strong>%1$s</strong> changed from <em>%2$s</em> to <em>%3$s</em>'), $name, $values['del'], $values['add']);
+                       }
+                       // added
+                       else if (isset($values['add']))
+                       {
+                               $data = sprintf(_('Property <strong>%1$s</strong> set to <em>%2$s</em>'), $name, $values['add']);
+                       }
+                       // removed
+                       else if (isset($values['del']))
+                       {
+                               $data = sprintf(_('Property <strong>%1$s</strong> deleted'), $name);
+                       }
+                       eval('$proplist .= "' . $template->fetch('property') . '";');
                }
-               eval('$hunktpl .= "' . $template->fetch('diff_hunk') . '";');
        }
        
        eval('$changes .= "' . $template->fetch('diff_file') . '";');