summaryrefslogtreecommitdiffstats
path: root/application/models/mfile.php
diff options
context:
space:
mode:
authorFlorian Pritz <bluewind@xinu.at>2013-06-22 18:34:24 +0200
committerFlorian Pritz <bluewind@xinu.at>2013-06-22 18:58:57 +0200
commit73d6d76ec4d1c8bc9fce9ba1a1dcf8fa6735f621 (patch)
tree1787be8aab9afebb3d28b6ae673a5283bb568682 /application/models/mfile.php
parent5887754d12d84c6a72a95392ad01b70fbf981fa8 (diff)
mfile: extension -> lexer mapping; mark some functions public
Also assure that autodetect_lexer always returns false if the file can't be highlit. Signed-off-by: Florian Pritz <bluewind@xinu.at>
Diffstat (limited to 'application/models/mfile.php')
-rw-r--r--application/models/mfile.php24
1 files changed, 20 insertions, 4 deletions
diff --git a/application/models/mfile.php b/application/models/mfile.php
index 27f05e46b..0a97da5a6 100644
--- a/application/models/mfile.php
+++ b/application/models/mfile.php
@@ -244,7 +244,7 @@ class Mfile extends CI_Model {
return $lexers;
}
- function should_highlight($type)
+ public function should_highlight($type)
{
if ($this->mime2lexer($type)) return true;
@@ -252,7 +252,7 @@ class Mfile extends CI_Model {
}
// Allow certain types to be highlight without doing it automatically
- function can_highlight($type)
+ public function can_highlight($type)
{
$typearray = array(
'image/svg+xml',
@@ -265,8 +265,12 @@ class Mfile extends CI_Model {
}
// Return the lexer that should be used for highlighting
- function autodetect_lexer($type, $filename)
+ public function autodetect_lexer($type, $filename)
{
+ if (!$this->can_highlight($type)) {
+ return false;
+ }
+
$lexer = $this->mime2lexer($type);
// filename lexers overwrite mime type mappings
@@ -351,11 +355,23 @@ class Mfile extends CI_Model {
);
if (array_key_exists($name, $namearray)) return $namearray[$name];
+
+ if (strpos($name, ".") !== false) {
+ $extension = substr($name, strrpos($name, ".") + 1);
+
+ $extensionarray = array(
+ 'ml' => 'ocaml',
+ 'tcl' => 'tcl',
+ 'tex' => 'tex',
+ );
+ if (array_key_exists($extension, $extensionarray)) return $extensionarray[$extension];
+ }
+
return false;
}
// Handle lexer aliases
- function resolve_lexer_alias($alias)
+ public function resolve_lexer_alias($alias)
{
if ($alias === false) return false;
$aliasarray = array(