8 * Repository ID (number in repositories directory)
15 * Full path to the git repository
22 * Load Repository data from GET-Request
26 * @throws Exception When something is wrong
28 public function loadFromRequest()
30 if (!isset($_GET['id'])) {
31 throw new Exception_Input('Paste ID missing');
33 if (!is_numeric($_GET['id'])) {
34 throw new Exception_Input('Paste ID not numeric');
36 $this->id = (int)$_GET['id'];
38 $repoDir = $GLOBALS['phorkie']['cfg']['repos'] . '/' . $this->id;
39 if (!is_dir($repoDir)) {
40 throw new Exception_NotFound('Paste not found');
42 $this->repoDir = $repoDir;
46 * Loads the list of files in this repository
48 * @return File[] Array of files
50 public function getFiles()
52 $files = glob($this->repoDir . '/*');
54 foreach ($files as $path) {
55 $arFiles[] = new File($path, $this);
60 public function getFileByName($name)
62 $base = basename($name);
64 throw new Exception('No directories supported for now');
66 $path = $this->repoDir . '/' . $base;
67 if (!is_readable($path)) {
68 throw new Exception_Input('File does not exist');
70 return new File($path, $this);
73 public function getDescription()
75 return file_get_contents($this->repoDir . '/.git/description');
79 * Get a link to the repository
81 * @param string $type Link type. Supported are:
87 public function getLink($type)
89 if ($type == 'edit') {
90 return '/' . $this->id . '/edit';
91 } else if ($type == 'display') {
92 return '/' . $this->id;
94 throw new Exception('Unknown type');