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);
28 chdir($this->workDir);
29 $dir = $this->workDir . '/' . $n . '/';
30 mkdir($dir, 0777);//FIXME
31 $r = new Repository();
34 $r->gitDir = $this->gitDir . '/' . $n . '.git/';
35 mkdir($r->gitDir, 0777);//FIXME
41 * Get a list of repository objects
43 * @param integer $page Page number, beginning with 0, or "last"
44 * @param integer $perPage Number of repositories per page
46 * @return array Array of Repositories first, number of repositories second
48 public function getList($page = 0, $perPage = 10)
51 $dirs = glob('*.git', GLOB_ONLYDIR);
52 sort($dirs, SORT_NUMERIC);
53 if ($page === 'last') {
54 //always show the last 10
55 $page = intval(count($dirs) / $perPage);
56 $start = count($dirs) - $perPage;
60 $some = array_slice($dirs, $start, $perPage);
62 $some = array_slice($dirs, $page * $perPage, $perPage);
66 foreach ($some as $oneDir) {
67 $r = new Repository();
69 $r->loadById(substr($oneDir, 0, -4));
70 } catch (\VersionControl_Git_Exception $e) {
71 if (strpos($e->getMessage(), 'does not have any commits') !== false) {
72 //the git repo is broken as the initial commit
73 // has not been finished
80 return array($repos, count($dirs), $page);