git.cweiske.de
/
phorkie.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
e8d1364
)
determine mime type by file extension, not by geshi type
author
Christian Weiske
<cweiske@cweiske.de>
Wed, 28 Mar 2012 04:39:25 +0000
(06:39 +0200)
committer
Christian Weiske
<cweiske@cweiske.de>
Wed, 28 Mar 2012 04:39:25 +0000
(06:39 +0200)
src/Phorkie/File.php
patch
|
blob
|
history
diff --git
a/src/Phorkie/File.php
b/src/Phorkie/File.php
index 84f7eb5301b448f72a8ce322a04d1ce5926367a9..bf2eb601d40b7d34d8c06a23dc0f18d7335aa8b4 100644
(file)
--- a/
src/Phorkie/File.php
+++ b/
src/Phorkie/File.php
@@
-58,6
+58,16
@@
class File
return basename($this->path);
}
return basename($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
*
/**
* Returns the type of the file, as used by Geshi
*
@@
-65,7
+75,7
@@
class File
*/
public function getType()
{
*/
public function getType()
{
- $ext =
substr($this->path, strrpos($this->path, '.') + 1
);
+ $ext =
$this->getExt(
);
if (isset(static::$arTypeMap[$ext])) {
$ext = static::$arTypeMap[$ext];
}
if (isset(static::$arTypeMap[$ext])) {
$ext = static::$arTypeMap[$ext];
}
@@
-93,11
+103,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
];
}
/**
}
/**