'text/sh' => 'sh',
];
- public static function fromExt($ext) {
+ public static function get($ext) {
foreach (self::Types as $t => $e) {
if ($ext == $e) return $t;
}
return null;
}
- public static function toExt($type) {
+ public static function ext($type) {
if (empty(self::Types[$type])) return null;
return self::Types[$type];
}
if (!defined('NB_P_GET')) define('NB_P_GET',true);
require_once(NB_ROOT.'/lib/php/functions.php');
-require_once(NB_ROOT.'/lib/php/http.php');
+require_once(NB_ROOT.'/lib/php/mime.php');
if (class_exists('NB')) return; # protect against double include
class NB {
#<_SHELL_REPLACE
);
+ # NB 19.01.18: TODEL
protected static $content_types = array(
'json' => 'text/json',
'doc' => 'application/msword',
* Function: prettyText
* Does what it says
*/
+ # NB 19.01.18: TODEL
public static function prettyText($text) {
return prettyText($text);
}
+ # NB 19.01.18: TODEL
public static function mime2ext($mime) {
+ return Mime::ext($mime);
static $aliases = null;
if ($aliases === null) $aliases = array_combine(
*/
#public static function ext2content_type($ext) { return self::ext2mime($ext); }
public static function ext2mime($ext) {
+ return Mime::get($ext);
foreach (self::$content_types as $e => $c) {
if ($ext == $e) return $c;
if ($this->params['format']) {
$format = $this->params['format'];
- } else if ($content_type = self::client_content_type() and ( $format = Mime::toExt($content_type) )) {
+ } else if ($content_type = self::client_content_type() and ( $format = Mime::ext($content_type) )) {
# Not empty !
} else {
if (!empty($this->limits)) $this->db->limits = $this->limits;
// Then content type
- if (empty($content_type)) $content_type = Mime::fromExt($format==$this->format_cli ? 'txt' : $format);
+ if (empty($content_type)) $content_type = Mime::get($format==$this->format_cli ? 'txt' : $format);
if (empty($content_type) and $this->db->out->is_html($format)) $content_type = 'text/html';
if (empty($content_type)) $content_type = 'text/plain';
if ($content_type) $this->page->content_type($content_type);