I really hate all of this crappy code
authorRobert Sesek <rsesek@bluestatic.org>
Sun, 22 Jan 2006 05:42:42 +0000 (05:42 +0000)
committerRobert Sesek <rsesek@bluestatic.org>
Sun, 22 Jan 2006 05:42:42 +0000 (05:42 +0000)
browse.php
includes/node.php
includes/paths.php
view.php

index 1d77ff988d2b5c7fcc2b1bfb940be25dbc1ad520..fa19899dc269b33f2fa12a24cbf8e2b6758f1b28 100644 (file)
@@ -33,19 +33,19 @@ $navbar = $controller->construct_breadcrumb();
 $node = preg_replace('#(^/|/$)#', '', ($viewsvn->paths->relpath == '' ? $viewsvn->paths->path : $viewsvn->paths->relpath));
 $latest = $controller->cachev->fetch_node($node);
 
-$link['log'] = $viewsvn->paths->out('log.php' . $viewsvn->paths->revstr, $viewsvn->paths->path);
+$link['log'] = $controller->out('log.php' . $viewsvn->paths->revstr);
 
 $show['head'] = ($latest['revision'] != $viewsvn->paths->revnum AND $viewsvn->paths->revnum != 'HEAD');
 if ($show['head'])
 {
-       $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->revnum), $viewsvn->paths->path);
+       $link['gohead'] = $controller->out('browse.php' . $viewsvn->paths->fetch_rev_str(false, 'HEAD'));
+       $link['diffhead'] = $controller->out('diff.php' . $viewsvn->paths->fetch_rev_str(true, 'HEAD', $viewsvn->paths->revnum));
 }
 
 $show['prev'] = ($prev = $controller->cachev->fetch_prev_revision($viewsvn->paths->relpath, $viewsvn->paths->revnum));
 if ($show['prev'])
 {
-       $link['diffprev'] = $viewsvn->paths->out('diff.php' . $viewsvn->paths->fetch_rev_str(true, $viewsvn->paths->revnum, $prev), $viewsvn->paths->path);
+       $link['diffprev'] = $controller->out('diff.php' . $viewsvn->paths->fetch_rev_str(true, $viewsvn->paths->revnum, $prev));
 }
 
 // ###################################################################
@@ -64,16 +64,16 @@ foreach ($listing AS $item)
        if ($item{ strlen($item) - 1 } == '/')
        {
                $show['directory'] = true;
-               $browse = $viewsvn->paths->out('browse.php' . $viewsvn->paths->revstr, $viewsvn->paths->path . $item);
+               $browse = $controller->out('browse.php' . $viewsvn->paths->revstr, $controller->path . '/' . $item);
        }
        else
        {
                $show['directory'] = false;
-               $view = $viewsvn->paths->out('view.php' . $viewsvn->paths->revstr, $viewsvn->paths->path . $item);
-               $blame = $viewsvn->paths->out('blame.php' . $viewsvn->paths->revstr, $viewsvn->paths->path . $item);
+               $view = $controller->out('view.php' . $viewsvn->paths->revstr, $controller->path . '/' . $item);
+               $blame = $controller->out('blame.php' . $viewsvn->paths->revstr, $controller->path . '/' . $item);
        }
        
-       $log = $viewsvn->paths->out('log.php' . $viewsvn->paths->revstr, $viewsvn->paths->path . $item);
+       $log = $controller->out('log.php' . $viewsvn->paths->revstr, $controller->path . '/' . $item);
        
        eval('$nodes .= "' . $template->fetch('browse_node') . '";');
 }
index 9b6693a501662aa7a1237f863aadf492fdad13ea..38ade4bab754ff596264e2b5c0c48914804503e1 100644 (file)
@@ -126,6 +126,41 @@ class Node_Controller
                $this->cachev = new cacheV($this);
        }
        
+       // ###################################################################
+       /**
+       * Constructs a repository browser link
+       *
+       * @access       public
+       *
+       * @param        string  Base path
+       * @param        string  Browser path, separated using '/'
+       *
+       * @return       string  Link path
+       */
+       function out($base, $addpath = null)
+       {
+               global $viewsvn;
+               
+               if ($addpath === null)
+               {
+                       $addpath = $this->path;
+               }
+               
+               $url = Paths::fetch_arguments($base);
+               $addpath = Paths::sanitize($addpath);
+               
+               // standard URL type
+               if ($this->registry->paths->type == 1)
+               {
+                       return $url[0] . '?path=' . $addpath . ($url[1] ? '&amp;' . $url[1] : '');
+               }
+               // advanced path system
+               else if ($this->registry->paths->type == 2)
+               {
+                       return $url[0] . '/' . $this->repos . ($addpath{0} != '/' ? '/' : '') . $addpath . ($url[1] ? '?' . $url[1] : '');
+               }
+       }
+       
        // ###################################################################
        /**
        * Create path breadcrumb
@@ -146,7 +181,7 @@ class Node_Controller
                {
                        $itembit .= $item;
                        $itembit .= (($count != $val OR $this->cachev->isdir($itembit)) ? '/' : '');
-                       $html .= '<a href="' . $this->path . '/' . $this->registry->paths->out('browse.php' . $this->revstr, $itembit) . '">' . $item . '</a>'. ($count != $val ? ' / ' : '');
+                       $html .= '<a href="' . $this->registry->path . '/' . $this->out('browse.php' . $this->revstr, $itembit) . '">' . $item . '</a>'. ($count != $val ? ' / ' : '');
                }
                
                return $html;
index 25eb2d3f91edb96156b05035ef5ddfd0d9bbac68..572c41eb1b3befe59e7d9fc99db4014bd0e13619 100644 (file)
@@ -99,36 +99,7 @@ class Paths
                $this->revnum = $this->revnum;
                $this->revstr = $this->revstr;
        }
-       
-       /**
-       * Constructs a repository browser link
-       *
-       * @access       public
-       *
-       * @param        string  Base path
-       * @param        string  Browser path, separated using '/'
-       *
-       * @return       string  Link path
-       */
-       function out($base, $addpath)
-       {
-               global $viewsvn;
-               
-               $url = $this->fetch_arguments($base);
-               $addpath = $this->sanitize($addpath);
                
-               // standard URL type
-               if ($this->type == 1)
-               {
-                       return $url[0] . '?path=' . $addpath . ($url[1] ? '&amp;' . $url[1] : '');
-               }
-               // advanced path system
-               else if ($this->type == 2)
-               {
-                       return $url[0] . ($addpath{0} != '/' ? '/' : '') . $addpath . ($url[1] ? '?' . $url[1] : '');
-               }
-       }
-       
        /**
        * Parses an incoming path with the various methods
        * and returns a universal form
index 1e6947f104760816875b71e77df1f6b9cf3132e7..6845255ec234926cb7d313ade9088716cdb49515 100644 (file)
--- a/view.php
+++ b/view.php
@@ -31,19 +31,19 @@ $navbar = $controller->construct_breadcrumb();
 
 $latest = $controller->cachev->fetch_node($viewsvn->paths->relpath);
 
-$link['log'] = $viewsvn->paths->out('log.php' . $viewsvn->paths->revstr, $viewsvn->paths->path);
+$link['log'] = $controller->out('log.php' . $viewsvn->paths->revstr);
 
 $show['head'] = ($latest['revision'] != $viewsvn->paths->revnum AND $viewsvn->paths->revnum != 'HEAD');
 if ($show['head'])
 {
-       $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->revnum), $viewsvn->paths->path);
+       $link['gohead'] = $controller->out('browse.php' . $viewsvn->paths->fetch_rev_str(false, 'HEAD'));
+       $link['diffhead'] = $controller->out('diff.php' . $viewsvn->paths->fetch_rev_str(true, 'HEAD', $viewsvn->paths->revnum));
 }
 
 $show['prev'] = ($prev = $controller->cachev->fetch_prev_revision($viewsvn->paths->relpath, $viewsvn->paths->revnum));
 if ($show['prev'])
 {
-       $link['diffprev'] = $viewsvn->paths->out('diff.php' . $viewsvn->paths->fetch_rev_str(true, $viewsvn->paths->revnum, $prev), $viewsvn->paths->path);
+       $link['diffprev'] = $controller->out('diff.php' . $viewsvn->paths->fetch_rev_str(true, $viewsvn->paths->revnum, $prev));
 }
 
 // ###################################################################