From 22f4518437df60985ce26d35fc49cba9208f52e5 Mon Sep 17 00:00:00 2001 From: wangyidong Date: Wed, 13 Dec 2017 13:38:46 +0800 Subject: [PATCH] * finish task #3383. --- module/git/control.php | 4 ++++ module/git/model.php | 23 ++++++++++++++++++++--- module/git/view/diff.html.php | 2 +- module/svn/control.php | 4 ++++ module/svn/model.php | 23 ++++++++++++++++++++--- module/svn/view/diff.html.php | 2 +- 6 files changed, 50 insertions(+), 8 deletions(-) diff --git a/module/git/control.php b/module/git/control.php index 88f37ce641..e513d6432f 100644 --- a/module/git/control.php +++ b/module/git/control.php @@ -32,7 +32,9 @@ class git extends control */ public function diff($path, $revision) { + if(isset($_GET['repoUrl'])) $path = $this->get->repoUrl; $path = helper::safe64Decode($path); + $this->view->path = $path; $this->view->revision = $revision; $this->view->diff = $this->git->diff($path, $revision); @@ -50,7 +52,9 @@ class git extends control */ public function cat($path, $revision) { + if(isset($_GET['repoUrl'])) $path = $this->get->repoUrl; $path = helper::safe64Decode($path); + $this->view->path = $path; $this->view->revision = $revision; $this->view->code = $this->git->cat($path, $revision); diff --git a/module/git/model.php b/module/git/model.php index ee564f1356..1932bc00b5 100644 --- a/module/git/model.php +++ b/module/git/model.php @@ -643,9 +643,8 @@ class gitModel extends model { foreach($actionFiles as $file) { - $param = array('url' => helper::safe64Encode($repoRoot . $file), 'revision' => $log->revision); - $catLink = trim(html::a(helper::createLink('git', 'cat', $param, 'html'), 'view', '', "class='repolink'")); - $diffLink = trim(html::a(helper::createLink('git', 'diff', $param, 'html'), 'diff', '', "class='repolink'")); + $catLink = trim(html::a($this->buildURL('cat', $repoRoot . $file, $log->revision), 'view', '', "class='repolink'")); + $diffLink = trim(html::a($this->buildURL('diff', $repoRoot . $file, $log->revision), 'diff', '', "class='repolink'")); $diff .= $action . " " . $file . " $catLink "; $diff .= $action == 'M' ? "$diffLink\n" : "\n" ; } @@ -747,4 +746,22 @@ class gitModel extends model { echo helper::now() . " $log\n"; } + + /** + * Build URL. + * + * @param string $methodName + * @param string $url + * @param int $revision + * @access public + * @return string + */ + public function buildURL($methodName, $url, $revision) + { + $buildedURL = helper::createLink('git', $methodName, "path=&revision=$revision", 'html'); + $buildedURL .= strpos($buildURL, '?') === false ? '?' : '&'; + $buildedURL .= 'repoUrl=' . helper::safe64Encode($url); + + return $buildedURL; + } } diff --git a/module/git/view/diff.html.php b/module/git/view/diff.html.php index 20c035297d..3c710254db 100644 --- a/module/git/view/diff.html.php +++ b/module/git/view/diff.html.php @@ -11,7 +11,7 @@ */ ?> - +git->buildURL('cat', $path, $revision);?>
<?php echo $diff;?>
diff --git a/module/svn/control.php b/module/svn/control.php index 78eb9cf9c9..1319e3c69c 100644 --- a/module/svn/control.php +++ b/module/svn/control.php @@ -32,7 +32,9 @@ class svn extends control */ public function diff($url, $revision) { + if(isset($_GET['repoUrl'])) $url = $this->get->repoUrl; $url = helper::safe64Decode($url); + $this->view->url = $url; $this->view->revision = $revision; $this->view->diff = $this->svn->diff($url, $revision); @@ -50,7 +52,9 @@ class svn extends control */ public function cat($url, $revision) { + if(isset($_GET['repoUrl'])) $url = $this->get->repoUrl; $url = helper::safe64Decode($url); + $this->view->url = $url; $this->view->revision = $revision; $this->view->code = $this->svn->cat($url, $revision); diff --git a/module/svn/model.php b/module/svn/model.php index 161337527c..1d8c2d8469 100644 --- a/module/svn/model.php +++ b/module/svn/model.php @@ -611,9 +611,8 @@ class svnModel extends model { foreach($actionFiles as $file) { - $param = array('url' => helper::safe64Encode($repoRoot . $file), 'revision' => $log->revision); - $catLink = trim(html::a(helper::createLink('svn', 'cat', $param, 'html'), 'view', '', "class='repolink'")); - $diffLink = trim(html::a(helper::createLink('svn', 'diff', $param, 'html'), 'diff', '', "class='repolink'")); + $catLink = trim(html::a($this->buildURL('cat', $repoRoot . $file, $log->revision), 'view', '', "class='repolink'")); + $diffLink = trim(html::a($this->buildURL('diff', $repoRoot . $file, $log->revision), 'diff', '', "class='repolink'")); $diff .= $action . " " . $file . " $catLink "; $diff .= $action == 'M' ? "$diffLink\n" : "\n" ; } @@ -715,4 +714,22 @@ class svnModel extends model { echo helper::now() . " $log\n"; } + + /** + * Build URL. + * + * @param string $methodName + * @param string $url + * @param int $revision + * @access public + * @return string + */ + public function buildURL($methodName, $url, $revision) + { + $buildedURL = helper::createLink('svn', $methodName, "url=&revision=$revision", 'html'); + $buildedURL .= strpos($buildedURL, '?') === false ? '?' : '&'; + $buildedURL .= 'repoUrl=' . helper::safe64Encode($url); + + return $buildedURL; + } } diff --git a/module/svn/view/diff.html.php b/module/svn/view/diff.html.php index e1ef71b6ee..a95e312446 100644 --- a/module/svn/view/diff.html.php +++ b/module/svn/view/diff.html.php @@ -11,7 +11,7 @@ */ ?> - +svn->buildURL('cat', $url, $revision);?>
<?php echo $diff;?>