git.cweiske.de
/
phorkie.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
editing works basically
[phorkie.git]
/
src
/
Phorkie
/
File.php
diff --git
a/src/Phorkie/File.php
b/src/Phorkie/File.php
index 729cbd6aaaf6293bf3e65cc309717915a8df6c29..3c6ea4b42e687b532563e54633a4557a4360b9fe 100644
(file)
--- a/
src/Phorkie/File.php
+++ b/
src/Phorkie/File.php
@@
-17,6
+17,11
@@
class File
*/
public $repo;
*/
public $repo;
+ /**
+ * Maps file extensions to MIME Types
+ *
+ * @var array
+ */
public static $arMimeTypeMap = array(
'css' => 'text/css',
'htm' => 'text/html',
public static $arMimeTypeMap = array(
'css' => 'text/css',
'htm' => 'text/html',
@@
-27,7
+32,17
@@
class File
'xml' => 'text/xml',
);
'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;
{
$this->path = $path;
$this->repo = $repo;
@@
-44,15
+59,40
@@
class File
}
/**
}
/**
- * Return
s the type of the file, as used internally by Phorki
e
+ * Return
the full path to the fil
e
*
* @return string
*/
*
* @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);
}
{
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 getContent()
{
return file_get_contents($this->path);
@@
-73,11
+113,11
@@
class File
public function getMimeType()
{
public function getMimeType()
{
- $
type = $this->getType
();
- if (!isset(static::$arMimeTypeMap[$
type
])) {
+ $
ext = $this->getExt
();
+ if (!isset(static::$arMimeTypeMap[$
ext
])) {
return null;
}
return null;
}
- return static::$arMimeTypeMap[$
type
];
+ return static::$arMimeTypeMap[$
ext
];
}
/**
}
/**