X-Git-Url: https://git.cweiske.de/phorkie.git/blobdiff_plain/089fcac67ae3c3e83e2c330498d211e6b7693534..e8d13647a1fba053a2b6c7d6ae18a3bd4d0193a0:/src/Phorkie/File.php diff --git a/src/Phorkie/File.php b/src/Phorkie/File.php index 6e71de3..84f7eb5 100644 --- a/src/Phorkie/File.php +++ b/src/Phorkie/File.php @@ -17,6 +17,11 @@ class File */ public $repo; + /** + * Maps file extensions to MIME Types + * + * @var array + */ public static $arMimeTypeMap = array( 'css' => 'text/css', 'htm' => 'text/html', @@ -24,6 +29,17 @@ class File 'js' => 'application/javascript', 'php' => 'text/x-php', 'txt' => 'text/plain', + 'xml' => 'text/xml', + ); + + /** + * Maps file extensions to geshi types + * + * @var array + */ + public static $arTypeMap = array( + 'htm' => 'xml', + 'html' => 'xml', ); public function __construct($path, Repository $repo) @@ -43,13 +59,18 @@ class File } /** - * Returns the type of the file, as used internally by Phorkie + * Returns the type of the file, as used by Geshi * * @return string */ public function getType() { - return substr($this->path, strrpos($this->path, '.') + 1); + $ext = substr($this->path, strrpos($this->path, '.') + 1); + if (isset(static::$arTypeMap[$ext])) { + $ext = static::$arTypeMap[$ext]; + } + + return $ext; } public function getContent()