-
Notifications
You must be signed in to change notification settings - Fork 154
/
repositoryview.php
122 lines (105 loc) · 3.23 KB
/
repositoryview.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
<?php
/**
* iF.SVNAdmin
* Copyright (c) 2010 by Manuel Freiholz
* http://www.insanefactory.com/
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; version 2
* of the License.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program.
*/
include("include/config.inc.php");
//
// Authentication
//
$engine = \svnadmin\core\Engine::getInstance();
if (!$engine->isProviderActive(PROVIDER_REPOSITORY_VIEW)) {
$engine->forwardError(ERROR_INVALID_MODULE);
}
$engine->checkUserAuthentication(true, ACL_MOD_REPO, ACL_ACTION_VIEW);
$appTR->loadModule("repositoryview");
//
// HTTP Request Vars
//
$varParentIdentifierEnc = get_request_var('pi');
$varRepoEnc = get_request_var('r');
$varPathEnc = get_request_var('p');
$varParentIdentifier = rawurldecode($varParentIdentifierEnc);
$varRepo = rawurldecode($varRepoEnc);
$varPath = rawurldecode($varPathEnc);
//
// View Data
//
$oR = new \svnadmin\core\entities\Repository($varRepo, $varParentIdentifier);
try {
// Get the files of the selected repository path.
$repoPathList = $engine->getRepositoryViewProvider()->listPath($oR, $varPath);
// Web-Link - Directory Listing
$apacheWebLink = $engine->getConfig()->getValue("GUI", "ApacheDirectoryListing");
$customWebLink = $engine->getConfig()->getValue("GUI", "CustomDirectoryListing");
$hasApacheWebLink = !empty($apacheWebLink) ? true : false;
$hasCustomWebLink = !empty($customWebLink) ? true : false;
// Is the current path the root directory of the repository?
$isRepositoryRoot = false;
if ($varPath == NULL || $varPath == "/")
{
$isRepositoryRoot = true;
}
// Create the list of directory items.
// $val->type => 0 is folder, 1 is file.
$itemList = array();
foreach ($repoPathList as &$val)
{
// Add weblink property.
if ($hasApacheWebLink || $hasCustomWebLink)
{
$args = array($oR->getEncodedName(), $val->getEncodedRelativePath());
if ($hasApacheWebLink)
{
$val->apacheWebLink = IF_StringUtils::arguments($apacheWebLink, $args);
}
if ($hasCustomWebLink)
{
$val->customWebLink = IF_StringUtils::arguments($customWebLink, $args);
}
}
$itemList[] = $val;
}
// Create "up" link.
// Load the user list template file and add the array of users.
$backLinkPath = "/";
if(empty($varPath))
{
$varPath = "";
}
else
{
$pos = strrpos($varPath, "/");
if ($pos !== false && $pos > 0)
{
$backLinkPath = substr($varPath, 0, $pos);
}
}
SetValue("ApacheWebLink", $hasApacheWebLink);
SetValue("CustomWebLink", $hasCustomWebLink);
SetValue("ItemList", $itemList);
SetValue("Repository", $oR);
SetValue("BackLinkPath", $backLinkPath);
SetValue("BackLinkPathEncoded", rawurlencode($backLinkPath));
SetValue("CurrentPath", $varPath);
SetValue("RepositoryRoot", $isRepositoryRoot);
}
catch (Exception $ex) {
$engine->addException($ex);
}
ProcessTemplate("repository/repositoryview.html.php");
?>