7 * Full path to the file
14 * Repository this file belongs to
20 public static $arMimeTypeMap = array(
23 'html' => 'text/html',
24 'js' => 'application/javascript',
25 'php' => 'text/x-php',
26 'txt' => 'text/plain',
29 public function __construct($path, Repository $repo)
36 * Get filename relative to the repository path
40 public function getFilename()
42 return basename($this->path);
46 * Returns the type of the file, as used internally by Phorkie
50 public function getType()
52 return substr($this->path, strrpos($this->path, '.') + 1);
55 public function getContent()
57 return file_get_contents($this->path);
60 public function getMimeType()
62 $type = $this->getType();
63 if (!isset(static::$arMimeTypeMap[$type])) {
66 return static::$arMimeTypeMap[$type];
70 * Get a link to the file
72 * @param string $type Link type. Supported are:
78 public function getLink($type)
81 return '/' . $this->repo->id . '/raw/' . $this->getFilename();
83 throw new Exception('Unknown type');