You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

44 lines
1.3 KiB

<?php
register_hook("get-repositories", function (&$result) {
global $repositoriesGitea;
if (isset($repositoriesGitea)) {
$d1 = opendir($repositoriesGitea['path']);
while ($f1 = readdir($d1)) {
if (substr($f1, 0, 1) !== '.') {
$d2 = opendir("{$repositoriesGitea['path']}/{$f1}");
while ($f2 = readdir($d2)) {
if (substr($f2, 0, 1) !== '.') {
$f2id = substr($f2, 0, -4);
$r = array(
'path' => "{$repositoriesGitea['path']}/{$f1}/{$f2}",
'type' => 'git',
'group' => 'gitea',
);
if (array_key_exists('url', $repositoriesGitea)) {
$r['repositoryUrl'] = "{$repositoriesGitea['url']}/{{ repositoryId }}";
$r['categoryUrl'] = "{$repositoriesGitea['url']}/{{ repositoryId }}/src/branch/{{ branchId }}/{{ categoryId }}.{{ categoryFormat }}";
}
$result["{$f1}/{$f2id}"] = $r;
}
}
closedir($d2);
}
}
closedir($d1);
}
});
register_hook('init', function () {
global $repositoriesGitea;
if (isset($repositoriesGitea) && array_key_exists('url', $repositoriesGitea)) {
$d = array('repositoriesGitea' => array(
'url' => $repositoriesGitea['url'],
));
html_export_var($d);
}
});