*/
public $repo;
+ /**
+ * Maps file extensions to MIME Types
+ *
+ * @var array
+ */
public static $arMimeTypeMap = array(
'css' => 'text/css',
'htm' => 'text/html',
'xml' => 'text/xml',
);
- public function __construct($path, Repository $repo)
+ /**
+ * Maps file extensions to geshi types
+ *
+ * @var array
+ */
+ public static $arTypeMap = array(
+ 'htm' => 'xml',
+ 'html' => 'xml',
+ );
+
+ public function __construct($path, Repository $repo = null)
{
$this->path = $path;
$this->repo = $repo;
}
/**
- * Returns the type of the file, as used internally by Phorkie
+ * Return the full path to the file
*
* @return string
*/
- public function getType()
+ public function getPath()
+ {
+ return $this->path;
+ }
+
+ /**
+ * Get file extension without dot
+ *
+ * @return string
+ */
+ public function getExt()
{
return substr($this->path, strrpos($this->path, '.') + 1);
}
+ /**
+ * Returns the type of the file, as used by Geshi
+ *
+ * @return string
+ */
+ public function getType()
+ {
+ $ext = $this->getExt();
+ if (isset(static::$arTypeMap[$ext])) {
+ $ext = static::$arTypeMap[$ext];
+ }
+
+ return $ext;
+ }
+
public function getContent()
{
return file_get_contents($this->path);
public function getMimeType()
{
- $type = $this->getType();
- if (!isset(static::$arMimeTypeMap[$type])) {
+ $ext = $this->getExt();
+ if (!isset(static::$arMimeTypeMap[$ext])) {
return null;
}
- return static::$arMimeTypeMap[$type];
+ return static::$arMimeTypeMap[$ext];
}
/**