+
+ protected function getType($content)
+ {
+ $tmp = tempnam(sys_get_temp_dir(), 'phorkie-autodetect-');
+ file_put_contents($tmp, $content);
+ $type = \MIME_Type_PlainDetect::autoDetect($tmp);
+ unlink($tmp);
+
+ return $this->findExtForType($type);
+ }
+
+ protected function findExtForType($type)
+ {
+ $ext = 'txt';
+ foreach ($GLOBALS['phorkie']['languages'] as $lext => $arLang) {
+ if ($arLang['mime'] == $type) {
+ $ext = $lext;
+ break;
+ }
+ }
+ return $ext;
+ }