Migrating the three *very* important variables into Paths
authorRobert Sesek <rsesek@bluestatic.org>
Mon, 9 Jan 2006 01:57:10 +0000 (01:57 +0000)
committerRobert Sesek <rsesek@bluestatic.org>
Mon, 9 Jan 2006 01:57:10 +0000 (01:57 +0000)
blame.php
browse.php
diff.php
global.php
includes/paths.php
log.php
view.php

index 9c12f49b4c07dfe94044af42027e509e33e68d25..84bc15251d7cbdb8dd363e3405112b2b026364d9 100644 (file)
--- a/blame.php
+++ b/blame.php
@@ -26,34 +26,34 @@ $fetchtemplates = array(
 
 require_once('./global.php');
 
-$navbar = $viewsvn->paths->construct_breadcrumb($path, false);
+$navbar = $viewsvn->paths->construct_breadcrumb($viewsvn->paths->path, false);
 
 // ###################################################################
 
-$link['log'] = $viewsvn->paths->out('log.php' . $viewsvn->paths->fetch_rev_str(), $path);
+$link['log'] = $viewsvn->paths->out('log.php' . $viewsvn->paths->fetch_rev_str(), $viewsvn->paths->path);
 
-$show['head'] = ($viewsvn->svn->common->fetch_head_rev($path) != $viewsvn->paths->fetch_rev_num() AND $viewsvn->paths->fetch_rev_num() != 'HEAD');
+$show['head'] = ($viewsvn->svn->common->fetch_head_rev($viewsvn->paths->path) != $viewsvn->paths->fetch_rev_num() AND $viewsvn->paths->fetch_rev_num() != 'HEAD');
 if ($show['head'])
 {
-       $link['gohead'] = $viewsvn->paths->out('blame.php' . $viewsvn->paths->fetch_rev_str(false, 'HEAD'), $path);
-       $link['diffhead'] = $viewsvn->paths->out('diff.php' . $viewsvn->paths->fetch_rev_str(true, 'HEAD', $viewsvn->paths->fetch_rev_num()), $path);
+       $link['gohead'] = $viewsvn->paths->out('blame.php' . $viewsvn->paths->fetch_rev_str(false, 'HEAD'), $viewsvn->paths->path);
+       $link['diffhead'] = $viewsvn->paths->out('diff.php' . $viewsvn->paths->fetch_rev_str(true, 'HEAD', $viewsvn->paths->fetch_rev_num()), $viewsvn->paths->path);
 }
 
-$show['prev'] = (($prev = $viewsvn->svn->common->fetch_prev_rev($path, $viewsvn->paths->fetch_rev_num())) != -1 ? true : false);
+$show['prev'] = (($prev = $viewsvn->svn->common->fetch_prev_rev($viewsvn->paths->path, $viewsvn->paths->fetch_rev_num())) != -1 ? true : false);
 if ($show['prev'])
 {
-       $link['diffprev'] = $viewsvn->paths->out('diff.php' . $viewsvn->paths->fetch_rev_str(true, $viewsvn->paths->fetch_rev_num(), $prev), $path);
+       $link['diffprev'] = $viewsvn->paths->out('diff.php' . $viewsvn->paths->fetch_rev_str(true, $viewsvn->paths->fetch_rev_num(), $prev), $viewsvn->paths->path);
 }
 
 // ###################################################################
 
-$blame = new SVNBlame($repos, $relpath, $viewsvn->paths->fetch_rev_num());
+$blame = new SVNBlame($viewsvn->paths->repos, $viewsvn->paths->relpath, $viewsvn->paths->fetch_rev_num());
 
 $lines = '';
 
 foreach ($blame->fetch() AS $entry)
 {
-       $entry['view_link'] = $viewsvn->paths->out('view.php' . $viewsvn->paths->fetch_rev_str(false, $entry['rev']), $path);
+       $entry['view_link'] = $viewsvn->paths->out('view.php' . $viewsvn->paths->fetch_rev_str(false, $entry['rev']), $viewsvn->paths->path);
        $entry['line_clean'] = $viewsvn->svn->format($entry['line']);
        eval('$lines .= "' . $template->fetch('blame_line') . '";');
 }
index ebe2a1030e5edb272640ced872178d0c94a14019..5e259d05f3c80ad5b10d197b1dfc264dcf8ecdd4 100644 (file)
@@ -26,32 +26,32 @@ $fetchtemplates = array(
 
 require_once('./global.php');
 
-$navbar = $viewsvn->paths->construct_breadcrumb($path);
+$navbar = $viewsvn->paths->construct_breadcrumb($viewsvn->paths->path);
 
 // ###################################################################
 
-$link['log'] = $viewsvn->paths->out('log.php' . $viewsvn->paths->fetch_rev_str(), $path);
+$link['log'] = $viewsvn->paths->out('log.php' . $viewsvn->paths->fetch_rev_str(), $viewsvn->paths->path);
 
-$show['head'] = ($viewsvn->svn->common->fetch_head_rev($path) != $viewsvn->paths->fetch_rev_num() AND $viewsvn->paths->fetch_rev_num() != 'HEAD');
+$show['head'] = ($viewsvn->svn->common->fetch_head_rev($viewsvn->paths->path) != $viewsvn->paths->fetch_rev_num() AND $viewsvn->paths->fetch_rev_num() != 'HEAD');
 if ($show['head'])
 {
-       $link['gohead'] = $viewsvn->paths->out('browse.php' . $viewsvn->paths->fetch_rev_str(false, 'HEAD'), $path);
-       $link['diffhead'] = $viewsvn->paths->out('diff.php' . $viewsvn->paths->fetch_rev_str(true, 'HEAD', $viewsvn->paths->fetch_rev_num()), $path);
+       $link['gohead'] = $viewsvn->paths->out('browse.php' . $viewsvn->paths->fetch_rev_str(false, 'HEAD'), $viewsvn->paths->path);
+       $link['diffhead'] = $viewsvn->paths->out('diff.php' . $viewsvn->paths->fetch_rev_str(true, 'HEAD', $viewsvn->paths->fetch_rev_num()), $viewsvn->paths->path);
 }
 
-$show['prev'] = (($prev = $viewsvn->svn->common->fetch_prev_rev($path, $viewsvn->paths->fetch_rev_num())) != -1 ? true : false);
+$show['prev'] = (($prev = $viewsvn->svn->common->fetch_prev_rev($viewsvn->paths->path, $viewsvn->paths->fetch_rev_num())) != -1 ? true : false);
 if ($show['prev'])
 {
-       $link['diffprev'] = $viewsvn->paths->out('diff.php' . $viewsvn->paths->fetch_rev_str(true, $viewsvn->paths->fetch_rev_num(), $prev), $path);
+       $link['diffprev'] = $viewsvn->paths->out('diff.php' . $viewsvn->paths->fetch_rev_str(true, $viewsvn->paths->fetch_rev_num(), $prev), $viewsvn->paths->path);
 }
 
 // ###################################################################
 
-$revinfo = $viewsvn->svn->common->fetch_log($path, $viewsvn->paths->fetch_rev_num());
+$revinfo = $viewsvn->svn->common->fetch_log($viewsvn->paths->path, $viewsvn->paths->fetch_rev_num());
 
 $revinfo['message_clean'] = $viewsvn->svn->format_log_message($revinfo['message']);
 
-$listing = $viewsvn->svn->ls($repos, $relpath, $viewsvn->paths->fetch_rev_num());
+$listing = $viewsvn->svn->ls($viewsvn->paths->repos, $viewsvn->paths->relpath, $viewsvn->paths->fetch_rev_num());
 
 $nodes = '';
 
@@ -60,16 +60,16 @@ foreach ($listing AS $item)
        if ($item{ strlen($item) - 1 } == '/')
        {
                $show['directory'] = true;
-               $browse = $viewsvn->paths->out('browse.php' . $viewsvn->paths->fetch_rev_str(), $path . $item);
+               $browse = $viewsvn->paths->out('browse.php' . $viewsvn->paths->fetch_rev_str(), $viewsvn->paths->path . $item);
        }
        else
        {
                $show['directory'] = false;
-               $view = $viewsvn->paths->out('view.php' . $viewsvn->paths->fetch_rev_str(), $path . $item);
-               $blame = $viewsvn->paths->out('blame.php' . $viewsvn->paths->fetch_rev_str(), $path . $item);
+               $view = $viewsvn->paths->out('view.php' . $viewsvn->paths->fetch_rev_str(), $viewsvn->paths->path . $item);
+               $blame = $viewsvn->paths->out('blame.php' . $viewsvn->paths->fetch_rev_str(), $viewsvn->paths->path . $item);
        }
        
-       $log = $viewsvn->paths->out('log.php' . $viewsvn->paths->fetch_rev_str(), $path . $item);
+       $log = $viewsvn->paths->out('log.php' . $viewsvn->paths->fetch_rev_str(), $viewsvn->paths->path . $item);
        
        eval('$nodes .= "' . $template->fetch('browse_node') . '";');
 }
index 067cbdb8d31199da333c77a669b8f7c926d3ee17..11d6b4c843ec46a1e1c0f774c6875db12b480651 100644 (file)
--- a/diff.php
+++ b/diff.php
@@ -30,11 +30,11 @@ $fetchtemplates = array(
 
 require_once('./global.php');
 
-$navbar = $viewsvn->paths->construct_breadcrumb($path, false);
+$navbar = $viewsvn->paths->construct_breadcrumb($viewsvn->paths->path, false);
 
 // ###################################################################
 
-$link['log'] = $viewsvn->paths->out('log.php' . $viewsvn->paths->fetch_rev_str(), $path);
+$link['log'] = $viewsvn->paths->out('log.php' . $viewsvn->paths->fetch_rev_str(), $viewsvn->paths->path);
 
 // ###################################################################
 
@@ -44,33 +44,33 @@ $low = $revs['low'];
 
 if ($high == 'HEAD')
 {
-       $high = $viewsvn->svn->common->fetch_head_rev($path);
+       $high = $viewsvn->svn->common->fetch_head_rev($viewsvn->paths->path);
 }
 
 if ($low == 0)
 {
-       $low = $viewsvn->svn->common->fetch_prev_rev($path, $high);
+       $low = $viewsvn->svn->common->fetch_prev_rev($viewsvn->paths->path, $high);
 }
 
 // ###################################################################
 
-$show['fullchangeset'] = ($viewsvn->paths->is_root_path($path) ? false : true);
+$show['fullchangeset'] = ($viewsvn->paths->is_root_path($viewsvn->paths->path) ? false : true);
 if ($show['fullchangeset'])
 {
-       $link['changeset'] = $viewsvn->paths->out('diff.php' . $viewsvn->paths->fetch_rev_str(true, $high, $low), $repos . '/');
+       $link['changeset'] = $viewsvn->paths->out('diff.php' . $viewsvn->paths->fetch_rev_str(true, $high, $low), $viewsvn->paths->repos . '/');
 }
 
-$log = $viewsvn->svn->common->fetch_log($path, $high);
+$log = $viewsvn->svn->common->fetch_log($viewsvn->paths->path, $high);
 
 $log['message_clean'] = $viewsvn->svn->format_log_message($log['message']);
 
-$files = $viewsvn->svn->common->construct_file_changes($log['files'], $repos, $high);
+$files = $viewsvn->svn->common->construct_file_changes($log['files'], $viewsvn->paths->repos, $high);
 
 // ###################################################################
 
-$diff = new SVNDiff($repos, $relpath, $low, $high);
+$diff = new SVNDiff($viewsvn->paths->repos, $viewsvn->paths->relpath, $low, $high);
 
-$isdir = (bool)$viewsvn->svn->common->isdir($path);
+$isdir = (bool)$viewsvn->svn->common->isdir($viewsvn->paths->path);
 
 $changes = '';
 
@@ -96,7 +96,7 @@ foreach ($diff->fetch() AS $filename => $file)
                        $show['hunk'] = false;
                        if ($key == 'hunk' AND isset($line['old']))
                        {
-                               $filepath = ($isdir ? $path . $filename : $path);
+                               $filepath = ($isdir ? $viewsvn->paths->path . $filename : $viewsvn->paths->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;
index d49de7051407496ec90dc6cfeb65917ebb44ecff..fc40155d113f8056527ee12bd9e2c71bfbda4e7a 100644 (file)
 
 require_once('./includes/init.php');
 
-$dochooser = false;
-if (!defined('PATH_OVERRIDE') OR PATH_OVERRIDE != 1)
-{
-       $path = $viewsvn->paths->parse();
-       $repos = $viewsvn->paths->fetch_repos($path);
-       $relpath = $viewsvn->paths->fetch_path($path);
-       
-       $dochooser = true;
-}
+$dochooser = (defined('PATH_OVERRIDE') AND PATH_OVERRIDE == 1 ? false: true);
 
 $fetchtemplates[] = 'header';
 $fetchtemplates[] = 'footer';
index cab45614b974a12ee9956794b9894a768f0f9da3..1f5178fba9c2ce8c131dcbbc38add7f36342abd9 100644 (file)
@@ -41,6 +41,24 @@ class Paths
        */
        var $type;
        
+       /**
+       * The universal path that is currently being browsed
+       * @var  string
+       */
+       var $path;
+       
+       /**
+       * Current repository that we're in
+       * @var  string
+       */
+       var $repos;
+       
+       /**
+       * Current internal path inside the repository
+       * @var  string
+       */
+       var $relpath;
+       
        /**
        * Constructor: determine the type of linking to use
        *
@@ -56,6 +74,8 @@ class Paths
                }
                
                $this->type = (int)$type;
+               
+               $this->path = $this->parse();
        }
        
        /**
@@ -99,6 +119,11 @@ class Paths
        {
                global $viewsvn;
                
+               if (defined('PATH_OVERRIDE') AND PATH_OVERRIDE == 1)
+               {
+                       return;
+               }
+               
                // standard URL type
                if ($this->type == 1)
                {
@@ -122,7 +147,7 @@ class Paths
                        $viewsvn->trigger->error($viewsvn->lang->string('Invalid path sent'));
                }
                
-               if (!$viewsvn->repos->verify($this->fetch_repos($path), $this->fetch_path($path)))
+               if (!$viewsvn->repos->verify($this->repos = $this->fetch_repos($path), $this->relpath = $this->fetch_path($path)))
                {
                        $viewsvn->trigger->error($viewsvn->lang->string('The path specified could not be verified'));
                }
diff --git a/log.php b/log.php
index 4041c1bfb84353692862014575d9419c410283b0..e69cea10bbfa83784dc4429ab980fad8740fa0b7 100644 (file)
--- a/log.php
+++ b/log.php
@@ -26,34 +26,34 @@ $fetchtemplates = array(
 
 require_once('./global.php');
 
-$navbar = $viewsvn->paths->construct_breadcrumb($path, false);
+$navbar = $viewsvn->paths->construct_breadcrumb($viewsvn->paths->path, false);
 
 // ###################################################################
 
 // this is NOT supposed to allow for revision ranges
-$logs = new SVNLog($repos, $relpath, 0, $viewsvn->svn->common->fetch_head_rev($path));
+$logs = new SVNLog($viewsvn->paths->repos, $viewsvn->paths->relpath, 0, $viewsvn->svn->common->fetch_head_rev($viewsvn->paths->path));
 
-$isdir = $viewsvn->svn->common->isdir($path);
+$isdir = $viewsvn->svn->common->isdir($viewsvn->paths->path);
 
 $nodes = '';
 
 foreach ($logs->fetch() AS $log)
 {
-       $prev = $viewsvn->svn->common->fetch_prev_rev($path, $log['rev']);
+       $prev = $viewsvn->svn->common->fetch_prev_rev($viewsvn->paths->path, $log['rev']);
        
-       $link['view'] = $viewsvn->paths->out(($isdir ? 'browse.php' : 'view.php') . $viewsvn->paths->fetch_rev_str(false, $log['rev']), $path);
-       $link['blame'] = $viewsvn->paths->out('blame.php' . $viewsvn->paths->fetch_rev_str(false, $log['rev']), $path);
+       $link['view'] = $viewsvn->paths->out(($isdir ? 'browse.php' : 'view.php') . $viewsvn->paths->fetch_rev_str(false, $log['rev']), $viewsvn->paths->path);
+       $link['blame'] = $viewsvn->paths->out('blame.php' . $viewsvn->paths->fetch_rev_str(false, $log['rev']), $viewsvn->paths->path);
        
-       $show['diffhead'] = $viewsvn->svn->common->fetch_head_rev($path) != $log['rev'];
+       $show['diffhead'] = $viewsvn->svn->common->fetch_head_rev($viewsvn->paths->path) != $log['rev'];
        if ($show['diffhead'])
        {
-               $link['diffhead'] = $viewsvn->paths->out('diff.php' . $viewsvn->paths->fetch_rev_str(true, 'HEAD', $log['rev']), $path);
+               $link['diffhead'] = $viewsvn->paths->out('diff.php' . $viewsvn->paths->fetch_rev_str(true, 'HEAD', $log['rev']), $viewsvn->paths->path);
        }
        
        $show['diffprev'] = $prev != -1;
        if ($show['diffprev'])
        {
-               $link['diffprev'] = $viewsvn->paths->out('diff.php' . $viewsvn->paths->fetch_rev_str(true, $log['rev'], $prev), $path);
+               $link['diffprev'] = $viewsvn->paths->out('diff.php' . $viewsvn->paths->fetch_rev_str(true, $log['rev'], $prev), $viewsvn->paths->path);
        }
        
        $log['message_clean'] = $viewsvn->svn->format_log_message($log['message']);
index 3c49e76fb3929b684c19fef9f78b3baeaf6457a0..ce3314c7218789f52145cf5e1261a96c6d8e6f85 100644 (file)
--- a/view.php
+++ b/view.php
@@ -25,37 +25,37 @@ $fetchtemplates = array(
 
 require_once('./global.php');
 
-$navbar = $viewsvn->paths->construct_breadcrumb($path);
+$navbar = $viewsvn->paths->construct_breadcrumb($viewsvn->paths->path);
 
 // ###################################################################
 
-$link['log'] = $viewsvn->paths->out('log.php' . $viewsvn->paths->fetch_rev_str(), $path);
+$link['log'] = $viewsvn->paths->out('log.php' . $viewsvn->paths->fetch_rev_str(), $viewsvn->paths->path);
 
-$show['head'] = ($viewsvn->svn->common->fetch_head_rev($path) != $viewsvn->paths->fetch_rev_num() AND $viewsvn->paths->fetch_rev_num() != 'HEAD');
+$show['head'] = ($viewsvn->svn->common->fetch_head_rev($viewsvn->paths->path) != $viewsvn->paths->fetch_rev_num() AND $viewsvn->paths->fetch_rev_num() != 'HEAD');
 if ($show['head'])
 {
-       $link['gohead'] = $viewsvn->paths->out('browse.php' . $viewsvn->paths->fetch_rev_str(false, 'HEAD'), $path);
-       $link['diffhead'] = $viewsvn->paths->out('diff.php' . $viewsvn->paths->fetch_rev_str(true, 'HEAD', $viewsvn->paths->fetch_rev_num()), $path);
+       $link['gohead'] = $viewsvn->paths->out('browse.php' . $viewsvn->paths->fetch_rev_str(false, 'HEAD'), $viewsvn->paths->path);
+       $link['diffhead'] = $viewsvn->paths->out('diff.php' . $viewsvn->paths->fetch_rev_str(true, 'HEAD', $viewsvn->paths->fetch_rev_num()), $viewsvn->paths->path);
 }
 
-$show['prev'] = (($prev = $viewsvn->svn->common->fetch_prev_rev($path, $viewsvn->paths->fetch_rev_num())) != -1 ? true : false);
+$show['prev'] = (($prev = $viewsvn->svn->common->fetch_prev_rev($viewsvn->paths->path, $viewsvn->paths->fetch_rev_num())) != -1 ? true : false);
 if ($show['prev'])
 {
-       $link['diffprev'] = $viewsvn->paths->out('diff.php' . $viewsvn->paths->fetch_rev_str(true, $viewsvn->paths->fetch_rev_num(), $prev), $path);
+       $link['diffprev'] = $viewsvn->paths->out('diff.php' . $viewsvn->paths->fetch_rev_str(true, $viewsvn->paths->fetch_rev_num(), $prev), $viewsvn->paths->path);
 }
 
 // ###################################################################
 
-$logmsg = $viewsvn->svn->common->fetch_log($path, $viewsvn->paths->fetch_rev_num());
+$logmsg = $viewsvn->svn->common->fetch_log($viewsvn->paths->path, $viewsvn->paths->fetch_rev_num());
 unset($logmsg['files']);
 
 $logmsg['message_clean'] = $viewsvn->svn->format_log_message($logmsg['message']);
 
-$catdata = implode("\n", $viewsvn->svn->cat($repos, $relpath, $viewsvn->paths->fetch_rev_num()));
+$catdata = implode("\n", $viewsvn->svn->cat($viewsvn->paths->repos, $viewsvn->paths->relpath, $viewsvn->paths->fetch_rev_num()));
 
 // get language information
 require_once('./includes/file_types.php');
-$language = $filetypes[ $funct->fetch_extension($relpath) ];
+$language = $filetypes[ $funct->fetch_extension($viewsvn->paths->relpath) ];
 
 // initialize GeSHi
 $mtstart = microtime();