7 * Full path to the file
14 * Repository this file belongs to
20 public function __construct($path, Repository $repo = null)
27 * Get filename relative to the repository path
31 public function getFilename()
33 return basename($this->path);
37 * Return the full path to the file
41 public function getPath()
47 * Get file extension without dot
51 public function getExt()
53 return substr($this->path, strrpos($this->path, '.') + 1);
56 public function getContent()
58 return file_get_contents($this->path);
61 public function getHighlightedContent()
63 $ext = $this->getExt();
64 if (isset($GLOBALS['phorkie']['languages'][$ext]['renderer'])) {
65 $class = $GLOBALS['phorkie']['languages'][$ext]['renderer'];
67 $class = '\\phorkie\\Renderer_Geshi';
70 return $rend->toHtml($this);
74 * Get a link to the file
76 * @param string $type Link type. Supported are:
82 public function getLink($type)
85 return '/' . $this->repo->id . '/raw/' . $this->getFilename();
87 throw new Exception('Unknown type');
90 public function getMimeType()
92 $ext = $this->getExt();
93 if (!isset($GLOBALS['phorkie']['languages'][$ext])) {
96 return $GLOBALS['phorkie']['languages'][$ext]['mime'];