From c52c397e2bb459661091e29d5692ecb6cbfc9dfb Mon Sep 17 00:00:00 2001 From: Robert Sesek Date: Mon, 9 Jan 2006 01:57:10 +0000 Subject: [PATCH] Migrating the three *very* important variables into Paths --- blame.php | 18 +++++++++--------- browse.php | 26 +++++++++++++------------- diff.php | 22 +++++++++++----------- global.php | 10 +--------- includes/paths.php | 27 ++++++++++++++++++++++++++- log.php | 18 +++++++++--------- view.php | 20 ++++++++++---------- 7 files changed, 79 insertions(+), 62 deletions(-) diff --git a/blame.php b/blame.php index 9c12f49..84bc152 100644 --- a/blame.php +++ b/blame.php @@ -26,34 +26,34 @@ $fetchtemplates = array( require_once('./global.php'); -$navbar = $viewsvn->paths->construct_breadcrumb($path, false); +$navbar = $viewsvn->paths->construct_breadcrumb($viewsvn->paths->path, false); // ################################################################### -$link['log'] = $viewsvn->paths->out('log.php' . $viewsvn->paths->fetch_rev_str(), $path); +$link['log'] = $viewsvn->paths->out('log.php' . $viewsvn->paths->fetch_rev_str(), $viewsvn->paths->path); -$show['head'] = ($viewsvn->svn->common->fetch_head_rev($path) != $viewsvn->paths->fetch_rev_num() AND $viewsvn->paths->fetch_rev_num() != 'HEAD'); +$show['head'] = ($viewsvn->svn->common->fetch_head_rev($viewsvn->paths->path) != $viewsvn->paths->fetch_rev_num() AND $viewsvn->paths->fetch_rev_num() != 'HEAD'); if ($show['head']) { - $link['gohead'] = $viewsvn->paths->out('blame.php' . $viewsvn->paths->fetch_rev_str(false, 'HEAD'), $path); - $link['diffhead'] = $viewsvn->paths->out('diff.php' . $viewsvn->paths->fetch_rev_str(true, 'HEAD', $viewsvn->paths->fetch_rev_num()), $path); + $link['gohead'] = $viewsvn->paths->out('blame.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->fetch_rev_num()), $viewsvn->paths->path); } -$show['prev'] = (($prev = $viewsvn->svn->common->fetch_prev_rev($path, $viewsvn->paths->fetch_rev_num())) != -1 ? true : false); +$show['prev'] = (($prev = $viewsvn->svn->common->fetch_prev_rev($viewsvn->paths->path, $viewsvn->paths->fetch_rev_num())) != -1 ? true : false); if ($show['prev']) { - $link['diffprev'] = $viewsvn->paths->out('diff.php' . $viewsvn->paths->fetch_rev_str(true, $viewsvn->paths->fetch_rev_num(), $prev), $path); + $link['diffprev'] = $viewsvn->paths->out('diff.php' . $viewsvn->paths->fetch_rev_str(true, $viewsvn->paths->fetch_rev_num(), $prev), $viewsvn->paths->path); } // ################################################################### -$blame = new SVNBlame($repos, $relpath, $viewsvn->paths->fetch_rev_num()); +$blame = new SVNBlame($viewsvn->paths->repos, $viewsvn->paths->relpath, $viewsvn->paths->fetch_rev_num()); $lines = ''; foreach ($blame->fetch() AS $entry) { - $entry['view_link'] = $viewsvn->paths->out('view.php' . $viewsvn->paths->fetch_rev_str(false, $entry['rev']), $path); + $entry['view_link'] = $viewsvn->paths->out('view.php' . $viewsvn->paths->fetch_rev_str(false, $entry['rev']), $viewsvn->paths->path); $entry['line_clean'] = $viewsvn->svn->format($entry['line']); eval('$lines .= "' . $template->fetch('blame_line') . '";'); } diff --git a/browse.php b/browse.php index ebe2a10..5e259d0 100644 --- a/browse.php +++ b/browse.php @@ -26,32 +26,32 @@ $fetchtemplates = array( require_once('./global.php'); -$navbar = $viewsvn->paths->construct_breadcrumb($path); +$navbar = $viewsvn->paths->construct_breadcrumb($viewsvn->paths->path); // ################################################################### -$link['log'] = $viewsvn->paths->out('log.php' . $viewsvn->paths->fetch_rev_str(), $path); +$link['log'] = $viewsvn->paths->out('log.php' . $viewsvn->paths->fetch_rev_str(), $viewsvn->paths->path); -$show['head'] = ($viewsvn->svn->common->fetch_head_rev($path) != $viewsvn->paths->fetch_rev_num() AND $viewsvn->paths->fetch_rev_num() != 'HEAD'); +$show['head'] = ($viewsvn->svn->common->fetch_head_rev($viewsvn->paths->path) != $viewsvn->paths->fetch_rev_num() AND $viewsvn->paths->fetch_rev_num() != 'HEAD'); if ($show['head']) { - $link['gohead'] = $viewsvn->paths->out('browse.php' . $viewsvn->paths->fetch_rev_str(false, 'HEAD'), $path); - $link['diffhead'] = $viewsvn->paths->out('diff.php' . $viewsvn->paths->fetch_rev_str(true, 'HEAD', $viewsvn->paths->fetch_rev_num()), $path); + $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->fetch_rev_num()), $viewsvn->paths->path); } -$show['prev'] = (($prev = $viewsvn->svn->common->fetch_prev_rev($path, $viewsvn->paths->fetch_rev_num())) != -1 ? true : false); +$show['prev'] = (($prev = $viewsvn->svn->common->fetch_prev_rev($viewsvn->paths->path, $viewsvn->paths->fetch_rev_num())) != -1 ? true : false); if ($show['prev']) { - $link['diffprev'] = $viewsvn->paths->out('diff.php' . $viewsvn->paths->fetch_rev_str(true, $viewsvn->paths->fetch_rev_num(), $prev), $path); + $link['diffprev'] = $viewsvn->paths->out('diff.php' . $viewsvn->paths->fetch_rev_str(true, $viewsvn->paths->fetch_rev_num(), $prev), $viewsvn->paths->path); } // ################################################################### -$revinfo = $viewsvn->svn->common->fetch_log($path, $viewsvn->paths->fetch_rev_num()); +$revinfo = $viewsvn->svn->common->fetch_log($viewsvn->paths->path, $viewsvn->paths->fetch_rev_num()); $revinfo['message_clean'] = $viewsvn->svn->format_log_message($revinfo['message']); -$listing = $viewsvn->svn->ls($repos, $relpath, $viewsvn->paths->fetch_rev_num()); +$listing = $viewsvn->svn->ls($viewsvn->paths->repos, $viewsvn->paths->relpath, $viewsvn->paths->fetch_rev_num()); $nodes = ''; @@ -60,16 +60,16 @@ foreach ($listing AS $item) if ($item{ strlen($item) - 1 } == '/') { $show['directory'] = true; - $browse = $viewsvn->paths->out('browse.php' . $viewsvn->paths->fetch_rev_str(), $path . $item); + $browse = $viewsvn->paths->out('browse.php' . $viewsvn->paths->fetch_rev_str(), $viewsvn->paths->path . $item); } else { $show['directory'] = false; - $view = $viewsvn->paths->out('view.php' . $viewsvn->paths->fetch_rev_str(), $path . $item); - $blame = $viewsvn->paths->out('blame.php' . $viewsvn->paths->fetch_rev_str(), $path . $item); + $view = $viewsvn->paths->out('view.php' . $viewsvn->paths->fetch_rev_str(), $viewsvn->paths->path . $item); + $blame = $viewsvn->paths->out('blame.php' . $viewsvn->paths->fetch_rev_str(), $viewsvn->paths->path . $item); } - $log = $viewsvn->paths->out('log.php' . $viewsvn->paths->fetch_rev_str(), $path . $item); + $log = $viewsvn->paths->out('log.php' . $viewsvn->paths->fetch_rev_str(), $viewsvn->paths->path . $item); eval('$nodes .= "' . $template->fetch('browse_node') . '";'); } diff --git a/diff.php b/diff.php index 067cbdb..11d6b4c 100644 --- a/diff.php +++ b/diff.php @@ -30,11 +30,11 @@ $fetchtemplates = array( require_once('./global.php'); -$navbar = $viewsvn->paths->construct_breadcrumb($path, false); +$navbar = $viewsvn->paths->construct_breadcrumb($viewsvn->paths->path, false); // ################################################################### -$link['log'] = $viewsvn->paths->out('log.php' . $viewsvn->paths->fetch_rev_str(), $path); +$link['log'] = $viewsvn->paths->out('log.php' . $viewsvn->paths->fetch_rev_str(), $viewsvn->paths->path); // ################################################################### @@ -44,33 +44,33 @@ $low = $revs['low']; if ($high == 'HEAD') { - $high = $viewsvn->svn->common->fetch_head_rev($path); + $high = $viewsvn->svn->common->fetch_head_rev($viewsvn->paths->path); } if ($low == 0) { - $low = $viewsvn->svn->common->fetch_prev_rev($path, $high); + $low = $viewsvn->svn->common->fetch_prev_rev($viewsvn->paths->path, $high); } // ################################################################### -$show['fullchangeset'] = ($viewsvn->paths->is_root_path($path) ? false : true); +$show['fullchangeset'] = ($viewsvn->paths->is_root_path($viewsvn->paths->path) ? false : true); if ($show['fullchangeset']) { - $link['changeset'] = $viewsvn->paths->out('diff.php' . $viewsvn->paths->fetch_rev_str(true, $high, $low), $repos . '/'); + $link['changeset'] = $viewsvn->paths->out('diff.php' . $viewsvn->paths->fetch_rev_str(true, $high, $low), $viewsvn->paths->repos . '/'); } -$log = $viewsvn->svn->common->fetch_log($path, $high); +$log = $viewsvn->svn->common->fetch_log($viewsvn->paths->path, $high); $log['message_clean'] = $viewsvn->svn->format_log_message($log['message']); -$files = $viewsvn->svn->common->construct_file_changes($log['files'], $repos, $high); +$files = $viewsvn->svn->common->construct_file_changes($log['files'], $viewsvn->paths->repos, $high); // ################################################################### -$diff = new SVNDiff($repos, $relpath, $low, $high); +$diff = new SVNDiff($viewsvn->paths->repos, $viewsvn->paths->relpath, $low, $high); -$isdir = (bool)$viewsvn->svn->common->isdir($path); +$isdir = (bool)$viewsvn->svn->common->isdir($viewsvn->paths->path); $changes = ''; @@ -96,7 +96,7 @@ foreach ($diff->fetch() AS $filename => $file) $show['hunk'] = false; if ($key == 'hunk' AND isset($line['old'])) { - $filepath = ($isdir ? $path . $filename : $path); + $filepath = ($isdir ? $viewsvn->paths->path . $filename : $viewsvn->paths->path); $rlow = $viewsvn->paths->out('view.php' . $viewsvn->paths->fetch_rev_str(false, $low), $filepath); $rhigh = $viewsvn->paths->out('view.php' . $viewsvn->paths->fetch_rev_str(false, $high), $filepath); $show['hunk'] = true; diff --git a/global.php b/global.php index d49de70..fc40155 100644 --- a/global.php +++ b/global.php @@ -21,15 +21,7 @@ require_once('./includes/init.php'); -$dochooser = false; -if (!defined('PATH_OVERRIDE') OR PATH_OVERRIDE != 1) -{ - $path = $viewsvn->paths->parse(); - $repos = $viewsvn->paths->fetch_repos($path); - $relpath = $viewsvn->paths->fetch_path($path); - - $dochooser = true; -} +$dochooser = (defined('PATH_OVERRIDE') AND PATH_OVERRIDE == 1 ? false: true); $fetchtemplates[] = 'header'; $fetchtemplates[] = 'footer'; diff --git a/includes/paths.php b/includes/paths.php index cab4561..1f5178f 100644 --- a/includes/paths.php +++ b/includes/paths.php @@ -41,6 +41,24 @@ class Paths */ var $type; + /** + * The universal path that is currently being browsed + * @var string + */ + var $path; + + /** + * Current repository that we're in + * @var string + */ + var $repos; + + /** + * Current internal path inside the repository + * @var string + */ + var $relpath; + /** * Constructor: determine the type of linking to use * @@ -56,6 +74,8 @@ class Paths } $this->type = (int)$type; + + $this->path = $this->parse(); } /** @@ -99,6 +119,11 @@ class Paths { global $viewsvn; + if (defined('PATH_OVERRIDE') AND PATH_OVERRIDE == 1) + { + return; + } + // standard URL type if ($this->type == 1) { @@ -122,7 +147,7 @@ class Paths $viewsvn->trigger->error($viewsvn->lang->string('Invalid path sent')); } - if (!$viewsvn->repos->verify($this->fetch_repos($path), $this->fetch_path($path))) + if (!$viewsvn->repos->verify($this->repos = $this->fetch_repos($path), $this->relpath = $this->fetch_path($path))) { $viewsvn->trigger->error($viewsvn->lang->string('The path specified could not be verified')); } diff --git a/log.php b/log.php index 4041c1b..e69cea1 100644 --- a/log.php +++ b/log.php @@ -26,34 +26,34 @@ $fetchtemplates = array( require_once('./global.php'); -$navbar = $viewsvn->paths->construct_breadcrumb($path, false); +$navbar = $viewsvn->paths->construct_breadcrumb($viewsvn->paths->path, false); // ################################################################### // this is NOT supposed to allow for revision ranges -$logs = new SVNLog($repos, $relpath, 0, $viewsvn->svn->common->fetch_head_rev($path)); +$logs = new SVNLog($viewsvn->paths->repos, $viewsvn->paths->relpath, 0, $viewsvn->svn->common->fetch_head_rev($viewsvn->paths->path)); -$isdir = $viewsvn->svn->common->isdir($path); +$isdir = $viewsvn->svn->common->isdir($viewsvn->paths->path); $nodes = ''; foreach ($logs->fetch() AS $log) { - $prev = $viewsvn->svn->common->fetch_prev_rev($path, $log['rev']); + $prev = $viewsvn->svn->common->fetch_prev_rev($viewsvn->paths->path, $log['rev']); - $link['view'] = $viewsvn->paths->out(($isdir ? 'browse.php' : 'view.php') . $viewsvn->paths->fetch_rev_str(false, $log['rev']), $path); - $link['blame'] = $viewsvn->paths->out('blame.php' . $viewsvn->paths->fetch_rev_str(false, $log['rev']), $path); + $link['view'] = $viewsvn->paths->out(($isdir ? 'browse.php' : 'view.php') . $viewsvn->paths->fetch_rev_str(false, $log['rev']), $viewsvn->paths->path); + $link['blame'] = $viewsvn->paths->out('blame.php' . $viewsvn->paths->fetch_rev_str(false, $log['rev']), $viewsvn->paths->path); - $show['diffhead'] = $viewsvn->svn->common->fetch_head_rev($path) != $log['rev']; + $show['diffhead'] = $viewsvn->svn->common->fetch_head_rev($viewsvn->paths->path) != $log['rev']; if ($show['diffhead']) { - $link['diffhead'] = $viewsvn->paths->out('diff.php' . $viewsvn->paths->fetch_rev_str(true, 'HEAD', $log['rev']), $path); + $link['diffhead'] = $viewsvn->paths->out('diff.php' . $viewsvn->paths->fetch_rev_str(true, 'HEAD', $log['rev']), $viewsvn->paths->path); } $show['diffprev'] = $prev != -1; if ($show['diffprev']) { - $link['diffprev'] = $viewsvn->paths->out('diff.php' . $viewsvn->paths->fetch_rev_str(true, $log['rev'], $prev), $path); + $link['diffprev'] = $viewsvn->paths->out('diff.php' . $viewsvn->paths->fetch_rev_str(true, $log['rev'], $prev), $viewsvn->paths->path); } $log['message_clean'] = $viewsvn->svn->format_log_message($log['message']); diff --git a/view.php b/view.php index 3c49e76..ce3314c 100644 --- a/view.php +++ b/view.php @@ -25,37 +25,37 @@ $fetchtemplates = array( require_once('./global.php'); -$navbar = $viewsvn->paths->construct_breadcrumb($path); +$navbar = $viewsvn->paths->construct_breadcrumb($viewsvn->paths->path); // ################################################################### -$link['log'] = $viewsvn->paths->out('log.php' . $viewsvn->paths->fetch_rev_str(), $path); +$link['log'] = $viewsvn->paths->out('log.php' . $viewsvn->paths->fetch_rev_str(), $viewsvn->paths->path); -$show['head'] = ($viewsvn->svn->common->fetch_head_rev($path) != $viewsvn->paths->fetch_rev_num() AND $viewsvn->paths->fetch_rev_num() != 'HEAD'); +$show['head'] = ($viewsvn->svn->common->fetch_head_rev($viewsvn->paths->path) != $viewsvn->paths->fetch_rev_num() AND $viewsvn->paths->fetch_rev_num() != 'HEAD'); if ($show['head']) { - $link['gohead'] = $viewsvn->paths->out('browse.php' . $viewsvn->paths->fetch_rev_str(false, 'HEAD'), $path); - $link['diffhead'] = $viewsvn->paths->out('diff.php' . $viewsvn->paths->fetch_rev_str(true, 'HEAD', $viewsvn->paths->fetch_rev_num()), $path); + $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->fetch_rev_num()), $viewsvn->paths->path); } -$show['prev'] = (($prev = $viewsvn->svn->common->fetch_prev_rev($path, $viewsvn->paths->fetch_rev_num())) != -1 ? true : false); +$show['prev'] = (($prev = $viewsvn->svn->common->fetch_prev_rev($viewsvn->paths->path, $viewsvn->paths->fetch_rev_num())) != -1 ? true : false); if ($show['prev']) { - $link['diffprev'] = $viewsvn->paths->out('diff.php' . $viewsvn->paths->fetch_rev_str(true, $viewsvn->paths->fetch_rev_num(), $prev), $path); + $link['diffprev'] = $viewsvn->paths->out('diff.php' . $viewsvn->paths->fetch_rev_str(true, $viewsvn->paths->fetch_rev_num(), $prev), $viewsvn->paths->path); } // ################################################################### -$logmsg = $viewsvn->svn->common->fetch_log($path, $viewsvn->paths->fetch_rev_num()); +$logmsg = $viewsvn->svn->common->fetch_log($viewsvn->paths->path, $viewsvn->paths->fetch_rev_num()); unset($logmsg['files']); $logmsg['message_clean'] = $viewsvn->svn->format_log_message($logmsg['message']); -$catdata = implode("\n", $viewsvn->svn->cat($repos, $relpath, $viewsvn->paths->fetch_rev_num())); +$catdata = implode("\n", $viewsvn->svn->cat($viewsvn->paths->repos, $viewsvn->paths->relpath, $viewsvn->paths->fetch_rev_num())); // get language information require_once('./includes/file_types.php'); -$language = $filetypes[ $funct->fetch_extension($relpath) ]; +$language = $filetypes[ $funct->fetch_extension($viewsvn->paths->relpath) ]; // initialize GeSHi $mtstart = microtime(); -- 2.43.5