From bfa1501efa1a49893208c794ea262a075b13fc1d Mon Sep 17 00:00:00 2001 From: Christian Weiske Date: Mon, 26 Mar 2012 23:38:53 +0200 Subject: use repositories class --- src/Phorkie/Repositories.php | 27 +++++++++++++++++++++++++++ src/Phorkie/Repository.php | 8 ++++++++ 2 files changed, 35 insertions(+) create mode 100644 src/Phorkie/Repositories.php (limited to 'src') diff --git a/src/Phorkie/Repositories.php b/src/Phorkie/Repositories.php new file mode 100644 index 0000000..6582ae8 --- /dev/null +++ b/src/Phorkie/Repositories.php @@ -0,0 +1,27 @@ +reposDir = $GLOBALS['phorkie']['cfg']['repos']; + } + + /** + * @return Repository + */ + public function createNew() + { + $n = basename(end(glob($this->reposDir . '/*', GLOB_ONLYDIR))) + 1; + $dir = $this->reposDir . '/' . $n . '/'; + mkdir($dir, 0777);//FIXME + $r = new Repository(); + $r->id = $n; + $r->repoDir = $dir; + return $r; + } + +} + +?> diff --git a/src/Phorkie/Repository.php b/src/Phorkie/Repository.php index 531ff68..f23db7e 100644 --- a/src/Phorkie/Repository.php +++ b/src/Phorkie/Repository.php @@ -42,6 +42,11 @@ class Repository $this->repoDir = $repoDir; } + public function getVc() + { + return new \VersionControl_Git($this->repoDir); + } + /** * Loads the list of files in this repository * @@ -84,6 +89,7 @@ class Repository * @param string $type Link type. Supported are: * - "edit" * - "display" + * - "fork" * * @return string */ @@ -93,6 +99,8 @@ class Repository return '/' . $this->id . '/edit'; } else if ($type == 'display') { return '/' . $this->id; + } else if ($type == 'fork') { + return '/' . $this->id . '/fork'; } throw new Exception('Unknown type'); } -- cgit v1.2.3