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',
30 public function __construct($path, Repository $repo)
37 * Get filename relative to the repository path
41 public function getFilename()
43 return basename($this->path);
47 * Returns the type of the file, as used internally by Phorkie
51 public function getType()
53 return substr($this->path, strrpos($this->path, '.') + 1);
56 public function getContent()
58 return file_get_contents($this->path);
61 public function getHighlightedContent()
64 * Yes, geshi needs to be in your include path
65 * We use the mediawiki geshi extension package.
67 require 'MediaWiki/geshi/geshi/geshi.php';
68 $geshi = new \GeSHi($this->getContent(), $this->getType());
69 $geshi->enable_line_numbers(GESHI_NORMAL_LINE_NUMBERS);
70 $geshi->set_header_type(GESHI_HEADER_DIV);
71 return $geshi->parse_code();
74 public function getMimeType()
76 $type = $this->getType();
77 if (!isset(static::$arMimeTypeMap[$type])) {
80 return static::$arMimeTypeMap[$type];
84 * Get a link to the file
86 * @param string $type Link type. Supported are:
92 public function getLink($type)
95 return '/' . $this->repo->id . '/raw/' . $this->getFilename();
97 throw new Exception('Unknown type');