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

  1. <?php
  2. register_hook("get-repositories", function (&$result) {
  3. global $repositoriesGitea;
  4. if (isset($repositoriesGitea)) {
  5. $d1 = opendir($repositoriesGitea['path']);
  6. while ($f1 = readdir($d1)) {
  7. if (substr($f1, 0, 1) !== '.') {
  8. $d2 = opendir("{$repositoriesGitea['path']}/{$f1}");
  9. while ($f2 = readdir($d2)) {
  10. if (substr($f2, 0, 1) !== '.') {
  11. $f2id = substr($f2, 0, -4);
  12. $r = array(
  13. 'path' => "{$repositoriesGitea['path']}/{$f1}/{$f2}",
  14. 'type' => 'git',
  15. 'group' => 'gitea',
  16. );
  17. if (array_key_exists('url', $repositoriesGitea)) {
  18. $r['repositoryUrl'] = "{$repositoriesGitea['url']}/{{ repositoryId }}";
  19. $r['categoryUrl'] = "{$repositoriesGitea['url']}/{{ repositoryId }}/src/branch/{{ branchId }}/{{ categoryId }}.{{ categoryFormat }}";
  20. }
  21. $result["{$f1}/{$f2id}"] = $r;
  22. }
  23. }
  24. closedir($d2);
  25. }
  26. }
  27. closedir($d1);
  28. }
  29. });
  30. register_hook('init', function () {
  31. global $repositoriesGitea;
  32. if (isset($repositoriesGitea) && array_key_exists('url', $repositoriesGitea)) {
  33. $d = array('repositoriesGitea' => array(
  34. 'url' => $repositoriesGitea['url'],
  35. ));
  36. html_export_var($d);
  37. }
  38. });