* finish task #3383.

This commit is contained in:
wangyidong
2017-12-13 13:38:46 +08:00
parent 391ac047d9
commit 22f4518437
6 changed files with 50 additions and 8 deletions
+4
View File
@@ -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);
+20 -3
View File
@@ -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;
}
}
+1 -1
View File
@@ -11,7 +11,7 @@
*/
?>
<?php include '../../common/view/header.lite.html.php';?>
<?php $catLink = inlink('cat', 'url=' . helper::safe64Encode($path) . "&revision=$revision");?>
<?php $catLink = $this->git->buildURL('cat', $path, $revision);?>
<div class='box-title'><?php echo html::a($catLink, "$path@$revision");?></div>
<div class='box-content'><xmp><?php echo $diff;?></xmp></div>
<?php include '../../common/view/footer.lite.html.php';?>
+4
View File
@@ -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);
+20 -3
View File
@@ -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;
}
}
+1 -1
View File
@@ -11,7 +11,7 @@
*/
?>
<?php include '../../common/view/header.lite.html.php';?>
<?php $catLink = inlink('cat', 'url=' . helper::safe64Encode($url) . "&revision=$revision");?>
<?php $catLink = $this->svn->buildURL('cat', $url, $revision);?>
<div class='box-title'><?php echo html::a($catLink, "$url@$revision");?></div>
<div class='box-content'><xmp><?php echo $diff;?></xmp></div>
<?php include '../../common/view/footer.lite.html.php';?>