In short:
authorRobert Sesek <rsesek@bluestatic.org>
Sun, 22 Jan 2006 06:22:03 +0000 (06:22 +0000)
committerRobert Sesek <rsesek@bluestatic.org>
Sun, 22 Jan 2006 06:22:03 +0000 (06:22 +0000)
- A whole bunch of stuff regarding paths
- We no longer use $viewsvn->path in template, it's generated fully by href_struct()
- browse.php should [somewhat] work
- Moved SVNLib::rev() to SVNCommon

browse.php
includes/node.php
includes/paths.php
includes/svncommon.php
includes/svnlib.php
templates/default/browse_node.tpl

index ef8c9763cf7b485de9d844ceaa3fb0bf7ad15001..51776138cdad16bd6f1a638fb15d65cc41d00bc7 100644 (file)
@@ -28,8 +28,6 @@ require_once('./global.php');
 
 $navbar = $controller->construct_breadcrumb();
 
-print_r($controller);
-
 // ###################################################################
 
 $node = preg_replace('#(^/|/$)#', '', ($viewsvn->paths->relpath == '' ? $viewsvn->paths->path : $viewsvn->paths->relpath));
@@ -57,7 +55,7 @@ $revinfo['message_clean'] = SVNCommon::format_log_message($revinfo['message']);
 
 $revinfo['date'] = SVNCommon::format_date_string($revinfo['dateline']);
 
-$listing = $controller->library->ls($viewsvn->paths->repos, $viewsvn->paths->relpath, $viewsvn->paths->revnum);
+$listing = $controller->library->ls($controller->repos, $controller->path, $controller->revnum);
 
 $nodes = '';
 
@@ -66,16 +64,16 @@ foreach ($listing AS $item)
        if ($item{ strlen($item) - 1 } == '/')
        {
                $show['directory'] = true;
-               $browse = $controller->out('browse.php' . $viewsvn->paths->revstr, $controller->path . '/' . $item);
+               $browse = $controller->href_compound('browse.php', $item);
        }
        else
        {
                $show['directory'] = false;
-               $view = $controller->out('view.php' . $viewsvn->paths->revstr, $controller->path . '/' . $item);
-               $blame = $controller->out('blame.php' . $viewsvn->paths->revstr, $controller->path . '/' . $item);
+               $view = $controller->href_compound('view.php', $item);
+               $blame = $controller->href_compound('blame.php', $item);
        }
        
-       $log = $controller->out('log.php' . $viewsvn->paths->revstr, $controller->path . '/' . $item);
+       $log = $controller->href_compound('log.php', $item);
        
        eval('$nodes .= "' . $template->fetch('browse_node') . '";');
 }
index 2dee9377407f011a6cc877c6004fc6f7aeac92e7..5fa7c7357550ddfba23cd8c17bb864910ed26c60 100644 (file)
@@ -158,7 +158,7 @@ class Node_Controller
        function href_struct($base, $path)
        {
                $url = Paths::fetch_arguments($base);
-               $path = Paths::sanitize($addpath);
+               $path = Paths::sanitize($path);
                
                return $this->registry->path . '/' . $url[0] . '/' . $this->repos . ($path{0} != '/' ? '/' : '') . $path . ($url[1] ? '?' . $url[1] : '');
        }
@@ -172,12 +172,13 @@ class Node_Controller
        *
        * @param        string  Base path (e.g. browse.php)
        * @param        string  Attach path (or none for current)
+       * @param        bool    Attach the current revision string?
        *
        * @return       string  Constructed path
        */
-       function href_compound($base, $attach = null)
+       function href_compound($base, $attach = null, $revstr = true)
        {
-               $url = Paths::fetch_arguments($base);
+               $url = Paths::fetch_arguments($base . ($revstr ? ((strpos($base, '?') !== false) ? '&' . $this->revstr : $this->revstr) : ''));
                $attach = Paths::sanitize($attach);
                
                if ($attach === null)
@@ -186,10 +187,10 @@ class Node_Controller
                }
                else
                {
-                       $path = $this->path . ($attach{0} != '/' ? '/' : '') . $attach;
+                       $path = $this->path . (($attach[0] != '/' AND $this->path[ strlen($this->path) - 1 ] != '/') ? '/' : '') . $attach;
                }
                
-               return $this->href_struct($base, $path);
+               return $this->href_struct($base . ($url[1] ? '?' . $url[1] : ''), $path);
        }
        
        // ###################################################################
@@ -240,14 +241,14 @@ class Node_Controller
                $html = '/ ';
                $itembit = '/';
                
-               $temp = preg_split('#/#', $this->path, -1, PREG_SPLIT_NO_EMPTY);
+               $temp = preg_split('#/#', $this->fullpath, -1, PREG_SPLIT_NO_EMPTY);
                $count = count($temp) - 1;
                
                foreach ($temp AS $val => $item)
                {
                        $itembit .= $item;
                        $itembit .= (($count != $val OR $this->cachev->isdir($itembit)) ? '/' : '');
-                       $html .= '<a href="' . $this->href_struct('browse.php' . $this->revstr, $itembit) . '">' . $item . '</a>'. ($count != $val ? ' / ' : '');
+                       $html .= '<a href="' . $this->href_struct('browse.php' . $this->revstr, ($val == 0 ? '' : $itembit)) . '">' . $item . '</a>'. ($count != $val ? ' / ' : '');
                }
                
                return $html;
index fa6a615fd107dfb211521b1b52f25754c26c19cc..00ac0c2cc6801369912ee7740370844fe7c8f63e 100644 (file)
@@ -215,7 +215,7 @@ class Paths
                {
                        if (isset($viewsvn->in['rev']) AND is_null($high))
                        {
-                               $rev = $viewsvn->svn->rev($viewsvn->in['rev']);
+                               $rev = SVNCommon::rev($viewsvn->in['rev']);
                        }
                        else if (is_null($high))
                        {
index bdc2f803eabdc15589a9df654662af8dd3b5622d..48a3edc6825111c395213a8e4f97aa129cab813f 100644 (file)
@@ -240,6 +240,24 @@ class SVNCommon
                
                return $files;
        }
+       
+       /**
+       * Generates a clean revision number
+       *
+       * @access       public
+       *
+       * @param        integer Revision number
+       *
+       * @return       mixed   Cleaned revision or HEAD
+       */
+       function rev($revision)
+       {
+               if (($revision = intval($revision)) < 1)
+               {
+                       $revision = 'HEAD';
+               }
+               return $revision;
+       }
 }
 
 /**
index 4cd1afc8a497c77d5dad855fd87fdb31cf194140..76491d97abec1f7363f2b2267a17b591f303bf3b 100644 (file)
@@ -113,7 +113,7 @@ class SVNLib
        {
                global $viewsvn;
                
-               $revision = $this->rev($revision);
+               $revision = SVNCommon::rev($revision);
                $repospath = $viewsvn->repos->fetch_path($repos, false);
                
                return $this->svn($command . ' ' . $repospath . $path . '@' . $revision);
@@ -246,24 +246,6 @@ class SVNLib
        {
                return $this->std('list', $repos, $path, $revision);
        }
-       
-       /**
-       * Generates a clean revision number
-       *
-       * @access       public
-       *
-       * @param        integer Revision number
-       *
-       * @return       mixed   Cleaned revision or HEAD
-       */
-       function rev($revision)
-       {
-               if (($revision = intval($revision)) < 1)
-               {
-                       $revision = 'HEAD';
-               }
-               return $revision;
-       }
 }
 
 /*=====================================================================*\
index 0e37e84087766600a2d6a052ab5af394a425ef03..c2102a7538b63fb5734a6e70ab72013512e5a59b 100644 (file)
@@ -1,11 +1,11 @@
 <div class="content" style="border-width: 0px 1px 1px 1px">
        <if condition="$show['directory']">
-               <a href="$viewsvn->path/$browse"><strong>$item</strong></a>
+               <a href="$browse"><strong>$item</strong></a>
        <else />
-               <a href="$viewsvn->path/$view">$item</a>
+               <a href="$view">$item</a>
        </if>
        <span class="nodelink">
-               <if condition="!$show['directory']"><a href="$viewsvn->path/$blame">{@"Blame"}</a> - </if>
-               <a href="$viewsvn->path/$log">{@"View Log"}</a>
+               <if condition="!$show['directory']"><a href="$blame">{@"Blame"}</a> - </if>
+               <a href="$log">{@"View Log"}</a>
        </span>
 </div>
\ No newline at end of file