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);
19 foreach ($dirs as $key => $dir) {
20 $dirs[$key] = substr($dir, 0, -4);
22 sort($dirs, SORT_NUMERIC);
24 if ($GLOBALS['phorkie']['cfg']['randomIds']) {
25 $n = end($dirs) + mt_rand(65536, 16777216);
30 chdir($this->workDir);
31 $dir = $this->workDir . '/' . $n . '/';
32 mkdir($dir, fileperms($this->workDir) & 0777);
33 $r = new Repository();
36 $r->gitDir = $this->gitDir . '/' . $n . '.git/';
37 mkdir($r->gitDir, fileperms($this->gitDir) & 0777);
43 * Get a list of repository objects
45 * @param integer $page Page number, beginning with 0, or "last"
46 * @param integer $perPage Number of repositories per page
48 * @return array Array of Repositories first, number of repositories second
50 public function getList($page = 0, $perPage = 10)
53 $dirs = glob('*.git', GLOB_ONLYDIR);
54 sort($dirs, SORT_NUMERIC);
55 if ($page === 'last') {
56 //always show the last 10
57 $page = intval(count($dirs) / $perPage);
58 $start = count($dirs) - $perPage;
62 $some = array_slice($dirs, $start, $perPage);
64 $some = array_slice($dirs, $page * $perPage, $perPage);
68 foreach ($some as $oneDir) {
69 $r = new Repository();
71 $r->loadById(substr($oneDir, 0, -4));
72 } catch (\VersionControl_Git_Exception $e) {
73 if (strpos($e->getMessage(), 'does not have any commits') !== false) {
74 //the git repo is broken as the initial commit
75 // has not been finished
82 return array($repos, count($dirs), $page);