<?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");
$appEngine->forwardInvalidModule(!$appEngine->isRepositoryViewActive());
$appEngine->checkUserAuthentication(true, ACL_MOD_REPO, ACL_ACTION_VIEW);
$appTR->loadModule("repositoryview");
// Request variables.
$varRepoEnc = get_request_var("r");
$varPathEnc = get_request_var("p");
$varRepo = rawurldecode($varRepoEnc);
$varPath = rawurldecode($varPathEnc);
// Is the current path the root directory of the repository?
if ($varPath == NULL || $varPath == "/")
{
$appTemplate->addDefine("IS_REPOSITORY_ROOT");
}
$oR = new \svnadmin\core\entities\Repository();
$oR->name = $varRepo;
// Get the files of the selected repository path.
$repoPathList = $appEngine->getRepositoryViewProvider()->listPath($oR, $varPath);
// Create two seperate lists. One with folders and one with files.
// Why? Well... the template system currently does not support if-statements xD
$folderList = array();
$fileList = array();
foreach ($repoPathList as &$val)
{
if ($val->type == 0)
array_push($folderList, $val);
else
array_push($fileList, $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);
}
}
$appTemplate->loadFromFile(new \IF_File("templates/repositoryview.html"));
$appTemplate->addReplacement("REPOSITORY", $oR->name);
$appTemplate->addReplacement("REPOSITORY_ENCODED", $varRepoEnc);
$appTemplate->addReplacement("BACKLINKPATH", $backLinkPath );
$appTemplate->addReplacement("BACKLINKPATH_ENCODED", rawurlencode($backLinkPath));
$appTemplate->addReplacement("CURRENTPATH", $varPath);
$appTemplate->addReplacement("folders", $folderList);
$appTemplate->addReplacement("files", $fileList);
$appTemplate->processTemplate();
?>