id = (int)$_GET['id']; $repoDir = $GLOBALS['phorkie']['cfg']['repos'] . '/' . $this->id; if (!is_dir($repoDir)) { throw new Exception_NotFound('Paste not found'); } $this->repoDir = $repoDir; } /** * Loads the list of files in this repository * * @return File[] Array of files */ public function getFiles() { $files = glob($this->repoDir . '/*'); $arFiles = array(); foreach ($files as $path) { $arFiles[] = new File($path, $this); } return $arFiles; } public function getFileByName($name) { $base = basename($name); if ($base != $name) { throw new Exception('No directories supported for now'); } $path = $this->repoDir . '/' . $base; if (!is_readable($path)) { throw new Exception_Input('File does not exist'); } return new File($path, $this); } public function getDescription() { return file_get_contents($this->repoDir . '/.git/description'); } /** * Get a link to the repository * * @param string $type Link type. Supported are: * - "edit" * - "display" * * @return string */ public function getLink($type) { if ($type == 'edit') { return '/' . $this->id . '/edit'; } else if ($type == 'display') { return '/' . $this->id; } throw new Exception('Unknown type'); } } ?>