Added new functions to mimic out()
authorRobert Sesek <rsesek@bluestatic.org>
Sun, 22 Jan 2006 05:51:37 +0000 (05:51 +0000)
committerRobert Sesek <rsesek@bluestatic.org>
Sun, 22 Jan 2006 05:51:37 +0000 (05:51 +0000)
includes/node.php

index 38ade4bab754ff596264e2b5c0c48914804503e1..f588c5837193d9f97d36151ea066c9966a746ace 100644 (file)
@@ -126,6 +126,55 @@ class Node_Controller
                $this->cachev = new cacheV($this);
        }
        
+       // ###################################################################
+       /**
+       * Produces a link href that allows for a completely different path
+       * than the one in the controller. This is used for navigating upstream.
+       *
+       * @access       public
+       *
+       * @param        string  Base path (e.g. browse.php)
+       * @param        string  New relative path
+       *
+       * @return       string  Constructed path
+       */
+       function href_struct($base, $path)
+       {
+               $url = Paths::fetch_arguments($base);
+               $path = Paths::sanitize($addpath);
+               
+               return $this->registry->path . '/' . $url[0] . '/' . $this->repos . ($path{0} != '/' ? '/' : '') . $path . ($url[1] ? '?' . $url[1] : '');
+       }
+       
+       // ###################################################################
+       /**
+       * Compounds a path by adding another level. This is used for navigating
+       * downstream.
+       *
+       * @access       public
+       *
+       * @param        string  Base path (e.g. browse.php)
+       * @param        string  Attach path (or none for current)
+       *
+       * @return       string  Constructed path
+       */
+       function href_compound($base, $attach = null)
+       {
+               $url = Paths::fetch_arguments($base);
+               $attach = Paths::sanitize($attach);
+               
+               if ($attach === null)
+               {
+                       $path = $this->path;
+               }
+               else
+               {
+                       $path = $this->path . ($attach{0} != '/' ? '/' : '') . $attach;
+               }
+               
+               return $this->href_struct($base, $path);
+       }
+       
        // ###################################################################
        /**
        * Constructs a repository browser link
@@ -181,7 +230,7 @@ class Node_Controller
                {
                        $itembit .= $item;
                        $itembit .= (($count != $val OR $this->cachev->isdir($itembit)) ? '/' : '');
-                       $html .= '<a href="' . $this->registry->path . '/' . $this->out('browse.php' . $this->revstr, $itembit) . '">' . $item . '</a>'. ($count != $val ? ' / ' : '');
+                       $html .= '<a href="' . $this->href_struct('browse.php' . $this->revstr, $itembit) . '">' . $item . '</a>'. ($count != $val ? ' / ' : '');
                }
                
                return $html;