- Making it so the last component in ConstructNavbar() doesn't work as a link
authorRobert Sesek <rsesek@bluestatic.org>
Mon, 9 Apr 2007 05:35:03 +0000 (05:35 +0000)
committerRobert Sesek <rsesek@bluestatic.org>
Mon, 9 Apr 2007 05:35:03 +0000 (05:35 +0000)
- Making ConstructNavbar() carry over revisions
- Added ConstructLink()

browse.php
includes/functions.php
templates/default/browse_node.tpl

index 2fb0eeab9a722e13b0ecb5613ec7ebeaef62dd3b..f6f075863131781a8850f36444e9dbd65c53553b 100644 (file)
@@ -53,6 +53,7 @@ foreach ($listing['lists']['list']['entry'] AS $item)
 {
        $isDir = ($item['kind'] == 'dir');
        $item = $item['name']['value'];
+       $itemLink = ConstructLink(($isDir ? 'browse' : 'view'), $input->in['repos'], $input->in['path'] . '/' . $item, $input->in['rev']);
        eval('$nodes .= "' . $template->fetch('browse_node') . '";');
 }
 
index 004d7bb2d28c58c7271a2d491d2d4ae3aca966ac..21a9374e917eabc4e170a333c9cbd2b06ec3f190 100644 (file)
@@ -31,7 +31,7 @@ function ConstructNavbar()
        $path = preg_split('#/#', BSRegister::Get('input')->in['path'], -1, PREG_SPLIT_NO_EMPTY);
        $input =& BSRegister::Get('input');
        
-       $html = '[<a href="' . BSRegister::Get('webpath') . '/browse/' . $input->in['repos'] . ':">' . $input->in['repos'] . '</a>]: ';
+       $html = '[<a href="' . ConstructLink('browse', $input->in['repos'], null, $input->in['rev']) . '">' . $input->in['repos'] . '</a>]: ';
        
        if (empty($path))
        {
@@ -39,10 +39,17 @@ function ConstructNavbar()
        }
        
        $build = '';
-       foreach ($path AS $part)
+       foreach ($path AS $index => $part)
        {
                $build .= '/' . $part;
-               $html .= '/ <a href="' . BSRegister::Get('webpath') .  '/browse/' . $input->in['repos'] . ':' . $build . '"><strong>' . $part . '</strong></a> ';
+               if (sizeof($path) - 1 == $index)
+               {
+                       $html .= '/ <strong>' . $part . '</strong>';
+               }
+               else
+               {
+                       $html .= '/ <a href="' . ConstructLink('browse', $input->in['repos'], $build, $input->in['rev']) . '"><strong>' . $part . '</strong></a> ';
+               }
        }
        
        return $html;
@@ -147,6 +154,23 @@ function FormatSvnDate($string)
        return preg_replace('#(....)\-(..)\-(..)T(..):(..):(..).(.*)Z#e', 'gmdate("r", mktime(\4, \5, \6, \2, \3, \1))', $string);
 }
 
+// ###################################################################
+/**
+* Generates an absolute-pathed link if you just pass it the four
+* paramaters
+*
+* @param       string  Action/script
+* @param       string  Repository name
+* @param       string  Subpath in repository
+* @param       integer Revision
+*
+* @return      string  Link (not wrapped in <a>)
+*/
+function ConstructLink($action, $repos, $path, $rev)
+{
+       return BSRegister::Get('webpath') . '/' . $action . '/' . $repos . ':' . $path . ($rev > 0 ? '@' . $rev : '');
+}
+
 /*=====================================================================*\
 || ###################################################################
 || # $HeadURL$
index d67275c625f2f6c6eab8c5dca61ed0107225c43e..1388e85d03050b3f397eb138c74d131a6d2dffef 100644 (file)
@@ -1,8 +1,8 @@
 <div class="content" style="border-width: 0px 1px 1px 1px">
        <if condition="$isDir">
-               <a href="{BSRegister::Get('webpath')}/browse/{$input->in['repos']}:{$input->in['path']}/$item"><strong>$item/</strong></a>
+               <a href="$itemLink"><strong>$item/</strong></a>
        <else />
-               <a href="{BSRegister::Get('webpath')}/view/{$input->in['repos']}:{$input->in['path']}/$item">$item</a>
+               <a href="$itemLink">$item</a>
        </if>
        <!-- <span class="nodelink">
                <if condition="$isDir"><a href="$blame">{@"Blame"}</a> - </if>