diff options
| author | Christian Weiske <cweiske@cweiske.de> | 2012-04-15 22:12:44 +0200 |
|---|---|---|
| committer | Christian Weiske <cweiske@cweiske.de> | 2012-04-15 22:12:44 +0200 |
| commit | 670d927b0cdc6cea596e35676676aef8f36080bc (patch) | |
| tree | 8067cb48a3bbff4355cf538eee067b6d5ef1854a /src/phorkie/File.php | |
| parent | 6c5e3a87419ab5f9a896403bbca2d41c7222e732 (diff) | |
| download | phorkie-670d927b0cdc6cea596e35676676aef8f36080bc.tar.gz phorkie-670d927b0cdc6cea596e35676676aef8f36080bc.zip | |
do not show text field for binary files
Diffstat (limited to 'src/phorkie/File.php')
| -rw-r--r-- | src/phorkie/File.php | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/src/phorkie/File.php b/src/phorkie/File.php index 519413d..53925ee 100644 --- a/src/phorkie/File.php +++ b/src/phorkie/File.php @@ -115,6 +115,22 @@ class File $tm = new Tool_Manager(); return $tm->getSuitable($this); } + + /** + * Tells if the file contains textual content and is editable. + * + * @return boolean + */ + public function isText() + { + $ext = $this->getExt(); + if (!isset($GLOBALS['phorkie']['languages'][$ext]['mime'])) { + return false; + } + + $type = $GLOBALS['phorkie']['languages'][$ext]['mime']; + return substr($type, 0, 5) === 'text/'; + } } ?>
\ No newline at end of file |
