X-Git-Url: https://git.cweiske.de/phorkie.git/blobdiff_plain/7dcd592544ae0b55d0e205ff83631067a0d0aa6b..2b4b34a76f42841e964a549fc64c02ba4f60a3f4:/src/phorkie/Repositories.php diff --git a/src/phorkie/Repositories.php b/src/phorkie/Repositories.php new file mode 100644 index 0000000..ef59dd7 --- /dev/null +++ b/src/phorkie/Repositories.php @@ -0,0 +1,55 @@ +reposDir = $GLOBALS['phorkie']['cfg']['repos']; + } + + /** + * @return Repository + */ + public function createNew() + { + chdir($this->reposDir); + $dirs = glob('*', GLOB_ONLYDIR); + sort($dirs, SORT_NUMERIC); + $n = end($dirs) + 1; + unset($dirs); + + $dir = $this->reposDir . '/' . $n . '/'; + mkdir($dir, 0777);//FIXME + $r = new Repository(); + $r->id = $n; + $r->repoDir = $dir; + return $r; + } + + /** + * Get a list of repository objects + * + * @param integer $page Page number, beginning with 0 + * @param integer $perPage Number of repositories per page + * + * @return array Array of Repositories + */ + public function getList($page = 0, $perPage = 10) + { + chdir($this->reposDir); + $dirs = glob('*', GLOB_ONLYDIR); + sort($dirs, SORT_NUMERIC); + + $some = array_slice($dirs, $page * $perPage, $perPage); + $repos = array(); + foreach ($some as $oneDir) { + $r = new Repository(); + $r->loadById($oneDir); + $repos[] = $r; + } + return $repos; + } +} + +?>