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 getHighlightedContent()
63 * Yes, geshi needs to be in your include path
64 * We use the mediawiki geshi extension package.
66 require 'MediaWiki/geshi/geshi/geshi.php';
67 $geshi = new \GeSHi($this->getContent(), $this->getType());
68 $geshi->enable_line_numbers(GESHI_NORMAL_LINE_NUMBERS);
69 $geshi->set_header_type(GESHI_HEADER_DIV);
70 return $geshi->parse_code();
73 public function getMimeType()
75 $type = $this->getType();
76 if (!isset(static::$arMimeTypeMap[$type])) {
79 return static::$arMimeTypeMap[$type];
83 * Get a link to the file
85 * @param string $type Link type. Supported are:
91 public function getLink($type)
94 return '/' . $this->repo->id . '/raw/' . $this->getFilename();
96 throw new Exception('Unknown type');