From 8cbb5106bd8ac938ba146617f256cd2ee85442b3 Mon Sep 17 00:00:00 2001 From: Robert Sesek Date: Sun, 22 Jan 2006 06:22:03 +0000 Subject: [PATCH] In short: - 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 | 12 +++++------- includes/node.php | 15 ++++++++------- includes/paths.php | 2 +- includes/svncommon.php | 18 ++++++++++++++++++ includes/svnlib.php | 20 +------------------- templates/default/browse_node.tpl | 8 ++++---- 6 files changed, 37 insertions(+), 38 deletions(-) diff --git a/browse.php b/browse.php index ef8c976..5177613 100644 --- a/browse.php +++ b/browse.php @@ -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') . '";'); } diff --git a/includes/node.php b/includes/node.php index 2dee937..5fa7c73 100644 --- a/includes/node.php +++ b/includes/node.php @@ -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 .= '' . $item . ''. ($count != $val ? ' / ' : ''); + $html .= '' . $item . ''. ($count != $val ? ' / ' : ''); } return $html; diff --git a/includes/paths.php b/includes/paths.php index fa6a615..00ac0c2 100644 --- a/includes/paths.php +++ b/includes/paths.php @@ -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)) { diff --git a/includes/svncommon.php b/includes/svncommon.php index bdc2f80..48a3edc 100644 --- a/includes/svncommon.php +++ b/includes/svncommon.php @@ -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; + } } /** diff --git a/includes/svnlib.php b/includes/svnlib.php index 4cd1afc..76491d9 100644 --- a/includes/svnlib.php +++ b/includes/svnlib.php @@ -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; - } } /*=====================================================================*\ diff --git a/templates/default/browse_node.tpl b/templates/default/browse_node.tpl index 0e37e84..c2102a7 100644 --- a/templates/default/browse_node.tpl +++ b/templates/default/browse_node.tpl @@ -1,11 +1,11 @@
- $item + $item - $item + $item - {@"Blame"} - - {@"View Log"} + {@"Blame"} - + {@"View Log"}
\ No newline at end of file -- 2.43.5