From 5b2d65e72a563641789c7a00be0aebd407f2722a Mon Sep 17 00:00:00 2001 From: Robert Sesek Date: Sun, 22 Jan 2006 05:42:42 +0000 Subject: [PATCH] I really hate all of this crappy code --- browse.php | 16 ++++++++-------- includes/node.php | 37 ++++++++++++++++++++++++++++++++++++- includes/paths.php | 29 ----------------------------- view.php | 8 ++++---- 4 files changed, 48 insertions(+), 42 deletions(-) diff --git a/browse.php b/browse.php index 1d77ff9..fa19899 100644 --- a/browse.php +++ b/browse.php @@ -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') . '";'); } diff --git a/includes/node.php b/includes/node.php index 9b6693a..38ade4b 100644 --- a/includes/node.php +++ b/includes/node.php @@ -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] ? '&' . $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 .= '' . $item . ''. ($count != $val ? ' / ' : ''); + $html .= '' . $item . ''. ($count != $val ? ' / ' : ''); } return $html; diff --git a/includes/paths.php b/includes/paths.php index 25eb2d3..572c41e 100644 --- a/includes/paths.php +++ b/includes/paths.php @@ -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] ? '&' . $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 diff --git a/view.php b/view.php index 1e6947f..6845255 100644 --- 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)); } // ################################################################### -- 2.43.5