6 public function __construct()
8 $this->workDir = $GLOBALS['phorkie']['cfg']['workdir'];
9 $this->gitDir = $GLOBALS['phorkie']['cfg']['gitdir'];
15 public function createNew()
18 $dirs = glob('*.git', GLOB_ONLYDIR);
22 return substr($dir, 0, -4);
25 sort($dirs, SORT_NUMERIC);
26 if ($GLOBALS['phorkie']['cfg']['randomIds']) {
27 $n = end($dirs) + mt_rand(65536, 16777216);
32 chdir($this->workDir);
33 $dir = $this->workDir . '/' . $n . '/';
34 mkdir($dir, fileperms($this->workDir) & 0777);
35 $r = new Repository();
38 $r->gitDir = $this->gitDir . '/' . $n . '.git/';
39 mkdir($r->gitDir, fileperms($this->gitDir) & 0777);
45 * Get a list of repository objects
47 * @param integer $page Page number, beginning with 0, or "last"
48 * @param integer $perPage Number of repositories per page
50 * @return array Array of Repositories first, number of repositories second
52 public function getList($page = 0, $perPage = 10)
55 $dirs = glob('*.git', GLOB_ONLYDIR);
56 sort($dirs, SORT_NUMERIC);
57 if ($page === 'last') {
58 //always show the last 10
59 $page = intval(count($dirs) / $perPage);
60 $start = count($dirs) - $perPage;
64 $some = array_slice($dirs, $start, $perPage);
66 $some = array_slice($dirs, $page * $perPage, $perPage);
70 foreach ($some as $oneDir) {
71 $r = new Repository();
73 $r->loadById(substr($oneDir, 0, -4));
74 } catch (\VersionControl_Git_Exception $e) {
75 if (strpos($e->getMessage(), 'does not have any commits') !== false) {
76 //the git repo is broken as the initial commit
77 // has not been finished
84 return array($repos, count($dirs), $page);