Adding language settings to config.php so that people can control the language output...
[viewsvn.git] / diff.php
index 034c541ffd74deebcc1c4ade2726c39447452c44..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
@@ -28,52 +28,35 @@ $fetchtemplates = array(
        'property'
 );
 
-require_once('./global.php');
-
-$navbar = $viewsvn->paths->construct_breadcrumb($path, false);
+define('SVN', '$Id$');
 
-// ###################################################################
+require_once('./global.php');
+require_once('./includes/class_diff.php');
 
-$link['log'] = $viewsvn->paths->out('log.php' . $viewsvn->paths->fetch_rev_str(), $path);
+$navbar = ConstructNavbar();
 
 // ###################################################################
 
-$revs = $viewsvn->paths->fetch_rev_num(true);
-$high = $revs['high'];
-$low = $revs['low'];
-
-if ($high == 'HEAD')
-{
-       $high = $viewsvn->svn->common->fetch_head_rev($path);
-}
-
-if ($low == 0)
-{
-       $low = $viewsvn->svn->common->fetch_prev_rev($path, $high);
-}
+$link['log'] = ConstructLink('log', $input->in['repos'], $input->in['path'], $input->in['rev']);
 
 // ###################################################################
 
-$show['fullchangeset'] = ($viewsvn->paths->is_root_path($path) ? false : true);
+$show['fullchangeset'] = !($input->in['path'] == '' OR $input->in['path'] == '/');
 if ($show['fullchangeset'])
 {
-       $link['changeset'] = $viewsvn->paths->out('diff.php' . $viewsvn->paths->fetch_rev_str(true, $high, $low), $repos . '/');
+       $link['changeset'] = ConstructLink('diff', $input->in['repos'], null, $input->in['rev']);
 }
 
-$log = $viewsvn->svn->common->fetch_log($path, $high);
+$revision = new Revision($input->in['repos'], $input->in['rev'], $input->in['path']);
+$revision->getRevisionInfo();
 
-$log['message_clean'] = nl2br(htmlspecialchars($log['message']));
-
-$files = $viewsvn->svn->common->construct_file_changes($log['files'], $repos, $high);
+$files = ConstructFileChanges($revision->files, $input->in['repos'], $revision->revision);
 
 // ###################################################################
 
-$diff = new SVNDiff($repos, $relpath, $low, $high);
-
-$isdir = (bool)$viewsvn->svn->common->isdir($path);
+$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 = '';
@@ -84,25 +67,24 @@ foreach ($diff->fetch() AS $filename => $file)
                continue;
        }
        
-       $props = $file['props'];
-       $show['props'] = (bool)$props;
-       unset($file['props']);
-       
-       foreach ($file AS $hunk)
+       if (is_array($file['lines']))
        {
-               $lines = '';
-               foreach ($hunk AS $key => $line)
+               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';
@@ -115,18 +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') . '";');
                }
-               eval('$hunktpl .= "' . $template->fetch('diff_hunk') . '";');
        }
        
-       foreach ($props AS $name => $value)
+       if (is_array($file['props']))
        {
-               eval('$proplist .= "' . $template->fetch('property') . '";');
+               $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('$changes .= "' . $template->fetch('diff_file') . '";');
@@ -134,7 +135,6 @@ foreach ($diff->fetch() AS $filename => $file)
 
 // ###################################################################
 
-//echo('$template->flush("' . $template->fetch('diff') . '");');
 eval('$template->flush("' . $template->fetch('diff') . '");');
 
 /*=====================================================================*\
@@ -143,4 +143,4 @@ eval('$template->flush("' . $template->fetch('diff') . '");');
 || # $Id$
 || ###################################################################
 \*=====================================================================*/
-?>
+?>
\ No newline at end of file